-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Feature] support createRequire
#1828
Comments
Do other bundlers support this too? I mainly try to have esbuild follow existing conventions instead of inventing new ones. I don't think esbuild should do something like this without e.g. Webpack doing this too, because I don't want to create new conventions and fragment the community. |
It seems this has been implemented in Webpack 30 days ago |
#1921 (comment) |
I'm currently hijacking the /* index.mts */
import { createRequire } from 'node:module'
let foo
try {
const originalRequire = require
require = createRequire(__filename)
foo = require('path/to/foo')
require = originalRequire
} catch (error) {
console.error(error)
process.exit(1)
} |
$ # remove `createRequire`, let `require` global web-streams-polyfill/dist/ponyfill.js is bundled
But, reference to a global variable
require
within ESM, I think it's not in standard?The text was updated successfully, but these errors were encountered: