Skip to content

Commit d2fc4be

Browse files
authored
fix(optimizer): skip rolldownCjsExternalPlugin for platform: neutral (#21452)
1 parent ff9dd7f commit d2fc4be

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/vite/src/node/optimizer/rolldownDepPlugin.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,14 @@ export function rolldownCjsExternalPlugin(
315315
if (platform === 'node') {
316316
return undefined
317317
}
318+
// Skip this plugin for `platform: 'neutral'` as we are not sure whether `require` is available
319+
if (platform === 'neutral') {
320+
return undefined
321+
}
318322

319323
// Apply this plugin for `platform: 'browser'` as `require` is not available in browser and
320324
// converting to `import` would be necessary to make the code work
321-
platform satisfies 'browser' | 'neutral'
325+
platform satisfies 'browser'
322326

323327
const filter = new RegExp(externals.map(matchesEntireLine).join('|'))
324328

0 commit comments

Comments
 (0)