Skip to content

Commit

Permalink
chore(vscode): share @vue/language-core between build files
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Nov 6, 2024
1 parent bdab27d commit 71ff65a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
],
"typescriptServerPlugins": [
{
"name": "typescript-vue-plugin-bundle",
"name": "typescript-vue-plugin-pack",
"enableForWorkspaceTypeScriptVersions": true,
"configNamespace": "typescript"
}
Expand Down
20 changes: 16 additions & 4 deletions extensions/vscode/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ require('esbuild').context({
entryPoints: {
'dist/client': './out/nodeClientMain.js',
'dist/server': './node_modules/@vue/language-server/bin/vue-language-server.js',
'node_modules/typescript-vue-plugin-bundle/index': './node_modules/@vue/typescript-plugin/index.js',
'node_modules/vue-language-core-pack/index': './node_modules/@vue/language-core/index.js',
'node_modules/typescript-vue-plugin-pack/index': './node_modules/@vue/typescript-plugin/index.js',
},
bundle: true,
metafile: process.argv.includes('--metafile'),
Expand All @@ -22,13 +23,24 @@ require('esbuild').context({
name: 'umd2esm',
setup(build) {
build.onResolve({ filter: /^(vscode-.*-languageservice|jsonc-parser)/ }, args => {
const pathUmdMay = require.resolve(args.path, { paths: [args.resolveDir] })
const pathUmdMay = require.resolve(args.path, { paths: [args.resolveDir] });
// Call twice the replace is to solve the problem of the path in Windows
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\')
return { path: pathEsm }
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\');
return { path: pathEsm };
})
},
},
{
name: 'resolve-share-module',
setup(build) {
build.onResolve({ filter: /^@vue\/language-core$/ }, () => {
return {
path: 'vue-language-core-pack',
external: true,
};
});
},
},
{
name: 'schemas',
setup(build) {
Expand Down
4 changes: 2 additions & 2 deletions extensions/vscode/src/nodeClientMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,15 @@ try {
if (!enabledTypeScriptPlugin.value) {
text = text.replace(
'for(const e of n.contributes.typescriptServerPlugins',
s => s + `.filter(p=>p.name!=='typescript-vue-plugin-bundle')`
s => s + `.filter(p=>p.name!=='typescript-vue-plugin-pack')`
);
} else if (enabledHybridMode.value) {
// patch readPlugins
text = text.replace(
'languages:Array.isArray(e.languages)',
[
'languages:',
`e.name==='typescript-vue-plugin-bundle'?[${config.server.includeLanguages
`e.name==='typescript-vue-plugin-pack'?[${config.server.includeLanguages
.map(lang => `'${lang}'`)
.join(',')}]`,
':Array.isArray(e.languages)'
Expand Down

0 comments on commit 71ff65a

Please sign in to comment.