Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Dec 2, 2024
1 parent 4854b71 commit dbd6399
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/node-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export function nodeResolve(opts = {}) {
const warn = (...args) => context.warn(...args);
const isRequire = custom && custom['node-resolve'] && custom['node-resolve'].isRequire;
const exportConditions = isRequire ? conditionsCjs : conditionsEsm;

Check warning on line 182 in packages/node-resolve/src/index.js

View workflow job for this annotation

GitHub Actions / Node v20

'exportConditions' is already declared in the upper scope on line 55 column 9

Check warning on line 182 in packages/node-resolve/src/index.js

View workflow job for this annotation

GitHub Actions / Node v18

'exportConditions' is already declared in the upper scope on line 55 column 9

Check warning on line 182 in packages/node-resolve/src/index.js

View workflow job for this annotation

GitHub Actions / Node v20

'exportConditions' is already declared in the upper scope on line 55 column 9

Check warning on line 182 in packages/node-resolve/src/index.js

View workflow job for this annotation

GitHub Actions / Node v18

'exportConditions' is already declared in the upper scope on line 55 column 9

if (useBrowserOverrides && !exportConditions.includes('browser'))
exportConditions.push('browser');

Expand Down
3 changes: 3 additions & 0 deletions packages/node-resolve/test/fixtures/dev-prod-conditions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import mode from 'dev-prod-conditions';

export default mode;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions packages/node-resolve/test/package-entry-points.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,3 +413,13 @@ test('custom condition takes precedence over browser field with `browser: true`'

t.deepEqual(module.exports, 'FROM WEBWORKER CONDITION');
});

test('production condition is used by default', async (t) => {
const bundle = await rollup({
input: 'dev-prod-conditions.js',
plugins: [nodeResolve()]
});
const { module } = await testBundle(t, bundle);

t.deepEqual(module.exports, 'DEV');
});

0 comments on commit dbd6399

Please sign in to comment.