I have a 3rd party dependency that internally relies on https://github.com/google/zx . Now zx does not publish with cjs, only ESM, and when I try to run my-script.ts that includes the dependency via:
node --loader @swc-node/register/esm my-script.ts
I get an error:
Error [ERR_REQUIRE_ESM]: require() of ES Module node_modules/zx/build/index.js from node_modules/3rd-party/dist/cjs/whatever.js not supported.
Instead change the require of index.js in node_modules/3rd-party/dist/cjs/whatever.js to a dynamic import() which is available in all CommonJS modules.
Obviously, cannot change the 3rd party dependency import statements. Also this was marked as "resolved" in #634 but seems like it works only on 1st level imports?
Other tools handle this properly (eg node -r esbuild-register) but I'd love to stick with SWC 🙏
I have a 3rd party dependency that internally relies on https://github.com/google/zx . Now
zxdoes not publish with cjs, only ESM, and when I try to runmy-script.tsthat includes the dependency via:I get an error:
Obviously, cannot change the 3rd party dependency import statements. Also this was marked as "resolved" in #634 but seems like it works only on 1st level imports?
Other tools handle this properly (eg
node -r esbuild-register) but I'd love to stick with SWC 🙏