next.js
08aad0c4 - Turbopack: fix codegen of directives (#80895)

Commit
270 days ago
Turbopack: fix codegen of directives (#80895) Closes PACK-4894 Previously, directives in the input weren't handled correctly, this was the output: The `use strict` doesn't do anything here because directives only have an effect at the top of modules and at the top of functions. ```js "[project]/turbopack/crates/turbopack-tests/tests/snapshot/basic/use-strict/input/index.js [test] (ecmascript)": ((__turbopack_context__) => { var { m: module, e: exports } = __turbopack_context__; { 'use strict'; console.log('this is CJS'); module.exports = 1234; }}), }]); ``` Instead: 1. detect if `use strict` is in the input file 2. strip all directives 3. prepend `"use strict"` at the top of the chunk item, if it was strict strict
Author
Parents
Loading