You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The code above will convert umd imports to esm by replacing "umd" with "esm" in the filepath.
However, the path generated no longer work for vscode-uri as of 3.0.8.
The path for umd import is "lib/umd/index.js", but the path for esm import is "lib/esm/index.mjs". As the script replaces "lib/umd/index.js" with "lib/esm/index.js", esbuild fails to resolve the esm import.
I managed to build my VSCode extension with this code:
build.onResolve({filter: /^(vscode-.*|estree-walker|jsonc-parser)/},(args)=>{constpathUmdMay=require.resolve(args.path,{paths: [args.resolveDir]})// Call twice the replace is to solve the problem of the path in WindowsletpathEsm=pathUmdMay.replace('/umd/','/esm/').replace('\\umd\\','\\esm\\')// Try to resolve the path// If it fails, if the file extension is .js, try to replace it with .mjstry{require.resolve(pathEsm,{paths: [args.resolveDir]})}catch{if(pathEsm.endsWith('.js'))pathEsm=pathEsm.replace(/\.js$/,'.mjs')}return{path: pathEsm}})
This code tries to resolve the new path. If it fails, it tries to resolve the import by replacing .js with .mjs.
It works, but I think it is still not robust enough. Another solution might be considered.
The text was updated successfully, but these errors were encountered:
Thanks for the report! Thanks to @remcohaszing efforts at microsoft/vscode#192144, some vscode packages have fixed the module format, we fixed the build script in other repo, but forgot to fix the starter repo, will update it!
Description
starter/packages/vscode/scripts/build.js
Lines 22 to 27 in 45c67d8
The code above will convert
umd
imports toesm
by replacing "umd" with "esm" in the filepath.However, the path generated no longer work for
vscode-uri
as of 3.0.8.The path for
umd
import is"lib/umd/index.js"
, but the path foresm
import is"lib/esm/index.mjs"
. As the script replaces"lib/umd/index.js"
with"lib/esm/index.js"
, esbuild fails to resolve theesm
import.Steps to Reproduce
Use
vscode-uri>=3.0.8
.Solutions
I managed to build my VSCode extension with this code:
This code tries to resolve the new path. If it fails, it tries to resolve the import by replacing
.js
with.mjs
.It works, but I think it is still not robust enough. Another solution might be considered.
The text was updated successfully, but these errors were encountered: