Files
Niklas MischkulnigandGitHub 08aad0c425 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
2025-06-27 12:10:11 +02:00

5 lines
63 B
JavaScript

'use strict'
console.log('this is CJS')
module.exports = 1234