Skip to content

Commit

Permalink
Add test for using nearest package.json for sideEffects
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Binns-Smith committed Apr 6, 2022
1 parent a8a4f51 commit 3b01d23
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 0 deletions.
@@ -0,0 +1,3 @@
import {one} from 'foo/bar'

output = one;

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.

@@ -0,0 +1,3 @@
import {one} from 'foo/bar'

output = one;

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.

34 changes: 34 additions & 0 deletions packages/core/integration-tests/test/scope-hoisting.js
Expand Up @@ -2264,6 +2264,40 @@ describe('scope hoisting', function () {
assert.equal(await output, 42);
});

describe("considers an asset's closest package.json for sideEffects, not the package through which it found the asset", () => {
it('handles redirects up the tree', async () => {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/es6/side-effects-package-redirect-up/index.js',
),
);

let result = await run(b);
assert.strictEqual(result, 1);

let bar = findAsset(b, 'real-bar.js');
assert(bar);
assert.strictEqual(bar.sideEffects, false);
});

it('handles redirects down the tree', async () => {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/es6/side-effects-package-redirect-down/index.js',
),
);

let result = await run(b);
assert.strictEqual(result, 1);

let bar = findAsset(b, 'real-bar.js');
assert(bar);
assert.strictEqual(bar.sideEffects, false);
});
});

describe('correctly updates used symbols on changes', () => {
it('dependency symbols change', async function () {
let testDir = path.join(
Expand Down

0 comments on commit 3b01d23

Please sign in to comment.