Turbopack: fix require handling with alternative (#98258)
Regression from - https://github.com/vercel/next.js/pull/97867 (which uncovered this bug in this particular case with the default parameter assignment) and - https://github.com/vercel/next.js/pull/97697 (because previously `unknown | WellKnownFunction` was just unknown. Now it stays `unknown | WellKnownFunction`) Fixes ``` ./node_modules/.pnpm/@vue+compiler-sfc@3.5.26/node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js:45756:20 Error: Module not found: Can't resolve 'less' 45754 | ); 45755 | const less = (source, map, options, load = require) => { > 45756 | const nodeLess = load("less"); | ^^^^^^^^^^^^ ``` because basically ```js const load = globalThis.foobar || require const x = load("less"); ``` would get replaced to ```js const load = globalThis.foobar || require const x = __turbopack_context__.require(191912); ``` which would be wrong if `globalThis.foobar` isn't actually `require` at runtime. Instead, if we are inside an alternative, don't emit a codegen replacement but only add reference
Showing
This diff is collapsed.
Please
register
or
sign in
to comment