Unverified Commit 8f8c78e0 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: add more side effects test cases (#82465)

### What?

Add more test cases for the side effects optimization that are currently broken

Closes https://github.com/vercel/next.js/pull/82411
parent 7f1ad3ae
import { something } from './main'
it('correct order', () => {
expect(something).toBe('inner')
expect(globalThis.order).toEqual([
// TODO Order should be 'inner throws', 'module'
'module',
'inner no-throws',
'main',
])
})
import { value } from './module.js'
export const something = 'inner'
let throws = false
try {
value
} catch {
throws = true
}
;(globalThis.order ??= []).push(`inner ${throws ? 'throws' : 'no-throws'}`)
export { something } from './module.js'
;(globalThis.order ??= []).push('main')
export { something } from './inner.js'
export const value = 42
;(globalThis.order ??= []).push('module')
export { a } from './side-effect.js'
import { effect } from './check-side-effect.js'
effect('index.js')
export { a } from 'package-star'
import { effect } from './check-side-effect.js'
effect('side-effect.js')
export * from './side-effect.js'
import { effect } from './check-side-effect.js'
effect('index.js')
export * from 'package-star'
import { effect } from './check-side-effect.js'
effect('side-effect.js')
...@@ -18,3 +18,23 @@ it('should run side effects of a reexporting module with side effects (async mod ...@@ -18,3 +18,23 @@ it('should run side effects of a reexporting module with side effects (async mod
require('package-require-side-effect') require('package-require-side-effect')
expect(effects8).toEqual(['side-effect.js', 'side-effect2.js', 'index.js']) expect(effects8).toEqual(['side-effect.js', 'side-effect2.js', 'index.js'])
}) })
import { a as a9 } from 'package-intermediate-side-effect'
import { effects as effects9 } from 'package-intermediate-side-effect/check-side-effect'
it('should run side effects of an intermediate module with side effects (star reexports)', () => {
expect(a9).toBe('a')
expect(effects9).toEqual([
// TODO This should execute the side effect of the intermediate module
// 'side-effect.js'
])
})
import { a as a10 } from 'package-intermediate-named-side-effect'
import { effects as effects10 } from 'package-intermediate-named-side-effect/check-side-effect'
it('should run side effects of an intermediate module with side effects (named reexports)', () => {
expect(a10).toBe('a')
expect(effects10).toEqual([
// TODO This should execute the side effect of the intermediate module
// 'side-effect.js'
])
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment