Node w/ ESM uses CJS files #696
Labels
c: refactor
PR that affects the runtime behavior, but doesn't add new features or fixes bugs
p: 1-normal
Nothing urgent
s: accepted
Accepted feature / Confirmed bug
Milestone
Describe the bug
I'm trying to compile my NodeJS app with ESM. When I build with esbuild, it selects the CJS build of Faker instead of the ESM version.
Reproduction
I'm using esbuild with
--bundle --target node14 --mainFields module,main --format esm
Additional Info
I believe the problem is in faker's package.json:
It appears to assume if I'm using node I want commonjs. I'm using node and I want ESM.
I think it should be using
require
vsimport
- see the nodejs docs here https://nodejs.org/api/packages.html#conditional-exportsThen it will select the proper version depending on if the consumer is using
require
orimport
. No assumptions needed.The text was updated successfully, but these errors were encountered: