Replies: 1 comment
-
// tsup.config.ts
import { defineConfig } from "tsup";
export default defineConfig({
banner: {
js: `import {createRequire as __createRequire} from 'module';var require=__createRequire(import\.meta.url);`,
},
}); Shouldn't we use |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If you're building in esm format, and one of your dependency is written in CJS and you want to bundle it, the result code might contain
require
call:That's because built-in modules can't be resolved and esbuild just leaves it as is, a workaround is to use the
banner.js
option to makerequire
available in your esm bundle:Beta Was this translation helpful? Give feedback.
All reactions