Skip to content

Commit

Permalink
Add test for side effects directive
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic committed Mar 7, 2025
1 parent 77129c6 commit c20b83f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { foo } from './lib/index.js'

it('should respect side effects directive', () => {
expect(foo).toBe(789)

const modules = Object.keys(__turbopack_modules__)
expect(modules).toContainEqual(expect.stringContaining('input/lib/foo'))
expect(modules).not.toContainEqual(expect.stringContaining('input/lib/index'))
expect(modules).not.toContainEqual(expect.stringContaining('input/lib/bar'))
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use turbopack no side effects"

export const bar = 123;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"use turbopack no side effects"

export const foo = 789;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
"use turbopack no side effects"

export {foo} from "./foo";
export {bar} from "./bar";
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"treeShakingMode": "reexports-only"
}

0 comments on commit c20b83f

Please sign in to comment.