Skip to content

Commit

Permalink
test(node-resolve): add tests for mixing custom exportConditions wi…
Browse files Browse the repository at this point in the history
…th `browser: true` (#1043)
  • Loading branch information
Andarist authored Dec 13, 2021
1 parent 8aa447a commit 9e6db2d
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import sample from 'exports-only-worker-condition-with-browser-field';

export default sample;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import sample from 'exports-worker-condition-with-browser-field';

export default sample;

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.

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.

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

20 changes: 20 additions & 0 deletions packages/node-resolve/test/package-entry-points.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,3 +380,23 @@ test('does not warn when resolving typescript imports with fallback', async (t)
a: 'A'
});
});

test('custom condition takes precedence over browser field and condition with `browser: true`', async (t) => {
const bundle = await rollup({
input: 'exports-worker-condition-with-browser-field.js',
plugins: [nodeResolve({ exportConditions: ['browser', 'webworker'], browser: true })]
});
const { module } = await testBundle(t, bundle);

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

test('custom condition takes precedence over browser field with `browser: true`', async (t) => {
const bundle = await rollup({
input: 'exports-only-worker-condition-with-browser-field.js',
plugins: [nodeResolve({ exportConditions: ['browser', 'webworker'], browser: true })]
});
const { module } = await testBundle(t, bundle);

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

0 comments on commit 9e6db2d

Please sign in to comment.