Open jdion84 opened 1 year ago
This issue is already tracked here: https://github.com/evanw/esbuild/issues/1921
In summary, this runtime error is caused by bundling CJS libraries into ESM context (i.e. bundle express
in format: 'esm'
). esbuild uses closures to wrap these CJS liraries, and Node.js forbids dynamic (i.e. not at the top level) require on builtin modules.
I would still suggest you to exclude these dependencies from your bundle with --packages=external
or --external:express
since your runtime supports loading them from the file system, and it also bundles less code.
@hyrious will work if i deploy the code?
@hyrious will work if i deploy the code?
It depends on your deployment environment, if you are only sending the build output upstream then no - it won't. If you are sending the whole application root up, including any modules and all the other files needed to produce the build; then it should work fine :)
im trying to build and run express server code
entry/server.js
:entry/build.js
:package.json
:when i do
npm run dev
i get this error: