Skip to content

Commit

Permalink
fix(build): enhance module resolution for vscode-languageserver-types…
Browse files Browse the repository at this point in the history
… and vscode-uri
  • Loading branch information
johnsoncodehk committed Nov 6, 2024
1 parent 71ff65a commit 80f0770
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions extensions/vscode/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,23 @@ require('esbuild').context({
{
name: 'umd2esm',
setup(build) {
build.onResolve({ filter: /^(vscode-.*-languageservice|jsonc-parser)/ }, args => {
build.onResolve({ filter: /^(vscode-.*-languageservice|vscode-languageserver-types|jsonc-parser)$/ }, args => {
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 };
})
});
build.onResolve({ filter: /^vscode-uri$/ }, args => {
const pathUmdMay = require.resolve(args.path, { paths: [args.resolveDir] });
// v3
let pathEsm = pathUmdMay.replace('/umd/index.js', '/esm/index.mjs').replace('\\umd\\index.js', '\\esm\\index.mjs');
if (pathEsm !== pathUmdMay && fs.existsSync(pathEsm)) {
return { path: pathEsm };
}
// v2
pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\');
return { path: pathEsm };
});
},
},
{
Expand Down

0 comments on commit 80f0770

Please sign in to comment.