Skip to content

Commit f6cbfd7

Browse files
committed
Add test for side effects directive
1 parent 2a2c74f commit f6cbfd7

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { foo } from './lib/index.js'
2+
3+
it('should respect side effects directive', () => {
4+
expect(foo).toBe(789)
5+
6+
const modules = Object.keys(__turbopack_modules__)
7+
expect(modules).toContainEqual(expect.stringContaining('input/lib/foo'))
8+
expect(modules).not.toContainEqual(expect.stringContaining('input/lib/index'))
9+
expect(modules).not.toContainEqual(expect.stringContaining('input/lib/bar'))
10+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use turbopack no side effects"
2+
3+
export const bar = 123;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"use turbopack no side effects"
2+
3+
export const foo = 789;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
"use turbopack no side effects"
2+
3+
export {foo} from "./foo";
4+
export {bar} from "./bar";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"treeShakingMode": "reexports-only"
3+
}

0 commit comments

Comments
 (0)