Unverified Commit 99bfe967 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: add failing test for cross-module side-effect inference (#93323)

Currently not implemented, but maybe in the future
parent 28c9eefa
import { used } from './lib'
it('should skip over module', () => {
expect(used()).toBe('used')
const modules = Array.from(__turbopack_modules__.keys())
expect(modules).toContainEqual(
expect.stringMatching(/cross-function\/input\/lib\.js/)
)
// TODO the side-effect inference is currently not smart enough to perform cross-function analysis
// expect(modules).not.toContainEqual(
// expect.stringMatching(/cross-function\/input\/util\.js/)
// )
})
import { exec } from './util.js'
export function unused() {
return exec
}
export function used() {
return 'used'
}
export function cached(getter) {
const set = false
return {
get value() {
if (!set) {
const value = getter()
Object.defineProperty(this, 'value', { value })
return value
}
throw new Error('cached value already set')
},
}
}
export const allowsEval = cached(() => {
try {
const F = Function
new F('')
return true
} catch (_) {
return false
}
})
export function exec(foo) {
return 'x ' + foo
}
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