diff --git a/.vscode/settings.json b/.vscode/settings.json index c4458aa22..ec326028d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,5 +19,6 @@ ], "[json]": { "editor.defaultFormatter": "vscode.json-language-features" - } + }, + "vitest.disableWorkspaceWarning": true } diff --git a/packages/wrapper/src/languageClientWrapper.ts b/packages/wrapper/src/languageClientWrapper.ts index 7486eaa18..db8112087 100644 --- a/packages/wrapper/src/languageClientWrapper.ts +++ b/packages/wrapper/src/languageClientWrapper.ts @@ -137,14 +137,14 @@ export class LanguageClientWrapper { if (!this.worker) { if (lccOptions.$type === 'WorkerConfig') { const workerConfig = lccOptions as WorkerConfigOptionsParams; - this.worker = new Worker(new URL(workerConfig.url, import.meta.url).href, { + this.worker = new Worker(workerConfig.url.href, { type: workerConfig.type, name: workerConfig.workerName }); this.worker.onerror = (ev) => { const languageClientError: LanguageClientError = { - message: `languageClientWrapper (${this.name}): Illegal worker configuration detected. Potentially the url is wrong.`, + message: `languageClientWrapper (${this.name}): Illegal worker configuration detected.`, error: ev.error ?? 'No error was provided.' }; reject(languageClientError); diff --git a/packages/wrapper/test/languageClientWrapper.test.ts b/packages/wrapper/test/languageClientWrapper.test.ts index 54bd6a2c4..f0efdd6eb 100644 --- a/packages/wrapper/test/languageClientWrapper.test.ts +++ b/packages/wrapper/test/languageClientWrapper.test.ts @@ -145,7 +145,7 @@ describe('Test LanguageClientWrapper', () => { connection: { options: { $type: 'WorkerConfig', - url: new URL('http://localhost:20101'), + url: new URL(`${import.meta.url.split('@fs')[0]}/packages/wrapper/test/worker/langium-server.ts`), type: 'classic' } } @@ -158,7 +158,7 @@ describe('Test LanguageClientWrapper', () => { expect(languageClientWrapper).toBeDefined(); await expect(languageClientWrapper!.start()).rejects.toEqual({ - message: 'languageClientWrapper (unnamed): Illegal worker configuration detected. Potentially the url is wrong.', + message: 'languageClientWrapper (unnamed): Illegal worker configuration detected.', error: 'No error was provided.' }); }); diff --git a/vite.config.ts b/vite.config.ts index 9de75895b..5f1a1b5ed 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -9,71 +9,70 @@ import importMetaUrlPlugin from '@codingame/esbuild-import-meta-url-plugin'; import vsixPlugin from '@codingame/monaco-vscode-rollup-vsix-plugin'; import react from '@vitejs/plugin-react'; -export default defineConfig(({ command }) => { - console.log(`Running: ${command}`); - return { - build: { - target: 'esnext', - rollupOptions: { - input: { - index: path.resolve(__dirname, 'index.html'), - // bare monaco-languageclient - bare: path.resolve(__dirname, 'packages/examples/bare.html'), +export const definedViteConfig = defineConfig({ + build: { + target: 'esnext', + rollupOptions: { + input: { + index: path.resolve(__dirname, 'index.html'), + // bare monaco-languageclient + bare: path.resolve(__dirname, 'packages/examples/bare.html'), - // monaco-editor-wrapper - // json - wrapperWebSocket: path.resolve(__dirname, 'packages/examples/json.html'), - browser: path.resolve(__dirname, 'packages/examples/browser.html'), - // langium - wrapperStatemachine: path.resolve(__dirname, 'packages/examples/statemachine.html'), - wrapperLangium: path.resolve(__dirname, 'packages/examples/langium.html'), - // python - python: path.resolve(__dirname, 'packages/examples/python.html'), - // grrovy - groovy: path.resolve(__dirname, 'packages/examples/groovy.html'), + // monaco-editor-wrapper + // json + wrapperWebSocket: path.resolve(__dirname, 'packages/examples/json.html'), + browser: path.resolve(__dirname, 'packages/examples/browser.html'), + // langium + wrapperStatemachine: path.resolve(__dirname, 'packages/examples/statemachine.html'), + wrapperLangium: path.resolve(__dirname, 'packages/examples/langium.html'), + // python + python: path.resolve(__dirname, 'packages/examples/python.html'), + // grrovy + groovy: path.resolve(__dirname, 'packages/examples/groovy.html'), - // json & python - twoLangaugeClients: path.resolve(__dirname, 'packages/examples/two_langauge_clients.html'), + // json & python + twoLangaugeClients: path.resolve(__dirname, 'packages/examples/two_langauge_clients.html'), - // monaco-editor-react - // langium - reactStatemachine: path.resolve(__dirname, 'packages/examples/react_statemachine.html'), - // python - reactPython: path.resolve(__dirname, 'packages/examples/react_python.html'), + // monaco-editor-react + // langium + reactStatemachine: path.resolve(__dirname, 'packages/examples/react_statemachine.html'), + // python + reactPython: path.resolve(__dirname, 'packages/examples/react_python.html'), - // other examples - wrapperTs: path.resolve(__dirname, 'packages/examples/ts.html') - } + // other examples + wrapperTs: path.resolve(__dirname, 'packages/examples/ts.html') } - }, - resolve: { - // not needed here, see https://github.com/TypeFox/monaco-languageclient#vite-dev-server-troubleshooting - // dedupe: ['vscode'] - }, - server: { - origin: 'http://localhost:20001', - port: 20001 - }, - optimizeDeps: { - esbuildOptions: { - plugins: [ - importMetaUrlPlugin - ] - }, - include: [ - 'vscode-textmate', - 'vscode-oniguruma' + } + }, + resolve: { + // not needed here, see https://github.com/TypeFox/monaco-languageclient#vite-dev-server-troubleshooting + // dedupe: ['vscode'] + }, + server: { + origin: 'http://localhost:20001', + port: 20001 + }, + optimizeDeps: { + esbuildOptions: { + plugins: [ + importMetaUrlPlugin ] }, - plugins: [ - vsixPlugin(), - react(), - ], - define: { - rootDirectory: JSON.stringify(__dirname) - }, - worker: { - format: 'es' - } - }; + include: [ + 'vscode-textmate', + 'vscode-oniguruma' + ] + }, + plugins: [ + vsixPlugin(), + react(), + ], + define: { + rootDirectory: JSON.stringify(__dirname) + }, + worker: { + format: 'es' + } }); + +export default definedViteConfig; diff --git a/vitest.config.ts b/vitest.config.ts index 7889b113e..88818c933 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -3,10 +3,11 @@ * Licensed under the MIT License. See LICENSE in the package root for license information. * ------------------------------------------------------------------------------------------ */ -import { defineConfig, defineConfig as vitestDefineConfig, mergeConfig, UserConfig } from 'vitest/config'; -import viteConfig from './vite.config.js'; +import { mergeConfig } from 'vite'; +import { defineConfig as defineVitestConfig } from 'vitest/config'; +import definedViteConfig from './vite.config.js'; -export const vitestConfig: UserConfig = { +export const vitestBaseConfig = { test: { testTimeout: 10000, pool: 'threads', @@ -38,14 +39,7 @@ export const vitestConfig: UserConfig = { } }; -export default defineConfig(configEnv => { +const definedVitestConfig = defineVitestConfig(vitestBaseConfig); - console.log('vitestConfig:', vitestConfig); +export default mergeConfig(definedVitestConfig, definedViteConfig); - const mergedConfig = mergeConfig( - viteConfig(configEnv), - vitestDefineConfig(vitestConfig) - ); - - return mergedConfig; -}); diff --git a/vitest.debug.config.ts b/vitest.debug.config.ts index 75a4de6bf..d17fb185e 100644 --- a/vitest.debug.config.ts +++ b/vitest.debug.config.ts @@ -3,23 +3,15 @@ * Licensed under the MIT License. See LICENSE in the package root for license information. * ------------------------------------------------------------------------------------------ */ -import { defineConfig, mergeConfig } from 'vitest/config'; -import viteConfig from './vite.config.js'; -import { vitestConfig } from './vitest.config.js'; +import { mergeConfig } from 'vite'; +import { defineConfig as defineVitestConfig } from 'vitest/config'; +import { definedViteConfig } from './vite.config.js'; +import { vitestBaseConfig } from './vitest.config.js'; -export default defineConfig(configEnv => { +const vitestDebugConfig = vitestBaseConfig; +vitestDebugConfig.test.browser.name = 'chromium'; +vitestDebugConfig.test.browser.provider = 'playwright'; - const vitestDebugConfig = vitestConfig; - vitestDebugConfig.test!.browser!.name = 'chromium'; - vitestDebugConfig.test!.browser!.provider = 'playwright'; +const definedVitestDebugConfig = defineVitestConfig(vitestDebugConfig); - console.log('vitestDebugConfig:', vitestDebugConfig); - - const mergedConfig = mergeConfig( - viteConfig(configEnv), - defineConfig(vitestDebugConfig) - ); - - return mergedConfig; - -}); +export default mergeConfig(definedVitestDebugConfig, definedViteConfig); diff --git a/vitest.workspace.ts b/vitest.workspace.ts deleted file mode 100644 index 0d797a68a..000000000 --- a/vitest.workspace.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* -------------------------------------------------------------------------------------------- - * Copyright (c) 2024 TypeFox and others. - * Licensed under the MIT License. See LICENSE in the package root for license information. - * ------------------------------------------------------------------------------------------ */ - -import * as path from 'path'; -import { defineWorkspace } from 'vitest/config'; - -export default defineWorkspace([ - path.resolve(__dirname, './vitest.config.ts') -]);