Revert "[turbopack] Enable CJS tree shaking by default (#96779)" (#97018)
Reverts vercel/next.js#96779
With this flag enabled, CJS modules written as `var X = module.exports =
{ … }` lose properties that are only read back through the alias.
`@mixmark-io/domino` (Turndown's server DOM), `lib/LinkedList.js`:
```js
// source
var LinkedList = module.exports = {
valid: function(a) { /* … */ return true; },
insertBefore: function(a, b) {
utils.assert(LinkedList.valid(a) && LinkedList.valid(b));
```
```js
// emitted with turbopackCjsTreeShaking: true
var LinkedList = module.exports = {
...void function(a) { /* … */ return true; }, // `valid:` key dropped
```
`valid` is only referenced via the alias, so it is judged unused and
elided, and the elision emits `...void <fnExpr>`, i.e. `...undefined`,
which spreads nothing. Result: `TypeError: LinkedList.valid is not a
function`.
Not domino-specific (same corruption in its `NodeUtils.js`), and the
failure mode is a silent property elision rather than a build error.
Showing
Please
register
or
sign in
to comment