-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
How can we use dependencies that still use require while shipping esm? Is that possible?
Minimal reproduction:
https://github.com/enricoschaaf/esbuild-issue
Just run node index.mjs. This was generated from running build which executes esbuild to bundle this file.
Problem:
The problem is that node internal modules can of course not bet bundled so I expected the require syntax would get written to import syntax if the target is esm but they are still require.
Error message:
Error: Dynamic require of "os" is not supported
at file:///home/enrico/work/esbuild-issue/index.mjs:1:450
at file:///home/enrico/work/esbuild-issue/index.mjs:1:906
at file:///home/enrico/work/esbuild-issue/index.mjs:1:530
at file:///home/enrico/work/esbuild-issue/index.mjs:1:950
at ModuleJob.run (node:internal/modules/esm/module_job:195:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
at async loadESM (node:internal/process/esm_loader:88:5)
at async handleMainPromise (node:internal/modules/run_main:65:12)