Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Aug 12, 2022
1 parent 69ee892 commit 6566e0e
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 0 deletions.
@@ -0,0 +1,3 @@
import { Context } from "./library";

output = [Context, () => import("./library/dynamic")];
@@ -0,0 +1,2 @@
sideEffect("a");
export const Ctx = 1;
@@ -0,0 +1,2 @@
sideEffect("b");
export const Ctx = 2;
@@ -0,0 +1,4 @@
sideEffect("dynamic");
import { Ctx } from "./a.js";
import { id } from "./index.js";
export default [Ctx, id];
@@ -0,0 +1,4 @@
sideEffect("index");
export { Ctx } from "./a.js";
export { Ctx as Context } from "./b.js";
export const id = 3;
@@ -0,0 +1,3 @@
{
"sideEffects": false
}
37 changes: 37 additions & 0 deletions packages/core/integration-tests/test/javascript.js
Expand Up @@ -7186,6 +7186,43 @@ describe('javascript', function () {
assert.deepEqual(res.output, ['foo', 'bar']);
});

it('supports partially used reexporting index file', async function () {
let b = await bundle(
path.join(
__dirname,
'/integration/scope-hoisting/es6/side-effects-re-exports-partially-used/index.js',
),
options,
);

let calls = [];
let res = (
await run(
b,
{
sideEffect: caller => {
calls.push(caller);
},
},
{require: false},
)
).output;

let [v, async] = res;

assert.deepEqual(calls, shouldScopeHoist ? ['b'] : ['a', 'b', 'index']);
assert.deepEqual(v, 2);

v = await async();
assert.deepEqual(
calls,
shouldScopeHoist
? ['b', 'a', 'index', 'dynamic']
: ['a', 'b', 'index', 'dynamic'],
);
assert.deepEqual(v.default, [1, 3]);
});

it('supports deferring non-weak dependencies that are not used', async function () {
let b = await bundle(
path.join(
Expand Down

0 comments on commit 6566e0e

Please sign in to comment.