Skip to content

Commit 0f96738

Browse files
authored
(fix) add esm flag to support node 12 < version < 12.17 (#939)
Node versions prior to v12.17 need the `--experimental-modules` flag or the dynamic import introduced in #930 won't work. This node version is used in VS Code versions prior to 1.55 and could be used by users setting the node executable to a node version below 12.17. Remove this in mid 2022 and bump vs code minimum required version to 1.55
1 parent 1e47f20 commit 0f96738

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

packages/svelte-vscode/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,14 @@ More docs and troubleshooting: [See here](/docs/README.md).
6262
##### `svelte.language-server.runtime`
6363

6464
Path to the node executable you would like to use to run the language server.
65-
This is useful when you depend on native modules such as node-sass as without
66-
this they will run in the context of vscode, meaning node version mismatch is likely.
65+
This is useful when you depend on native modules such as node-sass as without this they will run in the context of vscode, meaning node version mismatch is likely.
66+
Minimum required node version is `12.17`.
67+
This setting can only be changed in user settings for security reasons.
6768

6869
##### `svelte.language-server.ls-path`
6970

70-
You normally don't set this. Path to the language server executable. If you installed the \"svelte-language-server\" npm package, it's within there at \"bin/server.js\". Path can be either relative to your workspace root or absolute. Set this only if you want to use a custom version of the language server.
71+
You normally don't set this. Path to the language server executable. If you installed the `svelte-language-server` npm package, it's within there at `bin/server.js`. Path can be either relative to your workspace root or absolute. Set this only if you want to use a custom version of the language server.
72+
This setting can only be changed in user settings for security reasons.
7173

7274
##### `svelte.language-server.port`
7375

packages/svelte-vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"scope": "application",
5353
"type": "string",
5454
"title": "Language Server Runtime",
55-
"description": "- You normally don't need this - Path to the node executable to use to spawn the language server. This is useful when you depend on native modules such as node-sass as without this they will run in the context of vscode, meaning node version mismatch is likely. This setting can only be changed in user settings for security reasons."
55+
"description": "- You normally don't need this - Path to the node executable to use to spawn the language server. This is useful when you depend on native modules such as node-sass as without this they will run in the context of vscode, meaning node version mismatch is likely. Minimum required node version is 12.17. This setting can only be changed in user settings for security reasons."
5656
},
5757
"svelte.language-server.ls-path": {
5858
"scope": "application",

packages/svelte-vscode/src/extension.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ export function activate(context: ExtensionContext) {
5656
const serverModule = require.resolve(lsPath || 'svelte-language-server/bin/server.js');
5757
console.log('Loading server from ', serverModule);
5858

59-
const runExecArgv: string[] = [];
59+
// Add --experimental-modules flag for people using node 12 < version < 12.17
60+
// Remove this in mid 2022 and bump vs code minimum required version to 1.55
61+
const runExecArgv: string[] = ['--experimental-modules'];
6062
let port = runtimeConfig.get<number>('port') ?? -1;
6163
if (port < 0) {
6264
port = 6009;
6365
} else {
6466
console.log('setting port to', port);
6567
runExecArgv.push(`--inspect=${port}`);
6668
}
67-
const debugOptions = { execArgv: ['--nolazy', `--inspect=${port}`] };
69+
const debugOptions = { execArgv: ['--nolazy', '--experimental-modules', `--inspect=${port}`] };
6870

6971
const serverOptions: ServerOptions = {
7072
run: {
@@ -376,6 +378,7 @@ function addExtracComponentCommand(getLS: () => LanguageClient, context: Extensi
376378
}
377379

378380
function createLanguageServer(serverOptions: ServerOptions, clientOptions: LanguageClientOptions) {
381+
console.log('NEWWWWWWWWWWWWWWWW');
379382
return new LanguageClient('svelte', 'Svelte', serverOptions, clientOptions);
380383
}
381384

0 commit comments

Comments
 (0)