Skip to content

Commit

Permalink
chore(test): add tests for mixing custom exportConditions with `bro…
Browse files Browse the repository at this point in the history
…wser: true`
  • Loading branch information
Andarist committed Nov 16, 2021
1 parent 02fb349 commit 28b14c7
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 0 deletions.
@@ -0,0 +1,3 @@
import sample from 'exports-only-worker-condition-with-browser-field';

export default sample;
@@ -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
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 28b14c7

Please sign in to comment.