astro-vscode 2.17.1 → 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 +6 -0
- package/dist/node/client.js +67 -21
- package/dist/node/server.js +862 -660
- package/package.json +2 -3
- 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",
|
|
@@ -245,11 +245,10 @@
|
|
|
245
245
|
"@vscode/test-cli": "^0.0.15",
|
|
246
246
|
"@vscode/test-electron": "^3.1.0",
|
|
247
247
|
"@vscode/vsce": "^4.0.0",
|
|
248
|
-
"esbuild": "^0.17.19",
|
|
249
|
-
"esbuild-plugin-copy": "^2.1.1",
|
|
250
248
|
"kleur": "^4.1.5",
|
|
251
249
|
"mocha": "^12.0.2",
|
|
252
250
|
"ovsx": "^1.2.0",
|
|
251
|
+
"rolldown": "^1.2.11",
|
|
253
252
|
"tsx": "^4.23.13",
|
|
254
253
|
"vscode-languageclient": "^10.1.2",
|
|
255
254
|
"vscode-tmgrammar-test": "^0.1.3",
|
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
|
+
}
|