mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 15:15:19 +00:00
fix(nuxt): handle vite preload-helper id with extension (#23230)
This commit is contained in:
parent
bdbb87ac0b
commit
3334ca26c6
@ -1,11 +1,15 @@
|
||||
import MagicString from 'magic-string'
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
const vitePreloadHelperId = '\0vite/preload-helper'
|
||||
|
||||
// TODO: remove this function when we upgrade to vite 5
|
||||
export function chunkErrorPlugin (options: { sourcemap?: boolean }): Plugin {
|
||||
return {
|
||||
name: 'nuxt:chunk-error',
|
||||
transform (code, id) {
|
||||
if (id !== '\0vite/preload-helper' || code.includes('nuxt.preloadError')) { return }
|
||||
// Vite 5 has an id with extension
|
||||
if (!(id === vitePreloadHelperId || id === `${vitePreloadHelperId}.js`) || code.includes('nuxt.preloadError')) { return }
|
||||
|
||||
const s = new MagicString(code)
|
||||
s.replace(/__vitePreload/g, '___vitePreload')
|
||||
|
Loading…
Reference in New Issue
Block a user