Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(node-resolve): add tests for mixing custom exportConditions with browser: true #1043

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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');
});