Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 212
feat: serve the client UI as devframe remote assets via @nuxt/devtools-assets#1071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+239
−228
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3fc40da
feat: serve the client UI as devframe remote assets via @nuxt/devtool…
antfubot 6f3425f
refactor: drop the clientAssets module option, detect the dogfooding …
antfubot ba6f6a1
Merge branch 'main' into dark-turkeys-march
antfu 51b153e
fix(release): route package prepack through turbo
antfubot 23eae77
refactor: remove the legacy v3 iframe-embedding path
antfubot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # @nuxt/devtools-assets | ||
| Pre-built client UI assets for [Nuxt DevTools](https://github.com/nuxt/devtools). | ||
| `@nuxt/devtools` does not bundle its client UI. Instead, it declares this | ||
| version-locked package as [devframe remote assets](https://devfra.me/guide/client-assets.html#remote-assets): | ||
| files are resolved from a locally installed copy of this package when present, | ||
| otherwise streamed on demand from a CDN mirror of npm and cached on disk. | ||
| You normally don't need to install this package. For offline or air-gapped | ||
| environments, install it explicitly so the UI is served with zero network: | ||
| ```sh | ||
| npm install -D @nuxt/devtools-assets | ||
| ``` | ||
| Keep its version in lockstep with `@nuxt/devtools` (it is published together | ||
| with each release). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| { | ||
| "name": "@nuxt/devtools-assets", | ||
| "type": "module", | ||
| "version": "4.0.0-alpha.12", | ||
| "description": "Pre-built client UI assets for Nuxt DevTools, resolved on demand.", | ||
| "license": "MIT", | ||
| "homepage": "https://devtools.nuxt.com", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/nuxt/devtools.git", | ||
| "directory": "packages/devtools-assets" | ||
| }, | ||
| "exports": { | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "scripts": { | ||
| "build": "pnpm -C ../devtools run build:client", | ||
| "prepack": "turbo run build --filter=@nuxt/devtools-assets" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,44 @@ | ||
| import { cpSync } from 'node:fs' | ||
| // Copy the generated client SPA into the `@nuxt/devtools-assets` package and | ||
| // make it mount-path portable, so devframe can serve the directory verbatim | ||
| // at any base (a local install, the on-disk cache, or its CDN back-proxy) — | ||
| // see https://devfra.me/guide/client-assets.html. | ||
| import { cpSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' | ||
| import { join } from 'node:path' | ||
| cpSync('client/.output/public', 'dist/client', { recursive: true }) | ||
| const SOURCE = 'client/.output/public' | ||
| const TARGET = '../devtools-assets/dist' | ||
| // The client is generated with the `/__NUXT_DEVTOOLS_BASE__/` placeholder as | ||
| // its base URL (see `client/nuxt.config.ts` — Nuxt cannot generate with a | ||
| // relative base directly). Rewrite each HTML shell so it works at any mount | ||
| // point: | ||
| // | ||
| // 1. The inline runtime config's `baseURL` becomes a `location`-derived | ||
| // expression. The client uses hash routing in production, so | ||
| // `location.pathname` is always the mount path (possibly ending in | ||
| // `index.html`, hence stripping the trailing filename). | ||
| // 2. Every other placeholder occurrence (asset `href`/`src`, importmap) | ||
| // becomes `./`, relative to the document — which, per 1., is always the | ||
| // mount root. | ||
| const PLACEHOLDER = '/__NUXT_DEVTOOLS_BASE__/' | ||
| const RUNTIME_CONFIG_BASE_RE = /baseURL:"\/__NUXT_DEVTOOLS_BASE__\/"/ | ||
| const RUNTIME_CONFIG_BASE_REPLACEMENT = 'baseURL:location.pathname.replace(/[^/]*$/,"")' | ||
| rmSync(TARGET, { recursive: true, force: true }) | ||
| cpSync(SOURCE, TARGET, { recursive: true }) | ||
| const htmlFiles = readdirSync(TARGET).filter(file => file.endsWith('.html')) | ||
| if (htmlFiles.length === 0) | ||
| throw new Error(`No HTML shell found in ${TARGET} — did \`nuxi generate client\` run?`) | ||
| for (const file of htmlFiles) { | ||
| const path = join(TARGET, file) | ||
| let html = readFileSync(path, 'utf-8') | ||
| if (!RUNTIME_CONFIG_BASE_RE.test(html)) | ||
| throw new Error(`Expected the inline runtime-config \`baseURL:"${PLACEHOLDER}"\` in ${file} — Nuxt's serialization may have changed; update copy-client.mjs.`) | ||
| // Order matters: rewrite the runtime-config occurrence first, then the | ||
| // remaining (asset URL) occurrences. | ||
| html = html.replace(RUNTIME_CONFIG_BASE_RE, RUNTIME_CONFIG_BASE_REPLACEMENT) | ||
| html = html.replaceAll(PLACEHOLDER, './') | ||
| writeFileSync(path, html) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use the workspace catalog for
@nuxt/devtools-assets.Both dependency declarations use
workspace:*. Replace them withcatalog:<name>. Add the matching asset package version to the appropriate catalog inpnpm-workspace.yaml.packages/devtools/package.json#L35-L35: reference the optional peer dependency through the catalog.packages/devtools/package.json#L88-L88: reference the development dependency through the same catalog entry.As per coding guidelines, reference dependency versions using
catalog:<name>in package manifests instead of pinning raw versions; add missing versions to the appropriate catalog inpnpm-workspace.yaml.📍 Affects 1 file
packages/devtools/package.json#L35-L35(this comment)packages/devtools/package.json#L88-L88🤖 Prompt for AI Agents
Source: Coding guidelines