mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-18 09:25:54 +00:00
fix(nuxt): allow url-specific chars in vfs (#30584)
This commit is contained in:
parent
2fee14df8b
commit
06d5840d26
@ -38,25 +38,25 @@ export const VirtualFSPlugin = (nuxt: Nuxt, options: VirtualFSPluginOptions) =>
|
|||||||
|
|
||||||
const resolvedId = resolveWithExt(id)
|
const resolvedId = resolveWithExt(id)
|
||||||
if (resolvedId) {
|
if (resolvedId) {
|
||||||
return PREFIX + resolvedId
|
return PREFIX + encodeURIComponent(resolvedId)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (importer && RELATIVE_ID_RE.test(id)) {
|
if (importer && RELATIVE_ID_RE.test(id)) {
|
||||||
const path = resolve(dirname(withoutPrefix(importer)), id)
|
const path = resolve(dirname(withoutPrefix(importer)), id)
|
||||||
const resolved = resolveWithExt(path)
|
const resolved = resolveWithExt(path)
|
||||||
if (resolved) {
|
if (resolved) {
|
||||||
return PREFIX + resolved
|
return PREFIX + encodeURIComponent(resolved)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
loadInclude (id) {
|
loadInclude (id) {
|
||||||
return id.startsWith(PREFIX) && withoutPrefix(id) in nuxt.vfs
|
return id.startsWith(PREFIX) && withoutPrefix(decodeURIComponent(id)) in nuxt.vfs
|
||||||
},
|
},
|
||||||
|
|
||||||
load (id) {
|
load (id) {
|
||||||
return {
|
return {
|
||||||
code: nuxt.vfs[withoutPrefix(id)] || '',
|
code: nuxt.vfs[withoutPrefix(decodeURIComponent(id))] || '',
|
||||||
map: null,
|
map: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -287,9 +287,9 @@ export const PageMetaPlugin = (options: PageMetaPluginOptions = {}) => createUnp
|
|||||||
handleHotUpdate: {
|
handleHotUpdate: {
|
||||||
order: 'post',
|
order: 'post',
|
||||||
handler: ({ file, modules, server }) => {
|
handler: ({ file, modules, server }) => {
|
||||||
if (options.isPage?.(file)) {
|
if (options.routesPath && options.isPage?.(file)) {
|
||||||
const macroModule = server.moduleGraph.getModuleById(file + '?macro=true')
|
const macroModule = server.moduleGraph.getModuleById(file + '?macro=true')
|
||||||
const routesModule = server.moduleGraph.getModuleById('virtual:nuxt:' + options.routesPath)
|
const routesModule = server.moduleGraph.getModuleById('virtual:nuxt:' + encodeURIComponent(options.routesPath))
|
||||||
return [
|
return [
|
||||||
...modules,
|
...modules,
|
||||||
...macroModule ? [macroModule] : [],
|
...macroModule ? [macroModule] : [],
|
||||||
|
@ -44,7 +44,7 @@ export function viteNodePlugin (ctx: ViteBuildContext): VitePlugin {
|
|||||||
// invalidate changed virtual modules when templates are regenerated
|
// invalidate changed virtual modules when templates are regenerated
|
||||||
ctx.nuxt.hook('app:templatesGenerated', (_app, changedTemplates) => {
|
ctx.nuxt.hook('app:templatesGenerated', (_app, changedTemplates) => {
|
||||||
for (const template of changedTemplates) {
|
for (const template of changedTemplates) {
|
||||||
const mods = server.moduleGraph.getModulesByFile(`virtual:nuxt:${template.dst}`)
|
const mods = server.moduleGraph.getModulesByFile(`virtual:nuxt:${encodeURIComponent(template.dst)}`)
|
||||||
|
|
||||||
for (const mod of mods || []) {
|
for (const mod of mods || []) {
|
||||||
markInvalidate(mod)
|
markInvalidate(mod)
|
||||||
|
@ -212,7 +212,7 @@ export const bundle: NuxtBuilder['bundle'] = async (nuxt) => {
|
|||||||
// Invalidate virtual modules when templates are re-generated
|
// Invalidate virtual modules when templates are re-generated
|
||||||
ctx.nuxt.hook('app:templatesGenerated', (_app, changedTemplates) => {
|
ctx.nuxt.hook('app:templatesGenerated', (_app, changedTemplates) => {
|
||||||
for (const template of changedTemplates) {
|
for (const template of changedTemplates) {
|
||||||
for (const mod of server.moduleGraph.getModulesByFile(`virtual:nuxt:${template.dst}`) || []) {
|
for (const mod of server.moduleGraph.getModulesByFile(`virtual:nuxt:${encodeURIComponent(template.dst)}`) || []) {
|
||||||
server.moduleGraph.invalidateModule(mod)
|
server.moduleGraph.invalidateModule(mod)
|
||||||
server.reloadModule(mod)
|
server.reloadModule(mod)
|
||||||
}
|
}
|
||||||
|
@ -134,7 +134,7 @@ if (process.env.TEST_ENV !== 'built' && !isWindows) {
|
|||||||
'type': 'debug',
|
'type': 'debug',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'text': `[vite] hot updated: /@id/virtual:nuxt:${fixturePath}/.nuxt/routes.mjs`,
|
'text': `[vite] hot updated: /@id/virtual:nuxt:${encodeURIComponent(join(fixturePath, '.nuxt/routes.mjs'))}`,
|
||||||
'type': 'debug',
|
'type': 'debug',
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
Loading…
Reference in New Issue
Block a user