Skip to content

Commit

Permalink
Resolve using "node" export condition for --target node
Browse files Browse the repository at this point in the history
When bundling for a Node.js target, Microbundle should follow the "node" conditional package export key to match Node's own resolution. Fixes #886.
  • Loading branch information
developit authored Sep 1, 2021
1 parent b1a6374 commit 8fb4202
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ function createConfig(options, entry, format, writeMeta) {
nodeResolve({
mainFields: ['module', 'jsnext', 'main'],
browser: options.target !== 'node',
exportConditions: options.target === 'node' ? ['node'] : ['browser'],
// defaults + .jsx
extensions: ['.mjs', '.js', '.jsx', '.json', '.node'],
preferBuiltins: options.target === 'node',
Expand Down

0 comments on commit 8fb4202

Please sign in to comment.