astro-vscode 2.17.0 → 2.17.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/node/client.js +75 -45
- package/dist/node/server.js +863 -653
- package/package.json +13 -15
- package/scripts/build-grammar.mjs +2 -2
- package/scripts/build.mjs +90 -56
- package/scripts/shared.mjs +12 -20
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"color": "#17191E",
|
|
25
25
|
"theme": "dark"
|
|
26
26
|
},
|
|
27
|
-
"version": "2.17.
|
|
27
|
+
"version": "2.17.2",
|
|
28
28
|
"author": "withastro",
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"publisher": "astro-build",
|
|
@@ -237,29 +237,27 @@
|
|
|
237
237
|
"devDependencies": {
|
|
238
238
|
"@astrojs/language-server": "^2.17.0",
|
|
239
239
|
"@astrojs/ts-plugin": "^1.10.12",
|
|
240
|
-
"@types/js-yaml": "^4.0.9",
|
|
241
240
|
"@types/mocha": "^10.0.10",
|
|
242
241
|
"@types/node": "^22.10.6",
|
|
243
242
|
"@types/vscode": "^1.101.0",
|
|
244
243
|
"@volar/language-server": "~2.4.28",
|
|
245
244
|
"@volar/vscode": "~2.4.28",
|
|
246
|
-
"@vscode/test-cli": "^0.0.
|
|
245
|
+
"@vscode/test-cli": "^0.0.15",
|
|
247
246
|
"@vscode/test-electron": "^3.1.0",
|
|
248
|
-
"@vscode/vsce": "
|
|
249
|
-
"esbuild": "^0.17.19",
|
|
250
|
-
"esbuild-plugin-copy": "^2.1.1",
|
|
251
|
-
"js-yaml": "^4.3.0",
|
|
247
|
+
"@vscode/vsce": "^4.0.0",
|
|
252
248
|
"kleur": "^4.1.5",
|
|
253
|
-
"mocha": "^
|
|
254
|
-
"ovsx": "^
|
|
255
|
-
"
|
|
256
|
-
"
|
|
257
|
-
"vscode-
|
|
249
|
+
"mocha": "^12.0.2",
|
|
250
|
+
"ovsx": "^1.2.0",
|
|
251
|
+
"rolldown": "^1.2.11",
|
|
252
|
+
"tsx": "^4.23.13",
|
|
253
|
+
"vscode-languageclient": "^10.1.2",
|
|
254
|
+
"vscode-tmgrammar-test": "^0.1.3",
|
|
255
|
+
"yaml": "^2.9.1"
|
|
258
256
|
},
|
|
259
257
|
"dependencies": {
|
|
260
|
-
"@astrojs/astro2tsx": "^0.1.
|
|
261
|
-
"prettier": "^3.9.
|
|
262
|
-
"prettier-plugin-astro": "^
|
|
258
|
+
"@astrojs/astro2tsx": "^0.1.2",
|
|
259
|
+
"prettier": "^3.9.6",
|
|
260
|
+
"prettier-plugin-astro": "^1.1.0"
|
|
263
261
|
},
|
|
264
262
|
"scripts": {
|
|
265
263
|
"build": "tsc -b && node scripts/build.mjs -- --minify",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
-
import
|
|
4
|
+
import { parse } from 'yaml';
|
|
5
5
|
import { dim, green } from 'kleur/colors';
|
|
6
6
|
|
|
7
7
|
const dt = new Intl.DateTimeFormat('en-us', {
|
|
@@ -36,7 +36,7 @@ for (const grammarFile of grammarFiles) {
|
|
|
36
36
|
* @param {URL} grammarFile
|
|
37
37
|
*/
|
|
38
38
|
function buildGrammar(grammarFile) {
|
|
39
|
-
const grammar =
|
|
39
|
+
const grammar = parse(fs.readFileSync(grammarFile, 'utf8'));
|
|
40
40
|
const finalPath = fileURLToPath(grammarFile).replace('.src.yaml', '.json');
|
|
41
41
|
fs.writeFileSync(finalPath, JSON.stringify(grammar, null, 2));
|
|
42
42
|
|
package/scripts/build.mjs
CHANGED
|
@@ -1,78 +1,112 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
import fs from 'node:fs';
|
|
3
|
+
import path from 'node:path';
|
|
3
4
|
import { createRequire } from 'node:module';
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import { rebuildPlugin } from './shared.mjs';
|
|
5
|
+
import { rolldown, watch } from 'rolldown';
|
|
6
|
+
import { logError, logUpdated } from './shared.mjs';
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url);
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const isDev = process.argv.includes('--watch');
|
|
11
|
+
const minify = process.argv.includes('--minify');
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Resolve UMD builds of `vscode-*-languageservice` and `jsonc-parser` to their
|
|
15
|
+
* ESM counterparts.
|
|
16
|
+
* @returns {import('rolldown').Plugin}
|
|
17
|
+
*/
|
|
18
|
+
function umd2esm() {
|
|
19
|
+
return {
|
|
20
|
+
name: 'umd2esm',
|
|
21
|
+
resolveId(source, importer) {
|
|
22
|
+
if (/^(?:vscode-.*-languageservice|jsonc-parser)/.test(source)) {
|
|
23
|
+
const resolveDir = importer ? path.dirname(importer) : process.cwd();
|
|
24
|
+
const pathUmdMay = require.resolve(source, { paths: [resolveDir] });
|
|
25
|
+
// Call twice the replace is to solve the problem of the path in Windows
|
|
26
|
+
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\');
|
|
27
|
+
return pathEsm;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
}
|
|
13
32
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
'
|
|
23
|
-
|
|
33
|
+
/**
|
|
34
|
+
* Copy the language server types into `dist/types` so VS Code can resolve them.
|
|
35
|
+
* @returns {import('rolldown').Plugin}
|
|
36
|
+
*/
|
|
37
|
+
function copyTypes() {
|
|
38
|
+
return {
|
|
39
|
+
name: 'astro:copy-types',
|
|
40
|
+
async writeBundle() {
|
|
41
|
+
await fs.promises.cp('../language-server/types', './dist/types', {
|
|
42
|
+
recursive: true,
|
|
43
|
+
filter: (src) => fs.statSync(src).isDirectory() || src.endsWith('.d.ts'),
|
|
44
|
+
});
|
|
24
45
|
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** @type {Record<string, string>} */
|
|
50
|
+
const entries = {
|
|
51
|
+
'dist/node/client': './src/client.ts',
|
|
52
|
+
'dist/node/server': './node_modules/@astrojs/language-server/bin/nodeServer.js',
|
|
53
|
+
// We need to generate this inside node_modules so VS Code can resolve it
|
|
54
|
+
'node_modules/astro-ts-plugin-bundle/index': './node_modules/@astrojs/ts-plugin/dist/index.js',
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Each entry is bundled on its own so shared code is inlined instead of emitted
|
|
59
|
+
* as extra chunks.
|
|
60
|
+
* @param {string} name
|
|
61
|
+
* @param {string} input
|
|
62
|
+
*/
|
|
63
|
+
function config(name, input) {
|
|
64
|
+
return {
|
|
65
|
+
input,
|
|
66
|
+
platform: /** @type {const} */ ('node'),
|
|
29
67
|
external: ['vscode', '@astrojs/astro2tsx', 'prettier', 'prettier-plugin-astro'],
|
|
30
|
-
format: 'cjs',
|
|
31
|
-
platform: 'node',
|
|
32
68
|
tsconfig: './tsconfig.json',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
name: 'umd2esm',
|
|
46
|
-
setup(pluginBuild) {
|
|
47
|
-
pluginBuild.onResolve(
|
|
48
|
-
{ filter: /^(vscode-.*-languageservice|jsonc-parser)/ },
|
|
49
|
-
(buildArgs) => {
|
|
50
|
-
const pathUmdMay = require.resolve(buildArgs.path, { paths: [buildArgs.resolveDir] });
|
|
51
|
-
// Call twice the replace is to solve the problem of the path in Windows
|
|
52
|
-
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\');
|
|
53
|
-
return { path: pathEsm };
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
],
|
|
69
|
+
transform: {
|
|
70
|
+
define: { 'process.env.NODE_ENV': '"production"' },
|
|
71
|
+
},
|
|
72
|
+
plugins: [copyTypes(), umd2esm()],
|
|
73
|
+
output: {
|
|
74
|
+
dir: '.',
|
|
75
|
+
format: /** @type {const} */ ('cjs'),
|
|
76
|
+
sourcemap: isDev,
|
|
77
|
+
minify,
|
|
78
|
+
codeSplitting: false,
|
|
79
|
+
entryFileNames: `${name}.js`,
|
|
80
|
+
},
|
|
59
81
|
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default async function build() {
|
|
85
|
+
const configs = Object.entries(entries).map(([name, input]) => config(name, input));
|
|
60
86
|
|
|
61
87
|
if (!isDev) {
|
|
62
|
-
const
|
|
63
|
-
|
|
88
|
+
for (const options of configs) {
|
|
89
|
+
const bundle = await rolldown(options);
|
|
90
|
+
try {
|
|
91
|
+
await bundle.write(options.output);
|
|
92
|
+
} finally {
|
|
93
|
+
await bundle.close();
|
|
94
|
+
}
|
|
95
|
+
}
|
|
64
96
|
return;
|
|
65
97
|
}
|
|
66
98
|
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
-
|
|
99
|
+
const watcher = watch(configs);
|
|
100
|
+
watcher.on('event', (event) => {
|
|
101
|
+
if (event.code === 'ERROR') {
|
|
102
|
+
logError(event.error);
|
|
103
|
+
} else if (event.code === 'END') {
|
|
104
|
+
logUpdated();
|
|
105
|
+
}
|
|
70
106
|
});
|
|
71
107
|
|
|
72
|
-
await builder.watch();
|
|
73
|
-
|
|
74
108
|
process.on('beforeExit', () => {
|
|
75
|
-
void
|
|
109
|
+
void watcher.close();
|
|
76
110
|
});
|
|
77
111
|
}
|
|
78
112
|
|
package/scripts/shared.mjs
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
// @ts-check
|
|
2
|
-
import { dim, green, red
|
|
2
|
+
import { dim, green, red } from 'kleur/colors';
|
|
3
3
|
|
|
4
4
|
const dt = new Intl.DateTimeFormat('en-us', {
|
|
5
5
|
hour: '2-digit',
|
|
6
6
|
minute: '2-digit',
|
|
7
7
|
});
|
|
8
8
|
|
|
9
|
+
export function logUpdated() {
|
|
10
|
+
console.info(dim(`[${dt.format(new Date())}] `) + green('✔ updated'));
|
|
11
|
+
}
|
|
12
|
+
|
|
9
13
|
/**
|
|
10
|
-
* @
|
|
14
|
+
* @param {unknown} error
|
|
11
15
|
*/
|
|
12
|
-
export
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
console.error(dim(`[${date}] `) + red(result.errors.map((error) => error.text).join('\n')));
|
|
19
|
-
} else {
|
|
20
|
-
if (result.warnings.length) {
|
|
21
|
-
console.info(
|
|
22
|
-
dim(`[${date}] `) + yellow('⚠ updated with warnings:\n' + result.warnings.join('\n')),
|
|
23
|
-
);
|
|
24
|
-
}
|
|
25
|
-
console.info(dim(`[${date}] `) + green('✔ updated'));
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
},
|
|
29
|
-
};
|
|
16
|
+
export function logError(error) {
|
|
17
|
+
console.error(
|
|
18
|
+
dim(`[${dt.format(new Date())}] `) +
|
|
19
|
+
red(error instanceof Error ? error.message : String(error)),
|
|
20
|
+
);
|
|
21
|
+
}
|