[lts-active] Revert "Optimize strict module factory chunks (#98421)"

Merged
LU
5d ago
+408-826

Reverts #98421 on releases/lts/active.

Fixes #100617

Summary

#98421 moved "use strict" from each module factory into a shared strict-mode wrapper around the chunk. This exposed an SWC minifier bug (swc-project/swc#12580): the if_return pass could merge a function's directive prologue into a sequence expression, so the function silently lost strict mode in production builds.

On canary, this is fixed by bumping to SWC v82.2.0 (#100508). LTS is still on swc_core 79, and getting that fix here would mean also backporting the v81 (#99720) and v82 (#100270) bumps. So instead, this reverts the optimization on LTS only. Each factory gets its own "use strict" again, which is the format LTS used before #98421. Canary doesn't need the revert.

Conflicts with #98953 (Remove TraceRawVcs) were resolved by dropping the TraceRawVcs import. Turbopack snapshot outputs were regenerated with UPDATE=1.

Verification

  • cargo nextest r -p turbopack-tests --test snapshot (132 passed, after UPDATE=1)
  • cargo nextest r -p turbopack-ecmascript -p turbopack-browser -p turbopack-nodejs (592 passed)
  • cargo check -p turbopack-ecmascript -p turbopack-browser -p turbopack-nodejs -p next-api with -Dwarnings
  • pnpm check in turbopack/crates/turbopack-ecmascript-runtime/js