Skip to content

Commit be76c28

Browse files
committed
chore: update deps
1 parent f7e4819 commit be76c28

6 files changed

Lines changed: 1272 additions & 875 deletions

File tree

packages/devtools/client/modules/markdown.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { BuiltinLanguage } from 'shiki'
2-
import { addVitePlugin, defineNuxtModule, logger } from '@nuxt/kit'
2+
import { defineNuxtModule, logger } from '@nuxt/kit'
33
import { consola } from 'consola'
44
import LinkAttributes from 'markdown-it-link-attributes'
55
import { createHighlighter } from 'shiki'
@@ -28,7 +28,7 @@ export default defineNuxtModule({
2828

2929
nuxt.options.extensions.push('.md')
3030

31-
addVitePlugin(() => {
31+
const markdownPlugin = () => {
3232
return Markdown({
3333
frontmatter: false,
3434
async markdownItSetup(md) {
@@ -61,11 +61,18 @@ export default defineNuxtModule({
6161
}
6262
},
6363
})
64-
// `prepend: true` because Nuxt's `addVitePlugin` hard-codes `enforce`
65-
// to `post` for non-isomorphic (client-only/server-only) plugins unless
66-
// prepended — which would otherwise discard `unplugin-vue-markdown`'s
67-
// own `enforce: 'pre'` and let `@vitejs/plugin-vue` see raw markdown
68-
// before it's transformed into a Vue SFC.
69-
}, { server: false, client: true, prepend: true })
64+
}
65+
66+
// Registered directly on `vite:extend` (rather than via `@nuxt/kit`'s
67+
// `addVitePlugin`) and unshifted onto `config.plugins` so it lands
68+
// before `@vitejs/plugin-vue` regardless of its `enforce` tier.
69+
// `addVitePlugin`'s environment-scoping (`{ server: false, client: true }`)
70+
// doesn't reliably apply the plugin under Vite 8's rolldown-based builder:
71+
// `.md` files were reaching `@vitejs/plugin-vue` untransformed, so it
72+
// parsed raw markdown as a Vue SFC and failed.
73+
nuxt.hook('vite:extend', ({ config }) => {
74+
config.plugins ||= []
75+
config.plugins.unshift(markdownPlugin())
76+
})
7077
},
7178
})

packages/devtools/scripts/copy-client.mjs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@ const TARGET = '../devtools-assets/dist'
1313
// relative base directly). Rewrite each HTML shell so it works at any mount
1414
// point:
1515
//
16-
// 1. The inline runtime config's `baseURL` becomes a `location`-derived
17-
// expression. The client uses hash routing in production, so
18-
// `location.pathname` is always the mount path (possibly ending in
19-
// `index.html`, hence stripping the trailing filename).
16+
// 1. The inline runtime config's `app` object gets a `baseURL` set to a
17+
// `location`-derived expression (Nuxt no longer serializes `baseURL` into
18+
// the prerendered shell's `window.__NUXT__.config.app` at all — it's read
19+
// at runtime, just never populated for a static `ssr:false` generate — so
20+
// this injects it rather than rewriting an existing value). The client
21+
// uses hash routing in production, so `location.pathname` is always the
22+
// mount path (possibly ending in `index.html`, hence stripping the
23+
// trailing filename).
2024
// 2. Every other placeholder occurrence (asset `href`/`src`, importmap)
2125
// becomes `./`, relative to the document — which, per 1., is always the
2226
// mount root.
2327
const PLACEHOLDER = '/__NUXT_DEVTOOLS_BASE__/'
24-
const RUNTIME_CONFIG_BASE_RE = /baseURL:"\/__NUXT_DEVTOOLS_BASE__\/"/
25-
const RUNTIME_CONFIG_BASE_REPLACEMENT = 'baseURL:location.pathname.replace(/[^/]*$/,"")'
28+
const RUNTIME_CONFIG_APP_RE = /(window\.__NUXT__\.config\s*=\s*\{[\s\S]*?\bapp:\{)([^}]*)(\})/
29+
const RUNTIME_CONFIG_BASE_URL = 'location.pathname.replace(/[^/]*$/,"")'
2630

2731
rmSync(TARGET, { recursive: true, force: true })
2832
cpSync(SOURCE, TARGET, { recursive: true })
@@ -34,11 +38,14 @@ if (htmlFiles.length === 0)
3438
for (const file of htmlFiles) {
3539
const path = join(TARGET, file)
3640
let html = readFileSync(path, 'utf-8')
37-
if (!RUNTIME_CONFIG_BASE_RE.test(html))
38-
throw new Error(`Expected the inline runtime-config \`baseURL:"${PLACEHOLDER}"\` in ${file} — Nuxt's serialization may have changed; update copy-client.mjs.`)
39-
// Order matters: rewrite the runtime-config occurrence first, then the
40-
// remaining (asset URL) occurrences.
41-
html = html.replace(RUNTIME_CONFIG_BASE_RE, RUNTIME_CONFIG_BASE_REPLACEMENT)
41+
if (!RUNTIME_CONFIG_APP_RE.test(html))
42+
throw new Error(`Expected to find \`window.__NUXT__.config\`'s \`app: {...}\` object in ${file} — Nuxt's serialization may have changed; update copy-client.mjs.`)
43+
// Order matters: inject the runtime-config baseURL first, then rewrite the
44+
// remaining (asset URL) placeholder occurrences.
45+
html = html.replace(RUNTIME_CONFIG_APP_RE, (_, prefix, existingProps, suffix) => {
46+
const baseUrlProp = `baseURL:${RUNTIME_CONFIG_BASE_URL}`
47+
return `${prefix}${existingProps ? `${baseUrlProp},${existingProps}` : baseUrlProp}${suffix}`
48+
})
4249
html = html.replaceAll(PLACEHOLDER, './')
4350
writeFileSync(path, html)
4451
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/dist/vite.mjs b/dist/vite.mjs
2+
index d8633aa8e81f4c9631a43764f344625e2c2358d7..2a97aecf23827faf5421e0055eef46fbf9ada4d9 100644
3+
--- a/dist/vite.mjs
4+
+++ b/dist/vite.mjs
5+
@@ -117,7 +117,9 @@ async function buildEnvironments(ctx, builder) {
6+
}
7+
ctx.nitro.routing.sync();
8+
await prerender(nitro);
9+
- const output = await builder.build(builder.environments.nitro);
10+
+ const nitroEnvironment = builder.environments.nitro;
11+
+ const hasNitroEntry = Boolean(nitroEnvironment.config.build.rollupOptions.input || nitroEnvironment.config.build.rolldownOptions?.input);
12+
+ const output = hasNitroEntry ? await builder.build(nitroEnvironment) : void 0;
13+
await nitro.close();
14+
await nitro.hooks.callHook("compiled", nitro);
15+
await writeBuildInfo(nitro, output);

0 commit comments

Comments
 (0)