Closed manast closed 7 months ago
Ok, it seems like the issue comes from this Node bug: https://github.com/nodejs/node/issues/43663
👍🏼 keep me updated
In practice, the only way to get "pkg" to work in modern codebases is to prebundle everything with esbuild and then compile the resulting bundle. It can get complicated if you have a lot of dynamic imports or you load static assets, etc, but it is doable with some non trivial effort.
That's exactly what i do on my packages and I have some that are really big. Take a look at this tool: https://github.com/chjj/bpkg
It's like esbuild but it handles better node native addons by loading them as base64
What version of pkg are you using?
5.11.1
What version of Node.js are you using?
Node 20
What operating system are you using?
macOs
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
Node 20, linux
Describe the Bug
If the code to be packaged includes a dynamic import, like this one:
When running the resulting exe we get an exception with the following error:
Seems like for some reason the resulting exe is not compatible with dynamic imports, despite using node20 as target which has full support for dynamic imports.
Expected Behavior
It should work as it does when just running the given code with node.
To Reproduce