|
|
import { nextTestSetup } from 'e2e-utils' |
|
|
|
|
|
describe('Dynamic Code Evaluation (DCE)', () => { |
|
|
const { next } = nextTestSetup({ |
|
|
skipStart: true, |
|
|
dependencies: { 'function-bind': 'latest' }, |
|
|
files: __dirname, |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should not fail when "function-bind" package is used', async () => { |
|
|
const { exitCode, cliOutput } = await next.build() |
|
|
expect(exitCode).toBe(0) |
|
|
expect(cliOutput).not.toContain( |
|
|
`Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime` |
|
|
) |
|
|
}) |
|
|
;(process.env.IS_TURBOPACK_TEST ? it.skip : it)( |
|
|
"should show the user's import trace", |
|
|
async () => { |
|
|
await next.patchFile( |
|
|
'middleware.js', |
|
|
` |
|
|
import { foo } from './lib/foo' |
|
|
export function middleware() { |
|
|
foo() |
|
|
}` |
|
|
) |
|
|
const { exitCode, cliOutput } = await next.build() |
|
|
|
|
|
expect(exitCode).toBe(1) |
|
|
|
|
|
|
|
|
expect(cliOutput).toContain(`./lib/foo.js |
|
|
Dynamic Code Evaluation (e. g. 'eval', 'new Function', 'WebAssembly.compile') not allowed in Edge Runtime |
|
|
Used by bar`) |
|
|
|
|
|
|
|
|
expect(cliOutput).toContain(`Import trace for requested module: |
|
|
./lib/foo.js |
|
|
./middleware.js`) |
|
|
} |
|
|
) |
|
|
}) |
|
|
|