Skip to content

Commit 6c50ead

Browse files
authored
Turbopack: improve unit tests (#80940)
1 parent c2be57c commit 6c50ead

File tree

3 files changed

+26
-1
lines changed
  • turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/comptime

3 files changed

+26
-1
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
11
import { something } from 'package/dep.js'
22
import { something2 } from 'package/dep2.js'
3+
import { something3 } from 'package-directive/dep.js'
34

45
it('should not include a module that is side effect free and exports are not used due to static analysis', () => {
6+
const modules = Object.keys(__turbopack_modules__)
7+
expect(modules).toContainEqual(
8+
expect.stringMatching(/input\/node_modules\/package\/dep2\.js/)
9+
)
10+
expect(modules).not.toContainEqual(
11+
expect.stringMatching(/input\/node_modules\/package\/dep\.js/)
12+
)
13+
514
if (true) {
615
something2()
716
return
817
}
918
something()
1019
})
20+
21+
it('should not include a module that is side effect free via directive and exports are not used due to static analysis', () => {
22+
const modules = Object.keys(__turbopack_modules__)
23+
expect(modules).not.toContainEqual(
24+
expect.stringMatching(/input\/node_modules\/package-directive\/dep\.js/)
25+
)
26+
27+
if (true) {
28+
} else {
29+
something3()
30+
}
31+
})

turbopack/crates/turbopack-tests/tests/execution/turbopack/side-effects-optimization/comptime/input/node_modules/package-directive/dep.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"treeShakingMode": "reexports-only"
2+
"treeShakingMode": "reexports-only",
3+
"scopeHoisting": false
34
}

0 commit comments

Comments
 (0)