-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Strip node:
prefix when converting to CJS and target < node14.18
#1760
Comments
Relevant links: |
Simple redirect and mark it as external in var stripNodeColonPlugin = {
name: 'strip-node-colon',
setup({ onResolve, onLoad }) {
onResolve({ filter: /^node:/ }, args => {
return { path: args.path.slice('node:'.length), external: true }
})
}
} |
i was just thinking... what if you transpile: import fs from 'node:fs'
export const foo = 'bar' into something like: // main.cjs
(async () => {
const { default: fs } = await import('node:fs')
return { foo: 'bar' }
})() Everything about ESM is async from the ground up. All imports, top-level await. |
Open
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A recent release of
node-fetch
exposed an issue wherenode:*
prefix imports compiled intorequire()
calls are not supported if < node v14.18node-fetch/node-fetch#1367
Is there a way to check the compile target, and if the target is CJS without
node:*
prefix support, strip away the prefix?Thanks Evan! :)
The text was updated successfully, but these errors were encountered: