-
-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No fallback for Register when entrypoint is a commonjs
vscode extension
#795
Comments
commonjs
vscode extensioncommonjs
vscode extension
commonjs
vscode extensioncommonjs
vscode extension
commonjs
vscode extensioncommonjs
vscode extension
I have the same issue, however I think it is not specific to VSCode extension. I encounter it when I import a |
I'm even wondering if in export const load: LoadHook = async (url, context, nextLoad) => {
debug('load', url, JSON.stringify(context))
if (url.startsWith('data:')) {
debug('skip load: data url', url)
return nextLoad(url, context)
}
if (['builtin', 'json', 'wasm'].includes(context.format)) {
debug('loaded: internal format', url)
return nextLoad(url, context)
}
+ if (context.format === "commonjs") {
+ debug('skip load: commonjs file', url);
+ return nextLoad(url, context);
+ }
const { source, format: resolvedFormat } = await nextLoad(url, context)
debug('loaded', url, resolvedFormat)
const code = !source || typeof source === 'string' ? source : Buffer.from(source).toString()
const compiled = await compile(code, url, tsconfigForSWCNode, true)
debug('compiled', url, resolvedFormat)
return addShortCircuitSignal({
// for lazy: ts-node think format would undefined, actually it should not, keep it as original temporarily
format: resolvedFormat,
source: compiled,
})
}
WDYT @Brooooooklyn? |
definitely no. import commonjs in esm is a very common case
A workaround should be. but ignoring by path prefix is too rude. I would look at this, maybe we could have a better way. |
could you please provide a minimal reproduction |
Got a different error on this sandbox, but fails on |
Hi, trying to execute my custom runtime with a vscode extension to support loading ESM files with register hook v1.10. However, I am getting this error in outputs:
What would be executed for example would be
ESLINT_USE_FLAT_CONFIG=true node bin/swc-node.js "../../.vscode/extensions/dbaeumer.vscode-eslint-3.0.10/server/out/eslintServer.js" -c eslint.config.ts
.Analysis
It seems that any
commonjs
file would cause the same error. For example I've created a simple test:Would recieve the same error:
Seeing here we shortcircuit and fails to compile when source is undefined. I would assume we need a similar fallback, which fixed the Yarn loader case . I have my workaround which works in my case:
The text was updated successfully, but these errors were encountered: