From df97fd36e8d81d3c498fd17cfa612390aa113c98 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:25:49 +0500 Subject: [PATCH 01/17] feat(bundler-plugin-core): export stampAssets, AssetStore, notify, resolveIdentity and the env-file loaders The Next.js integration drives the same stamp and upload pipeline from its own per-compilation hooks. Co-Authored-By: Claude Sonnet 5.5 --- packages/bundler-plugin-core/src/index.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/bundler-plugin-core/src/index.ts b/packages/bundler-plugin-core/src/index.ts index c2fe5624..7f585425 100644 --- a/packages/bundler-plugin-core/src/index.ts +++ b/packages/bundler-plugin-core/src/index.ts @@ -10,6 +10,7 @@ export { findPackageVersion, } from './app-identity'; export { deriveBuildUuid } from './build-id'; +export { loadBuildPluginEnv, mergeBuildPluginEnv } from './env-file'; export { defaultDeleteMapFiles, type RunFn, @@ -36,8 +37,11 @@ export { } from './register-build'; export { type BugseePluginOptions, + notify, type PluginRunResult, + type ResolvedIdentity, type ResolvedPluginOptions, + resolveIdentity, resolvePluginOptions, runPluginUpload, } from './resolve'; @@ -52,6 +56,7 @@ export { type SpawnResult, spawnProcess, } from './run-cli'; +export { type AssetStore, type StampAssetsOptions, stampAssets } from './stamp-assets'; export { isWorkingTreeDirty, type ResolveVcsMetadataOptions, From 00ceee27a405713683288854598adcad42f291b5 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:25:49 +0500 Subject: [PATCH 02/17] feat(nextjs): withBugsee() build integration for webpack and Turbopack (@bugsee/nextjs/config) webpack: one plugin per compilation (client, server, edge) stamping inside the compilation and uploading exactly its own emitted files. Turbopack: compiler.runAfterProductionCompile (Next 15.4.1+) stamps and uploads the written .next, pairing bundles with maps by their sourceMappingURL pointer. Composes with user webpack / runAfterProductionCompile / define / productionBrowserSourceMaps and function or async configs; inert for dev, start and export. Co-Authored-By: Claude Sonnet 5.5 --- packages/nextjs/package.json | 19 +- .../nextjs/src/config/build-files.test.ts | 192 +++++++++ packages/nextjs/src/config/build-files.ts | 116 ++++++ packages/nextjs/src/config/context.test.ts | 133 ++++++ packages/nextjs/src/config/context.ts | 98 +++++ packages/nextjs/src/config/index.ts | 10 + packages/nextjs/src/config/post-build.test.ts | 141 +++++++ packages/nextjs/src/config/post-build.ts | 97 +++++ .../nextjs/src/config/webpack-plugin.test.ts | 391 ++++++++++++++++++ packages/nextjs/src/config/webpack-plugin.ts | 187 +++++++++ .../src/config/with-bugsee.kind.test.ts | 44 ++ .../nextjs/src/config/with-bugsee.test.ts | 350 ++++++++++++++++ packages/nextjs/src/config/with-bugsee.ts | 196 +++++++++ packages/nextjs/tsup.config.ts | 10 +- pnpm-lock.yaml | 384 ++++++++++++----- 15 files changed, 2251 insertions(+), 117 deletions(-) create mode 100644 packages/nextjs/src/config/build-files.test.ts create mode 100644 packages/nextjs/src/config/build-files.ts create mode 100644 packages/nextjs/src/config/context.test.ts create mode 100644 packages/nextjs/src/config/context.ts create mode 100644 packages/nextjs/src/config/index.ts create mode 100644 packages/nextjs/src/config/post-build.test.ts create mode 100644 packages/nextjs/src/config/post-build.ts create mode 100644 packages/nextjs/src/config/webpack-plugin.test.ts create mode 100644 packages/nextjs/src/config/webpack-plugin.ts create mode 100644 packages/nextjs/src/config/with-bugsee.kind.test.ts create mode 100644 packages/nextjs/src/config/with-bugsee.test.ts create mode 100644 packages/nextjs/src/config/with-bugsee.ts diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 18f984e3..3d4bbc6c 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -7,7 +7,7 @@ "url": "git+https://github.com/bugsee/bugsee-javascript.git", "directory": "packages/nextjs" }, - "description": "Next.js meta-adapter: client + server + edge entries", + "description": "Next.js meta-adapter: client + server + edge entries, plus the withBugsee() build integration (source-map upload)", "type": "module", "main": "./src/index.ts", "types": "./src/index.ts", @@ -31,6 +31,10 @@ "./middleware": { "types": "./src/middleware.ts", "import": "./src/middleware.ts" + }, + "./config": { + "types": "./src/config/index.ts", + "import": "./src/config/index.ts" } }, "files": [ @@ -49,7 +53,8 @@ "@bugsee/protocol": "workspace:*", "@bugsee/react": "workspace:*", "@bugsee/vercel-edge": "workspace:*", - "@bugsee/bugsee": "workspace:*" + "@bugsee/bugsee": "workspace:*", + "@bugsee/bundler-plugin-core": "workspace:*" }, "peerDependencies": { "@opentelemetry/api": ">=1.0.0", @@ -133,6 +138,16 @@ "types": "./dist/middleware.d.cts", "default": "./dist/middleware.cjs" } + }, + "./config": { + "import": { + "types": "./dist/config.d.ts", + "default": "./dist/config.js" + }, + "require": { + "types": "./dist/config.d.cts", + "default": "./dist/config.cjs" + } } }, "access": "public" diff --git a/packages/nextjs/src/config/build-files.test.ts b/packages/nextjs/src/config/build-files.test.ts new file mode 100644 index 00000000..ad3d8466 --- /dev/null +++ b/packages/nextjs/src/config/build-files.test.ts @@ -0,0 +1,192 @@ +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { collectBuildFiles, mapPointerOf, pairByPointer, partitionBuildFiles } from './build-files'; + +describe('partitionBuildFiles', () => { + it('pairs each bundle with its map and sorts both', () => { + const files = ['/o/b.js.map', '/o/a.js', '/o/b.js', '/o/a.js.map']; + expect(partitionBuildFiles(files)).toEqual({ + scripts: ['/o/a.js', '/o/b.js'], + maps: ['/o/a.js.map', '/o/b.js.map'], + stylesheetMaps: [], + }); + }); + + it('accepts .mjs and .cjs bundles', () => { + const files = ['/o/a.mjs', '/o/a.mjs.map', '/o/b.cjs', '/o/b.cjs.map']; + expect(partitionBuildFiles(files).scripts).toEqual(['/o/a.mjs', '/o/b.cjs']); + }); + + it('never stamps a bundle that has no map, and never sends a map that has no bundle', () => { + const files = ['/o/lonely.js', '/o/orphan.js.map', '/o/ok.js', '/o/ok.js.map']; + const parts = partitionBuildFiles(files); + expect(parts.scripts).toEqual(['/o/ok.js']); + expect(parts.maps).toEqual(['/o/ok.js.map']); + }); + + it('keeps stylesheet maps apart: deleted with the rest, never sent', () => { + const files = ['/o/a.css', '/o/a.css.map', '/o/a.js', '/o/a.js.map']; + const parts = partitionBuildFiles(files); + expect(parts.stylesheetMaps).toEqual(['/o/a.css.map']); + expect(parts.maps).toEqual(['/o/a.js.map']); + }); + + it('ignores everything else', () => { + expect(partitionBuildFiles(['/o/a.html', '/o/a.json', '/o/a.png'])).toEqual({ + scripts: [], + maps: [], + stylesheetMaps: [], + }); + }); +}); + +describe('mapPointerOf', () => { + it('resolves the pointer against the bundle directory', () => { + expect(mapPointerOf('/o/chunks/a.js', 'code();\n//# sourceMappingURL=other.js.map\n')).toBe( + '/o/chunks/other.js.map', + ); + expect(mapPointerOf('/o/chunks/a.js', 'x\n//@ sourceMappingURL=../m/a.map')).toBe('/o/m/a.map'); + }); + + it('decodes a percent-encoded pointer (Turbopack names contain brackets)', () => { + expect(mapPointerOf('/o/a.js', 'x\n//# sourceMappingURL=%5Broot%5D__a._.js.map\n')).toBe( + '/o/[root]__a._.js.map', + ); + }); + + it('uses a pointer as written when it is not valid percent-encoding', () => { + expect(mapPointerOf('/o/a.js', 'x\n//# sourceMappingURL=100%.js.map')).toBe('/o/100%.js.map'); + }); + + it('has no pointer for a bundle without a comment, or with an inline map', () => { + expect(mapPointerOf('/o/a.js', 'no comment')).toBeUndefined(); + expect( + mapPointerOf('/o/a.js', 'x\n//# sourceMappingURL=data:application/json;base64,e30='), + ).toBeUndefined(); + }); + + it('only counts the comment that ends the bundle', () => { + expect(mapPointerOf('/o/a.js', '//# sourceMappingURL=a.map\nmore();')).toBeUndefined(); + }); +}); + +describe('pairByPointer', () => { + const code = (map: string): string => `code();\n//# sourceMappingURL=${map}\n`; + const reader = (sources: Record) => async (file: string) => sources[file] ?? ''; + + it('pairs a bundle with a map that is NOT named after it', async () => { + const files = ['/o/0ihtw.js', '/o/1wkfrb.js.map']; + const parts = await pairByPointer(files, reader({ '/o/0ihtw.js': code('1wkfrb.js.map') })); + expect(parts).toEqual({ + scripts: ['/o/0ihtw.js'], + maps: ['/o/1wkfrb.js.map'], + stylesheetMaps: [], + shared: [], + }); + }); + + it('ignores a pointer to a file that is not there', async () => { + const parts = await pairByPointer(['/o/a.js'], reader({ '/o/a.js': code('gone.js.map') })); + expect(parts.scripts).toEqual([]); + }); + + it('ignores a pointer to something that is not a map', async () => { + const parts = await pairByPointer(['/o/a.js', '/o/b.js'], reader({ '/o/a.js': code('b.js') })); + expect(parts.scripts).toEqual([]); + expect(parts.maps).toEqual([]); + }); + + it('pairs neither bundle of a map two bundles share, and reports them', async () => { + const parts = await pairByPointer( + ['/o/a.js', '/o/b.js', '/o/shared.js.map', '/o/c.js', '/o/c.js.map'], + reader({ + '/o/a.js': code('shared.js.map'), + '/o/b.js': code('shared.js.map'), + '/o/c.js': code('c.js.map'), + }), + ); + expect(parts.scripts).toEqual(['/o/c.js']); + expect(parts.maps).toEqual(['/o/c.js.map']); + expect(parts.shared).toEqual(['/o/a.js', '/o/b.js']); + }); + + it('does not read files that are not scripts', async () => { + const read = vi.fn(async () => ''); + await pairByPointer(['/o/a.json', '/o/a.js.map', '/o/a.css'], read); + expect(read).not.toHaveBeenCalled(); + }); + + it('keeps stylesheet maps apart', async () => { + const parts = await pairByPointer(['/o/a.css.map'], reader({})); + expect(parts.stylesheetMaps).toEqual(['/o/a.css.map']); + }); + + it('sorts its output', async () => { + const parts = await pairByPointer( + ['/o/z.js', '/o/a.js', '/o/m1.map', '/o/m0.map'], + reader({ '/o/z.js': code('m1.map'), '/o/a.js': code('m0.map') }), + ); + expect(parts.scripts).toEqual(['/o/a.js', '/o/z.js']); + expect(parts.maps).toEqual(['/o/m0.map', '/o/m1.map']); + }); +}); + +describe('collectBuildFiles', () => { + let root: string; + beforeEach(() => { + root = mkdtempSync(join(tmpdir(), 'bugsee-bf-')); + }); + afterEach(() => { + rmSync(root, { recursive: true, force: true }); + }); + const put = (rel: string, content = 'x'): void => { + mkdirSync(join(root, rel, '..'), { recursive: true }); + writeFileSync(join(root, rel), content); + }; + const bundle = (rel: string, mapName = `${rel.split('/').pop()}.map`): void => { + put(rel, `code();\n//# sourceMappingURL=${encodeURIComponent(mapName)}\n`); + put(`${rel}/../${mapName}`); + }; + + it('walks nested directories, bracketed names included', async () => { + bundle('chunks/[root-of-the-server]__a._.js'); + bundle('chunks/ssr/b.js'); + const parts = await collectBuildFiles(root); + expect(parts.scripts).toEqual([ + join(root, 'chunks/[root-of-the-server]__a._.js'), + join(root, 'chunks/ssr/b.js'), + ]); + expect(parts.maps).toHaveLength(2); + }); + + it('pairs by the pointer inside the bundle when the map has another name', async () => { + bundle('chunks/0ihtw.js', '1wkfrb.js.map'); + const parts = await collectBuildFiles(root); + expect(parts.scripts).toEqual([join(root, 'chunks/0ihtw.js')]); + expect(parts.maps).toEqual([join(root, 'chunks/1wkfrb.js.map')]); + }); + + it('never descends into node_modules or cache', async () => { + bundle('node_modules/x/a.js'); + bundle('cache/webpack/b.js'); + bundle('ok.js'); + expect((await collectBuildFiles(root)).scripts).toEqual([join(root, 'ok.js')]); + }); + + it('returns nothing for a directory that does not exist', async () => { + expect(await collectBuildFiles(join(root, 'absent'))).toEqual({ + scripts: [], + maps: [], + stylesheetMaps: [], + shared: [], + }); + }); + + it('stops at a depth limit instead of walking an unbounded tree', async () => { + bundle(`${Array.from({ length: 14 }, (_, i) => `d${i}`).join('/')}/a.js`); + bundle('top.js'); + expect((await collectBuildFiles(root)).scripts).toEqual([join(root, 'top.js')]); + }); +}); diff --git a/packages/nextjs/src/config/build-files.ts b/packages/nextjs/src/config/build-files.ts new file mode 100644 index 00000000..e5750891 --- /dev/null +++ b/packages/nextjs/src/config/build-files.ts @@ -0,0 +1,116 @@ +// Which files of a Next build the upload covers, named explicitly. The upload never walks `.next` and never +// takes a directory: it is handed exactly these paths, so it cannot stamp, upload or delete a file that is not +// part of the build it is looking at (the webpack compilations and the Turbopack output share `.next`). +import { readdir, readFile } from 'node:fs/promises'; +import { dirname, join, resolve } from 'node:path'; + +/** A build's bundles and the maps that belong to them. */ +export interface BuildFiles { + /** Bundles that have a map. A bundle without one cannot be symbolicated, so it is never stamped. */ + scripts: string[]; + /** The maps of those bundles. */ + maps: string[]; + /** Stylesheet maps: never sent, but deleted with the rest after a confirmed upload (they embed the source). */ + stylesheetMaps: string[]; + /** Bundles left out because their map is shared with another bundle (see {@link pairByPointer}). */ + shared?: string[]; +} + +const SCRIPT = /\.[cm]?js$/; +const MAX_DEPTH = 12; +/** Directories that are never build output, wherever they appear. */ +const SKIP = new Set(['node_modules', 'cache']); + +async function listFiles(dir: string, depth: number): Promise { + if (depth > MAX_DEPTH) { + return []; + } + let entries: import('node:fs').Dirent[]; + try { + entries = await readdir(dir, { withFileTypes: true }); + } catch { + // A directory the build did not produce (no `server` output, say) contributes nothing. + return []; + } + const found: string[] = []; + for (const entry of entries) { + const full = join(dir, entry.name); + if (entry.isDirectory()) { + if (!SKIP.has(entry.name)) { + found.push(...(await listFiles(full, depth + 1))); + } + } else if (entry.isFile()) { + found.push(full); + } + } + return found; +} + +/** Split a list of files into the bundles that have a map, their maps, and the stylesheet maps. */ +export function partitionBuildFiles(files: readonly string[]): BuildFiles { + const present = new Set(files); + const scripts = files.filter((file) => SCRIPT.test(file) && present.has(`${file}.map`)); + const owned = new Set(scripts); + return { + scripts: scripts.sort(), + maps: files.filter((file) => file.endsWith('.map') && owned.has(file.slice(0, -4))).sort(), + stylesheetMaps: files.filter((file) => file.endsWith('.css.map')).sort(), + }; +} + +/** A bundle's source-map pointer: the last `//# sourceMappingURL=` comment. */ +const POINTER = /\/\/[#@] sourceMappingURL=([^\s'"]+)\s*$/; + +/** The path a bundle's source-map comment names, or `undefined` when it has none or the map is inline. */ +export function mapPointerOf(file: string, code: string): string | undefined { + const reference = POINTER.exec(code)?.[1]; + if (reference === undefined || reference.startsWith('data:')) { + return undefined; + } + let decoded = reference; + try { + decoded = decodeURIComponent(reference); + } catch { + // Not percent-encoded after all: use it as written. + } + return resolve(dirname(file), decoded); +} + +/** + * Pair bundles with their maps by the pointer inside each bundle, not by name. Turbopack does not name a map after + * its bundle (measured, Next 16.4: `chunks/0ihtwxitjxx9w.js` ends in `sourceMappingURL=1wkfrb_3m2k-z.js.map`), so + * `.map` finds nothing there. Only a pointer that names a `.map` file that exists counts. + */ +export async function pairByPointer( + files: readonly string[], + read: (file: string) => Promise = (file) => readFile(file, 'utf8'), +): Promise { + const present = new Set(files); + const pointers = new Map(); + const users = new Map(); + for (const file of files.filter((f) => SCRIPT.test(f))) { + const map = mapPointerOf(file, await read(file)); + if (map?.endsWith('.map') && present.has(map)) { + pointers.set(file, map); + users.set(map, (users.get(map) ?? 0) + 1); + } + } + // A map belongs to one bundle: a debug-ID is the hash of the bundle AND its map, and a map carries one. Two + // bundles pointing at the same map (Next 15.5's Turbopack does this for its runtime chunks, measured) cannot both + // be keyed to it, so neither is paired: stamping one would leave the other with an id no map answers to. + const paired = [...pointers].filter(([, map]) => users.get(map) === 1); + return { + scripts: paired.map(([file]) => file).sort(), + maps: paired.map(([, map]) => map).sort(), + stylesheetMaps: files.filter((file) => file.endsWith('.css.map')).sort(), + shared: [...pointers] + .filter(([, map]) => (users.get(map) as number) > 1) + .map(([file]) => file) + .sort(), + }; +} + +/** The build files under `dir` (recursively), paired by pointer; none when `dir` does not exist. */ +export async function collectBuildFiles(dir: string): Promise { + return pairByPointer(await listFiles(dir, 0)); +} diff --git a/packages/nextjs/src/config/context.test.ts b/packages/nextjs/src/config/context.test.ts new file mode 100644 index 00000000..0c12eb8b --- /dev/null +++ b/packages/nextjs/src/config/context.test.ts @@ -0,0 +1,133 @@ +import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { createBugseeContext } from './context'; + +let dir: string; +beforeEach(() => { + dir = mkdtempSync(join(tmpdir(), 'bugsee-ctx-')); + writeFileSync(join(dir, 'package.json'), JSON.stringify({ name: 'app', version: '4.5.6' })); +}); +afterEach(() => { + rmSync(dir, { recursive: true, force: true }); + delete (globalThis as { __BUGSEE_REAL_ENV_FILE__?: boolean }).__BUGSEE_REAL_ENV_FILE__; +}); + +describe('createBugseeContext', () => { + it('takes the token from the option, then the environment', () => { + expect(createBugseeContext({ appToken: 'opt' }, dir, { env: {} }).resolved.appToken).toBe( + 'opt', + ); + expect( + createBugseeContext({}, dir, { env: { BUGSEE_APP_TOKEN: 'from-env' } }).resolved, + ).toMatchObject({ appToken: 'from-env', enabled: true }); + }); + + it('is disabled without a token, and with disabled: true', () => { + expect(createBugseeContext({}, dir, { env: {} }).resolved.enabled).toBe(false); + expect( + createBugseeContext({ appToken: 't', disabled: true }, dir, { env: {} }).resolved.enabled, + ).toBe(false); + }); + + it('reads the token from .env.bugsee-build-plugin in the project directory', () => { + // The shared test setup hides this file from every test; opt in, as the core's env-file tests do. + (globalThis as { __BUGSEE_REAL_ENV_FILE__?: boolean }).__BUGSEE_REAL_ENV_FILE__ = true; + writeFileSync(join(dir, '.env.bugsee-build-plugin'), 'BUGSEE_APP_TOKEN=from-file\n'); + expect(createBugseeContext({}, dir, { env: {} }).resolved).toMatchObject({ + appToken: 'from-file', + enabled: true, + }); + }); + + it('does not read the env file at all when disabled', () => { + (globalThis as { __BUGSEE_REAL_ENV_FILE__?: boolean }).__BUGSEE_REAL_ENV_FILE__ = true; + writeFileSync(join(dir, '.env.bugsee-build-plugin'), 'BUGSEE_APP_TOKEN=from-file\n'); + expect(createBugseeContext({ disabled: true }, dir, { env: {} }).resolved.appToken).toBe(''); + }); + + it('says once when the env file was found but gave nothing', () => { + (globalThis as { __BUGSEE_REAL_ENV_FILE__?: boolean }).__BUGSEE_REAL_ENV_FILE__ = true; + writeFileSync(join(dir, '.env.bugsee-build-plugin'), Buffer.from([0xff, 0xfe, 0x41, 0x00])); + const notices: string[] = []; + createBugseeContext({ onNotice: (m) => notices.push(m) }, dir, { env: {} }); + expect(notices).toHaveLength(1); + expect(notices[0]).toMatch(/^\[bugsee\] /); + }); + + it('resolves the identity from the project directory, option first', () => { + expect(createBugseeContext({ appToken: 't' }, dir, { env: {} }).resolved).toMatchObject({ + appVersion: '4.5.6', + identityDefines: expect.objectContaining({ __BUGSEE_APP_VERSION__: '"4.5.6"' }), + }); + expect( + createBugseeContext({ appToken: 't', appVersion: '9.9.9', appBuild: '7' }, dir, { env: {} }) + .resolved, + ).toMatchObject({ appVersion: '9.9.9', appBuild: '7' }); + }); + + it('points the VCS root at the project unless told otherwise', () => { + expect(createBugseeContext({}, dir, { env: {} }).resolved.projectRoot).toBe(dir); + expect( + createBugseeContext({ projectRoot: '/repo' }, dir, { env: {} }).resolved.projectRoot, + ).toBe('/repo'); + }); + + it('defaults the Next policy: server maps on, server maps kept', () => { + const context = createBugseeContext({}, dir, { env: {} }); + expect(context.serverSourceMaps).toBe(true); + expect(context.deleteServerMaps).toBe(false); + const custom = createBugseeContext({ serverSourceMaps: false, deleteServerMaps: true }, dir, { + env: {}, + }); + expect(custom.serverSourceMaps).toBe(false); + expect(custom.deleteServerMaps).toBe(true); + }); + + it('sends notices to onNotice with one [bugsee] prefix, de-duplicated', () => { + const notices: string[] = []; + const context = createBugseeContext({ onNotice: (m) => notices.push(m) }, dir, { env: {} }); + context.say('hello'); + context.say('hello'); + context.resolved.onNotice?.('[bugsee] from core'); + expect(notices).toEqual(['[bugsee] hello', '[bugsee] from core']); + }); + + it('warns on the console by default', () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + createBugseeContext({}, dir, { env: {} }).say('careful'); + expect(warn).toHaveBeenCalledWith('[bugsee] careful'); + warn.mockRestore(); + }); + + it('says nothing when silent', () => { + const onNotice = vi.fn(); + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const context = createBugseeContext({ silent: true, onNotice }, dir, { env: {} }); + context.say('quiet'); + context.resolved.onNotice?.('[bugsee] quiet too'); + expect(onNotice).not.toHaveBeenCalled(); + expect(warn).not.toHaveBeenCalled(); + warn.mockRestore(); + }); + + it('survives a throwing notice sink', () => { + const context = createBugseeContext( + { + onNotice: () => { + throw new Error('logger down'); + }, + }, + dir, + { env: {} }, + ); + expect(() => context.say('x')).not.toThrow(); + }); + + it('reads process.env when no environment is injected', () => { + vi.stubEnv('BUGSEE_APP_TOKEN', 'ambient'); + expect(createBugseeContext({}, dir).resolved.appToken).toBe('ambient'); + vi.unstubAllEnvs(); + }); +}); diff --git a/packages/nextjs/src/config/context.ts b/packages/nextjs/src/config/context.ts new file mode 100644 index 00000000..6f6fc348 --- /dev/null +++ b/packages/nextjs/src/config/context.ts @@ -0,0 +1,98 @@ +// The one place `withBugsee` turns its options into a resolved build context: the plugin options merged with the +// environment (and `.env.bugsee-build-plugin`), the app identity, and the Next-specific policy. Resolved ONCE, at +// config-evaluation time, from the project directory: the define baked into the bundle and the identity the upload +// is labelled with come from this single resolution, so they cannot disagree. +import { + type BugseePluginOptions, + loadBuildPluginEnv, + mergeBuildPluginEnv, + type ResolvedPluginOptions, + resolveIdentity, + resolvePluginOptions, +} from '@bugsee/bundler-plugin-core'; + +/** Options for {@link withBugsee}: everything the bundler plugins take, plus the Next-specific switches. */ +export interface WithBugseeOptions extends BugseePluginOptions { + /** + * Emit AND upload source maps for the server and edge bundles too. Default `true`. + * + * Next only writes server maps with `experimental.serverSourceMaps`; with this on, the webpack server and + * edge compilations get `devtool: 'source-map'` (set after your own `webpack` function ran, only when you + * left `devtool` unset), and Turbopack always emits them. Turn it off to symbolicate browser crashes only. + * This never sets Next's `experimental.serverSourceMaps`, so the server's runtime behaviour is unchanged. + */ + serverSourceMaps?: boolean; + /** + * Delete the server and edge `.map` files after a confirmed upload. Default `false`. + * + * Unlike `.next/static` (served to every visitor, so `deleteMaps` removes those), `.next/server` is never + * served, and a server running with `--enable-source-maps` reads these files at runtime. + */ + deleteServerMaps?: boolean; + /** + * Say nothing about configuration notices (a skipped upload, source maps switched off, a dry run's + * capture). Failures are still reported through `onError` / the console. Default `false`. + */ + silent?: boolean; +} + +/** What every part of the integration reads. */ +export interface BugseeNextContext { + /** The plugin options after env / env-file / identity resolution. */ + resolved: ResolvedPluginOptions; + /** Whether server/edge maps are emitted and uploaded. */ + serverSourceMaps: boolean; + /** Whether server/edge maps are deleted after a confirmed upload. */ + deleteServerMaps: boolean; + /** A notice said once per distinct text (a no-op when `silent`). */ + say(message: string): void; +} + +/** Seams for tests. */ +export interface ContextDeps { + env?: Record; +} + +/** Resolve the integration's context for `projectDir`. Never throws. */ +export function createBugseeContext( + options: WithBugseeOptions, + projectDir: string, + deps: ContextDeps = {}, +): BugseeNextContext { + const said = new Set(); + // `text` already carries the `[bugsee]` prefix: that is what the core hands an `onNotice` sink. + const emit = (text: string): void => { + if (options.silent === true || said.has(text)) { + return; + } + said.add(text); + try { + (options.onNotice ?? console.warn)(text); + } catch { + // A throwing host logger must not cost the build (the same containment the core's notify applies). + } + }; + const sink = (message: string): void => emit(`[bugsee] ${message}`); + const { values, problem } = + options.disabled === true ? { values: {}, problem: undefined } : loadBuildPluginEnv(projectDir); + if (problem !== undefined) { + sink(problem); + } + const env = mergeBuildPluginEnv(deps.env ?? process.env, values); + const base = resolvePluginOptions(options, env); + const identity = resolveIdentity(options, env, projectDir); + return { + resolved: { + ...base, + ...identity, + // The repository the VCS resolver inspects, unless the caller chose one: the project, not the + // process cwd (which in a monorepo is usually the workspace root). + projectRoot: base.projectRoot ?? projectDir, + // Routed through the integration's own sink so `silent` and de-duplication apply to every notice. + onNotice: emit, + }, + serverSourceMaps: options.serverSourceMaps ?? true, + deleteServerMaps: options.deleteServerMaps ?? false, + say: sink, + }; +} diff --git a/packages/nextjs/src/config/index.ts b/packages/nextjs/src/config/index.ts new file mode 100644 index 00000000..ec949c94 --- /dev/null +++ b/packages/nextjs/src/config/index.ts @@ -0,0 +1,10 @@ +// `@bugsee/nextjs/config` — the build-time half of the Next.js integration (source-map upload). Node-only: import it +// from `next.config.{js,mjs,ts}`, never from application code. +export type { BugseeNextContext, WithBugseeOptions } from './context'; +export type { + NextConfigFunction, + NextConfigInput, + NextConfigObject, + WithBugseeDeps, +} from './with-bugsee'; +export { withBugsee } from './with-bugsee'; diff --git a/packages/nextjs/src/config/post-build.test.ts b/packages/nextjs/src/config/post-build.test.ts new file mode 100644 index 00000000..47244e07 --- /dev/null +++ b/packages/nextjs/src/config/post-build.test.ts @@ -0,0 +1,141 @@ +import { describe, expect, it, vi } from 'vitest'; +import type { BuildFiles } from './build-files'; +import type { BugseeNextContext } from './context'; +import { runPostBuild } from './post-build'; + +const files = (name: string): BuildFiles => ({ + scripts: [`/d/${name}.js`], + maps: [`/d/${name}.js.map`], + stylesheetMaps: [], +}); +const none: BuildFiles = { scripts: [], maps: [], stylesheetMaps: [] }; + +function context( + overrides: Partial = {}, + extra: Partial = {}, +): BugseeNextContext { + return { + resolved: { + enabled: true, + appToken: 't', + deleteMaps: true, + registerBuild: 'release', + ...overrides, + } as BugseeNextContext['resolved'], + serverSourceMaps: true, + deleteServerMaps: false, + say: vi.fn(), + ...extra, + }; +} + +const metadata = { projectDir: '/app', distDir: '/app/.next' }; + +function deps(map: Record, sri = false) { + return { + upload: vi.fn(async () => undefined), + collect: vi.fn(async (dir: string) => map[dir] ?? none), + exists: vi.fn(async () => sri), + }; +} + +describe('runPostBuild', () => { + it('does nothing when disabled', async () => { + const d = deps({}); + await runPostBuild(context({ enabled: false }), metadata, d); + expect(d.collect).not.toHaveBeenCalled(); + expect(d.upload).not.toHaveBeenCalled(); + }); + + it('uploads the browser output, then the server output, each over its own explicit files', async () => { + const client = files('client'); + const server = files('server'); + const d = deps({ '/app/.next/static': client, '/app/.next/server': server }); + await runPostBuild(context(), metadata, d); + expect(d.upload).toHaveBeenCalledTimes(2); + type Call = [ + Record, + string, + { files: BuildFiles; preStamped?: boolean; bundler: unknown }, + ]; + const [first, second] = (d.upload as ReturnType).mock.calls as [Call, Call]; + expect(first[1]).toBe('/app/.next/static'); + expect(first[2].files).toBe(client); + expect(first[0]).toMatchObject({ deleteMaps: true, registerBuild: 'release' }); + expect(second[1]).toBe('/app/.next/server'); + expect(second[2].files).toBe(server); + // Server output: the server deletion policy, and the build is registered once (by the browser run). + expect(second[0]).toMatchObject({ deleteMaps: false, registerBuild: false }); + // Stamped AFTER emit: not pre-stamped. + expect(first[2].preStamped).toBeUndefined(); + expect(first[2].bundler).toEqual({ isProduction: true, configuration: 'production' }); + }); + + it('resolves a relative distDir against the project directory', async () => { + const d = deps({ '/app/.next/static': files('c') }); + await runPostBuild(context(), { projectDir: '/app', distDir: '.next' }, d); + expect(d.collect).toHaveBeenCalledWith('/app/.next/static'); + }); + + it('honours deleteServerMaps', async () => { + const d = deps({ '/app/.next/server': files('s') }); + await runPostBuild(context({}, { deleteServerMaps: true }), metadata, d); + const [resolved] = (d.upload as ReturnType).mock.calls[0] as [ + Record, + ]; + expect(resolved).toMatchObject({ deleteMaps: true }); + }); + + it('skips the server output entirely when server maps are off', async () => { + const d = deps({ '/app/.next/static': files('c'), '/app/.next/server': files('s') }); + await runPostBuild(context({}, { serverSourceMaps: false }), metadata, d); + expect(d.collect).not.toHaveBeenCalledWith('/app/.next/server'); + expect(d.upload).toHaveBeenCalledTimes(1); + }); + + it('says so, and uploads nothing for the browser, when it emitted no maps', async () => { + const ctx = context(); + const d = deps({ '/app/.next/server': files('s') }); + await runPostBuild(ctx, metadata, d); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('productionBrowserSourceMaps')); + expect(d.upload).toHaveBeenCalledTimes(1); + }); + + it('says how many bundles were left unstamped because they share a map', async () => { + const ctx = context(); + const d = deps({ + '/app/.next/static': { ...files('c'), shared: ['/d/x.js'] }, + '/app/.next/server': { ...files('s'), shared: ['/d/y.js', '/d/z.js'] }, + }); + await runPostBuild(ctx, metadata, d); + expect(ctx.say).toHaveBeenCalledWith( + expect.stringContaining('3 bundle(s) share one source map'), + ); + expect(d.upload).toHaveBeenCalledTimes(2); + }); + + it('stays quiet about shared maps when there are none', async () => { + const ctx = context(); + await runPostBuild(ctx, metadata, deps({ '/app/.next/static': files('c') })); + expect(ctx.say).not.toHaveBeenCalled(); + }); + + it('leaves an SRI build exactly as Next wrote it, and says why', async () => { + const ctx = context(); + const d = deps({ '/app/.next/static': files('c'), '/app/.next/server': files('s') }, true); + await runPostBuild(ctx, metadata, d); + expect(d.exists).toHaveBeenCalledWith('/app/.next/server/subresource-integrity-manifest.json'); + expect(d.collect).not.toHaveBeenCalled(); + expect(d.upload).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('Subresource Integrity')); + }); + + it('uses the real upload, collector and filesystem when none are injected', async () => { + const ctx = context(); + // Nothing exists under this directory: no SRI manifest, no files, so no upload, only the notice. + await expect( + runPostBuild(ctx, { projectDir: '/definitely/not/here', distDir: '.next' }), + ).resolves.toBeUndefined(); + expect(ctx.say).toHaveBeenCalledTimes(1); + }); +}); diff --git a/packages/nextjs/src/config/post-build.ts b/packages/nextjs/src/config/post-build.ts new file mode 100644 index 00000000..e9d22cde --- /dev/null +++ b/packages/nextjs/src/config/post-build.ts @@ -0,0 +1,97 @@ +// The Turbopack side of `withBugsee`. Turbopack has no plugin API, so the upload runs from Next's own +// `compiler.runAfterProductionCompile` hook: after the bundler finished writing `.next` and before Next generates +// the static pages. Everything the hook needs is on disk by then, so this stamps the debug-IDs into the written +// bundles (the real `bugsee-cli sourcemaps inject`, with the same verify-and-restore the post-emit path has), +// uploads the maps and deletes them per policy. +// +// What it cannot do is stamp a build that pins Subresource Integrity (`experimental.sri`): Turbopack writes the +// hashes BEFORE this hook runs (measured, Next 16.4.6: appending a byte to a chunk in the hook makes every +// `integrity` the page carries wrong), so stamping afterwards would ship a page whose scripts the browser +// refuses to run. That build is left exactly as Next wrote it, and the notice says why. +import { stat } from 'node:fs/promises'; +import { join, resolve } from 'node:path'; +import { type ResolvedPluginOptions, runPluginUpload } from '@bugsee/bundler-plugin-core'; +import { type BuildFiles, collectBuildFiles } from './build-files'; +import type { BugseeNextContext } from './context'; + +/** What Next hands `compiler.runAfterProductionCompile`. */ +export interface PostBuildMetadata { + projectDir: string; + distDir: string; +} + +/** Seams for tests. */ +export interface PostBuildDeps { + upload?: typeof runPluginUpload; + collect?: (dir: string) => Promise; + exists?: (path: string) => Promise; +} + +async function fileExists(path: string): Promise { + try { + return (await stat(path)).isFile(); + } catch { + return false; + } +} + +/** Where Next records the integrity hashes it pinned (`experimental.sri`). */ +const SRI_MANIFEST = join('server', 'subresource-integrity-manifest.json'); + +/** Stamp, upload and delete for a finished Turbopack build. Skips (and says why) when it cannot be done safely. */ +export async function runPostBuild( + context: BugseeNextContext, + metadata: PostBuildMetadata, + deps: PostBuildDeps = {}, +): Promise { + const { resolved } = context; + if (!resolved.enabled) { + return; + } + const upload = deps.upload ?? runPluginUpload; + const collect = deps.collect ?? collectBuildFiles; + const exists = deps.exists ?? fileExists; + const distDir = resolve(metadata.projectDir, metadata.distDir); + + if (await exists(join(distDir, SRI_MANIFEST))) { + context.say( + 'this build uses Subresource Integrity (`experimental.sri`). Turbopack hashes its output before the post-build hook runs, so stamping debug-IDs now would make the browser refuse the scripts. Source maps were NOT uploaded and the build was left unmodified. Build with `next build --webpack` to upload source maps for an SRI build.', + ); + return; + } + + const client = await collect(join(distDir, 'static')); + const server = context.serverSourceMaps ? await collect(join(distDir, 'server')) : undefined; + if (client.scripts.length === 0) { + context.say( + 'the browser build emitted no source maps, so nothing was uploaded for it. Set `productionBrowserSourceMaps: true` (withBugsee does this unless you set it to false).', + ); + } + + const shared = (client.shared?.length ?? 0) + (server?.shared?.length ?? 0); + if (shared > 0) { + context.say( + `${shared} bundle(s) share one source map with another bundle (Next 15's Turbopack does this for its runtime chunks), so they were left unstamped: a map carries one debug-ID.`, + ); + } + + const bundler = { isProduction: true, configuration: 'production' }; + const runFor = async ( + dir: string, + files: BuildFiles, + options: Partial, + ): Promise => { + if (files.scripts.length === 0) { + return; + } + await upload({ ...resolved, ...options }, dir, { bundler, files }); + }; + // Browser first (it registers the build once); the server and edge output follows its own deletion policy. + await runFor(join(distDir, 'static'), client, {}); + if (server !== undefined) { + await runFor(join(distDir, 'server'), server, { + deleteMaps: context.deleteServerMaps, + registerBuild: false, + }); + } +} diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts new file mode 100644 index 00000000..0252646b --- /dev/null +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -0,0 +1,391 @@ +import { describe, expect, it, vi } from 'vitest'; +import type { BugseeNextContext } from './context'; +import { + type CompilerLike, + createNextWebpackPlugin, + nextAssetStore, + type WebpackPluginDeps, +} from './webpack-plugin'; + +class RawSource { + constructor(readonly content: Buffer) {} +} + +type Processor = () => Promise; + +/** A fake webpack compilation holding named assets, recording updates. */ +function fakeCompilation(assets: Record) { + const store = new Map( + Object.entries(assets).map(([k, v]) => [k, Buffer.from(v)]), + ); + let processor: Processor | undefined; + let stage: number | undefined; + return { + store, + run: () => (processor as Processor)(), + stage: () => stage, + compilation: { + hooks: { + processAssets: { + tapPromise: (o: { name: string; stage: number }, fn: Processor) => { + stage = o.stage; + processor = fn; + }, + }, + }, + getAssets: () => [...store.keys()].map((name) => ({ name })), + getAsset: (name: string) => + store.has(name) ? { source: { buffer: () => store.get(name) as Buffer } } : undefined, + updateAsset: vi.fn((name: string, source: unknown) => { + store.set(name, (source as RawSource).content); + }), + }, + }; +} + +type Compilation = ReturnType['compilation']; + +/** A fake compiler: records taps and lets the test fire them. */ +function fakeCompiler(options: { path?: string; api?: boolean } = {}) { + let onThis: ((c: Compilation) => void) | undefined; + let onEmit: ((c: Compilation) => Promise) | undefined; + const compiler = { + options: { output: { path: options.path ?? '/out/.next/server/chunks' } }, + hooks: { + thisCompilation: { tap: (_n: string, fn: (c: Compilation) => void) => (onThis = fn) }, + afterEmit: { + tapPromise: (_n: string, fn: (c: Compilation) => Promise) => (onEmit = fn), + }, + }, + ...(options.api === false + ? {} + : { + webpack: { + Compilation: { PROCESS_ASSETS_STAGE_DEV_TOOLING: 100 }, + sources: { RawSource }, + }, + }), + } as unknown as CompilerLike; + return { + compiler, + startCompilation: (c: Compilation) => (onThis as (c: Compilation) => void)(c), + emit: (c: Compilation) => (onEmit as (c: Compilation) => Promise)(c), + hasThis: () => onThis !== undefined, + hasEmit: () => onEmit !== undefined, + }; +} + +function context( + overrides: Partial = {}, + extra = {}, +): BugseeNextContext { + return { + resolved: { + enabled: true, + appToken: 't', + deleteMaps: true, + registerBuild: 'release', + dryRun: false, + failOnError: false, + ...overrides, + } as BugseeNextContext['resolved'], + serverSourceMaps: true, + deleteServerMaps: false, + say: vi.fn(), + ...extra, + }; +} + +const deps = (over: WebpackPluginDeps = {}): WebpackPluginDeps => ({ + stamp: vi.fn(async () => ({ stamped: [] })), + upload: vi.fn(async () => undefined), + exists: vi.fn(async () => true), + ...over, +}); + +describe('nextAssetStore', () => { + it('stages `../` asset names under a stand-in directory and maps them back', () => { + const { compilation, store } = fakeCompilation({ + '../app/page.js': 'code', + '../app/page.js.map': 'map', + 'chunks/1.js': 'one', + '../../deep.js': 'deep', + }); + const assets = nextAssetStore(compilation, RawSource); + const names = assets.names(); + expect(names).toEqual([ + '__bugsee_up__/app/page.js', + '__bugsee_up__/app/page.js.map', + 'chunks/1.js', + '__bugsee_up__/__bugsee_up__/deep.js', + ]); + // Nothing staged escapes the staging directory. + expect(names.some((n) => n.startsWith('..') || n.includes('/../'))).toBe(false); + expect(assets.read('__bugsee_up__/app/page.js').toString()).toBe('code'); + expect(assets.read('chunks/1.js').toString()).toBe('one'); + assets.update('__bugsee_up__/app/page.js', Buffer.from('stamped')); + expect(store.get('../app/page.js')?.toString()).toBe('stamped'); + assets.update('chunks/1.js', Buffer.from('stamped-one')); + expect(store.get('chunks/1.js')?.toString()).toBe('stamped-one'); + }); + + it('reads an unknown asset as empty rather than throwing', () => { + const { compilation } = fakeCompilation({}); + expect(nextAssetStore(compilation, RawSource).read('nope.js')).toEqual(Buffer.alloc(0)); + }); +}); + +describe('createNextWebpackPlugin', () => { + it('does nothing when the plugin is not enabled', () => { + const fake = fakeCompiler(); + createNextWebpackPlugin(context({ enabled: false }), 'client', deps()).apply(fake.compiler); + expect(fake.hasThis()).toBe(false); + expect(fake.hasEmit()).toBe(false); + }); + + it('does nothing for server and edge when server maps are off, but still serves the client', () => { + const off = context({}, { serverSourceMaps: false }); + for (const kind of ['server', 'edge'] as const) { + const fake = fakeCompiler(); + createNextWebpackPlugin(off, kind, deps()).apply(fake.compiler); + expect(fake.hasEmit()).toBe(false); + } + const client = fakeCompiler(); + createNextWebpackPlugin(off, 'client', deps()).apply(client.compiler); + expect(client.hasEmit()).toBe(true); + }); + + it('stamps the compilation one stage after dev-tooling', async () => { + const d = deps(); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x' }); + fake.startCompilation(c.compilation); + expect(c.stage()).toBe(101); + await c.run(); + expect(d.stamp).toHaveBeenCalledTimes(1); + expect(d.stamp).toHaveBeenCalledWith(expect.any(Object), { dryRun: false }); + }); + + it('passes dryRun to the stamp', async () => { + const d = deps(); + const fake = fakeCompiler(); + createNextWebpackPlugin(context({ dryRun: true }), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x' }); + fake.startCompilation(c.compilation); + await c.run(); + expect(d.stamp).toHaveBeenCalledWith(expect.any(Object), { dryRun: true }); + }); + + it('uploads after emit with the stamped flag, over exactly this compilation’s own files', async () => { + const d = deps(); + const fake = fakeCompiler({ path: '/out/.next/server/chunks' }); + createNextWebpackPlugin(context(), 'server', d).apply(fake.compiler); + const c = fakeCompilation({ + '../app/page.js': 'x', + '../app/page.js.map': 'm', + 'chunks/1.js': 'x', + 'chunks/1.js.map': 'm', + 'no-map.js': 'x', + }); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + expect(d.upload).toHaveBeenCalledTimes(1); + const [resolved, outDir, options] = (d.upload as ReturnType).mock.calls[0] as [ + Record, + string, + { bundler: unknown; preStamped: boolean; files: Record }, + ]; + expect(outDir).toBe('/out/.next/server/chunks'); + expect(options.preStamped).toBe(true); + expect(options.bundler).toEqual({ isProduction: true, configuration: 'server' }); + expect(options.files.scripts).toEqual([ + '/out/.next/server/app/page.js', + '/out/.next/server/chunks/chunks/1.js', + ]); + expect(options.files.maps).toEqual([ + '/out/.next/server/app/page.js.map', + '/out/.next/server/chunks/chunks/1.js.map', + ]); + // The server follows the server deletion policy and never registers the build. + expect(resolved).toMatchObject({ deleteMaps: false, registerBuild: false }); + }); + + it('gives the client the client policy: deleted maps, the build registered', async () => { + const d = deps(); + const fake = fakeCompiler({ path: '/out/.next' }); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'static/a.js': 'x', 'static/a.js.map': 'm' }); + fake.startCompilation(c.compilation); + await fake.emit(c.compilation); + const [resolved] = (d.upload as ReturnType).mock.calls[0] as [ + Record, + ]; + expect(resolved).toMatchObject({ deleteMaps: true, registerBuild: 'release' }); + }); + + it('honours deleteServerMaps for server and edge', async () => { + const d = deps(); + const fake = fakeCompiler(); + createNextWebpackPlugin(context({}, { deleteServerMaps: true }), 'edge', d).apply( + fake.compiler, + ); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(c.compilation); + await fake.emit(c.compilation); + const [resolved] = (d.upload as ReturnType).mock.calls[0] as [ + Record, + ]; + expect(resolved).toMatchObject({ deleteMaps: true }); + }); + + it('only counts assets that exist on disk', async () => { + const d = deps({ exists: vi.fn(async (p: string) => !p.endsWith('gone.js')) }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'server', d).apply(fake.compiler); + const c = fakeCompilation({ + 'gone.js': 'x', + 'gone.js.map': 'm', + 'here.js': 'x', + 'here.js.map': 'm', + }); + fake.startCompilation(c.compilation); + await fake.emit(c.compilation); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { files: { scripts: string[] } }, + ]; + expect(options.files.scripts).toEqual(['/out/.next/server/chunks/here.js']); + }); + + it('falls back to the post-emit stamp (preStamped false) and warns when the in-build stamp fails', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const d = deps({ + stamp: vi.fn(async () => { + throw new Error('inject broke'); + }), + }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + expect(warn).toHaveBeenCalledWith(expect.stringContaining('inject broke')); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { preStamped: boolean }, + ]; + expect(options.preStamped).toBe(false); + warn.mockRestore(); + }); + + it('reports a stamp failure through onError', async () => { + const onError = vi.fn(); + const d = deps({ + stamp: vi.fn(async () => { + throw new Error('boom'); + }), + }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context({ onError }), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x' }); + fake.startCompilation(c.compilation); + await c.run(); + expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'boom' })); + }); + + it('rethrows a stamp failure under failOnError', async () => { + const d = deps({ + stamp: vi.fn(async () => { + throw new Error('strict'); + }), + }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context({ failOnError: true }), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x' }); + fake.startCompilation(c.compilation); + await expect(c.run()).rejects.toThrow('strict'); + }); + + it('a stamp from the previous compilation cannot vouch for the next one (watch mode)', async () => { + const d = deps(); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const first = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(first.compilation); + await first.run(); + const second = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(second.compilation); + await fake.emit(second.compilation); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { preStamped: boolean }, + ]; + expect(options.preStamped).toBe(false); + }); + + it('skips the in-build stamp when the compiler exposes no webpack API, and still uploads', async () => { + const d = deps(); + const fake = fakeCompiler({ api: false }); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + expect(fake.hasThis()).toBe(false); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + await fake.emit(c.compilation); + expect(d.upload).toHaveBeenCalledTimes(1); + }); + + it('works through Rspack’s API object', async () => { + const d = deps(); + const fake = fakeCompiler(); + const raw = fake.compiler as unknown as { webpack?: unknown; rspack?: unknown }; + raw.rspack = raw.webpack; + raw.webpack = undefined; + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + expect(fake.hasThis()).toBe(true); + }); + + it('says so when the browser build emitted no maps, and does not upload', async () => { + const d = deps(); + const ctx = context(); + const fake = fakeCompiler(); + createNextWebpackPlugin(ctx, 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x' }); + fake.startCompilation(c.compilation); + await fake.emit(c.compilation); + expect(d.upload).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('productionBrowserSourceMaps')); + }); + + it('is quiet when a server compilation emitted no maps', async () => { + const d = deps(); + const ctx = context(); + const fake = fakeCompiler(); + createNextWebpackPlugin(ctx, 'server', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x' }); + await fake.emit(c.compilation); + expect(d.upload).not.toHaveBeenCalled(); + expect(ctx.say).not.toHaveBeenCalled(); + }); + + it('does nothing after emit when the compiler has no output path', async () => { + const d = deps(); + const fake = fakeCompiler(); + (fake.compiler as unknown as { options: unknown }).options = {}; + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + await fake.emit(fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }).compilation); + expect(d.upload).not.toHaveBeenCalled(); + }); + + it('uses the real stamp, upload and filesystem when none are injected', async () => { + const fake = fakeCompiler({ path: '/definitely/not/here' }); + createNextWebpackPlugin(context({ enabled: true }), 'server').apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + // Nothing exists on disk, so the real `exists` filters everything out and nothing is uploaded. + await expect(fake.emit(c.compilation)).resolves.toBeUndefined(); + }); +}); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts new file mode 100644 index 00000000..3cf28599 --- /dev/null +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -0,0 +1,187 @@ +// The webpack side of `withBugsee` (`next build --webpack`, and the default for Next <= 15). One plugin instance per +// Next compilation (client, server, edge), each doing two things for ITS OWN assets only: +// +// 1. stamp the debug-IDs inside the compilation, before anything hashes the output (Subresource Integrity), and +// 2. after emit, upload the maps of exactly the files this compilation wrote, then delete them per policy. +// +// It deliberately does not reuse the generic webpack plugin of `@bugsee/webpack-plugin`: measured against a real +// `next build`, that plugin assumes one compilation per output directory. Next's server compilation emits to +// `.next/server/chunks` with asset names like `../app/page.js` (outside its own output path), so the generic +// plugin neither stamped them (an asset name may not escape the staging directory) nor found their maps, and its +// directory-wide upload of `.next` swept up the server compilation's half-written files. +import { stat } from 'node:fs/promises'; +import { resolve } from 'node:path'; +import { + type AssetStore, + type ResolvedPluginOptions, + runPluginUpload, + stampAssets, +} from '@bugsee/bundler-plugin-core'; +import { type BuildFiles, partitionBuildFiles } from './build-files'; +import type { BugseeNextContext } from './context'; + +/** Which of Next's three webpack compilations a plugin instance serves. */ +export type NextCompilationKind = 'client' | 'server' | 'edge'; + +/** The slice of a webpack compilation the stamp and the file list read and write. */ +interface CompilationLike { + hooks: { + processAssets: { + tapPromise: (options: { name: string; stage: number }, fn: () => Promise) => void; + }; + }; + getAssets(): ReadonlyArray<{ name: string }>; + getAsset(name: string): { source: { buffer(): Buffer } } | undefined; + updateAsset(name: string, source: unknown): void; +} + +/** The slice of a webpack compiler this taps. Read from the compiler, never imported (see core's plugin.ts). */ +export interface CompilerLike { + options: { output?: { path?: string } }; + hooks: { + thisCompilation: { tap: (name: string, fn: (compilation: CompilationLike) => void) => void }; + afterEmit: { + tapPromise: (name: string, fn: (compilation: CompilationLike) => Promise) => void; + }; + }; + webpack?: WebpackApi; + rspack?: WebpackApi; +} + +interface WebpackApi { + Compilation?: { PROCESS_ASSETS_STAGE_DEV_TOOLING?: number }; + sources?: { RawSource?: new (content: Buffer) => unknown }; +} + +/** Seams for tests. */ +export interface WebpackPluginDeps { + stamp?: typeof stampAssets; + upload?: typeof runPluginUpload; + /** Whether a path exists on disk (default `fs.stat`). */ + exists?: (path: string) => Promise; +} + +const PLUGIN = 'bugsee-next'; +/** Stands in for each leading `../` of an asset name inside the staging directory. */ +const UP = '__bugsee_up__'; + +async function fileExists(path: string): Promise { + try { + return (await stat(path)).isFile(); + } catch { + return false; + } +} + +/** + * A compilation's assets as an {@link AssetStore}. Asset names that start with `../` (Next's server output sits + * one level above the compilation's output path) are staged under a stand-in directory, consistently for a bundle + * and its map, so their relative layout survives and nothing can escape the staging directory. + */ +export function nextAssetStore( + compilation: CompilationLike, + RawSource: new (content: Buffer) => unknown, +): AssetStore { + const staged = (name: string): string => + name.replace(/^(?:\.\.\/)+/, (up) => `${UP}/`.repeat(up.length / 3)); + const actual = new Map(); + return { + names: () => { + actual.clear(); + for (const { name } of compilation.getAssets()) { + actual.set(staged(name), name); + } + return [...actual.keys()]; + }, + read: (name) => + compilation.getAsset(actual.get(name) ?? name)?.source.buffer() ?? Buffer.alloc(0), + update: (name, content) => + compilation.updateAsset(actual.get(name) ?? name, new RawSource(content)), + }; +} + +/** The webpack plugin for one Next compilation. */ +export function createNextWebpackPlugin( + context: BugseeNextContext, + kind: NextCompilationKind, + deps: WebpackPluginDeps = {}, +): { apply(compiler: CompilerLike): void } { + const stamp = deps.stamp ?? stampAssets; + const upload = deps.upload ?? runPluginUpload; + const exists = deps.exists ?? fileExists; + const { resolved } = context; + // Only the browser compilation registers the build (once per `next build`), and only it follows the client + // deletion policy: `.next/static` is public, `.next/server` is not. + const forKind: ResolvedPluginOptions = { + ...resolved, + deleteMaps: kind === 'client' ? resolved.deleteMaps : context.deleteServerMaps, + registerBuild: kind === 'client' ? resolved.registerBuild : false, + }; + + return { + apply(compiler) { + if (!resolved.enabled || (kind !== 'client' && !context.serverSourceMaps)) { + return; + } + const api = compiler.webpack ?? compiler.rspack; + const stage = api?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING; + const RawSource = api?.sources?.RawSource; + // Reset per compilation: in watch mode a stamp from the previous build cannot vouch for this one. + let preStamped = false; + if (stage !== undefined && RawSource !== undefined) { + compiler.hooks.thisCompilation.tap(PLUGIN, (compilation) => { + preStamped = false; + // One stage past the source-map plugin (500): the final bytes, before the SRI plugin hashes them. + compilation.hooks.processAssets.tapPromise( + { name: PLUGIN, stage: stage + 1 }, + async () => { + try { + await stamp(nextAssetStore(compilation, RawSource), { dryRun: resolved.dryRun }); + preStamped = true; + } catch (error) { + if (resolved.failOnError) { + throw error; + } + ( + resolved.onError ?? + ((e: unknown) => + console.warn( + `[bugsee] in-build debug-ID stamping failed; falling back to stamping after emit: ${String(e)}`, + )) + )(error); + } + }, + ); + }); + } + + compiler.hooks.afterEmit.tapPromise(PLUGIN, async (compilation) => { + const outDir = compiler.options.output?.path; + if (typeof outDir !== 'string' || outDir === '') { + return; + } + const emitted: string[] = []; + for (const { name } of compilation.getAssets()) { + const path = resolve(outDir, name); + if (await exists(path)) { + emitted.push(path); + } + } + const files: BuildFiles = partitionBuildFiles(emitted); + if (files.scripts.length === 0) { + if (kind === 'client') { + context.say( + 'the browser build emitted no source maps, so nothing was uploaded for it. Set `productionBrowserSourceMaps: true` (withBugsee does this unless you set it to false).', + ); + } + return; + } + await upload(forKind, outDir, { + bundler: { isProduction: true, configuration: kind }, + preStamped, + files, + }); + }); + }, + }; +} diff --git a/packages/nextjs/src/config/with-bugsee.kind.test.ts b/packages/nextjs/src/config/with-bugsee.kind.test.ts new file mode 100644 index 00000000..1e3e23bd --- /dev/null +++ b/packages/nextjs/src/config/with-bugsee.kind.test.ts @@ -0,0 +1,44 @@ +import { describe, expect, it, vi } from 'vitest'; +import type { BugseeNextContext } from './context'; +import { withBugsee } from './with-bugsee'; + +// The compilation kind Next's webpack function is called with decides which policy a plugin instance gets +// (browser maps are public and deleted, server maps are kept), so it is pinned here at the seam. +const created = vi.hoisted(() => [] as string[]); +vi.mock('./webpack-plugin', () => ({ + createNextWebpackPlugin: (_context: unknown, kind: string) => { + created.push(kind); + return { apply: () => undefined }; + }, +})); + +const context = { + resolved: { enabled: true, identityDefines: {} }, + serverSourceMaps: true, + deleteServerMaps: false, + say: () => undefined, +} as unknown as BugseeNextContext; + +type Webpack = (config: object, options: object) => unknown; +const webpackOf = (): Webpack => + ( + withBugsee( + {}, + {}, + { env: {}, cwd: () => '/app', createContext: () => context, nextVersion: () => '16.4.6' }, + ) as { webpack: Webpack } + ).webpack; + +describe('withBugsee: which compilation a plugin is made for', () => { + it.each([ + [{ isServer: false }, 'client'], + [{ isServer: false, nextRuntime: 'edge' }, 'client'], + [{ isServer: true, nextRuntime: 'nodejs' }, 'server'], + [{ isServer: true }, 'server'], + [{ isServer: true, nextRuntime: 'edge' }, 'edge'], + ])('%j is the %s compilation', (options, kind) => { + created.length = 0; + webpackOf()({}, { dev: false, ...options }); + expect(created).toEqual([kind]); + }); +}); diff --git a/packages/nextjs/src/config/with-bugsee.test.ts b/packages/nextjs/src/config/with-bugsee.test.ts new file mode 100644 index 00000000..084aa875 --- /dev/null +++ b/packages/nextjs/src/config/with-bugsee.test.ts @@ -0,0 +1,350 @@ +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { describe, expect, it, vi } from 'vitest'; +import type { BugseeNextContext } from './context'; +import { versionAtLeast, type WithBugseeDeps, withBugsee } from './with-bugsee'; + +vi.mock('./post-build', () => ({ runPostBuild: vi.fn(async () => undefined) })); + +import { runPostBuild } from './post-build'; + +function context( + overrides: Partial = {}, + extra: Partial = {}, +): BugseeNextContext { + return { + resolved: { + enabled: true, + identityDefines: { __BUGSEE_APP_VERSION__: '"1.0.0"', __BUGSEE_APP_BUILD__: '"7"' }, + ...overrides, + } as BugseeNextContext['resolved'], + serverSourceMaps: true, + deleteServerMaps: false, + say: vi.fn(), + ...extra, + }; +} + +function deps( + ctx = context(), + over: WithBugseeDeps = {}, +): WithBugseeDeps & { ctx: BugseeNextContext } { + return { + ctx, + cwd: () => '/app', + env: {}, + nextVersion: () => '16.4.6', + createContext: vi.fn(() => ctx), + ...over, + }; +} + +// biome-ignore lint/suspicious/noExplicitAny: a Next config under test is open-ended. +type Obj = Record; +const apply = (config: Obj, d: WithBugseeDeps, options = {}): Obj => + withBugsee(config, options, d) as Obj; + +describe('versionAtLeast', () => { + it.each([ + ['16.4.6', true], + ['15.4.1', true], + ['15.4.2', true], + ['15.5.0', true], + ['15.4.0', false], + ['15.3.9', false], + ['14.9.9', false], + ['15.4.1-canary.3', true], + ['not-a-version', true], + ])('%s -> %s', (version, expected) => { + expect(versionAtLeast(version, [15, 4, 1])).toBe(expected); + }); +}); + +describe('withBugsee: composition', () => { + it('returns the config untouched when disabled', () => { + const config = { a: 1 }; + expect(withBugsee(config, { disabled: true })).toBe(config); + }); + + it('defaults to an empty config', () => { + expect(withBugsee(undefined, {}, deps()) as Obj).toMatchObject({ + productionBrowserSourceMaps: true, + }); + }); + + it('keeps every key of the app’s config', () => { + const out = apply({ reactStrictMode: true, images: { x: 1 } }, deps()); + expect(out).toMatchObject({ reactStrictMode: true, images: { x: 1 } }); + }); + + it('turns browser source maps on only when the app said nothing', () => { + expect(apply({}, deps()).productionBrowserSourceMaps).toBe(true); + expect(apply({ productionBrowserSourceMaps: false }, deps()).productionBrowserSourceMaps).toBe( + false, + ); + expect(apply({ productionBrowserSourceMaps: true }, deps()).productionBrowserSourceMaps).toBe( + true, + ); + }); + + it('does not change what Next emits when there is no token (nothing would be uploaded or removed)', () => { + const out = apply({}, deps(context({ enabled: false }))); + expect(out.productionBrowserSourceMaps).toBeUndefined(); + expect(out.webpack).toBeUndefined(); + expect(out.compiler?.runAfterProductionCompile).toBeUndefined(); + }); + + it('bakes the identity into compiler.define, the app’s own constants winning, never into defineServer', () => { + const out = apply( + { + compiler: { define: { __BUGSEE_APP_VERSION__: '"mine"', OTHER: '1' }, removeConsole: true }, + }, + deps(), + ); + expect(out.compiler.define).toEqual({ + __BUGSEE_APP_VERSION__: '"mine"', + __BUGSEE_APP_BUILD__: '"7"', + OTHER: '1', + }); + expect(out.compiler.defineServer).toBeUndefined(); + expect(out.compiler.removeConsole).toBe(true); + }); + + it('bakes the identity even without a token, but adds no define when none was found', () => { + expect(apply({}, deps(context({ enabled: false }))).compiler.define).toMatchObject({ + __BUGSEE_APP_VERSION__: '"1.0.0"', + }); + expect(apply({}, deps(context({ identityDefines: {} }))).compiler).toBeUndefined(); + }); +}); + +describe('withBugsee: phases and shapes', () => { + it('leaves a function config alone for every phase except the production build', async () => { + const d = deps(); + const fn = withBugsee(() => ({ a: 1 }), {}, d) as unknown as ( + p: string, + c: Obj, + ) => Promise; + for (const phase of ['phase-development-server', 'phase-production-server', 'phase-export']) { + expect(await fn(phase, { defaultConfig: {} })).toEqual({ a: 1 }); + } + expect(d.createContext).not.toHaveBeenCalled(); + const built = await fn('phase-production-build', { defaultConfig: {} }); + expect(built.productionBrowserSourceMaps).toBe(true); + }); + + it('awaits an async function config and passes it the phase arguments', async () => { + const user = vi.fn(async () => ({ a: 1 })); + const fn = withBugsee(user, {}, deps()) as unknown as (p: string, c: Obj) => Promise; + const out = await fn('phase-production-build', { defaultConfig: { d: 1 } }); + expect(user).toHaveBeenCalledWith('phase-production-build', { defaultConfig: { d: 1 } }); + expect(out.a).toBe(1); + }); + + it('extends a config that is a promise', async () => { + const out = (await withBugsee(Promise.resolve({ a: 1 }), {}, deps())) as Obj; + expect(out).toMatchObject({ a: 1, productionBrowserSourceMaps: true }); + }); + + it('resolves the context from the working directory, with the injected environment', () => { + const d = deps(context(), { cwd: () => '/work/app', env: { X: '1' } }); + apply({}, d, { appToken: 't' }); + expect(d.createContext).toHaveBeenCalledWith({ appToken: 't' }, '/work/app', { + env: { X: '1' }, + }); + }); + + it('uses the process cwd and environment when none are injected', () => { + const create = vi.fn(() => context()); + withBugsee({}, {}, { createContext: create, nextVersion: () => '16.0.0' }); + expect(create).toHaveBeenCalledWith({}, process.cwd(), { env: process.env }); + }); +}); + +describe('withBugsee: the webpack function', () => { + const nextArgs = (over: Obj = {}) => ({ + dev: false, + isServer: false, + nextRuntime: undefined, + ...over, + }); + + it('appends one Bugsee plugin per compilation and keeps the app’s plugins', () => { + const out = apply({}, deps()); + const result = out.webpack({ plugins: ['mine'], devtool: 'source-map' }, nextArgs()); + expect(result.plugins[0]).toBe('mine'); + expect(result.plugins).toHaveLength(2); + expect(typeof result.plugins[1].apply).toBe('function'); + }); + + it('creates the plugin list when the config has none', () => { + const result = apply({}, deps()).webpack({}, nextArgs()); + expect(result.plugins).toHaveLength(1); + }); + + it('does nothing for next dev', () => { + const config = { plugins: ['mine'] }; + const result = apply({}, deps()).webpack(config, nextArgs({ dev: true })); + expect(result.plugins).toEqual(['mine']); + expect(result.devtool).toBeUndefined(); + }); + + it('gives server and edge compilations a source-map devtool only when the app left it unset', () => { + const out = apply({}, deps()); + expect(out.webpack({}, nextArgs({ isServer: true, nextRuntime: 'nodejs' })).devtool).toBe( + 'source-map', + ); + expect(out.webpack({}, nextArgs({ isServer: true, nextRuntime: 'edge' })).devtool).toBe( + 'source-map', + ); + expect( + out.webpack({ devtool: 'hidden-source-map' }, nextArgs({ isServer: true })).devtool, + ).toBe('hidden-source-map'); + // The browser's devtool is Next's own business (productionBrowserSourceMaps). + expect(out.webpack({}, nextArgs()).devtool).toBeUndefined(); + }); + + it('leaves server devtool alone when server maps are off', () => { + const out = apply({}, deps(context({}, { serverSourceMaps: false }))); + expect(out.webpack({}, nextArgs({ isServer: true })).devtool).toBeUndefined(); + }); + + it('runs the app’s own webpack function first, on the same config, and uses what it returns', () => { + const user = vi.fn((config: Obj) => ({ ...config, custom: true })); + const out = apply({ webpack: user }, deps()); + const base = { plugins: [] }; + const args = nextArgs(); + const result = out.webpack(base, args); + expect(user).toHaveBeenCalledWith(base, args); + expect(result.custom).toBe(true); + expect(result.plugins).toHaveLength(1); + }); + + it('uses the original config when the app’s webpack function returns nothing', () => { + const out = apply({ webpack: () => undefined }, deps()); + expect(out.webpack({ plugins: [] }, nextArgs()).plugins).toHaveLength(1); + }); + + it('supports an async app webpack function', async () => { + const out = apply({ webpack: async (c: Obj) => ({ ...c, late: true }) }, deps()); + const result = await out.webpack({}, nextArgs()); + expect(result.late).toBe(true); + expect(result.plugins).toHaveLength(1); + }); +}); + +describe('withBugsee: Turbopack', () => { + const turbo = (over: Partial = {}, ctx = context()) => + deps(ctx, { env: { TURBOPACK: '1' }, ...over }); + + it('adds no webpack function to a Turbopack build (Next 16 refuses one), and leaves the app’s own', () => { + expect(apply({}, turbo()).webpack).toBeUndefined(); + const mine = () => undefined; + expect(apply({ webpack: mine }, turbo()).webpack).toBe(mine); + }); + + it('installs the post-build hook only for a Turbopack build', () => { + expect(apply({}, deps()).compiler?.runAfterProductionCompile).toBeUndefined(); + expect(typeof apply({}, turbo()).compiler.runAfterProductionCompile).toBe('function'); + }); + + it('runs the app’s own hook first, then the upload, with the same metadata', async () => { + const order: string[] = []; + (runPostBuild as ReturnType).mockImplementation(async () => { + order.push('bugsee'); + }); + const user = vi.fn(async () => { + order.push('user'); + }); + const d = turbo(); + const out = apply({ compiler: { runAfterProductionCompile: user, removeConsole: true } }, d); + const metadata = { projectDir: '/app', distDir: '/app/.next' }; + await out.compiler.runAfterProductionCompile(metadata); + expect(order).toEqual(['user', 'bugsee']); + expect(user).toHaveBeenCalledWith(metadata); + expect(runPostBuild).toHaveBeenCalledWith(d.ctx, metadata); + // The rest of `compiler`, and the baked identity, survive next to the hook. + expect(out.compiler.removeConsole).toBe(true); + expect(out.compiler.define.__BUGSEE_APP_VERSION__).toBe('"1.0.0"'); + }); + + it('works when the app has no hook of its own', async () => { + const out = apply({}, turbo()); + await expect( + out.compiler.runAfterProductionCompile({ projectDir: '/a', distDir: '/a/.next' }), + ).resolves.toBeUndefined(); + }); + + it('keeps the hook next to an app compiler block when there is no identity to bake', () => { + const out = apply( + { compiler: { removeConsole: true } }, + turbo({}, context({ identityDefines: {} })), + ); + expect(out.compiler.removeConsole).toBe(true); + expect(typeof out.compiler.runAfterProductionCompile).toBe('function'); + }); + + it('refuses to promise an upload on a Next that has no hook, and says so', () => { + const ctx = context(); + const out = apply({}, turbo({ nextVersion: () => '15.3.0' }, ctx)); + expect(out.compiler?.runAfterProductionCompile).toBeUndefined(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('15.4.1')); + }); + + it('draws the line at 15.4.1: the hook is installed from there, not before', () => { + const hooked = (version: string): boolean => + typeof apply({}, turbo({ nextVersion: () => version })).compiler + ?.runAfterProductionCompile === 'function'; + expect(hooked('15.4.0')).toBe(false); + expect(hooked('15.4.1')).toBe(true); + expect(hooked('15.5.28')).toBe(true); + expect(hooked('16.4.6')).toBe(true); + }); + + it('installs the hook when the Next version cannot be determined', () => { + const out = apply({}, turbo({ nextVersion: () => undefined })); + expect(typeof out.compiler.runAfterProductionCompile).toBe('function'); + }); + + it('reads the installed Next version from the project when none is injected', () => { + const dir = mkdtempSync(join(tmpdir(), 'bugsee-nextver-')); + try { + mkdirSync(join(dir, 'node_modules', 'next'), { recursive: true }); + writeFileSync(join(dir, 'package.json'), '{"name":"app"}'); + writeFileSync( + join(dir, 'node_modules', 'next', 'package.json'), + '{"name":"next","version":"15.3.0"}', + ); + const ctx = context(); + const out = withBugsee( + {}, + {}, + { env: { TURBOPACK: '1' }, cwd: () => dir, createContext: () => ctx }, + ) as Obj; + expect(out.compiler?.runAfterProductionCompile).toBeUndefined(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('Next 15.3.0')); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); + + it('treats an unreadable next manifest as an unknown version', () => { + const dir = mkdtempSync(join(tmpdir(), 'bugsee-nonext-')); + try { + // `next` is there but its manifest cannot be read: the version is unknown, never an error. + mkdirSync(join(dir, 'node_modules', 'next'), { recursive: true }); + writeFileSync(join(dir, 'node_modules', 'next', 'package.json'), '{not json'); + const ctx = context(); + const out = withBugsee( + {}, + {}, + { env: { TURBOPACK: '1' }, cwd: () => dir, createContext: () => ctx }, + ) as Obj; + expect(typeof out.compiler.runAfterProductionCompile).toBe('function'); + expect(ctx.say).not.toHaveBeenCalled(); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); +}); diff --git a/packages/nextjs/src/config/with-bugsee.ts b/packages/nextjs/src/config/with-bugsee.ts new file mode 100644 index 00000000..f1f2c663 --- /dev/null +++ b/packages/nextjs/src/config/with-bugsee.ts @@ -0,0 +1,196 @@ +// `withBugsee(nextConfig, options)` — the Next.js build integration that makes `next build` upload source maps. +// +// webpack (`next build --webpack`; the default up to Next 15): a Bugsee plugin on each of the client, server and +// edge compilations stamps the debug-IDs inside the build and uploads that compilation's own maps. +// Turbopack (the default in Next 16; `next build --turbopack` before): no plugin API, so Next's +// `compiler.runAfterProductionCompile` hook runs the stamp + upload over the written `.next`. +// +// The result composes with what the app already has: a config object, a (phase) function or an async one; the +// app's own `webpack` function, `compiler.runAfterProductionCompile`, `compiler.define` and +// `productionBrowserSourceMaps` are called, kept or extended, never replaced. Nothing runs for `next dev`. +import { createRequire } from 'node:module'; +import { join } from 'node:path'; +import { type BugseeNextContext, createBugseeContext, type WithBugseeOptions } from './context'; +import { type PostBuildMetadata, runPostBuild } from './post-build'; +import { createNextWebpackPlugin, type NextCompilationKind } from './webpack-plugin'; + +/** The Next config shapes this accepts. Structural: `next` is not a dependency. */ +// biome-ignore lint/suspicious/noExplicitAny: a user's Next config is open-ended; only the keys read below matter. +export type NextConfigObject = Record; +export type NextConfigFunction = ( + phase: string, + context: { defaultConfig: NextConfigObject }, +) => C | Promise; +export type NextConfigInput = C | Promise | NextConfigFunction; + +/** Next's `PHASE_PRODUCTION_BUILD`. The only phase that builds anything we touch. */ +const PHASE_PRODUCTION_BUILD = 'phase-production-build'; +/** The first Next with `compiler.runAfterProductionCompile` that Turbopack runs (measured, see post-build.ts). */ +const MIN_TURBOPACK_HOOK = [15, 4, 1] as const; + +/** Seams for tests. */ +export interface WithBugseeDeps { + cwd?: () => string; + env?: Record; + /** The installed `next` version, or `undefined` when unknown. */ + nextVersion?: (projectDir: string) => string | undefined; + createContext?: typeof createBugseeContext; +} + +function isThenable(value: unknown): value is PromiseLike { + return ( + typeof value === 'object' && + value !== null && + typeof (value as { then?: unknown }).then === 'function' + ); +} + +/** Whether `version` (`16.4.6`, `15.4.0-canary.12`) is at least `min`. Unparseable counts as new enough. */ +export function versionAtLeast(version: string, min: readonly [number, number, number]): boolean { + const match = /^(\d+)\.(\d+)\.(\d+)/.exec(version); + if (match === null) { + return true; + } + const parts = [Number(match[1]), Number(match[2]), Number(match[3])]; + for (let i = 0; i < 3; i++) { + if ((parts[i] as number) !== min[i]) { + return (parts[i] as number) > (min[i] as number); + } + } + return true; +} + +/** The `version` of the `next` installed for `projectDir`. */ +function installedNextVersion(projectDir: string): string | undefined { + try { + const require = createRequire(join(projectDir, 'package.json')); + return (require('next/package.json') as { version?: string }).version; + } catch { + return undefined; + } +} + +function compilationKind(next: { isServer?: boolean; nextRuntime?: string }): NextCompilationKind { + if (next.isServer !== true) { + return 'client'; + } + return next.nextRuntime === 'edge' ? 'edge' : 'server'; +} + +/** Build the extended config for one resolved context. */ +function extendConfig( + config: C, + context: BugseeNextContext, + turbopack: boolean, + nextVersion: string | undefined, +): C { + const { resolved } = context; + const next: NextConfigObject = { ...config }; + + // The app's version and build, baked into every bundle (browser, node, edge) for the runtime SDK to read. + // `compiler.define` applies to all three; `defineServer` must NOT repeat the keys (measured, Next 15.5: it + // throws "already configured"). A constant the app defined itself wins. + const identity = resolved.identityDefines; + if (Object.keys(identity).length > 0) { + const compiler: NextConfigObject = { ...(config.compiler ?? {}) }; + compiler.define = { ...identity, ...(config.compiler?.define ?? {}) }; + next.compiler = compiler; + } + if (!resolved.enabled) { + return next as C; + } + + // Browser maps are what Bugsee symbolicates browser crashes with. Forced on only when nothing says otherwise, + // and only here, where a token means they will be uploaded and then removed from `.next/static`. + if (config.productionBrowserSourceMaps === undefined) { + next.productionBrowserSourceMaps = true; + } + + // webpack builds only. A `webpack` function on a Turbopack build is an ERROR in Next 16 ("a `webpack` config and + // no `turbopack` config", measured) and a warning in 15.5, so Turbopack builds never get one from us. + if (!turbopack) { + const userWebpack = config.webpack as + | ((webpackConfig: NextConfigObject, options: NextConfigObject) => unknown) + | undefined; + next.webpack = (webpackConfig: NextConfigObject, options: NextConfigObject) => { + const result = + userWebpack === undefined ? webpackConfig : userWebpack(webpackConfig, options); + const finish = (value: unknown): NextConfigObject => { + const out = (value ?? webpackConfig) as NextConfigObject; + if (options.dev === true) { + return out; + } + const kind = compilationKind(options); + if (kind !== 'client' && context.serverSourceMaps && !out.devtool) { + out.devtool = 'source-map'; + } + out.plugins = [...(out.plugins ?? []), createNextWebpackPlugin(context, kind)]; + return out; + }; + return isThenable(result) ? result.then(finish) : finish(result); + }; + } + + if (turbopack) { + if (nextVersion !== undefined && !versionAtLeast(nextVersion, MIN_TURBOPACK_HOOK)) { + context.say( + `Next ${nextVersion} builds with Turbopack but has no post-build hook to upload from; source maps were NOT uploaded. Upgrade to Next 15.4.1 or later, or build with webpack.`, + ); + } else { + const userHook = config.compiler?.runAfterProductionCompile as + | ((metadata: PostBuildMetadata) => Promise) + | undefined; + next.compiler = { + ...(next.compiler ?? config.compiler ?? {}), + runAfterProductionCompile: async (metadata: PostBuildMetadata) => { + await userHook?.(metadata); + await runPostBuild(context, metadata); + }, + }; + } + } + return next as C; +} + +/** + * Wrap a Next config so `next build` stamps debug-IDs and uploads source maps to Bugsee. + * + * ```js + * // next.config.mjs + * import { withBugsee } from '@bugsee/nextjs/config'; + * export default withBugsee({ /* your config *\/ }, { appToken: process.env.BUGSEE_APP_TOKEN }); + * ``` + */ +export function withBugsee( + nextConfig: NextConfigInput = {} as C, + options: WithBugseeOptions = {}, + deps: WithBugseeDeps = {}, +): NextConfigInput { + if (options.disabled === true) { + return nextConfig; + } + const env = deps.env ?? process.env; + const turbopack = Boolean(env.TURBOPACK); + const apply = (config: C, phase: string | undefined): C => { + // `next dev`, `next start` and `next export` build nothing this touches. An object config has no phase; + // there the webpack function is gated on `dev` and the post-build hook only exists in a production build. + if (phase !== undefined && phase !== PHASE_PRODUCTION_BUILD) { + return config; + } + const projectDir = (deps.cwd ?? process.cwd)(); + const context = (deps.createContext ?? createBugseeContext)(options, projectDir, { env }); + return extendConfig( + config, + context, + turbopack, + (deps.nextVersion ?? installedNextVersion)(projectDir), + ); + }; + if (typeof nextConfig === 'function') { + return async (phase, context) => apply(await nextConfig(phase, context), phase); + } + if (isThenable(nextConfig)) { + return Promise.resolve(nextConfig).then((config) => apply(config, undefined)); + } + return apply(nextConfig, undefined); +} diff --git a/packages/nextjs/tsup.config.ts b/packages/nextjs/tsup.config.ts index f41159ee..d692e512 100644 --- a/packages/nextjs/tsup.config.ts +++ b/packages/nextjs/tsup.config.ts @@ -14,6 +14,14 @@ import { baseConfig } from '../../tsup.config.base'; // `.` entry (#172). Keeping them external is what preserves the code-split in the (non-splitting) CJS build. export default defineConfig({ ...baseConfig, - entry: ['src/index.ts', 'src/server.ts', 'src/client.ts', 'src/edge.ts', 'src/middleware.ts'], + entry: { + index: 'src/index.ts', + server: 'src/server.ts', + client: 'src/client.ts', + edge: 'src/edge.ts', + middleware: 'src/middleware.ts', + // The build-time integration (next.config): node-only, never imported by an app runtime. + config: 'src/config/index.ts', + }, external: ['@bugsee/nextjs/server', '@bugsee/nextjs/edge'], }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8f9fe40e..a7ba719e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -437,7 +437,7 @@ importers: devDependencies: '@rspack/core': specifier: 2.2.9 - version: 2.2.9 + version: 2.2.9(@swc/helpers@0.5.23) '@types/node': specifier: ^22.20.5 version: 22.20.5 @@ -787,7 +787,7 @@ importers: version: 0.8.3 html-webpack-plugin: specifier: ^5.6.8 - version: 5.6.8(@rspack/core@2.2.9)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + version: 5.6.8(@rspack/core@2.2.9(@swc/helpers@0.5.23))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) jsdom: specifier: ^25.0.1 version: 25.0.1 @@ -823,7 +823,7 @@ importers: version: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) webpack-subresource-integrity: specifier: ^5.1.0 - version: 5.1.0(html-webpack-plugin@5.6.8(@rspack/core@2.2.9)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + version: 5.1.0(html-webpack-plugin@5.6.8(@rspack/core@2.2.9(@swc/helpers@0.5.23))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) zone.js: specifier: 0.16.3 version: 0.16.3 @@ -924,6 +924,9 @@ importers: '@bugsee/bugsee': specifier: workspace:* version: link:../bugsee + '@bugsee/bundler-plugin-core': + specifier: workspace:* + version: link:../bundler-plugin-core '@bugsee/core': specifier: workspace:* version: link:../core @@ -968,12 +971,18 @@ importers: next: specifier: ^15.5.28 version: 15.5.28(@babel/core@7.29.0)(@opentelemetry/api@1.10.0)(@types/node@22.20.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next16: + specifier: npm:next@16.4.6 + version: next@16.4.6(@babel/core@7.29.0)(@opentelemetry/api@1.10.0)(@types/node@22.20.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: specifier: ^18.3.1 version: 18.3.1 react-dom: specifier: ^18.3.1 version: 18.3.1(react@18.3.1) + tsx: + specifier: 4.23.15 + version: 4.23.15 vitest: specifier: ^4.0.0 version: 4.1.7(@edge-runtime/vm@5.0.0)(@opentelemetry/api@1.10.0)(@types/node@22.20.5)(@vitest/coverage-v8@4.1.7)(jsdom@25.0.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) @@ -1035,14 +1044,14 @@ importers: version: link:../vue nuxt: specifier: '>=3.0.0' - version: 4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + version: 4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) devDependencies: '@nuxt/kit': specifier: ^3.21.11 version: 3.21.11(magicast@0.5.5) nitropack: specifier: ^2.13.5 - version: 2.13.5(@rspack/core@2.2.9)(oxc-parser@0.133.0)(rolldown@1.2.15)(srvx@1.0.7)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + version: 2.13.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(oxc-parser@0.133.0)(rolldown@1.2.15)(srvx@1.0.7)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) packages/nuxt-e2e: dependencies: @@ -1058,7 +1067,7 @@ importers: devDependencies: nuxt: specifier: ^4.6.2 - version: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + version: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) vitest: specifier: ^4.0.0 version: 4.1.7(@edge-runtime/vm@5.0.0)(@opentelemetry/api@1.10.0)(@types/node@22.20.5)(@vitest/coverage-v8@4.1.7)(jsdom@25.0.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) @@ -3154,18 +3163,33 @@ packages: '@next/env@15.5.28': resolution: {integrity: sha512-xxW5EBI8fMPuVTPBW7LL980IRbuDXlbkUAwp9DDhtb4Lnich3nJ13uYpvrX4VE74hWPf6AvHHAMmGCidcHjbfg==} + '@next/env@16.4.6': + resolution: {integrity: sha512-SunBjJ6t+oBtecS3dTjdVuMhUogP5wD/vrGL5EVuQYM1iS4O5ilL51HkiJ3sPjMzRHiCChvr4dbaSJbR7F3lxA==} + '@next/swc-darwin-arm64@15.5.28': resolution: {integrity: sha512-dPoQYXcfSIqx5o+TOXVXO7kONK5qbtNRDeiTfII0bT3puGIT6VF5e0QwmxNZfEZ5Zety5f3m9P/p4xqwfiLlPg==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] + '@next/swc-darwin-arm64@16.4.6': + resolution: {integrity: sha512-kJ4VVZkley17xKaJx72QN2IBqjrj7zenCQZaUF0l9ShS/1Mt2kW4+Z5KGG6vgr3L/J562xTOizVyM1iA/u5nlg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + '@next/swc-darwin-x64@15.5.28': resolution: {integrity: sha512-RgCJ7buBivTH+6sddqaVm+/v8kwMHlFkobvdt3DfETutws5HrxnToMIWSN9X3MZ3aAi7BbKrGZZWUDQLEycXqw==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] + '@next/swc-darwin-x64@16.4.6': + resolution: {integrity: sha512-eIPGZIqC+8JKaeZmvnCANJQF4xWkkHqSnAAajtFxgwDMAOnCgxNvP52SeWZ41PyVwoe+Le/NQuZSaQ8j7YshSA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + '@next/swc-linux-arm64-gnu@15.5.28': resolution: {integrity: sha512-OHXQe13olE59aKe++zHavGcJPh5SLHXi6Anret3BBeq1+qhSuOJDNAli/EDDfxs6UTqA4Qddo4uyYry2slyjiQ==} engines: {node: '>= 10'} @@ -3173,6 +3197,13 @@ packages: os: [linux] libc: [glibc] + '@next/swc-linux-arm64-gnu@16.4.6': + resolution: {integrity: sha512-9nI6O8vvczH2D9ZNdMGqb/3NuT15T9ksOZnAmx9/gjF2cOi74+xxyf1Hk96uIMfm14c9y6wHeBq6SH8g6udvcA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [glibc] + '@next/swc-linux-arm64-musl@15.5.28': resolution: {integrity: sha512-nTB7bB6vfn4ezCJNYP43ukt2o8L3+WxKF/sTcTxepdXsJh3SM9RhlU7wrZYbH7L4HO5M87dqDTwm8587vAkCiw==} engines: {node: '>= 10'} @@ -3180,6 +3211,13 @@ packages: os: [linux] libc: [musl] + '@next/swc-linux-arm64-musl@16.4.6': + resolution: {integrity: sha512-7/qPhTxDp2ScluOJOhLuhWmlA17o1yZ0SIgpISBCpBxXgtnK4+KGywBpFkfLPiU1rnSM1faFGzYkH6i7JdTrqA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + libc: [musl] + '@next/swc-linux-x64-gnu@15.5.28': resolution: {integrity: sha512-WXCfVI32rW3xCusoUX1RpZKtyChWU2Zwe27JUDmM3KrXwcDNc9vV4zEq0GKFAURnuQ/Ouo/XqPvB0yh445XZCg==} engines: {node: '>= 10'} @@ -3187,6 +3225,13 @@ packages: os: [linux] libc: [glibc] + '@next/swc-linux-x64-gnu@16.4.6': + resolution: {integrity: sha512-oOpbNa8XOW1qCGd9VvzC4fbkkRxEls7/WI6tz+YHC0xRA7KpV1U7DrAnCPjzVyOk/karzWEepCOcTIDmwK8FwQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [glibc] + '@next/swc-linux-x64-musl@15.5.28': resolution: {integrity: sha512-Miq+NDb/HWsXuxseYxMM6fuEOQXgTziarkKIRpVKCn8W69cEfhQaQr+90pO+u4q2CbJR2wzXmUuCFyZaJs/Nng==} engines: {node: '>= 10'} @@ -3194,18 +3239,37 @@ packages: os: [linux] libc: [musl] + '@next/swc-linux-x64-musl@16.4.6': + resolution: {integrity: sha512-aM8CZ+OR2EwXaAYw7KGkW2GDmNDsLBIRe1MMRZCJPTdw/xhTD0IMUVO4sf3KqrzuRouGzwwLZn34+gFeVXiUQA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + libc: [musl] + '@next/swc-win32-arm64-msvc@15.5.28': resolution: {integrity: sha512-5LR79lemgDlgxvG7MQJ+zHCkVcrUoQuO7CiIvq3I58vNW4goSOE2b+19Z6FujRWMouvni4gvudYFuFuNxolGWA==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] + '@next/swc-win32-arm64-msvc@16.4.6': + resolution: {integrity: sha512-U0p7/tEtqvHX2crhd841CDwKtp5CFkKXVjOhmfccR3Pvp64sj8KBwRqsvltqLOwVBbj0NtkxwXSDpEHYGbxeXQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + '@next/swc-win32-x64-msvc@15.5.28': resolution: {integrity: sha512-GNipvXUYROSTf4PXEyH95FrWImIB5zdaK6uEOg0RP1/X2drnvoMwiBkJ0VWdzX7w3iiBm3y5g2TxkKDGVTOQcg==} engines: {node: '>= 10'} cpu: [x64] os: [win32] + '@next/swc-win32-x64-msvc@16.4.6': + resolution: {integrity: sha512-3ZG15/5WIdlTQsIEvc9sPTTSL5XFrlLklIKmfF4fwsDnoAhu6NcBDXsk3mbGxNyo6aVLEGex+fHCv2MahY7a9g==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -4502,6 +4566,9 @@ packages: '@swc/helpers@0.5.15': resolution: {integrity: sha512-JQ5TuMi45Owi4/BIMAJBoSQoOJu12oOk/gADqlcUL9JEdHB8vyjUSsxqeNXnmXHjYKMi2WcYtezGEEhqUI/E2g==} + '@swc/helpers@0.5.23': + resolution: {integrity: sha512-5lSsMOTXURePglDfvuAQUqkGek9Hg2kksOYay2m0+XR++b2NWYL/4sWyuvVBIs8oKnJaxkdi9whaL/sqN13afw==} + '@tokenizer/inflate@0.5.2': resolution: {integrity: sha512-3AZIuReWQ7i916s/UWAzy4V4k2wrkAZLW2sTi448W3w7Hz5uoc+Y7h+cnwzr0cwrwf3PsC5xKsH8MOl0NRltlg==} engines: {node: '>=18'} @@ -7387,6 +7454,27 @@ packages: sass: optional: true + next@16.4.6: + resolution: {integrity: sha512-QZJiYhaZLJMo2KpkQGQIwvmd79WVsAWeYIU554a8d7zArS3si/IRy3lBNV/rtYhE70oLwdLYhPAXLPx8HwcwtA==} + engines: {node: '>=20.9.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.1.0 + '@playwright/test': ^1.51.1 + babel-plugin-react-compiler: '*' + react: ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0 + react-dom: ^18.2.0 || 19.0.0-rc-de68d2f4-20241204 || ^19.0.0 + sass: ^1.3.0 + peerDependenciesMeta: + '@opentelemetry/api': + optional: true + '@playwright/test': + optional: true + babel-plugin-react-compiler: + optional: true + sass: + optional: true + nitropack@2.13.5: resolution: {integrity: sha512-Aq7c7Bd35CZloj1xZm4b4SonDzIDA5FUinMVQu61U6GHq2z8oZXbNiFCJYSPGvLUkkCXNx6Fzc/mS2kjJPgKyA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -7973,6 +8061,10 @@ packages: resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} engines: {node: ^10 || ^12 || >=14} + postcss@8.5.23: + resolution: {integrity: sha512-g50586zr4bZmwFiTlflMu8E0bDTb5I5gertgwAKmsdUlTQIhZtunzUlD1WSzwcVWPoAVpsrA6vlfCD7oXvRwgg==} + engines: {node: ^10 || ^12 || >=14} + postcss@8.5.32: resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==} engines: {node: ^10 || ^12 || >=14} @@ -10643,17 +10735,17 @@ snapshots: transitivePeerDependencies: - magicast - '@dxup/nuxt@0.5.10(@nuxt/schema@4.6.2)(@rspack/core@2.2.9)(confbox@0.3.1)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(jiti@2.7.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))': + '@dxup/nuxt@0.5.10(@nuxt/schema@4.6.2)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(confbox@0.3.1)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(jiti@2.7.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))': dependencies: '@dxup/unimport': 0.1.2 - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) '@vue/compiler-dom': 3.5.44 chokidar: 5.0.0 knitwork: 1.3.0 magic-string: 1.4.4 pathe: 2.0.3 tinyglobby: 0.2.17 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) transitivePeerDependencies: - '@farmfe/core' - '@nuxt/schema' @@ -11554,30 +11646,56 @@ snapshots: '@next/env@15.5.28': {} + '@next/env@16.4.6': {} + '@next/swc-darwin-arm64@15.5.28': optional: true + '@next/swc-darwin-arm64@16.4.6': + optional: true + '@next/swc-darwin-x64@15.5.28': optional: true + '@next/swc-darwin-x64@16.4.6': + optional: true + '@next/swc-linux-arm64-gnu@15.5.28': optional: true + '@next/swc-linux-arm64-gnu@16.4.6': + optional: true + '@next/swc-linux-arm64-musl@15.5.28': optional: true + '@next/swc-linux-arm64-musl@16.4.6': + optional: true + '@next/swc-linux-x64-gnu@15.5.28': optional: true + '@next/swc-linux-x64-gnu@16.4.6': + optional: true + '@next/swc-linux-x64-musl@15.5.28': optional: true + '@next/swc-linux-x64-musl@16.4.6': + optional: true + '@next/swc-win32-arm64-msvc@15.5.28': optional: true + '@next/swc-win32-arm64-msvc@16.4.6': + optional: true + '@next/swc-win32-x64-msvc@15.5.28': optional: true + '@next/swc-win32-x64-msvc@16.4.6': + optional: true + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -11663,9 +11781,9 @@ snapshots: '@nuxt/devalue@2.0.2': {} - '@nuxt/devtools-kit@3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))': + '@nuxt/devtools-kit@3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))': dependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) execa: 8.0.1 vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) transitivePeerDependencies: @@ -11680,9 +11798,9 @@ snapshots: - rolldown - unplugin - '@nuxt/devtools-kit@3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))': + '@nuxt/devtools-kit@3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))': dependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) execa: 8.0.1 vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) transitivePeerDependencies: @@ -11719,9 +11837,9 @@ snapshots: pkg-types: 2.4.0 semver: 7.8.5 - '@nuxt/devtools@3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': + '@nuxt/devtools@3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': dependencies: - '@nuxt/devtools-kit': 3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) + '@nuxt/devtools-kit': 3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) '@nuxt/devtools-wizard': 3.2.4 '@nuxt/kit': 4.4.8(magicast@0.5.5) '@vue/devtools-core': 8.1.5(vue@3.5.44(typescript@6.0.3)) @@ -11770,11 +11888,11 @@ snapshots: - utf-8-validate - vue - '@nuxt/devtools@3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(giget@3.3.1)(ioredis@5.11.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': + '@nuxt/devtools@3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(giget@3.3.1)(ioredis@5.11.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': dependencies: - '@nuxt/devtools-kit': 3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) + '@nuxt/devtools-kit': 3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) '@nuxt/devtools-wizard': 3.4.4 - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) '@vue/devtools-core': 8.2.1(vue@3.5.44(typescript@6.0.3)) '@vue/devtools-kit': 8.2.1 birpc: 4.2.0 @@ -11802,7 +11920,7 @@ snapshots: tinyglobby: 0.2.17 unstorage: 1.17.6(db0@0.3.4)(ioredis@5.11.1) vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) - vite-plugin-inspect: 11.4.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) + vite-plugin-inspect: 11.4.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) vite-plugin-vue-tracer: 1.6.0(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) which: 6.0.1 ws: 8.22.0 @@ -11891,7 +12009,7 @@ snapshots: transitivePeerDependencies: - magicast - '@nuxt/kit@4.6.2(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))': + '@nuxt/kit@4.6.2(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))': dependencies: consola: 3.4.2 defu: 6.1.7 @@ -11909,7 +12027,7 @@ snapshots: std-env: 4.3.0 tinyexec: 1.3.1 tinyglobby: 0.2.17 - unctx: 3.0.1(magic-string@0.30.21)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + unctx: 3.0.1(magic-string@0.30.21)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) verkit: 0.5.0 optionalDependencies: '@nuxt/schema': 4.4.8 @@ -11924,7 +12042,7 @@ snapshots: - magic-string - unplugin - '@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))': + '@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))': dependencies: consola: 3.4.2 defu: 6.1.7 @@ -11942,7 +12060,7 @@ snapshots: std-env: 4.3.0 tinyexec: 1.3.1 tinyglobby: 0.2.17 - unctx: 3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + unctx: 3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) verkit: 0.5.0 optionalDependencies: '@nuxt/schema': 4.6.2 @@ -11956,7 +12074,7 @@ snapshots: - magic-string - unplugin - '@nuxt/nitro-server@4.4.8(4ccb48e3370c018111e0af0d67c2fbfb)': + '@nuxt/nitro-server@4.4.8(1fb0db978950a4e2a43583dba29e0fed)': dependencies: '@nuxt/devalue': 2.0.2 '@nuxt/kit': 4.4.8(magicast@0.5.5) @@ -11970,11 +12088,11 @@ snapshots: escape-string-regexp: 5.0.0 exsolve: 1.1.3 h3: 1.15.11 - impound: 1.1.5(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + impound: 1.1.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) klona: 2.0.6 mocked-exports: 0.1.1 - nitropack: 2.13.5(@rspack/core@2.2.9)(oxc-parser@0.133.0)(rolldown@1.2.15)(srvx@1.0.7)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - nuxt: 4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + nitropack: 2.13.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(oxc-parser@0.133.0)(rolldown@1.2.15)(srvx@1.0.7)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + nuxt: 4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) nypm: 0.6.8 ohash: 2.0.12 pathe: 2.0.3 @@ -12037,10 +12155,10 @@ snapshots: - webpack - xml2js - '@nuxt/nitro-server@4.6.2(c2ba9efba174cf70a0cc6f1acac00459)': + '@nuxt/nitro-server@4.6.2(52e37964f1f7ef587f00b154ecdb5cde)': dependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) - '@unhead/vue': 3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@unhead/vue': 3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) consola: 3.4.2 defu: 6.1.7 destr: 2.0.5 @@ -12050,20 +12168,20 @@ snapshots: exsolve: 1.1.3 flru: 1.0.2 h3: 1.15.11 - impound: 1.2.1(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + impound: 1.2.1(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) klona: 2.0.6 mocked-exports: 0.1.1 my-bad: 0.2.11(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) - nitropack: 2.13.5(@rspack/core@2.2.9)(rolldown@1.2.15)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + nitropack: 2.13.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(rolldown@1.2.15)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) nostics: 1.3.0 - nuxt: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + nuxt: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) ohash: 2.0.12 pathe: 2.0.3 radix3: 1.1.2 rou3: 0.9.2 std-env: 4.3.0 ufo: 1.6.4 - unctx: 3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + unctx: 3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) unrouting: 0.2.3 unstorage: 1.17.6(db0@0.3.4)(ioredis@5.11.1) vue: 3.5.44(typescript@6.0.3) @@ -12157,15 +12275,15 @@ snapshots: rc9: 3.1.0 std-env: 4.3.0 - '@nuxt/telemetry@2.9.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))))': + '@nuxt/telemetry@2.9.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))))': dependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) citty: 0.2.2 consola: 3.4.2 rc9: 3.1.0 std-env: 4.3.0 - '@nuxt/vite-builder@4.4.8(3354a4556a900d78e810631d79b6beed)': + '@nuxt/vite-builder@4.4.8(7af75c94026c581b3852593c5c306222)': dependencies: '@nuxt/kit': 4.4.8(magicast@0.5.5) '@rollup/plugin-replace': 6.0.3(rollup@4.65.1) @@ -12183,7 +12301,7 @@ snapshots: magic-string: 0.30.21 mlly: 1.8.2 mocked-exports: 0.1.1 - nuxt: 4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + nuxt: 4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) nypm: 0.6.8 pathe: 2.0.3 pkg-types: 2.4.0 @@ -12225,9 +12343,9 @@ snapshots: - vue-tsc - yaml - '@nuxt/vite-builder@4.6.2(a1e0ccda543b914c18281a779172dd8e)': + '@nuxt/vite-builder@4.6.2(eb90801e874833dc9f157dea7639fde5)': dependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) '@vitejs/plugin-vue': 6.0.10(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) '@vitejs/plugin-vue-jsx': 5.1.6(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) autoprefixer: 10.6.1(postcss@8.5.32) @@ -12243,7 +12361,7 @@ snapshots: knitwork: 1.3.0 mocked-exports: 0.1.1 my-bad: 0.2.11(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) - nuxt: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + nuxt: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) pathe: 2.0.3 pkg-types: 2.4.0 postcss: 8.5.32 @@ -12293,15 +12411,15 @@ snapshots: - vue-tsc - yaml - '@nuxt/vite-server@4.6.2(7bfc5fe44a2391dd76cbb71beeb7f1df)': + '@nuxt/vite-server@4.6.2(115a956a24cfb987bafa8ad25730897f)': dependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) clickable-path: 0.1.1 defu: 6.1.7 exsolve: 1.1.3 mocked-exports: 0.1.1 my-bad: 0.2.11(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) - nuxt: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) + nuxt: 4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1) pathe: 2.0.3 rou3: 0.9.2 srvx: 1.0.5 @@ -12848,9 +12966,11 @@ snapshots: '@rspack/binding-win32-ia32-msvc': 2.2.9 '@rspack/binding-win32-x64-msvc': 2.2.9 - '@rspack/core@2.2.9': + '@rspack/core@2.2.9(@swc/helpers@0.5.23)': dependencies: '@rspack/binding': 2.2.9 + optionalDependencies: + '@swc/helpers': 0.5.23 '@rushstack/node-core-library@5.25.1(@types/node@22.20.5)': dependencies: @@ -13108,6 +13228,10 @@ snapshots: dependencies: tslib: 2.8.1 + '@swc/helpers@0.5.23': + dependencies: + tslib: 2.8.1 + '@tokenizer/inflate@0.5.2': dependencies: debug: 4.4.3 @@ -13371,12 +13495,12 @@ snapshots: '@ungap/structured-clone@1.3.2': {} - '@unhead/bundler@3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(unhead@3.4.3(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))': + '@unhead/bundler@3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(unhead@3.4.3(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))': dependencies: magic-string: 1.4.5 oxc-walker: 1.1.1(@oxc-project/types@0.155.0)(rolldown@1.2.15) - unhead: 3.4.3(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unhead: 3.4.3(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) optionalDependencies: esbuild: 0.28.2 lightningcss: 1.33.0 @@ -13398,12 +13522,12 @@ snapshots: unhead: 2.1.15 vue: 3.5.44(typescript@6.0.3) - '@unhead/vue@3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))': + '@unhead/vue@3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))': dependencies: - '@unhead/bundler': 3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(unhead@3.4.3(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + '@unhead/bundler': 3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(unhead@3.4.3(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) hookable: 6.1.2 - unhead: 3.4.3(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unhead: 3.4.3(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) vue: 3.5.44(typescript@6.0.3) optionalDependencies: vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) @@ -15393,7 +15517,7 @@ snapshots: html-void-elements@3.0.0: {} - html-webpack-plugin@5.6.8(@rspack/core@2.2.9)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): + html-webpack-plugin@5.6.8(@rspack/core@2.2.9(@swc/helpers@0.5.23))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): dependencies: '@types/html-minifier-terser': 6.1.0 html-minifier-terser: 6.1.0 @@ -15401,7 +15525,7 @@ snapshots: pretty-error: 4.0.0 tapable: 2.3.3 optionalDependencies: - '@rspack/core': 2.2.9 + '@rspack/core': 2.2.9(@swc/helpers@0.5.23) webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) htmlparser2@6.1.0: @@ -15486,12 +15610,12 @@ snapshots: import-lazy@4.0.0: {} - impound@1.1.5(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + impound@1.1.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@jridgewell/trace-mapping': 0.3.31 es-module-lexer: 2.3.2 pathe: 2.0.3 - unplugin: 3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 transitivePeerDependencies: - '@farmfe/core' @@ -15504,12 +15628,12 @@ snapshots: - vite - webpack - impound@1.2.1(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + impound@1.2.1(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@jridgewell/trace-mapping': 0.3.31 es-module-lexer: 3.0.4 pathe: 2.0.3 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 transitivePeerDependencies: - '@farmfe/core' @@ -15973,12 +16097,12 @@ snapshots: transitivePeerDependencies: - supports-color - magic-regexp@0.11.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + magic-regexp@0.11.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: magic-string: 0.30.21 regexp-tree: 0.1.27 type-level-regexp: 0.1.17 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) transitivePeerDependencies: - '@farmfe/core' - '@rsbuild/core' @@ -16272,7 +16396,33 @@ snapshots: - '@types/node' - babel-plugin-macros - nitropack@2.13.5(@rspack/core@2.2.9)(oxc-parser@0.133.0)(rolldown@1.2.15)(srvx@1.0.7)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + next@16.4.6(@babel/core@7.29.0)(@opentelemetry/api@1.10.0)(@types/node@22.20.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + '@next/env': 16.4.6 + '@swc/helpers': 0.5.23 + baseline-browser-mapping: 2.11.33 + caniuse-lite: 1.0.30001819 + postcss: 8.5.23 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + styled-jsx: 5.1.6(@babel/core@7.29.0)(react@18.3.1) + optionalDependencies: + '@next/swc-darwin-arm64': 16.4.6 + '@next/swc-darwin-x64': 16.4.6 + '@next/swc-linux-arm64-gnu': 16.4.6 + '@next/swc-linux-arm64-musl': 16.4.6 + '@next/swc-linux-x64-gnu': 16.4.6 + '@next/swc-linux-x64-musl': 16.4.6 + '@next/swc-win32-arm64-msvc': 16.4.6 + '@next/swc-win32-x64-msvc': 16.4.6 + '@opentelemetry/api': 1.10.0 + sharp: 0.35.5(@types/node@22.20.5) + transitivePeerDependencies: + - '@babel/core' + - '@types/node' + - babel-plugin-macros + + nitropack@2.13.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(oxc-parser@0.133.0)(rolldown@1.2.15)(srvx@1.0.7)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@cloudflare/kv-asset-handler': 0.4.2 '@rollup/plugin-alias': 6.0.1(rollup@4.65.1) @@ -16337,7 +16487,7 @@ snapshots: uncrypto: 0.1.3 unctx: 2.5.0 unenv: 2.0.0-rc.24 - unimport: 6.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unimport: 6.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 unstorage: 1.17.6(db0@0.3.4)(ioredis@5.11.1) untyped: 2.0.0 @@ -16385,7 +16535,7 @@ snapshots: - vite - webpack - nitropack@2.13.5(@rspack/core@2.2.9)(rolldown@1.2.15)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + nitropack@2.13.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(rolldown@1.2.15)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@cloudflare/kv-asset-handler': 0.4.2 '@rollup/plugin-alias': 6.0.1(rollup@4.65.1) @@ -16450,7 +16600,7 @@ snapshots: uncrypto: 0.1.3 unctx: 2.5.0 unenv: 2.0.0-rc.24 - unimport: 6.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unimport: 6.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 unstorage: 1.17.6(db0@0.3.4)(ioredis@5.11.1) untyped: 2.0.0 @@ -16548,16 +16698,16 @@ snapshots: dependencies: boolbase: 1.0.0 - nuxt@4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1): + nuxt@4.4.8(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(cac@6.7.14)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(magicast@0.5.5)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(srvx@1.0.7)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1): dependencies: '@dxup/nuxt': 0.4.1(magicast@0.5.5)(typescript@6.0.3) '@nuxt/cli': 3.36.1(@nuxt/schema@4.4.8)(cac@6.7.14)(magicast@0.5.5) - '@nuxt/devtools': 3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + '@nuxt/devtools': 3.2.4(@nuxt/schema@4.4.8)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@0.30.21)(mlly@1.8.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) '@nuxt/kit': 4.4.8(magicast@0.5.5) - '@nuxt/nitro-server': 4.4.8(4ccb48e3370c018111e0af0d67c2fbfb) + '@nuxt/nitro-server': 4.4.8(1fb0db978950a4e2a43583dba29e0fed) '@nuxt/schema': 4.4.8 '@nuxt/telemetry': 2.8.0(@nuxt/kit@4.4.8(magicast@0.5.5)) - '@nuxt/vite-builder': 4.4.8(3354a4556a900d78e810631d79b6beed) + '@nuxt/vite-builder': 4.4.8(7af75c94026c581b3852593c5c306222) '@unhead/vue': 2.1.15(vue@3.5.44(typescript@6.0.3)) '@vue/shared': 3.5.38 chokidar: 5.0.0 @@ -16571,7 +16721,7 @@ snapshots: exsolve: 1.1.0 hookable: 6.1.1 ignore: 7.0.5 - impound: 1.1.5(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + impound: 1.1.5(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) jiti: 2.7.0 klona: 2.0.6 knitwork: 1.3.0 @@ -16585,7 +16735,7 @@ snapshots: oxc-minify: 0.133.0 oxc-parser: 0.133.0 oxc-transform: 0.133.0 - oxc-walker: 1.0.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + oxc-walker: 1.0.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) pathe: 2.0.3 perfect-debounce: 2.1.0 picomatch: 4.0.4 @@ -16600,12 +16750,12 @@ snapshots: uncrypto: 0.1.3 unctx: 2.5.0 unhead: 2.1.15 - unimport: 6.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - unplugin: 3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unimport: 6.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unrouting: 0.1.7 untyped: 2.0.0 vue: 3.5.44(typescript@6.0.3) - vue-router: 5.1.0(@rspack/core@2.2.9)(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + vue-router: 5.1.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) optionalDependencies: '@types/node': 22.20.5 transitivePeerDependencies: @@ -16686,20 +16836,20 @@ snapshots: - xml2js - yaml - nuxt@4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1): + nuxt@4.6.2(@babel/plugin-proposal-decorators@7.29.0(@babel/core@7.29.0))(@babel/plugin-syntax-jsx@7.28.6(@babel/core@7.29.0))(@babel/plugin-syntax-typescript@7.29.7(@babel/core@7.29.0))(@biomejs/biome@2.4.16)(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@types/node@22.20.5)(@vue/compiler-sfc@3.5.44)(acorn@8.19.0)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(ioredis@5.11.1)(lightningcss@1.33.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup-plugin-visualizer@7.1.1(rolldown@1.2.15)(rollup@4.65.1))(rollup@4.65.1)(terser@5.51.2)(tsx@4.23.15)(typescript@6.0.3)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))(yaml@2.9.1): dependencies: - '@dxup/nuxt': 0.5.10(@nuxt/schema@4.6.2)(@rspack/core@2.2.9)(confbox@0.3.1)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(jiti@2.7.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + '@dxup/nuxt': 0.5.10(@nuxt/schema@4.6.2)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(confbox@0.3.1)(dotenv@17.4.2)(esbuild@0.28.2)(giget@3.3.1)(jiti@2.7.0)(mlly@1.8.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) '@jridgewell/trace-mapping': 0.3.31 '@nuxt/cli': 4.0.1(@nuxt/schema@4.6.2)(jiti@2.7.0)(rolldown@1.2.15)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) '@nuxt/devalue': 2.0.2 - '@nuxt/devtools': 3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(giget@3.3.1)(ioredis@5.11.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) - '@nuxt/nitro-server': 4.6.2(c2ba9efba174cf70a0cc6f1acac00459) + '@nuxt/devtools': 3.4.4(@nuxt/schema@4.6.2)(confbox@0.3.1)(db0@0.3.4)(dotenv@17.4.2)(giget@3.3.1)(ioredis@5.11.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/nitro-server': 4.6.2(52e37964f1f7ef587f00b154ecdb5cde) '@nuxt/schema': 4.6.2 - '@nuxt/telemetry': 2.9.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))) - '@nuxt/vite-builder': 4.6.2(a1e0ccda543b914c18281a779172dd8e) - '@nuxt/vite-server': 4.6.2(7bfc5fe44a2391dd76cbb71beeb7f1df) - '@unhead/vue': 3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9)(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + '@nuxt/telemetry': 2.9.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)))) + '@nuxt/vite-builder': 4.6.2(eb90801e874833dc9f157dea7639fde5) + '@nuxt/vite-server': 4.6.2(115a956a24cfb987bafa8ad25730897f) + '@unhead/vue': 3.4.3(@oxc-project/types@0.155.0)(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(lightningcss@1.33.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) '@vue/shared': 3.5.44 chokidar: 5.0.0 clickable-path: 0.1.1 @@ -16716,7 +16866,7 @@ snapshots: fnv1a-64: 0.1.2 hookable: 6.1.2 ignore: 7.0.14 - impound: 1.2.1(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + impound: 1.2.1(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) iron-webcrypto: 2.0.0 jiti: 2.7.0 klona: 2.0.6 @@ -16743,18 +16893,18 @@ snapshots: ufo: 1.6.4 ultrahtml: 1.7.0 uncrypto: 0.1.3 - unctx: 3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + unctx: 3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) undici: 8.12.3 - unhead: 3.4.3(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - unimport: 7.0.2(@rspack/core@2.2.9)(acorn@8.19.0)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unhead: 3.4.3(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unimport: 7.0.2(@rspack/core@2.2.9(@swc/helpers@0.5.23))(acorn@8.19.0)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unrouting: 0.2.3 untyped: 2.0.0 verkit: 0.5.0 vue: 3.5.44(typescript@6.0.3) vue-bundle-renderer: 2.4.0 vue-component-type-helpers: 3.3.13 - vue-router: 5.4.0(@rspack/core@2.2.9)(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + vue-router: 5.4.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) optionalDependencies: '@types/node': 22.20.5 transitivePeerDependencies: @@ -16995,9 +17145,9 @@ snapshots: '@oxc-transform/binding-win32-ia32-msvc': 0.133.0 '@oxc-transform/binding-win32-x64-msvc': 0.133.0 - oxc-walker@1.0.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + oxc-walker@1.0.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: - magic-regexp: 0.11.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + magic-regexp: 0.11.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) optionalDependencies: oxc-parser: 0.133.0 rolldown: 1.2.15 @@ -17349,6 +17499,12 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.2 + postcss@8.5.23: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.2 + postcss@8.5.32: dependencies: nanoid: 3.3.20 @@ -18491,18 +18647,18 @@ snapshots: magic-string: 0.30.21 unplugin: 2.3.11 - unctx@3.0.1(magic-string@0.30.21)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))): + unctx@3.0.1(magic-string@0.30.21)(oxc-parser@0.133.0)(rolldown@1.2.15)(unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))): optionalDependencies: magic-string: 0.30.21 oxc-parser: 0.133.0 rolldown: 1.2.15 - unplugin: 3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) - unctx@3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))): + unctx@3.0.1(magic-string@1.4.4)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))): optionalDependencies: magic-string: 1.4.4 rolldown: 1.2.15 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) underscore@1.13.8: {} @@ -18520,10 +18676,10 @@ snapshots: dependencies: hookable: 6.1.2 - unhead@3.4.3(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + unhead@3.4.3(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: hookable: 6.1.2 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) optionalDependencies: vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) transitivePeerDependencies: @@ -18558,7 +18714,7 @@ snapshots: std-env: 4.3.0 undici: 8.12.3 - unimport@6.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + unimport@6.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: acorn: 8.19.0 escape-string-regexp: 5.0.0 @@ -18572,7 +18728,7 @@ snapshots: scule: 1.3.0 strip-literal: 3.1.0 tinyglobby: 0.2.17 - unplugin: 3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 optionalDependencies: oxc-parser: 0.133.0 @@ -18587,7 +18743,7 @@ snapshots: - vite - webpack - unimport@6.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + unimport@6.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(oxc-parser@0.133.0)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: acorn: 8.19.0 escape-string-regexp: 5.0.0 @@ -18601,7 +18757,7 @@ snapshots: scule: 1.3.0 strip-literal: 4.0.0 tinyglobby: 0.2.17 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 optionalDependencies: oxc-parser: 0.133.0 @@ -18617,7 +18773,7 @@ snapshots: - vite - webpack - unimport@7.0.2(@rspack/core@2.2.9)(acorn@8.19.0)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + unimport@7.0.2(@rspack/core@2.2.9(@swc/helpers@0.5.23))(acorn@8.19.0)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: escape-string-regexp: 5.0.0 estree-walker: 3.0.3 @@ -18630,7 +18786,7 @@ snapshots: scule: 1.3.0 strip-literal: 4.0.0 tinyglobby: 0.2.17 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 optionalDependencies: acorn: 8.19.0 @@ -18687,26 +18843,26 @@ snapshots: picomatch: 4.0.4 webpack-virtual-modules: 0.6.2 - unplugin@3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + unplugin@3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@jridgewell/remapping': 2.3.5 picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 optionalDependencies: - '@rspack/core': 2.2.9 + '@rspack/core': 2.2.9(@swc/helpers@0.5.23) esbuild: 0.28.2 rolldown: 1.2.15 rollup: 4.65.1 vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) webpack: 5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32) - unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@jridgewell/remapping': 2.3.5 picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 optionalDependencies: - '@rspack/core': 2.2.9 + '@rspack/core': 2.2.9(@swc/helpers@0.5.23) esbuild: 0.28.2 rolldown: 1.2.15 rollup: 4.65.1 @@ -18882,7 +19038,7 @@ snapshots: optionalDependencies: '@nuxt/kit': 4.4.8(magicast@0.5.5) - vite-plugin-inspect@11.4.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)): + vite-plugin-inspect@11.4.1(@nuxt/kit@4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))))(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)): dependencies: ansis: 4.3.1 error-stack-parser-es: 1.0.5 @@ -18895,7 +19051,7 @@ snapshots: vite: 8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1) vite-dev-rpc: 2.0.0(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1)) optionalDependencies: - '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) + '@nuxt/kit': 4.6.2(@nuxt/schema@4.6.2)(confbox@0.3.1)(dotenv@17.4.2)(giget@3.3.1)(jiti@2.7.0)(magic-string@1.4.4)(mlly@1.8.2)(rolldown@1.2.15)(unplugin@3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32))) vite-plugin-vue-tracer@1.4.0(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): dependencies: @@ -18997,7 +19153,7 @@ snapshots: vue-devtools-stub@0.1.0: {} - vue-router@5.1.0(@rspack/core@2.2.9)(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + vue-router@5.1.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@babel/generator': 8.0.0 '@vue-macros/common': 3.1.2(vue@3.5.44(typescript@6.0.3)) @@ -19013,7 +19169,7 @@ snapshots: picomatch: 4.0.7 scule: 1.3.0 tinyglobby: 0.2.17 - unplugin: 3.3.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.3.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 vue: 3.5.44(typescript@6.0.3) yaml: 2.9.0 @@ -19030,7 +19186,7 @@ snapshots: - unloader - webpack - vue-router@5.4.0(@rspack/core@2.2.9)(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): + vue-router@5.4.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)): dependencies: '@vue-macros/common': 3.1.4(vue@3.5.44(typescript@6.0.3)) '@vue/devtools-api': 8.2.1 @@ -19046,7 +19202,7 @@ snapshots: picomatch: 4.0.7 scule: 1.3.0 tinyglobby: 0.2.17 - unplugin: 3.5.0(@rspack/core@2.2.9)(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) + unplugin: 3.5.0(@rspack/core@2.2.9(@swc/helpers@0.5.23))(esbuild@0.28.2)(rolldown@1.2.15)(rollup@4.65.1)(vite@8.3.5(@types/node@22.20.5)(esbuild@0.28.2)(jiti@2.7.0)(terser@5.51.2)(tsx@4.23.15)(yaml@2.9.1))(webpack@5.112.2(esbuild@0.28.2)(lightningcss@1.33.0)(postcss@8.5.32)) unplugin-utils: 0.3.2 vue: 3.5.44(typescript@6.0.3) optionalDependencies: @@ -19105,12 +19261,12 @@ snapshots: webpack-sources@3.6.0: {} - webpack-subresource-integrity@5.1.0(html-webpack-plugin@5.6.8(@rspack/core@2.2.9)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): + webpack-subresource-integrity@5.1.0(html-webpack-plugin@5.6.8(@rspack/core@2.2.9(@swc/helpers@0.5.23))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)): dependencies: typed-assert: 1.0.9 webpack: 5.112.2(esbuild@0.28.2)(postcss@8.5.32) optionalDependencies: - html-webpack-plugin: 5.6.8(@rspack/core@2.2.9)(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) + html-webpack-plugin: 5.6.8(@rspack/core@2.2.9(@swc/helpers@0.5.23))(webpack@5.112.2(esbuild@0.28.2)(postcss@8.5.32)) webpack-virtual-modules@0.6.2: {} From abd725437925199a5e3d2663c9a42216ee394a26 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:25:49 +0500 Subject: [PATCH 03/17] test(nextjs-e2e): real next build for webpack and Turbopack on Next 15.5 and 16.4, with SRI cases Builds a fixture app through the real withBugsee and bugsee-cli against a mock collector and asserts stamped bundles, uploaded debug-IDs, deleted public maps, kept server maps, baked version, and that next start serves the build. Co-Authored-By: Claude Sonnet 5.5 --- .gitignore | 4 + packages/nextjs-e2e/package.json | 2 + packages/nextjs-e2e/test/source-maps.e2e.ts | 367 ++++++++++++++++++++ 3 files changed, 373 insertions(+) create mode 100644 packages/nextjs-e2e/test/source-maps.e2e.ts diff --git a/.gitignore b/.gitignore index 266576e0..c3215bf0 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,10 @@ reports/ # `biome check .` by the thousand. .next/ +# Fixture apps the Next source-map e2e generates and builds (packages/nextjs-e2e/test/source-maps.e2e.ts). +packages/nextjs-e2e/.fixtures/ +packages/nextjs-e2e/.scratch/ + # tsup writes a bundled config next to the package when tsup.config.ts needs transpiling, and leaves # it behind if the build is interrupted. Untracked, it fails `biome check .` on a formatting rule. tsup.config.bundled_*.mjs diff --git a/packages/nextjs-e2e/package.json b/packages/nextjs-e2e/package.json index 267d738f..97a674be 100644 --- a/packages/nextjs-e2e/package.json +++ b/packages/nextjs-e2e/package.json @@ -14,8 +14,10 @@ }, "devDependencies": { "next": "^15.5.28", + "next16": "npm:next@16.4.6", "react": "^18.3.1", "react-dom": "^18.3.1", + "tsx": "4.23.15", "vitest": "^4.0.0" } } diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts new file mode 100644 index 00000000..1fcf99da --- /dev/null +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -0,0 +1,367 @@ +// `withBugsee` against REAL `next build`s, for both bundlers and both Next generations that matter: +// +// next 15.5 + webpack (its default) next 15.5 + `--turbopack` +// next 16.4 + Turbopack (its default) next 16.4 + `--webpack` +// +// Each builds a tiny app (a client page with a lazy chunk, a node route, an edge route) through the REAL +// `@bugsee/nextjs/config`, the REAL `bugsee-cli` and a mock collector, then asserts the outcome on disk and on the +// wire: the bundles are stamped, the maps reached the collector keyed by those exact debug-IDs, the public maps are +// gone, the server maps are kept, the version is baked into the bundle, and the build still RUNS (`next start`). +// +// Plus the Subresource-Integrity cases: webpack stamps inside the build so the hashes stay right; Turbopack hashes +// before its post-build hook, so the build is left unmodified and says so. +import { type ChildProcess, spawn } from 'node:child_process'; +import { createHash } from 'node:crypto'; +import { + existsSync, + mkdirSync, + readdirSync, + readFileSync, + realpathSync, + rmSync, + statSync, + symlinkSync, + writeFileSync, +} from 'node:fs'; +import { createServer, type Server } from 'node:http'; +import { createRequire } from 'node:module'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; + +const here = dirname(fileURLToPath(import.meta.url)); +const pkgDir = join(here, '..'); +const fixturesRoot = join(pkgDir, '.fixtures'); +const require_ = createRequire(import.meta.url); +const tsxLoader = join(dirname(require_.resolve('tsx/package.json')), 'dist', 'loader.mjs'); + +let server: Server; +let endpoint: string; +const bodies: string[] = []; + +beforeAll(async () => { + rmSync(fixturesRoot, { recursive: true, force: true }); + mkdirSync(fixturesRoot, { recursive: true }); + // Every upload is answered "already have it", so it succeeds without a backend; the body is kept, so a test + // can look for the exact debug-IDs that were sent. + server = createServer((req, res) => { + const chunks: Buffer[] = []; + req.on('data', (c: Buffer) => chunks.push(c)); + req.on('end', () => { + bodies.push(Buffer.concat(chunks).toString('latin1')); + res.setHeader('content-type', 'application/json'); + res.end( + JSON.stringify({ ok: false, error: { type: 'DuplicateSymbolsFoundError', code: 16004 } }), + ); + }); + }); + await new Promise((r) => server.listen(0, '127.0.0.1', r)); + endpoint = `http://127.0.0.1:${(server.address() as { port: number }).port}`; +}); +afterAll(async () => { + await new Promise((r) => server.close(() => r())); + // BUGSEE_E2E_KEEP=1 leaves the built fixtures behind for inspection. + if (process.env.BUGSEE_E2E_KEEP === undefined) { + rmSync(fixturesRoot, { recursive: true, force: true }); + } +}); + +interface Spec { + name: string; + /** The dependency name of the Next copy to build with (`next` = 15.5, `next16` = 16.4). */ + next: 'next' | 'next16'; + args: string[]; + /** Extra source for the `withBugsee` options object and the Next config. */ + options?: string; + nextConfig?: string; +} + +interface Built { + dir: string; + status: number | null; + log: string; + uploads: string[]; +} + +const link = (target: string, path: string): void => { + mkdirSync(dirname(path), { recursive: true }); + symlinkSync(realpathSync(target), path, 'dir'); +}; + +/** Write a fixture app, build it with `spec`, and return what happened. */ +async function build(spec: Spec): Promise { + const dir = join(fixturesRoot, spec.name); + mkdirSync(join(dir, 'app', 'lazy'), { recursive: true }); + mkdirSync(join(dir, 'app', 'api', 'hi'), { recursive: true }); + mkdirSync(join(dir, 'app', 'edge'), { recursive: true }); + const modules = join(dir, 'node_modules'); + link(join(pkgDir, 'node_modules', spec.next), join(modules, 'next')); + link(join(pkgDir, 'node_modules', 'react'), join(modules, 'react')); + link(join(pkgDir, 'node_modules', 'react-dom'), join(modules, 'react-dom')); + link(join(pkgDir, '..', 'nextjs'), join(modules, '@bugsee', 'nextjs')); + writeFileSync(join(dir, 'package.json'), JSON.stringify({ name: spec.name, version: '1.2.3' })); + // Plain JavaScript on purpose: a `.ts` file makes Next install TypeScript into the project. + writeFileSync( + join(dir, 'app', 'layout.jsx'), + 'export default function Layout({ children }) { return {children}; }\n', + ); + writeFileSync( + join(dir, 'app', 'page.jsx'), + `'use client'; +import { useState } from 'react'; +import dynamic from 'next/dynamic'; +const Lazy = dynamic(() => import('./lazy/lazy.jsx')); +const version = typeof __BUGSEE_APP_VERSION__ === 'undefined' ? 'none' : __BUGSEE_APP_VERSION__; +export default function Page() { + const [n, setN] = useState(0); + return
; +} +`, + ); + writeFileSync( + join(dir, 'app', 'lazy', 'lazy.jsx'), + 'export default function Lazy() { return

lazy

; }\n', + ); + writeFileSync( + join(dir, 'app', 'api', 'hi', 'route.js'), + "export const GET = () => new Response('hi');\n", + ); + writeFileSync( + join(dir, 'app', 'edge', 'route.js'), + "export const runtime = 'edge';\nexport const GET = () => new Response('edge');\n", + ); + writeFileSync( + join(dir, 'next.config.mjs'), + `import { withBugsee } from '@bugsee/nextjs/config'; +export default withBugsee( + { ${spec.next === 'next' ? 'eslint: { ignoreDuringBuilds: true },' : ''} ${spec.nextConfig ?? ''} }, + { appToken: 'e2e-token', endpoint: ${JSON.stringify(endpoint)}, appVersion: '9.8.7', appBuild: '42', + vcs: false, registerBuild: false, failOnError: true, ${spec.options ?? ''} }, +); +`, + ); + const before = bodies.length; + // Asynchronous on purpose: the mock collector lives in THIS process, and a blocking spawn would starve it. + const child = spawn( + process.execPath, + [join(modules, 'next', 'dist', 'bin', 'next'), 'build', ...spec.args], + { + cwd: dir, + env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1', NODE_OPTIONS: `--import ${tsxLoader}` }, + }, + ); + let log = ''; + child.stdout.on('data', (c: Buffer) => (log += c.toString())); + child.stderr.on('data', (c: Buffer) => (log += c.toString())); + const status = await new Promise((r) => child.on('close', r)); + return { dir, status, log, uploads: bodies.slice(before) }; +} + +const walk = (dir: string): string[] => + existsSync(dir) + ? readdirSync(dir).flatMap((name) => { + const full = join(dir, name); + return statSync(full).isDirectory() ? walk(full) : [full]; + }) + : []; + +const DEBUG_ID = /\/\/# debugId=([0-9a-f-]{36})/; +const debugIdOf = (file: string): string | undefined => + DEBUG_ID.exec(readFileSync(file, 'utf8'))?.[1]; + +/** Every bundle under `dir` that points at a map, with the path it points at (the map may be deleted by now). */ +const pointing = (dir: string): Array<{ file: string; map: string }> => + walk(dir) + .filter((f) => f.endsWith('.js')) + .flatMap((file) => { + const ref = /\/\/# sourceMappingURL=(\S+)\s*$/m.exec(readFileSync(file, 'utf8'))?.[1]; + return ref === undefined ? [] : [{ file, map: join(dirname(file), decodeURIComponent(ref)) }]; + }); + +/** + * Bundles whose map belongs to them alone, and bundles that share a map with another (Next 15.5's Turbopack does + * that for its runtime chunks: a map carries one debug-id, so those are deliberately left unstamped). + */ +const split = (dir: string): { unique: string[]; shared: string[]; referenced: Set } => { + const all = pointing(dir); + const count = new Map(); + for (const { map } of all) count.set(map, (count.get(map) ?? 0) + 1); + return { + unique: all.filter(({ map }) => count.get(map) === 1).map(({ file }) => file), + shared: all.filter(({ map }) => (count.get(map) as number) > 1).map(({ file }) => file), + referenced: new Set(all.map(({ map }) => map)), + }; +}; + +const clientBundles = (dir: string): string[] => split(join(dir, '.next', 'static')).unique; + +const maps = (dir: string): string[] => walk(dir).filter((f) => f.endsWith('.map')); + +/** `next start` the build and fetch the paths; resolves their statuses. */ +async function runBuild(dir: string, paths: string[]): Promise { + const port = 41000 + Math.floor(Math.random() * 2000); + const child: ChildProcess = spawn( + process.execPath, + [join(dir, 'node_modules', 'next', 'dist', 'bin', 'next'), 'start', '-p', String(port)], + { + cwd: dir, + // `next start` loads next.config too, which imports the TypeScript source of @bugsee/nextjs/config. + env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1', NODE_OPTIONS: `--import ${tsxLoader}` }, + stdio: 'ignore', + }, + ); + try { + const statuses: number[] = []; + for (const path of paths) { + let status = 0; + for (let attempt = 0; attempt < 60 && status === 0; attempt++) { + try { + status = (await fetch(`http://127.0.0.1:${port}${path}`)).status; + } catch { + await new Promise((r) => setTimeout(r, 500)); + } + } + statuses.push(status); + } + return statuses; + } finally { + child.kill('SIGKILL'); + } +} + +const MATRIX: Spec[] = [ + { name: 'next15-webpack', next: 'next', args: [] }, + { name: 'next15-turbopack', next: 'next', args: ['--turbopack'] }, + { name: 'next16-turbopack', next: 'next16', args: [] }, + { name: 'next16-webpack', next: 'next16', args: ['--webpack'] }, +]; + +describe.each(MATRIX)('withBugsee — real `next build` ($name)', (spec) => { + let built: Built; + beforeAll(async () => { + built = await build(spec); + }); + + it('builds, and says nothing was skipped or failed', () => { + expect(built.status, built.log.split('\n').slice(-60).join('\n')).toBe(0); + // The one expected notice: bundles sharing a map are left alone (asserted below). + const notices = built.log.split('\n').filter((l) => l.includes('[bugsee]')); + expect(notices.filter((l) => !l.includes('share one source map'))).toEqual([]); + }); + + it('stamps every client bundle that has a map of its own, and none that share one', () => { + const { unique, shared } = split(join(built.dir, '.next', 'static')); + expect(unique.length).toBeGreaterThan(2); + for (const bundle of unique) { + expect(debugIdOf(bundle), bundle).toBeDefined(); + } + for (const bundle of shared) { + expect(debugIdOf(bundle), `${bundle} shares a map`).toBeUndefined(); + } + expect(built.log.includes('share one source map')).toBe(shared.length > 0); + }); + + it('uploaded the maps keyed by exactly those debug-IDs, client and server', () => { + expect(built.uploads.length).toBeGreaterThan(0); + const sent = built.uploads.join('\n'); + const ids = split(join(built.dir, '.next')) + .unique.map(debugIdOf) + .filter((id): id is string => id !== undefined); + // Server bundles as well as browser ones carry an id, and every id reached the collector. + expect(ids.length).toBeGreaterThan(clientBundles(built.dir).length); + for (const id of ids) { + expect(sent, `debug-id ${id} was not uploaded`).toContain(id); + } + }); + + it('removes the publicly served client maps and keeps the server maps', () => { + // What may remain in `.next/static` is a map no bundle points at (Next ships a polyfill that way) or the map + // two unstamped Turbopack runtime chunks share (Next 15.5). Neither is the app's code, neither was uploaded. + const staticDir = join(built.dir, '.next', 'static'); + const { shared, referenced } = split(staticDir); + const sharedMaps = new Set( + pointing(staticDir) + .filter((p) => shared.includes(p.file)) + .map((p) => p.map), + ); + for (const map of maps(staticDir)) { + expect(referenced.has(map) && !sharedMaps.has(map), `${map} is still served`).toBe(false); + } + const server = split(join(built.dir, '.next', 'server')); + const kept = maps(join(built.dir, '.next', 'server')).filter((m) => server.referenced.has(m)); + expect(kept.length).toBeGreaterThan(0); + for (const map of kept) { + expect(JSON.parse(readFileSync(map, 'utf8')).debugId, map).toMatch(/^[0-9a-f-]{36}$/); + } + }); + + it('covers the edge route too', () => { + const edgeBundles = split(join(built.dir, '.next', 'server')).unique.filter((f) => + /edge/.test(f), + ); + expect(edgeBundles.length).toBeGreaterThan(0); + for (const bundle of edgeBundles) { + expect(debugIdOf(bundle), bundle).toBeDefined(); + } + }); + + it('bakes the app version and build into the bundle', () => { + const text = clientBundles(built.dir) + .map((f) => readFileSync(f, 'utf8')) + .join('\n'); + expect(text).toContain('9.8.7'); + }); + + it('produces a build that still runs', async () => { + expect(await runBuild(built.dir, ['/', '/api/hi', '/edge'])).toEqual([200, 200, 200]); + }); +}); + +describe('withBugsee — Subresource Integrity', () => { + it('webpack: stamps inside the build, so every pinned hash still matches the bytes on disk', async () => { + const built = await build({ + name: 'sri-webpack', + next: 'next16', + args: ['--webpack'], + nextConfig: "experimental: { sri: { algorithm: 'sha256' } },", + }); + expect(built.status, built.log.split('\n').slice(-40).join('\n')).toBe(0); + expect(built.log).not.toMatch(/\[bugsee\]/); + const html = readFileSync(join(built.dir, '.next', 'server', 'app', 'index.html'), 'utf8'); + const pins = [ + ...html.matchAll( + /]*?(?:src="([^"]+)"[^>]*?integrity="([^"]+)"|integrity="([^"]+)"[^>]*?src="([^"]+)")/g, + ), + ]; + expect(pins.length).toBeGreaterThan(0); + for (const m of pins) { + const src = (m[1] ?? m[4]) as string; + const integrity = (m[2] ?? m[3]) as string; + const file = join(built.dir, '.next', src.replace(/^\/_next\//, '')); + const [algo] = integrity.split('-'); + const digest = createHash(algo as string) + .update(readFileSync(file)) + .digest('base64'); + expect(integrity, src).toBe(`${algo}-${digest}`); + expect(debugIdOf(file), `${src} was not stamped`).toBeDefined(); + } + expect(built.uploads.length).toBeGreaterThan(0); + }); + + it('turbopack: leaves an SRI build exactly as Next wrote it, and says why', async () => { + const built = await build({ + name: 'sri-turbopack', + next: 'next16', + args: [], + nextConfig: "experimental: { sri: { algorithm: 'sha256' } },", + options: 'failOnError: false,', + }); + expect(built.status, built.log.split('\n').slice(-40).join('\n')).toBe(0); + expect(built.log).toMatch(/Subresource Integrity/); + expect(built.uploads).toEqual([]); + // Unstamped, so the page's hashes still match. + for (const bundle of clientBundles(built.dir)) { + expect(debugIdOf(bundle), bundle).toBeUndefined(); + } + }); +}); From e6dc884717dc83d9b253a91f203ba16a79353dfb Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:25:49 +0500 Subject: [PATCH 04/17] docs(nextjs): withBugsee README, source-maps design section 7.3, PROGRESS entry, changeset Co-Authored-By: Claude Sonnet 5.5 --- .changeset/nextjs-with-bugsee.md | 6 ++++ docs/PROGRESS.md | 3 ++ docs/design/source-maps.md | 48 +++++++++++++++++++++++++++++++- packages/nextjs/README.md | 44 +++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 .changeset/nextjs-with-bugsee.md diff --git a/.changeset/nextjs-with-bugsee.md b/.changeset/nextjs-with-bugsee.md new file mode 100644 index 00000000..2fe5d748 --- /dev/null +++ b/.changeset/nextjs-with-bugsee.md @@ -0,0 +1,6 @@ +--- +'@bugsee/nextjs': minor +'@bugsee/bundler-plugin-core': minor +--- + +`@bugsee/nextjs/config` adds `withBugsee(nextConfig, options)`: `next build` now stamps debug-IDs and uploads source maps on both webpack and Turbopack (Next 15.4.1+ for Turbopack, through `compiler.runAfterProductionCompile`). Browser maps are deleted after a confirmed upload; server and edge maps are kept. `@bugsee/bundler-plugin-core` exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv` and `mergeBuildPluginEnv` for it. diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index b57d06c6..1b1ae9c5 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -1531,3 +1531,6 @@ Verified against current majors, all green with no adapter code changes: `@bugse ### Debug-ID stamping inside the build for Vite, Rollup and Rspack; verified stamps; safe map deletion (2026-11-23) `@bugsee/bundler-plugin-core` now stamps INSIDE the build wherever the bundler has a pre-write hook, so Subresource Integrity hashes taken later describe the stamped bytes: webpack 5 and **Rspack** at `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1` (shared `tapProcessAssetsStamp`), **Vite and Rollup** in `generateBundle` (`order: 'pre'`; `rollupAssetStore` over chunks + `.map` assets; the stamped id is also put on `chunk.map` because Vite regenerates the map of a lazy-loading chunk after user hooks). esbuild and the standalone CLI stay post-emit with the SRI refusal (its message now names the workaround). Every stamp is verified (`verify-stamp.ts`: parses, sourceMappingURL intact, map debugId matches, original bytes + appended stamp): in-build all-or-nothing, post-emit snapshot + restore of the failing pair (`stamp-files.ts`); an in-build stamp is re-checked on disk (`verifyStampedPairs`) and against the HTML (`findIntegrityMismatches`). `.map` deletion now requires a confirmed upload AND a debugId on the map (`partitionByKeyed`). Real-build proof: `plugin.in-build.real-build.test.ts` (Vite 7 + 8, Rollup, Rspack with its built-in SRI plugin) and a Chromium run in `instrumentation-tests/test/sri-vite-rollup.e2e.ts`. Measured ordering limits and what the guards do not see: `docs/design/source-maps.md` §7.1. + +### Next.js build integration: `withBugsee` (`@bugsee/nextjs/config`), webpack AND Turbopack (2026-11-23) +`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.1+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run. diff --git a/docs/design/source-maps.md b/docs/design/source-maps.md index 501b605a..e7aa874f 100644 --- a/docs/design/source-maps.md +++ b/docs/design/source-maps.md @@ -363,9 +363,55 @@ Windows hosts were not run. Bun does not map `Error.stack` and has no --- +## 7.3 Next.js: `withBugsee` (`@bugsee/nextjs/config`) + +Status: **BUILT** (`packages/nextjs/src/config/`, real-build e2e `packages/nextjs-e2e/test/source-maps.e2e.ts`). +`withBugsee(nextConfig, options)` wraps a Next config (object, phase function, async, or a promise) so +`next build` stamps debug-IDs and uploads source maps, on **both** bundlers. It takes the plugin options of §4 +(through `resolvePluginOptions`, same env / `.env.bugsee-build-plugin` lookup, same identity resolution) plus +`serverSourceMaps` (default on), `deleteServerMaps` (default off) and `silent`. It never touches `next dev` +(`next start`, `next export`): a function config is gated on the phase, an object config on `dev` in the webpack +function and on the hook only existing in a production build. + +**Why not the generic webpack plugin (measured).** Adding `@bugsee/webpack-plugin` in `webpack(config)` runs it +three times (client, server, edge) and breaks on Next's layout: the server compilation's `output.path` is +`.next/server/chunks` while its assets are named `../app/page.js`, so (1) the in-build stamp skipped them (an asset +name may not escape the staging directory; the verify step then failed the run) and (2) the plugin's directory-wide +upload of `.next` swept up the server compilation's files. `withBugsee` therefore ships a small per-compilation +plugin that reuses the same core (`stampAssets`, `runPluginUpload`) but stages `../` names under a stand-in +directory and uploads **exactly the files its own compilation emitted** (`files` mode; nothing walks `.next`). + +**Detecting the bundler.** `process.env.TURBOPACK` (set by `next build` before the config loads, Next 15.5 and 16 +alike); otherwise webpack. `NEXT_RSPACK` (the experimental Rspack adapter) is not special-cased and unverified. + +| | webpack (`--webpack`; default <= 15) | Turbopack (default 16; `--turbopack` in 15.x) | +|---|---|---| +| stamp | in the compilation, `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1` (SRI-safe), client + server + edge | after the build, in `compiler.runAfterProductionCompile`: the real `inject` over the written files, with the post-emit verify-and-restore | +| upload | each compilation's `afterEmit`, its own files | the hook: `.next/static` (browser) then `.next/server` (node + edge), explicit file lists | +| maps | client: `productionBrowserSourceMaps` (forced on only if unset); server/edge: `devtool: 'source-map'` unless the app set one | always emitted (browser: `productionBrowserSourceMaps`; server maps are emitted regardless of `serverSourceMaps`, measured on 16.4) | +| SRI (`experimental.sri`) | works: the hashes are of the stamped bytes (verified against the written HTML) | **not stampable**: Turbopack writes `server/subresource-integrity-manifest.json` and the HTML hashes BEFORE the hook (appending one byte in the hook made every `integrity` wrong), so the build is left unmodified, a notice says why, and nothing is uploaded | +| min Next | any with `webpack()` | 15.4.1 (the first release with `compiler.runAfterProductionCompile`; verified in the 15.4.0 and 15.4.1 types); older Turbopack builds get a notice | + +**Policy.** Browser maps live in `.next/static`, which `next start` and CDNs serve to every visitor: `deleteMaps` +(default true) removes them after a *confirmed* upload, exactly as the plugins do (and, as there, a failed upload +leaves them for a retry). `.next/server` is never served and a server run with source maps reads it, so server and +edge maps stay unless `deleteServerMaps`. The build is registered once (browser run). The app version and build are baked +through `compiler.define` (applies to all three runtimes; repeating the keys in `defineServer` is a Next error, +measured). Only bundles that have a map are stamped on Turbopack. + +**Composition.** The app's `webpack` function runs first (sync or async) and its result is extended; its +`compiler.runAfterProductionCompile` runs before ours; its `compiler.define` keys win; `productionBrowserSourceMaps` +is respected when set. Without a token the integration changes nothing Next emits. + +**Open.** Both runs resolve the app identity and the token file from `process.cwd()` at config load, so run +`next build` from the project directory (Next passes no project dir to a config function). A Turbopack SRI build +cannot be symbolicated by upload (see the table); an in-hook alternative would have to re-hash the integrity +manifests and the HTML Next writes later, which is Next's contract, not ours. + ## 8. Deferred - A real-`bugsee-cli` integration e2e (needs the built Rust binary in the harness) — follow-up once CI has it. -- Turbopack loader for Next.js (`turbopack.rules`) — Next-adapter follow-up. +- ~~Turbopack loader for Next.js (`turbopack.rules`)~~ — superseded by §7.3 (a post-build hook, not a loader: a loader + sees one module at a time and cannot stamp a finished chunk). - Node/edge runtime debug-ID wiring (browser done in SM7) — trivial. - The exact debug-ID WIRE FORMAT — additive ` debugId=` string suffix now; a structured `debug_meta`/per-frame field is a refinement gated on the JS-backend symbolication contract. diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index 0d6bd2f0..e8d95754 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -63,6 +63,49 @@ export const middleware = withBugseeMiddleware((request, event) => { }); ``` +## Source maps (build integration) + +`withBugsee` makes `next build` upload source maps to Bugsee, so a minified browser, server or edge stack trace is shown against your original source. It handles both bundlers: webpack (`next build --webpack`, the default up to Next 15) and Turbopack (the default in Next 16). + +```js +// next.config.mjs +import { withBugsee } from "@bugsee/nextjs/config"; + +export default withBugsee( + { + // your Next config: an object, a (phase) function, or an async one + }, + { + // BUGSEE_APP_TOKEN in the environment (or .env.bugsee-build-plugin) works too + appToken: process.env.BUGSEE_APP_TOKEN, + }, +); +``` + +CommonJS works as well: `const { withBugsee } = require("@bugsee/nextjs/config");` in `next.config.js`. + +What it does, for a production build: + +- Turns on `productionBrowserSourceMaps` (only when you did not set it) so the browser bundles have maps to upload. +- **webpack**: adds one Bugsee plugin to each of the client, server and edge compilations. Each stamps a debug ID into its bundles inside the build (before Subresource Integrity hashes are taken) and, after emit, uploads the maps of exactly the files that compilation wrote. +- **Turbopack**: has no plugin API, so the upload runs from Next's `compiler.runAfterProductionCompile` hook (Next 15.4.1 or later): after Turbopack wrote `.next` and before Next generates the static pages, it stamps the written bundles with the real `bugsee-cli sourcemaps inject` (verified, and undone if a stamp does not verify), uploads the maps and removes them. +- Deletes the browser maps (`.next/static/**/*.map`, which `next start` and CDNs serve publicly) after a confirmed upload. Server and edge maps stay on disk (`deleteServerMaps` to remove them). +- Bakes `appVersion` / `appBuild` into every bundle (`compiler.define`) for the runtime SDK. + +Your own config is kept: your `webpack` function runs first (sync or async) and its result is extended, your `compiler.runAfterProductionCompile` runs before ours, `compiler.define` keys you set win, and `productionBrowserSourceMaps: false` is respected. `next dev`, `next start` and `next export` are not touched. + +Options are those of the Bugsee bundler plugins (`appToken`, `appVersion`, `appBuild`, `endpoint`, `deleteMaps`, `dryRun`, `failOnError`, `stripSourcesContent`, `disabled`, `vcs`, `commit`, `registerBuild`, `onError`, `onNotice`, see `@bugsee/webpack-plugin`), plus: + +| Option | Default | | +| --- | --- | --- | +| `serverSourceMaps` | `true` | Emit and upload server and edge maps. With webpack the server and edge compilations get `devtool: "source-map"` if you left it unset; Next's own `experimental.serverSourceMaps` is never changed. | +| `deleteServerMaps` | `false` | Delete server and edge maps after a confirmed upload. | +| `silent` | `false` | Suppress configuration notices (failures are still reported). | + +Without a token the integration changes nothing about what Next emits and uploads nothing. Run `next build` from the project directory: the token file, version and build lookup start there. + +Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). + ## Options Both `register(appToken, options)` and `registerClient(appToken, options)` accept the SDK launch options. The most relevant ones: @@ -76,6 +119,7 @@ Both `register(appToken, options)` and `registerClient(appToken, options)` accep - `@bugsee/nextjs`: `register`, `onRequestError`, `createOnRequestError`, `getBugseeTraceData`. - `@bugsee/nextjs/client`: `registerClient`, `onRouterTransitionStart`, plus the React adapter. - `@bugsee/nextjs/middleware`: `withBugseeMiddleware`. +- `@bugsee/nextjs/config`: `withBugsee` (build-time; import it from `next.config`, never from app code). - `@bugsee/nextjs/server` and `@bugsee/nextjs/edge`: the Node.js and Edge compositions that `register()` loads for you. ## Links From 048b9985b73d07c31d8faf40778b2b3bda3502a8 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:25:55 +0500 Subject: [PATCH 05/17] docs(source-maps): Turbopack pairs bundles and maps by pointer; shared maps Co-Authored-By: Claude Sonnet 5.5 --- docs/design/source-maps.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/design/source-maps.md b/docs/design/source-maps.md index e7aa874f..f3441105 100644 --- a/docs/design/source-maps.md +++ b/docs/design/source-maps.md @@ -397,7 +397,11 @@ alike); otherwise webpack. `NEXT_RSPACK` (the experimental Rspack adapter) is no leaves them for a retry). `.next/server` is never served and a server run with source maps reads it, so server and edge maps stay unless `deleteServerMaps`. The build is registered once (browser run). The app version and build are baked through `compiler.define` (applies to all three runtimes; repeating the keys in `defineServer` is a Next error, -measured). Only bundles that have a map are stamped on Turbopack. +measured). Only bundles that have a map are stamped on Turbopack, and bundles are paired with maps by the +`sourceMappingURL` pointer inside each bundle: Turbopack does not name a map after its bundle (Next 16.4: +`0ihtwxitjxx9w.js` points at `1wkfrb_3m2k-z.js.map`), and Next 15.5's Turbopack points two runtime chunks at ONE map. +A map carries one debug-ID (the hash of bundle + map), so such bundles are left unstamped (a notice counts them) and +their shared map stays on disk, unuploaded; they are Turbopack's runtime, not the app. **Composition.** The app's `webpack` function runs first (sync or async) and its result is extended; its `compiler.runAfterProductionCompile` runs before ours; its `compiler.define` keys win; `productionBrowserSourceMaps` From 57b632b0107e9f1e55bd0c0025abcf3481291964 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:27:38 +0500 Subject: [PATCH 06/17] test(nextjs-e2e): run the edge-build test's Next by path (the next16 alias shadows the next bin) Co-Authored-By: Claude Sonnet 5.5 --- packages/nextjs-e2e/test/edge-build.e2e.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/nextjs-e2e/test/edge-build.e2e.ts b/packages/nextjs-e2e/test/edge-build.e2e.ts index d48ff874..c15bcc17 100644 --- a/packages/nextjs-e2e/test/edge-build.e2e.ts +++ b/packages/nextjs-e2e/test/edge-build.e2e.ts @@ -31,11 +31,17 @@ describe('@bugsee/nextjs — real `next build`', () => { beforeAll(() => { rmSync(outDir, { recursive: true, force: true }); - build = spawnSync('pnpm', ['exec', 'next', 'build'], { - cwd: appDir, - encoding: 'utf8', - env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1' }, - }); + // The `next` binary is invoked by path: this package also installs Next 16 (as `next16`, for the source-map + // e2e), whose bin of the same name would win a `pnpm exec next`. + build = spawnSync( + process.execPath, + [join(appDir, 'node_modules', 'next', 'dist', 'bin', 'next'), 'build'], + { + cwd: appDir, + encoding: 'utf8', + env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1' }, + }, + ); }); afterAll(() => { From 119abb8bbe6709c0fa3136410610c4d6814a9c2f Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 12:40:36 +0500 Subject: [PATCH 07/17] fix(nextjs): review round 1 (cache dirs, contained hook, version floors, idempotence, docs) - build files: a route directory named cache is build output, not skipped - post-build hook never throws unless failOnError (Next fails the build on anything it throws) - Turbopack hook floor is Next 15.4.0 (re-verified against the published tarballs; 15.3.x has none) - compiler.define only with a token and on Next >= 15.1.0 (schema checked: 15.0.x rejects it, 15.3.5 accepts it) - withBugsee applied twice is a no-op the second time - hook notices a project directory that differs from the one the config was resolved for - docs state the public-maps caveats Co-Authored-By: Claude Sonnet 5.5 --- .changeset/nextjs-with-bugsee.md | 2 +- docs/PROGRESS.md | 2 +- docs/design/source-maps.md | 12 ++- packages/nextjs/README.md | 11 ++- .../nextjs/src/config/build-files.test.ts | 10 ++- packages/nextjs/src/config/build-files.ts | 4 +- packages/nextjs/src/config/post-build.test.ts | 56 ++++++++++++ packages/nextjs/src/config/post-build.ts | 21 +++++ .../nextjs/src/config/with-bugsee.test.ts | 85 ++++++++++++++++--- packages/nextjs/src/config/with-bugsee.ts | 40 +++++++-- 10 files changed, 213 insertions(+), 30 deletions(-) diff --git a/.changeset/nextjs-with-bugsee.md b/.changeset/nextjs-with-bugsee.md index 2fe5d748..4c61addc 100644 --- a/.changeset/nextjs-with-bugsee.md +++ b/.changeset/nextjs-with-bugsee.md @@ -3,4 +3,4 @@ '@bugsee/bundler-plugin-core': minor --- -`@bugsee/nextjs/config` adds `withBugsee(nextConfig, options)`: `next build` now stamps debug-IDs and uploads source maps on both webpack and Turbopack (Next 15.4.1+ for Turbopack, through `compiler.runAfterProductionCompile`). Browser maps are deleted after a confirmed upload; server and edge maps are kept. `@bugsee/bundler-plugin-core` exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv` and `mergeBuildPluginEnv` for it. +`@bugsee/nextjs/config` adds `withBugsee(nextConfig, options)`: `next build` now stamps debug-IDs and uploads source maps on both webpack and Turbopack (Next 15.4.0+ for Turbopack, through `compiler.runAfterProductionCompile`). Browser maps are deleted after a confirmed upload; server and edge maps are kept. `@bugsee/bundler-plugin-core` exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv` and `mergeBuildPluginEnv` for it. diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 1b1ae9c5..2213a235 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -1533,4 +1533,4 @@ Verified against current majors, all green with no adapter code changes: `@bugse `@bugsee/bundler-plugin-core` now stamps INSIDE the build wherever the bundler has a pre-write hook, so Subresource Integrity hashes taken later describe the stamped bytes: webpack 5 and **Rspack** at `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1` (shared `tapProcessAssetsStamp`), **Vite and Rollup** in `generateBundle` (`order: 'pre'`; `rollupAssetStore` over chunks + `.map` assets; the stamped id is also put on `chunk.map` because Vite regenerates the map of a lazy-loading chunk after user hooks). esbuild and the standalone CLI stay post-emit with the SRI refusal (its message now names the workaround). Every stamp is verified (`verify-stamp.ts`: parses, sourceMappingURL intact, map debugId matches, original bytes + appended stamp): in-build all-or-nothing, post-emit snapshot + restore of the failing pair (`stamp-files.ts`); an in-build stamp is re-checked on disk (`verifyStampedPairs`) and against the HTML (`findIntegrityMismatches`). `.map` deletion now requires a confirmed upload AND a debugId on the map (`partitionByKeyed`). Real-build proof: `plugin.in-build.real-build.test.ts` (Vite 7 + 8, Rollup, Rspack with its built-in SRI plugin) and a Chromium run in `instrumentation-tests/test/sri-vite-rollup.e2e.ts`. Measured ordering limits and what the guards do not see: `docs/design/source-maps.md` §7.1. ### Next.js build integration: `withBugsee` (`@bugsee/nextjs/config`), webpack AND Turbopack (2026-11-23) -`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.1+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run. +`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.0+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run. diff --git a/docs/design/source-maps.md b/docs/design/source-maps.md index f3441105..f88e12d4 100644 --- a/docs/design/source-maps.md +++ b/docs/design/source-maps.md @@ -390,7 +390,7 @@ alike); otherwise webpack. `NEXT_RSPACK` (the experimental Rspack adapter) is no | upload | each compilation's `afterEmit`, its own files | the hook: `.next/static` (browser) then `.next/server` (node + edge), explicit file lists | | maps | client: `productionBrowserSourceMaps` (forced on only if unset); server/edge: `devtool: 'source-map'` unless the app set one | always emitted (browser: `productionBrowserSourceMaps`; server maps are emitted regardless of `serverSourceMaps`, measured on 16.4) | | SRI (`experimental.sri`) | works: the hashes are of the stamped bytes (verified against the written HTML) | **not stampable**: Turbopack writes `server/subresource-integrity-manifest.json` and the HTML hashes BEFORE the hook (appending one byte in the hook made every `integrity` wrong), so the build is left unmodified, a notice says why, and nothing is uploaded | -| min Next | any with `webpack()` | 15.4.1 (the first release with `compiler.runAfterProductionCompile`; verified in the 15.4.0 and 15.4.1 types); older Turbopack builds get a notice | +| min Next | any with `webpack()` | 15.4.0 (the first release with `compiler.runAfterProductionCompile`: present in the 15.4.0 types, schema and build, absent in 15.3.x, checked against the published tarballs); older Turbopack builds get a notice. `compiler.define` (the baked version/build) needs 15.1.0; below that it is not added | **Policy.** Browser maps live in `.next/static`, which `next start` and CDNs serve to every visitor: `deleteMaps` (default true) removes them after a *confirmed* upload, exactly as the plugins do (and, as there, a failed upload @@ -407,8 +407,14 @@ their shared map stays on disk, unuploaded; they are Turbopack's runtime, not th `compiler.runAfterProductionCompile` runs before ours; its `compiler.define` keys win; `productionBrowserSourceMaps` is respected when set. Without a token the integration changes nothing Next emits. -**Open.** Both runs resolve the app identity and the token file from `process.cwd()` at config load, so run -`next build` from the project directory (Next passes no project dir to a config function). A Turbopack SRI build +**Open.** Both runs resolve the app identity, the token file and the installed Next from `process.cwd()` at config +load, so run `next build` from the project directory (Next passes no project dir to a config function). The +Turbopack hook does receive `metadata.projectDir` and says so when it differs from the directory the config was +resolved for (`next build ` from a monorepo root); it does not re-resolve, so the baked define and the upload +identity cannot disagree. Applying `withBugsee` twice is a no-op the second time (a WeakSet of extended configs). Any +failure in the post-build hook is contained (reported, never thrown) unless `failOnError`, because Next fails the +build on anything the hook throws. A failed upload leaves the browser maps in the public `.next/static` (forced on +by `withBugsee`), and Next 15's shared Turbopack runtime map stays there too (unuploaded, not the app's code). A Turbopack SRI build cannot be symbolicated by upload (see the table); an in-hook alternative would have to re-hash the integrity manifests and the HTML Next writes later, which is Next's contract, not ours. diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index e8d95754..59da6854 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -88,7 +88,7 @@ What it does, for a production build: - Turns on `productionBrowserSourceMaps` (only when you did not set it) so the browser bundles have maps to upload. - **webpack**: adds one Bugsee plugin to each of the client, server and edge compilations. Each stamps a debug ID into its bundles inside the build (before Subresource Integrity hashes are taken) and, after emit, uploads the maps of exactly the files that compilation wrote. -- **Turbopack**: has no plugin API, so the upload runs from Next's `compiler.runAfterProductionCompile` hook (Next 15.4.1 or later): after Turbopack wrote `.next` and before Next generates the static pages, it stamps the written bundles with the real `bugsee-cli sourcemaps inject` (verified, and undone if a stamp does not verify), uploads the maps and removes them. +- **Turbopack**: has no plugin API, so the upload runs from Next's `compiler.runAfterProductionCompile` hook (Next 15.4.0 or later): after Turbopack wrote `.next` and before Next generates the static pages, it stamps the written bundles with the real `bugsee-cli sourcemaps inject` (verified, and undone if a stamp does not verify), uploads the maps and removes them. - Deletes the browser maps (`.next/static/**/*.map`, which `next start` and CDNs serve publicly) after a confirmed upload. Server and edge maps stay on disk (`deleteServerMaps` to remove them). - Bakes `appVersion` / `appBuild` into every bundle (`compiler.define`) for the runtime SDK. @@ -102,7 +102,14 @@ Options are those of the Bugsee bundler plugins (`appToken`, `appVersion`, `appB | `deleteServerMaps` | `false` | Delete server and edge maps after a confirmed upload. | | `silent` | `false` | Suppress configuration notices (failures are still reported). | -Without a token the integration changes nothing about what Next emits and uploads nothing. Run `next build` from the project directory: the token file, version and build lookup start there. +Without a token the integration changes nothing about what Next emits (it adds no source maps, no define, no hook) and uploads nothing. + +Things to know: + +- The config is resolved once, at load, from the working directory: the token file, the app version and the installed Next version are looked up there. Run `next build` from the project directory. For a Turbopack build the hook is told which project Next is building, and prints a notice if that differs (for example `next build apps/web` from a monorepo root). +- `withBugsee` turns `productionBrowserSourceMaps` on, so the browser maps are written to `.next/static`, which is served publicly. They are deleted after a confirmed upload. If the upload fails (and `failOnError` is off) they stay there, publicly served, so you can retry. If that is not acceptable, set `failOnError: true` so a failed upload stops the build, or delete `.next/static/**/*.map` in your deploy step. +- Next 15's Turbopack builds point two runtime chunks at one shared map. Those chunks are left unstamped and that map is neither uploaded nor deleted: it stays in `.next/static`, public. It contains Turbopack's runtime source, not your code. +- `compiler.define` (the baked version and build) needs Next 15.1.0 or later; the Turbopack upload needs 15.4.0 or later. Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). diff --git a/packages/nextjs/src/config/build-files.test.ts b/packages/nextjs/src/config/build-files.test.ts index ad3d8466..eb1c34a6 100644 --- a/packages/nextjs/src/config/build-files.test.ts +++ b/packages/nextjs/src/config/build-files.test.ts @@ -168,13 +168,19 @@ describe('collectBuildFiles', () => { expect(parts.maps).toEqual([join(root, 'chunks/1wkfrb.js.map')]); }); - it('never descends into node_modules or cache', async () => { + it('never descends into node_modules', async () => { bundle('node_modules/x/a.js'); - bundle('cache/webpack/b.js'); bundle('ok.js'); expect((await collectBuildFiles(root)).scripts).toEqual([join(root, 'ok.js')]); }); + it('does descend into a route directory that happens to be called cache', async () => { + bundle('chunks/app/cache/page.js'); + expect((await collectBuildFiles(root)).scripts).toEqual([ + join(root, 'chunks/app/cache/page.js'), + ]); + }); + it('returns nothing for a directory that does not exist', async () => { expect(await collectBuildFiles(join(root, 'absent'))).toEqual({ scripts: [], diff --git a/packages/nextjs/src/config/build-files.ts b/packages/nextjs/src/config/build-files.ts index e5750891..36e7dcc3 100644 --- a/packages/nextjs/src/config/build-files.ts +++ b/packages/nextjs/src/config/build-files.ts @@ -18,8 +18,8 @@ export interface BuildFiles { const SCRIPT = /\.[cm]?js$/; const MAX_DEPTH = 12; -/** Directories that are never build output, wherever they appear. */ -const SKIP = new Set(['node_modules', 'cache']); +/** Directories that are never build output, wherever they appear (a route may well be called `cache`). */ +const SKIP = new Set(['node_modules']); async function listFiles(dir: string, depth: number): Promise { if (depth > MAX_DEPTH) { diff --git a/packages/nextjs/src/config/post-build.test.ts b/packages/nextjs/src/config/post-build.test.ts index 47244e07..97513996 100644 --- a/packages/nextjs/src/config/post-build.test.ts +++ b/packages/nextjs/src/config/post-build.test.ts @@ -1,3 +1,6 @@ +import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; import { describe, expect, it, vi } from 'vitest'; import type { BuildFiles } from './build-files'; import type { BugseeNextContext } from './context'; @@ -139,3 +142,56 @@ describe('runPostBuild', () => { expect(ctx.say).toHaveBeenCalledTimes(1); }); }); + +describe('runPostBuild: containment', () => { + const boom = (): never => { + throw new Error('disk on fire'); + }; + + it('a failure in collecting files never fails the build by default, and goes to onError', async () => { + const onError = vi.fn(); + const d = { ...deps({}), collect: vi.fn(async () => boom()) }; + await expect(runPostBuild(context({ onError }), metadata, d)).resolves.toBeUndefined(); + expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'disk on fire' })); + }); + + it('warns on the console when there is no onError', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const d = { ...deps({}), collect: vi.fn(async () => boom()) }; + await runPostBuild(context(), metadata, d); + expect(warn).toHaveBeenCalledWith(expect.stringContaining('disk on fire')); + warn.mockRestore(); + }); + + it('a failure in the upload is contained the same way', async () => { + const onError = vi.fn(); + const d = { ...deps({ '/app/.next/static': files('c') }), upload: vi.fn(async () => boom()) }; + await expect(runPostBuild(context({ onError }), metadata, d)).resolves.toBeUndefined(); + expect(onError).toHaveBeenCalledTimes(1); + }); + + it('rethrows under failOnError', async () => { + const d = { ...deps({}), collect: vi.fn(async () => boom()) }; + await expect(runPostBuild(context({ failOnError: true }), metadata, d)).rejects.toThrow( + 'disk on fire', + ); + }); + + it('an unreadable bundle on disk does not fail the build', async () => { + const dir = mkdtempSync(join(tmpdir(), 'bugsee-pb-')); + try { + mkdirSync(join(dir, '.next', 'static'), { recursive: true }); + const bundle = join(dir, '.next', 'static', 'a.js'); + writeFileSync(bundle, 'x'); + chmodSync(bundle, 0o000); + const onError = vi.fn(); + await expect( + runPostBuild(context({ onError }), { projectDir: dir, distDir: '.next' }), + ).resolves.toBeUndefined(); + // Root can read it anyway; everyone else must see the failure reported, not thrown. + expect(onError).toHaveBeenCalledTimes(process.getuid?.() === 0 ? 0 : 1); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); +}); diff --git a/packages/nextjs/src/config/post-build.ts b/packages/nextjs/src/config/post-build.ts index e9d22cde..4c79b259 100644 --- a/packages/nextjs/src/config/post-build.ts +++ b/packages/nextjs/src/config/post-build.ts @@ -48,6 +48,27 @@ export async function runPostBuild( if (!resolved.enabled) { return; } + // Next rethrows whatever this hook throws and fails the build, so a telemetry step must not throw (an unreadable + // bundle, a full disk): it is reported, and only `failOnError` lets it stop the build. + try { + await postBuild(context, metadata, deps); + } catch (error) { + if (resolved.failOnError) { + throw error; + } + ( + resolved.onError ?? + ((e: unknown) => console.warn(`[bugsee] source-map upload skipped: ${String(e)}`)) + )(error); + } +} + +async function postBuild( + context: BugseeNextContext, + metadata: PostBuildMetadata, + deps: PostBuildDeps, +): Promise { + const { resolved } = context; const upload = deps.upload ?? runPluginUpload; const collect = deps.collect ?? collectBuildFiles; const exists = deps.exists ?? fileExists; diff --git a/packages/nextjs/src/config/with-bugsee.test.ts b/packages/nextjs/src/config/with-bugsee.test.ts index 084aa875..7edd1257 100644 --- a/packages/nextjs/src/config/with-bugsee.test.ts +++ b/packages/nextjs/src/config/with-bugsee.test.ts @@ -50,14 +50,14 @@ describe('versionAtLeast', () => { ['16.4.6', true], ['15.4.1', true], ['15.4.2', true], + ['15.4.0', true], ['15.5.0', true], - ['15.4.0', false], ['15.3.9', false], ['14.9.9', false], - ['15.4.1-canary.3', true], + ['15.4.0-canary.3', true], ['not-a-version', true], ])('%s -> %s', (version, expected) => { - expect(versionAtLeast(version, [15, 4, 1])).toBe(expected); + expect(versionAtLeast(version, [15, 4, 0])).toBe(expected); }); }); @@ -111,12 +111,24 @@ describe('withBugsee: composition', () => { expect(out.compiler.removeConsole).toBe(true); }); - it('bakes the identity even without a token, but adds no define when none was found', () => { - expect(apply({}, deps(context({ enabled: false }))).compiler.define).toMatchObject({ - __BUGSEE_APP_VERSION__: '"1.0.0"', - }); + it('adds no define when no identity was found', () => { expect(apply({}, deps(context({ identityDefines: {} }))).compiler).toBeUndefined(); }); + + it('adds nothing at all without a token, the define included', () => { + const config = { reactStrictMode: true }; + expect(apply(config, deps(context({ enabled: false })))).toEqual(config); + }); + + it('bakes the identity from Next 15.1.0 (where compiler.define exists), not before', () => { + const defined = (version: string | undefined): boolean => + apply({}, deps(context(), { nextVersion: () => version })).compiler?.define !== undefined; + expect(defined('15.0.8')).toBe(false); + expect(defined('14.2.35')).toBe(false); + expect(defined('15.1.0')).toBe(true); + expect(defined('16.4.6')).toBe(true); + expect(defined(undefined)).toBe(true); + }); }); describe('withBugsee: phases and shapes', () => { @@ -289,14 +301,15 @@ describe('withBugsee: Turbopack', () => { const ctx = context(); const out = apply({}, turbo({ nextVersion: () => '15.3.0' }, ctx)); expect(out.compiler?.runAfterProductionCompile).toBeUndefined(); - expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('15.4.1')); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('15.4.0')); }); - it('draws the line at 15.4.1: the hook is installed from there, not before', () => { + it('draws the line at 15.4.0: the hook is installed from there, not before', () => { const hooked = (version: string): boolean => typeof apply({}, turbo({ nextVersion: () => version })).compiler ?.runAfterProductionCompile === 'function'; - expect(hooked('15.4.0')).toBe(false); + expect(hooked('15.3.9')).toBe(false); + expect(hooked('15.4.0')).toBe(true); expect(hooked('15.4.1')).toBe(true); expect(hooked('15.5.28')).toBe(true); expect(hooked('16.4.6')).toBe(true); @@ -348,3 +361,55 @@ describe('withBugsee: Turbopack', () => { } }); }); + +describe('withBugsee: applied twice', () => { + const nextArgs = { dev: false, isServer: false }; + + it('is a no-op the second time for an object config (one plugin, one hook)', () => { + const d = deps(context(), { env: { TURBOPACK: '1' } }); + const once = apply({}, d); + const twice = withBugsee(once, {}, d) as Obj; + expect(twice).toBe(once); + expect(d.createContext).toHaveBeenCalledTimes(1); + }); + + it('adds one plugin when a webpack config is wrapped twice', () => { + const d = deps(); + const twice = withBugsee(withBugsee({}, {}, d), {}, d) as Obj; + expect(twice.webpack({}, nextArgs).plugins).toHaveLength(1); + }); + + it('is a no-op the second time for a function and an async config', async () => { + const d = deps(); + const wrapped = withBugsee(async () => ({}), {}, d); + const twice = withBugsee(wrapped, {}, d) as unknown as (p: string, c: Obj) => Promise; + const out = await twice('phase-production-build', { defaultConfig: {} }); + expect(out.webpack({}, nextArgs).plugins).toHaveLength(1); + expect(d.createContext).toHaveBeenCalledTimes(1); + }); + + it('still wraps a config the first pass skipped (another phase)', async () => { + const d = deps(); + const fn = withBugsee(() => ({}), {}, d) as unknown as (p: string, c: Obj) => Promise; + expect(await fn('phase-development-server', { defaultConfig: {} })).toEqual({}); + expect((await fn('phase-production-build', { defaultConfig: {} })).webpack).toBeDefined(); + }); +}); + +describe('withBugsee: the project directory', () => { + const metadata = { projectDir: '/monorepo/apps/web', distDir: '/monorepo/apps/web/.next' }; + + it('says so when the hook runs for a different project than the config was resolved for', async () => { + const d = deps(context(), { env: { TURBOPACK: '1' }, cwd: () => '/monorepo' }); + const out = apply({}, d); + await out.compiler.runAfterProductionCompile(metadata); + expect(d.ctx.say).toHaveBeenCalledWith(expect.stringContaining('/monorepo/apps/web')); + expect(d.ctx.say).toHaveBeenCalledWith(expect.stringContaining('resolved for /monorepo')); + }); + + it('is quiet when they agree', async () => { + const d = deps(context(), { env: { TURBOPACK: '1' }, cwd: () => '/monorepo/apps/web' }); + await apply({}, d).compiler.runAfterProductionCompile(metadata); + expect(d.ctx.say).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/nextjs/src/config/with-bugsee.ts b/packages/nextjs/src/config/with-bugsee.ts index f1f2c663..3e4b29c1 100644 --- a/packages/nextjs/src/config/with-bugsee.ts +++ b/packages/nextjs/src/config/with-bugsee.ts @@ -9,7 +9,7 @@ // app's own `webpack` function, `compiler.runAfterProductionCompile`, `compiler.define` and // `productionBrowserSourceMaps` are called, kept or extended, never replaced. Nothing runs for `next dev`. import { createRequire } from 'node:module'; -import { join } from 'node:path'; +import { join, resolve } from 'node:path'; import { type BugseeNextContext, createBugseeContext, type WithBugseeOptions } from './context'; import { type PostBuildMetadata, runPostBuild } from './post-build'; import { createNextWebpackPlugin, type NextCompilationKind } from './webpack-plugin'; @@ -25,8 +25,12 @@ export type NextConfigInput = C | Promise | NextC /** Next's `PHASE_PRODUCTION_BUILD`. The only phase that builds anything we touch. */ const PHASE_PRODUCTION_BUILD = 'phase-production-build'; -/** The first Next with `compiler.runAfterProductionCompile` that Turbopack runs (measured, see post-build.ts). */ -const MIN_TURBOPACK_HOOK = [15, 4, 1] as const; +/** The first Next with `compiler.runAfterProductionCompile` (in the 15.4.0 types, schema and build; absent in 15.3.x). */ +const MIN_TURBOPACK_HOOK = [15, 4, 0] as const; +/** The first Next whose config schema has `compiler.define` (15.1.0; 15.0.x rejects it as an unknown key). */ +const MIN_COMPILER_DEFINE = [15, 1, 0] as const; +/** Configs this has already extended, so applying `withBugsee` twice (a shared base config) adds nothing twice. */ +const WRAPPED = new WeakSet(); /** Seams for tests. */ export interface WithBugseeDeps { @@ -83,6 +87,7 @@ function extendConfig( context: BugseeNextContext, turbopack: boolean, nextVersion: string | undefined, + projectDir: string, ): C { const { resolved } = context; const next: NextConfigObject = { ...config }; @@ -90,15 +95,19 @@ function extendConfig( // The app's version and build, baked into every bundle (browser, node, edge) for the runtime SDK to read. // `compiler.define` applies to all three; `defineServer` must NOT repeat the keys (measured, Next 15.5: it // throws "already configured"). A constant the app defined itself wins. + // Only with a token: without one the integration changes nothing Next emits. + if (!resolved.enabled) { + return next as C; + } const identity = resolved.identityDefines; - if (Object.keys(identity).length > 0) { + if ( + Object.keys(identity).length > 0 && + (nextVersion === undefined || versionAtLeast(nextVersion, MIN_COMPILER_DEFINE)) + ) { const compiler: NextConfigObject = { ...(config.compiler ?? {}) }; compiler.define = { ...identity, ...(config.compiler?.define ?? {}) }; next.compiler = compiler; } - if (!resolved.enabled) { - return next as C; - } // Browser maps are what Bugsee symbolicates browser crashes with. Forced on only when nothing says otherwise, // and only here, where a token means they will be uploaded and then removed from `.next/static`. @@ -134,7 +143,7 @@ function extendConfig( if (turbopack) { if (nextVersion !== undefined && !versionAtLeast(nextVersion, MIN_TURBOPACK_HOOK)) { context.say( - `Next ${nextVersion} builds with Turbopack but has no post-build hook to upload from; source maps were NOT uploaded. Upgrade to Next 15.4.1 or later, or build with webpack.`, + `Next ${nextVersion} builds with Turbopack but has no post-build hook to upload from; source maps were NOT uploaded. Upgrade to Next 15.4.0 or later, or build with webpack.`, ); } else { const userHook = config.compiler?.runAfterProductionCompile as @@ -144,6 +153,13 @@ function extendConfig( ...(next.compiler ?? config.compiler ?? {}), runAfterProductionCompile: async (metadata: PostBuildMetadata) => { await userHook?.(metadata); + // The config (token file, version, installed Next) was resolved for the working directory at load time; + // Next says which project it is building. They differ for `next build ` from a monorepo root. + if (resolve(metadata.projectDir) !== resolve(projectDir)) { + context.say( + `the config was resolved for ${projectDir} but Next is building ${metadata.projectDir}: the token file, app version and Next version were looked up in the former. Run \`next build\` from the project directory.`, + ); + } await runPostBuild(context, metadata); }, }; @@ -177,14 +193,20 @@ export function withBugsee( if (phase !== undefined && phase !== PHASE_PRODUCTION_BUILD) { return config; } + if (WRAPPED.has(config)) { + return config; + } const projectDir = (deps.cwd ?? process.cwd)(); const context = (deps.createContext ?? createBugseeContext)(options, projectDir, { env }); - return extendConfig( + const extended = extendConfig( config, context, turbopack, (deps.nextVersion ?? installedNextVersion)(projectDir), + projectDir, ); + WRAPPED.add(extended); + return extended; }; if (typeof nextConfig === 'function') { return async (phase, context) => apply(await nextConfig(phase, context), phase); From bd997b4998b8cf912d5e6afd632ff3299f00e149 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 13:48:04 +0500 Subject: [PATCH 08/17] fix(nextjs): follow the frozen in-build stamping contract (own files only, query-free store, stamp counts) - Turbopack: a stylesheet map is this build's only when a stylesheet of the build points at it (/*# */ comment); a foreign .css.map or .d.ts.map under .next is never deleted - webpack: query-free asset names and the compilation's recorded source map (info.related) in the store, real asset names handed back as stampedBundles/stampedMaps for the on-disk re-check, a stamp that staged nothing while scripts were emitted falls back to post-emit and says so, an unreachable map abandons the compilation instead of half-stamping it - e2e: foreign pre-seeded .css.map and .d.ts.map (static and server) survive on both bundlers Co-Authored-By: Claude Sonnet 5.5 --- packages/nextjs-e2e/test/source-maps.e2e.ts | 77 +++++++- .../nextjs/src/config/build-files.test.ts | 41 +++- packages/nextjs/src/config/build-files.ts | 19 +- .../nextjs/src/config/webpack-plugin.test.ts | 181 +++++++++++++++++- packages/nextjs/src/config/webpack-plugin.ts | 123 +++++++++--- 5 files changed, 406 insertions(+), 35 deletions(-) diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts index 1fcf99da..fc71e427 100644 --- a/packages/nextjs-e2e/test/source-maps.e2e.ts +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -74,8 +74,43 @@ interface Spec { /** Extra source for the `withBugsee` options object and the Next config. */ options?: string; nextConfig?: string; + /** Pre-seed FOREIGN source-map files (stylesheet and declaration maps nothing in this build produced). */ + seedForeign?: boolean; } +/** Where the foreign files are written, relative to the dist dir, and what they contain. */ +const FOREIGN = [ + ['static', 'foreign.css.map'], + ['static', 'foreign.d.ts.map'], + ['server', 'foreign.css.map'], + ['server', 'foreign.d.ts.map'], +] as const; +const FOREIGN_BODY = '{"version":3,"sources":["foreign.css"],"names":[],"mappings":""}'; + +/** Next config source that writes the foreign files from BOTH bundlers' paths, before Bugsee's step runs. */ +const SEED_HOOK = ` + compiler: { runAfterProductionCompile: async ({ distDir }) => seed(distDir) },`; +const SEED_WEBPACK = ` + webpack(config, { isServer }) { + config.plugins.push({ apply(compiler) { + compiler.hooks.afterEmit.tap('seed', () => { + const out = compiler.options.output.path; + seed(isServer ? join(out, '..', '..') : out); + }); + } }); + return config; + },`; +const SEED_PRELUDE = ` +import { mkdirSync as mk, writeFileSync as wr } from 'node:fs'; +import { join } from 'node:path'; +function seed(dist) { + for (const [dir, name] of ${JSON.stringify(FOREIGN)}) { + mk(join(dist, dir), { recursive: true }); + wr(join(dist, dir, name), ${JSON.stringify(FOREIGN_BODY)}); + } +} +`; + interface Built { dir: string; status: number | null; @@ -103,8 +138,9 @@ async function build(spec: Spec): Promise { // Plain JavaScript on purpose: a `.ts` file makes Next install TypeScript into the project. writeFileSync( join(dir, 'app', 'layout.jsx'), - 'export default function Layout({ children }) { return {children}; }\n', + "import './style.css';\nexport default function Layout({ children }) { return {children}; }\n", ); + writeFileSync(join(dir, 'app', 'style.css'), 'body { margin: 0; color: rebeccapurple; }\n'); writeFileSync( join(dir, 'app', 'page.jsx'), `'use client'; @@ -132,9 +168,9 @@ export default function Page() { ); writeFileSync( join(dir, 'next.config.mjs'), - `import { withBugsee } from '@bugsee/nextjs/config'; + `import { withBugsee } from '@bugsee/nextjs/config';${spec.seedForeign ? SEED_PRELUDE : ''} export default withBugsee( - { ${spec.next === 'next' ? 'eslint: { ignoreDuringBuilds: true },' : ''} ${spec.nextConfig ?? ''} }, + { ${spec.next === 'next' ? 'eslint: { ignoreDuringBuilds: true },' : ''} ${spec.nextConfig ?? ''}${spec.seedForeign ? SEED_HOOK + (spec.args.includes('--webpack') ? SEED_WEBPACK : '') : ''} }, { appToken: 'e2e-token', endpoint: ${JSON.stringify(endpoint)}, appVersion: '9.8.7', appBuild: '42', vcs: false, registerBuild: false, failOnError: true, ${spec.options ?? ''} }, ); @@ -365,3 +401,38 @@ describe('withBugsee — Subresource Integrity', () => { } }); }); + +describe.each([ + { name: 'foreign-webpack', next: 'next16', args: ['--webpack'] }, + { name: 'foreign-turbopack', next: 'next16', args: [] }, +] as Spec[])('withBugsee — files this build did not produce ($name)', (spec) => { + let built: Built; + beforeAll(async () => { + built = await build({ ...spec, seedForeign: true }); + }); + + it('builds', () => { + expect(built.status, built.log.split('\n').slice(-40).join('\n')).toBe(0); + }); + + it('never deletes a stylesheet or declaration map it did not produce', () => { + for (const [dir, name] of FOREIGN) { + const file = join(built.dir, '.next', dir, name); + expect(existsSync(file), `${dir}/${name} was deleted`).toBe(true); + expect(readFileSync(file, 'utf8')).toBe(FOREIGN_BODY); + } + }); + + it('still uploaded and deleted its own maps', () => { + expect(built.uploads.length).toBeGreaterThan(0); + const { unique } = split(join(built.dir, '.next', 'static')); + expect(unique.length).toBeGreaterThan(2); + for (const bundle of unique) { + expect(debugIdOf(bundle), bundle).toBeDefined(); + } + const own = maps(join(built.dir, '.next', 'static')).filter( + (m) => !m.includes('foreign.') && split(join(built.dir, '.next', 'static')).referenced.has(m), + ); + expect(own).toEqual([]); + }); +}); diff --git a/packages/nextjs/src/config/build-files.test.ts b/packages/nextjs/src/config/build-files.test.ts index eb1c34a6..ad2b1b4d 100644 --- a/packages/nextjs/src/config/build-files.test.ts +++ b/packages/nextjs/src/config/build-files.test.ts @@ -14,6 +14,10 @@ describe('partitionBuildFiles', () => { }); }); + it('accepts an upper-case extension, as the core does', () => { + expect(partitionBuildFiles(['/o/A.JS', '/o/A.JS.map']).scripts).toEqual(['/o/A.JS']); + }); + it('accepts .mjs and .cjs bundles', () => { const files = ['/o/a.mjs', '/o/a.mjs.map', '/o/b.cjs', '/o/b.cjs.map']; expect(partitionBuildFiles(files).scripts).toEqual(['/o/a.mjs', '/o/b.cjs']); @@ -60,6 +64,12 @@ describe('mapPointerOf', () => { expect(mapPointerOf('/o/a.js', 'x\n//# sourceMappingURL=100%.js.map')).toBe('/o/100%.js.map'); }); + it('reads a stylesheet pointer from its /*# */ comment, not the // form', () => { + expect(mapPointerOf('/o/a.css', 'a{}\n/*# sourceMappingURL=a.css.map */')).toBe('/o/a.css.map'); + expect(mapPointerOf('/o/a.css', 'a{}\n//# sourceMappingURL=a.css.map')).toBeUndefined(); + expect(mapPointerOf('/o/a.js', 'x\n/*# sourceMappingURL=a.js.map */')).toBeUndefined(); + }); + it('has no pointer for a bundle without a comment, or with an inline map', () => { expect(mapPointerOf('/o/a.js', 'no comment')).toBeUndefined(); expect( @@ -114,15 +124,40 @@ describe('pairByPointer', () => { it('does not read files that are not scripts', async () => { const read = vi.fn(async () => ''); - await pairByPointer(['/o/a.json', '/o/a.js.map', '/o/a.css'], read); + await pairByPointer(['/o/a.json', '/o/a.js.map', '/o/a.txt'], read); expect(read).not.toHaveBeenCalled(); }); - it('keeps stylesheet maps apart', async () => { - const parts = await pairByPointer(['/o/a.css.map'], reader({})); + it("keeps this build's stylesheet maps apart (a stylesheet points at them): deleted, never sent", async () => { + const css = (map: string): string => `a{}\n/*# sourceMappingURL=${map} */\n`; + const parts = await pairByPointer( + ['/o/a.css', '/o/x1.map'], + reader({ '/o/a.css': css('x1.map') }), + ); + expect(parts.stylesheetMaps).toEqual(['/o/x1.map']); + expect(parts.maps).toEqual([]); + }); + + it("leaves a stylesheet or declaration map nothing points at alone: it is not this build's", async () => { + const parts = await pairByPointer( + ['/o/a.css', '/o/a.css.map', '/o/foreign.css.map', '/o/types.d.ts.map'], + reader({ '/o/a.css': 'a{}\n/*# sourceMappingURL=a.css.map */' }), + ); expect(parts.stylesheetMaps).toEqual(['/o/a.css.map']); }); + it('ignores a stylesheet pointer to a missing or non-map file, or an inline map', async () => { + const parts = await pairByPointer( + ['/o/a.css', '/o/b.css', '/o/c.css', '/o/c.txt'], + reader({ + '/o/a.css': 'a{}/*# sourceMappingURL=gone.css.map */', + '/o/b.css': 'a{}/*# sourceMappingURL=c.txt */', + '/o/c.css': 'a{}/*# sourceMappingURL=data:application/json;base64,e30= */', + }), + ); + expect(parts.stylesheetMaps).toEqual([]); + }); + it('sorts its output', async () => { const parts = await pairByPointer( ['/o/z.js', '/o/a.js', '/o/m1.map', '/o/m0.map'], diff --git a/packages/nextjs/src/config/build-files.ts b/packages/nextjs/src/config/build-files.ts index 36e7dcc3..7d84a630 100644 --- a/packages/nextjs/src/config/build-files.ts +++ b/packages/nextjs/src/config/build-files.ts @@ -16,7 +16,7 @@ export interface BuildFiles { shared?: string[]; } -const SCRIPT = /\.[cm]?js$/; +const SCRIPT = /\.[cm]?js$/i; const MAX_DEPTH = 12; /** Directories that are never build output, wherever they appear (a route may well be called `cache`). */ const SKIP = new Set(['node_modules']); @@ -58,12 +58,13 @@ export function partitionBuildFiles(files: readonly string[]): BuildFiles { }; } -/** A bundle's source-map pointer: the last `//# sourceMappingURL=` comment. */ +/** A bundle's source-map pointer: the last `//# sourceMappingURL=` comment (a `/*# ... *\/` comment in a stylesheet). */ const POINTER = /\/\/[#@] sourceMappingURL=([^\s'"]+)\s*$/; +const CSS_POINTER = /\/\*[#@] sourceMappingURL=([^\s'"*]+)\s*\*\/\s*$/; /** The path a bundle's source-map comment names, or `undefined` when it has none or the map is inline. */ export function mapPointerOf(file: string, code: string): string | undefined { - const reference = POINTER.exec(code)?.[1]; + const reference = (file.endsWith('.css') ? CSS_POINTER : POINTER).exec(code)?.[1]; if (reference === undefined || reference.startsWith('data:')) { return undefined; } @@ -95,6 +96,16 @@ export async function pairByPointer( users.set(map, (users.get(map) ?? 0) + 1); } } + // Stylesheet maps are never uploaded but embed the source, so they are deleted with the rest, and only THIS + // build's: a stylesheet map is this build's when one of its stylesheets points at it. A `.css.map` (or a + // `.d.ts.map`) that nothing here points at was put there by something else, and is left alone. + const styles = new Set(); + for (const file of files.filter((f) => f.endsWith('.css'))) { + const map = mapPointerOf(file, await read(file)); + if (map?.endsWith('.map') && present.has(map)) { + styles.add(map); + } + } // A map belongs to one bundle: a debug-ID is the hash of the bundle AND its map, and a map carries one. Two // bundles pointing at the same map (Next 15.5's Turbopack does this for its runtime chunks, measured) cannot both // be keyed to it, so neither is paired: stamping one would leave the other with an id no map answers to. @@ -102,7 +113,7 @@ export async function pairByPointer( return { scripts: paired.map(([file]) => file).sort(), maps: paired.map(([, map]) => map).sort(), - stylesheetMaps: files.filter((file) => file.endsWith('.css.map')).sort(), + stylesheetMaps: [...styles].sort(), shared: [...pointers] .filter(([, map]) => (users.get(map) as number) > 1) .map(([file]) => file) diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index 0252646b..8d12f7aa 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -14,7 +14,10 @@ class RawSource { type Processor = () => Promise; /** A fake webpack compilation holding named assets, recording updates. */ -function fakeCompilation(assets: Record) { +function fakeCompilation( + assets: Record, + related: Record = {}, +) { const store = new Map( Object.entries(assets).map(([k, v]) => [k, Buffer.from(v)]), ); @@ -35,7 +38,12 @@ function fakeCompilation(assets: Record) { }, getAssets: () => [...store.keys()].map((name) => ({ name })), getAsset: (name: string) => - store.has(name) ? { source: { buffer: () => store.get(name) as Buffer } } : undefined, + store.has(name) + ? { + source: { buffer: () => store.get(name) as Buffer }, + info: related[name] === undefined ? {} : { related: { sourceMap: related[name] } }, + } + : undefined, updateAsset: vi.fn((name: string, source: unknown) => { store.set(name, (source as RawSource).content); }), @@ -97,7 +105,7 @@ function context( } const deps = (over: WebpackPluginDeps = {}): WebpackPluginDeps => ({ - stamp: vi.fn(async () => ({ stamped: [] })), + stamp: vi.fn(async () => ({ stamped: [], maps: {}, bundles: 1 })), upload: vi.fn(async () => undefined), exists: vi.fn(async () => true), ...over, @@ -389,3 +397,170 @@ describe('createNextWebpackPlugin', () => { await expect(fake.emit(c.compilation)).resolves.toBeUndefined(); }); }); + +describe('nextAssetStore: query-free names and moved maps', () => { + it('presents names without their ?query and maps them back to the real asset', () => { + const { compilation, store } = fakeCompilation({ + 'static/a.js?h1': 'a', + 'static/a.js.map?h1': 'm', + 'static/a#1.js': 'hash kept', + }); + const assets = nextAssetStore(compilation, RawSource); + expect(assets.names()).toEqual(['static/a.js', 'static/a.js.map', 'static/a#1.js']); + expect(assets.read('static/a.js').toString()).toBe('a'); + assets.update('static/a.js', Buffer.from('b')); + expect(store.get('static/a.js?h1')?.toString()).toBe('b'); + expect(assets.real('static/a.js')).toBe('static/a.js?h1'); + expect(assets.real('static/a#1.js')).toBe('static/a#1.js'); + expect(assets.real('unknown.js')).toBe('unknown.js'); + }); + + it('keeps the real names of two assets that would collide once cleaned', () => { + const { compilation } = fakeCompilation({ 'a.js?x': '1', 'a.js?y': '2' }); + expect(nextAssetStore(compilation, RawSource).names()).toEqual(['a.js?x', 'a.js?y']); + }); + + it('names the map the compilation recorded for a bundle, staged like the bundle', () => { + const { compilation } = fakeCompilation( + { + '../app/page.js': 'x', + '../maps/page.js.map?v': 'm', + 'a.js': 'x', + 'a.js.map': 'm', + 'b.js': 'x', + }, + { '../app/page.js': '../maps/page.js.map?v', 'a.js': ['a.js.map', 'other'] }, + ); + const assets = nextAssetStore(compilation, RawSource); + assets.names(); + expect(assets.mapOf?.('__bugsee_up__/app/page.js')).toBe('__bugsee_up__/maps/page.js.map'); + expect(assets.mapOf?.('a.js')).toBe('a.js.map'); + expect(assets.mapOf?.('b.js')).toBeUndefined(); + }); +}); + +describe('createNextWebpackPlugin: the new core contract', () => { + const asset = { + '../app/page.js': 'x', + '../app/page.js.map': 'm', + 'static/c.js': 'x', + 'static/c.js.map': 'm', + }; + + it('hands the on-disk re-check the stamped bundles and maps by REAL asset name', async () => { + const d = deps({ + stamp: vi.fn(async () => ({ + stamped: ['__bugsee_up__/app/page.js', 'static/c.js'], + maps: { '__bugsee_up__/app/page.js': '__bugsee_up__/app/page.js.map' }, + bundles: 2, + })), + }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'server', d).apply(fake.compiler); + const c = fakeCompilation(asset); + fake.startCompilation(c.compilation); + await c.run(); + // The names are only translated if the store was listed (the stamp lists it first). + await fake.emit(c.compilation); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { stampedBundles: string[]; stampedMaps: Record }, + ]; + expect(options.stampedBundles).toEqual(['__bugsee_up__/app/page.js', 'static/c.js']); + expect(options.stampedMaps).toEqual({ + '__bugsee_up__/app/page.js': '__bugsee_up__/app/page.js.map', + }); + }); + + it('translates staged names back to real names when the store was listed', async () => { + const d = deps({ + stamp: vi.fn(async (store) => { + store.names(); + return { + stamped: ['__bugsee_up__/app/page.js'], + maps: { '__bugsee_up__/app/page.js': '__bugsee_up__/app/page.js.map' }, + bundles: 1, + }; + }), + }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'server', d).apply(fake.compiler); + const c = fakeCompilation(asset); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { stampedBundles: string[]; stampedMaps: Record }, + ]; + expect(options.stampedBundles).toEqual(['../app/page.js']); + expect(options.stampedMaps).toEqual({ '../app/page.js': '../app/page.js.map' }); + }); + + it('does not claim a stamp that staged nothing while the build emitted scripts: says so, stamps after emit', async () => { + const d = deps({ stamp: vi.fn(async () => ({ stamped: [], maps: {}, bundles: 0 })) }); + const ctx = context(); + const fake = fakeCompiler(); + createNextWebpackPlugin(ctx, 'server', d).apply(fake.compiler); + const c = fakeCompilation(asset); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('no debug-ID could be stamped')); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('server build')); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { preStamped: boolean; stampedBundles?: string[] }, + ]; + expect(options.preStamped).toBe(false); + expect(options.stampedBundles).toBeUndefined(); + }); + + it('a compilation with no scripts at all and nothing staged is not an alarm', async () => { + const d = deps({ stamp: vi.fn(async () => ({ stamped: [], maps: {}, bundles: 0 })) }); + const ctx = context(); + const fake = fakeCompiler(); + createNextWebpackPlugin(ctx, 'server', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.json': '{}' }); + fake.startCompilation(c.compilation); + await c.run(); + expect(ctx.say).not.toHaveBeenCalled(); + }); + + it('stamps and uploads nothing when the stamp is refused because a map lies outside the output', async () => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const refusal = Object.assign(new Error('map outside the output'), { unreachableMap: true }); + const d = deps({ + stamp: vi.fn(async () => { + throw refusal; + }), + }); + const fake = fakeCompiler(); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + expect(warn).toHaveBeenCalledWith(expect.stringContaining('half-stamp')); + expect(d.upload).not.toHaveBeenCalled(); + warn.mockRestore(); + }); + + it('looks for an asset whose name carries a ?query at the query-free path on disk', async () => { + const seen: string[] = []; + const d = deps({ + exists: vi.fn(async (path: string) => { + seen.push(path); + return true; + }), + }); + const fake = fakeCompiler({ path: '/out/.next' }); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'static/a.js?h': 'x', 'static/a.js.map?h': 'm' }); + await fake.emit(c.compilation); + expect(seen).toEqual(['/out/.next/static/a.js', '/out/.next/static/a.js.map']); + }); +}); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index 3cf28599..c4b035be 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -31,7 +31,13 @@ interface CompilationLike { }; }; getAssets(): ReadonlyArray<{ name: string }>; - getAsset(name: string): { source: { buffer(): Buffer } } | undefined; + getAsset(name: string): + | { + source: { buffer(): Buffer }; + /** `related.sourceMap` is how SourceMapDevToolPlugin records which asset is a bundle's map. */ + info?: { related?: { sourceMap?: string | string[] | null } }; + } + | undefined; updateAsset(name: string, source: unknown): void; } @@ -62,6 +68,18 @@ export interface WebpackPluginDeps { } const PLUGIN = 'bugsee-next'; +/** A script asset, query and upper-case extension included (what the core's own plugin counts). */ +const SCRIPT_ASSET = /\.[cm]?js(\?|$)/i; + +/** What the in-build stamp of one compilation established. */ +interface InBuildStamp { + preStamped: boolean; + /** The bundles it stamped and their maps, by real asset name, for the on-disk re-check. */ + stampedBundles?: string[]; + stampedMaps?: Record; + /** The stamp was refused in a way that makes stamping after emit unsafe too. */ + abandoned?: boolean; +} /** Stands in for each leading `../` of an asset name inside the staging directory. */ const UP = '__bugsee_up__'; @@ -74,29 +92,56 @@ async function fileExists(path: string): Promise { } /** - * A compilation's assets as an {@link AssetStore}. Asset names that start with `../` (Next's server output sits - * one level above the compilation's output path) are staged under a stand-in directory, consistently for a bundle - * and its map, so their relative layout survives and nothing can escape the staging directory. + * An asset name without its `?query`: webpack drops `?...` when it writes a file and keeps `#` (measured on real + * builds by the core's own asset store, which this follows). + */ +const withoutQuery = (name: string): string => name.replace(/\?.*$/, ''); + +/** A compilation's asset table as the core's {@link AssetStore}, plus the way back to real asset names. */ +export interface NextAssetStore extends AssetStore { + /** The real asset name behind a name this store presented. */ + real(name: string): string; +} + +/** + * A compilation's assets as an {@link AssetStore}. Names are presented query-free, and a name that starts with + * `../` (Next's server output sits one level above the compilation's output path) is staged under a stand-in + * directory, consistently for a bundle and its map, so their relative layout survives and nothing can escape the + * staging directory. Two assets that would collide once cleaned keep their real names. */ export function nextAssetStore( compilation: CompilationLike, RawSource: new (content: Buffer) => unknown, -): AssetStore { - const staged = (name: string): string => - name.replace(/^(?:\.\.\/)+/, (up) => `${UP}/`.repeat(up.length / 3)); +): NextAssetStore { + const up = (name: string): string => + name.replace(/^(?:\.\.\/)+/, (dots) => `${UP}/`.repeat(dots.length / 3)); const actual = new Map(); + const refresh = (): void => { + actual.clear(); + const names = compilation.getAssets().map((asset) => asset.name); + const counts = new Map(); + for (const name of names) { + counts.set(up(withoutQuery(name)), (counts.get(up(withoutQuery(name))) ?? 0) + 1); + } + for (const name of names) { + const clean = up(withoutQuery(name)); + actual.set(counts.get(clean) === 1 ? clean : up(name), name); + } + }; + const real = (name: string): string => actual.get(name) ?? name; return { names: () => { - actual.clear(); - for (const { name } of compilation.getAssets()) { - actual.set(staged(name), name); - } + refresh(); return [...actual.keys()]; }, - read: (name) => - compilation.getAsset(actual.get(name) ?? name)?.source.buffer() ?? Buffer.alloc(0), - update: (name, content) => - compilation.updateAsset(actual.get(name) ?? name, new RawSource(content)), + read: (name) => compilation.getAsset(real(name))?.source.buffer() ?? Buffer.alloc(0), + update: (name, content) => compilation.updateAsset(real(name), new RawSource(content)), + mapOf: (name) => { + const related = compilation.getAsset(real(name))?.info?.related?.sourceMap; + const map = Array.isArray(related) ? related[0] : related; + return map === undefined || map === null ? undefined : up(withoutQuery(map)); + }, + real, }; } @@ -127,28 +172,55 @@ export function createNextWebpackPlugin( const stage = api?.Compilation?.PROCESS_ASSETS_STAGE_DEV_TOOLING; const RawSource = api?.sources?.RawSource; // Reset per compilation: in watch mode a stamp from the previous build cannot vouch for this one. - let preStamped = false; + let state: InBuildStamp = { preStamped: false }; if (stage !== undefined && RawSource !== undefined) { compiler.hooks.thisCompilation.tap(PLUGIN, (compilation) => { - preStamped = false; + state = { preStamped: false }; // One stage past the source-map plugin (500): the final bytes, before the SRI plugin hashes them. compilation.hooks.processAssets.tapPromise( { name: PLUGIN, stage: stage + 1 }, async () => { + const store = nextAssetStore(compilation, RawSource); try { - await stamp(nextAssetStore(compilation, RawSource), { dryRun: resolved.dryRun }); - preStamped = true; + const { stamped, maps, bundles } = await stamp(store, { dryRun: resolved.dryRun }); + const scripts = compilation + .getAssets() + .filter(({ name }) => SCRIPT_ASSET.test(name)); + if (bundles === 0 && scripts.length > 0) { + // Never claim a stamp that staged nothing while the build emitted scripts. + context.say( + `no debug-ID could be stamped inside the ${kind} build (none of its ${scripts.length} script asset(s), e.g. ${scripts[0]?.name}, matched), so stamping after emit instead.`, + ); + return; + } + state = { + preStamped: true, + stampedBundles: stamped.map((name) => store.real(name)), + stampedMaps: Object.fromEntries( + Object.entries(maps).map(([bundle, map]) => [ + store.real(bundle), + store.real(map), + ]), + ), + }; } catch (error) { if (resolved.failOnError) { throw error; } + // A map that cannot be stamped with its bundle (outside the output): stamping after emit would + // half-stamp the build, so nothing is stamped or uploaded for it. + const abandoned = + (error as { unreachableMap?: boolean } | null)?.unreachableMap === true; ( resolved.onError ?? ((e: unknown) => console.warn( - `[bugsee] in-build debug-ID stamping failed; falling back to stamping after emit: ${String(e)}`, + abandoned + ? `[bugsee] debug-IDs were NOT stamped, and stamping after emit would half-stamp this build: ${String(e)}` + : `[bugsee] in-build debug-ID stamping failed; falling back to stamping after emit: ${String(e)}`, )) )(error); + state = { preStamped: false, ...(abandoned ? { abandoned: true } : {}) }; } }, ); @@ -160,9 +232,13 @@ export function createNextWebpackPlugin( if (typeof outDir !== 'string' || outDir === '') { return; } + if (state.abandoned === true) { + return; + } const emitted: string[] = []; for (const { name } of compilation.getAssets()) { - const path = resolve(outDir, name); + // The file on disk has no `?query` (webpack drops it when it writes the file). + const path = resolve(outDir, withoutQuery(name)); if (await exists(path)) { emitted.push(path); } @@ -178,7 +254,10 @@ export function createNextWebpackPlugin( } await upload(forKind, outDir, { bundler: { isProduction: true, configuration: kind }, - preStamped, + preStamped: state.preStamped, + ...(state.preStamped && state.stampedBundles !== undefined + ? { stampedBundles: state.stampedBundles, stampedMaps: state.stampedMaps } + : {}), files, }); }); From 85a192ec4339480c41935ed090fc4eb97502296b Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 14:05:01 +0500 Subject: [PATCH 09/17] fix(nextjs): stamped webpack assets as STRING sources; raw define values; real-browser e2e - nextAssetStore.update writes a string source (RealContentHashPlugin only rewrites hashed names inside string sources: a Buffer left every lazy-chunk URL stale, ChunkLoadError); non-UTF-8 assets are not offered - compiler.define takes RAW values (Next JSON-encodes them): the baked version no longer arrives quoted - nextjs-e2e opens all four Next x bundler builds and the SRI builds in headless Chromium: lazy chunk loads and runs, no 4xx, no console errors, debug-ids registered - legacy /*@ */ stylesheet pointer test; CLAUDE.md and README notes Co-Authored-By: Claude Sonnet 5.5 --- CLAUDE.md | 1 + docs/PROGRESS.md | 2 +- packages/nextjs-e2e/package.json | 1 + packages/nextjs-e2e/test/source-maps.e2e.ts | 105 +++++++++++++++++- packages/nextjs/README.md | 1 + .../nextjs/src/config/build-files.test.ts | 4 + .../nextjs/src/config/webpack-plugin.test.ts | 44 +++++++- packages/nextjs/src/config/webpack-plugin.ts | 30 ++++- .../nextjs/src/config/with-bugsee.test.ts | 16 ++- packages/nextjs/src/config/with-bugsee.ts | 18 ++- pnpm-lock.yaml | 3 + 11 files changed, 211 insertions(+), 14 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index c0f47b62..cf56c8e4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -23,6 +23,7 @@ Runnable SDKs exist for **Node, Browser, Bun, Electron, Cloudflare/Vercel edge, - Electron platform: `@bugsee/electron` (`docs/design/electron.md`, slices E0–E8, convergent-reviewed) — converges main (Node/`@bugsee/node`) + renderers (Chromium/`@bugsee/browser`) + native (`crashReporter` minidumps) into ONE session. Main OWNS the session; renderers stream capture UP over IPC (reusing the WebView **streaming CaptureStore** core, extracted to `@bugsee/core`) and are driven DOWN via a control channel (session handshake + pause/resume/flush/stop). Native crashes via Electron's built-in `crashReporter` (Crashpad), session-correlated `extra` (no bespoke native SDK). Visual capture D8: **rrweb DOM-replay is the DEFAULT** (rides the renderer streaming path free); **opt-in pixel video** (`video:{source}`) is a permission-gated report-time snapshot source (added the mobile-canonical `video` FileType + a generic node `reportSnapshots`/`fileEncoders` forwarding seam) supporting capturePage + MediaRecorder. Entries: `.`/`./main`/`./renderer`/`./preload`. `electron`/DOM taken as injected args — the package has **no electron/DOM dependency**. - Extensions / umbrella: `@bugsee/performance` (APM — web-vitals + metric catalog, on-by-default via the umbrella) and `@bugsee/bugsee` (umbrella, with per-runtime browser/node `exports` conditions). - E2E: `@bugsee/instrumentation-tests` — boots the REAL SDK in real node/bun processes against a mock collector and asserts the uploaded bundle (`pnpm test:e2e`; not in `pnpm test`). +- Build integration (source maps): **`@bugsee/nextjs/config`** `withBugsee()` — webpack (per-compilation plugin) AND Turbopack (`compiler.runAfterProductionCompile`) upload, real-Next e2e in `@bugsee/nextjs-e2e` (`docs/design/source-maps.md` §7.3). - Framework adapters: the **per-request context foundation** (portable `RequestContext` + `ContextProvider` in core; `AsyncLocalStorage` binding in node, with `run` + `enterWith`; **correlation-by-tagging** — entries stamped with `contextId`/trace, reports merge the active context) + **`@bugsee/express`** (`requestHandler`/`errorHandler`/`setupExpress`) + **`@bugsee/fastify`** (hook-based `setupFastify`) + **`@bugsee/nestjs`** (`setupNest`: `enterWith` context middleware + a configurable error seam — default non-intrusive interceptor, opt-in global ExceptionFilter or `both` deduped; real-Nest e2e on express+fastify) + **`@bugsee/hono`/`elysia`/`hapi`/`koa`** (each structural-peer, per-framework error-capture probed before building; real-framework e2e) are built. (Restify was built then dropped — unmaintained, doesn't import on Node ≥18.) Plus **incoming-server auto-instrumentation** (`docs/design/incoming-server-instrumentation.md`): a **shared server-instrument core in `@bugsee/node`** (`server-instrument.ts` — plain values → `ServerRequestSpan`; `runServerRequest`/`openServerRequest`/split `openServerContext`+`startServerSpan`/`getActiveServerSpan`; **first-owner-wins re-entrancy** = one context + one `http.server` txn even when the http layer AND an adapter both run; only a `run`-scoped owner is refinable) auto-instruments incoming requests via the **`node:http` `Server.prototype.emit` patch** + native **`Bun.serve`** wraps, **ON BY DEFAULT** (`instrumentIncomingRequests`, default `true`; `false` opts out). **All 7 adapters were refactored onto this core** (each keeps its own `shouldReport`/route extraction). `@bugsee/server-adapters` was **retired** (engine absorbed; `openBugsee*`→`server*`). See `docs/design/framework-adapters.md` + `docs/design/incoming-server-instrumentation.md` (`generic-server-adapter.md` is superseded). - `launch(appToken, options)` returns the started client (every platform). diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 2213a235..c909a11c 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -1533,4 +1533,4 @@ Verified against current majors, all green with no adapter code changes: `@bugse `@bugsee/bundler-plugin-core` now stamps INSIDE the build wherever the bundler has a pre-write hook, so Subresource Integrity hashes taken later describe the stamped bytes: webpack 5 and **Rspack** at `PROCESS_ASSETS_STAGE_DEV_TOOLING + 1` (shared `tapProcessAssetsStamp`), **Vite and Rollup** in `generateBundle` (`order: 'pre'`; `rollupAssetStore` over chunks + `.map` assets; the stamped id is also put on `chunk.map` because Vite regenerates the map of a lazy-loading chunk after user hooks). esbuild and the standalone CLI stay post-emit with the SRI refusal (its message now names the workaround). Every stamp is verified (`verify-stamp.ts`: parses, sourceMappingURL intact, map debugId matches, original bytes + appended stamp): in-build all-or-nothing, post-emit snapshot + restore of the failing pair (`stamp-files.ts`); an in-build stamp is re-checked on disk (`verifyStampedPairs`) and against the HTML (`findIntegrityMismatches`). `.map` deletion now requires a confirmed upload AND a debugId on the map (`partitionByKeyed`). Real-build proof: `plugin.in-build.real-build.test.ts` (Vite 7 + 8, Rollup, Rspack with its built-in SRI plugin) and a Chromium run in `instrumentation-tests/test/sri-vite-rollup.e2e.ts`. Measured ordering limits and what the guards do not see: `docs/design/source-maps.md` §7.1. ### Next.js build integration: `withBugsee` (`@bugsee/nextjs/config`), webpack AND Turbopack (2026-11-23) -`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.0+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run. +`withBugsee(nextConfig, options)` makes `next build` stamp debug-IDs and upload source maps (gap #1 of the source-map gap analysis). Design + measured limits: `docs/design/source-maps.md` §7.3; user docs: `packages/nextjs/README.md`. **webpack** (`--webpack`, default <= 15): one per-compilation plugin (client, server, edge) stamping inside the compilation (`PROCESS_ASSETS_STAGE_DEV_TOOLING + 1`, SRI-safe) and uploading exactly the files that compilation emitted (`files` mode, nothing walks `.next`). The generic `@bugsee/webpack-plugin` was NOT reused for Next: measured against a real build it cannot stamp the server compilation (assets named `../app/page.js`, output path `.next/server/chunks`) and its directory-wide upload of `.next` collides across the three compilations. **Turbopack** (default 16; `--turbopack` 15.x): `compiler.runAfterProductionCompile` (15.4.0+) runs the real `inject` + upload over `.next/static` and `.next/server`, bundles paired with maps by the `sourceMappingURL` pointer (Turbopack does not name a map after its bundle; Next 15.5 shares one map between two runtime chunks, which are left unstamped with a notice). Measured limits: Turbopack writes the SRI hashes BEFORE the hook, so an `experimental.sri` Turbopack build is left unmodified with a notice (webpack handles SRI); Next 16 errors on a `webpack` function without a `turbopack` config, so none is added on Turbopack builds; `compiler.define` (not `defineServer`) bakes the app identity. Policy: browser maps deleted after a confirmed upload, server/edge maps kept (`deleteServerMaps`). Composes with a user's `webpack`, `compiler.runAfterProductionCompile`, `compiler.define`, `productionBrowserSourceMaps`, function/async configs; inert for dev/start/export. Core change: `@bugsee/bundler-plugin-core` now also exports `stampAssets`, `AssetStore`, `notify`, `resolveIdentity`, `loadBuildPluginEnv`, `mergeBuildPluginEnv`. Found by the independent reviews and fixed: stamped webpack assets are written as STRING sources (a Buffer is opaque to webpack's RealContentHashPlugin, which renames `[contenthash]` chunks after the stamp, so every lazy chunk 404'd; the e2e now opens each build in headless Chromium and asserts the lazy chunk runs), the baked define is the RAW value (Next JSON-encodes `compiler.define` itself; a JSON string arrived double-quoted), own-files-only deletion on Turbopack, contained post-build hook, version floors (hook 15.4.0, define 15.1.0), idempotent application. Real builds (`@bugsee/nextjs-e2e`, `test/source-maps.e2e.ts`, `next` 15.5.28 and 16.4.6 x webpack/Turbopack + SRI cases, real `bugsee-cli`, mock collector, `next start` smoke): see the PR for the run. diff --git a/packages/nextjs-e2e/package.json b/packages/nextjs-e2e/package.json index 97a674be..529d5513 100644 --- a/packages/nextjs-e2e/package.json +++ b/packages/nextjs-e2e/package.json @@ -15,6 +15,7 @@ "devDependencies": { "next": "^15.5.28", "next16": "npm:next@16.4.6", + "playwright": "^1.64.1", "react": "^18.3.1", "react-dom": "^18.3.1", "tsx": "4.23.15", diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts index fc71e427..b4af7490 100644 --- a/packages/nextjs-e2e/test/source-maps.e2e.ts +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -27,6 +27,7 @@ import { createServer, type Server } from 'node:http'; import { createRequire } from 'node:module'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; +import { type Browser, chromium } from 'playwright'; import { afterAll, beforeAll, describe, expect, it } from 'vitest'; const here = dirname(fileURLToPath(import.meta.url)); @@ -36,10 +37,12 @@ const require_ = createRequire(import.meta.url); const tsxLoader = join(dirname(require_.resolve('tsx/package.json')), 'dist', 'loader.mjs'); let server: Server; +let browser: Browser; let endpoint: string; const bodies: string[] = []; beforeAll(async () => { + browser = await chromium.launch({ headless: true }); rmSync(fixturesRoot, { recursive: true, force: true }); mkdirSync(fixturesRoot, { recursive: true }); // Every upload is answered "already have it", so it succeeds without a backend; the body is kept, so a test @@ -59,6 +62,7 @@ beforeAll(async () => { endpoint = `http://127.0.0.1:${(server.address() as { port: number }).port}`; }); afterAll(async () => { + await browser?.close(); await new Promise((r) => server.close(() => r())); // BUGSEE_E2E_KEEP=1 leaves the built fixtures behind for inspection. if (process.env.BUGSEE_E2E_KEEP === undefined) { @@ -146,7 +150,7 @@ async function build(spec: Spec): Promise { `'use client'; import { useState } from 'react'; import dynamic from 'next/dynamic'; -const Lazy = dynamic(() => import('./lazy/lazy.jsx')); +const Lazy = dynamic(() => import('./lazy/lazy.jsx'), { ssr: false }); const version = typeof __BUGSEE_APP_VERSION__ === 'undefined' ? 'none' : __BUGSEE_APP_VERSION__; export default function Page() { const [n, setN] = useState(0); @@ -156,7 +160,7 @@ export default function Page() { ); writeFileSync( join(dir, 'app', 'lazy', 'lazy.jsx'), - 'export default function Lazy() { return

lazy

; }\n', + 'export default function Lazy() { return

lazy-ok

; }\n', ); writeFileSync( join(dir, 'app', 'api', 'hi', 'route.js'), @@ -265,6 +269,96 @@ async function runBuild(dir: string, paths: string[]): Promise { } } +interface Page { + /** What the page printed to the console as an error, plus uncaught exceptions. */ + errors: string[]; + /** Same-origin requests that answered 4xx/5xx (the favicon is not the app's). */ + failed: string[]; + /** The text of the lazily loaded component, which renders only if its chunk loaded and ran. */ + lazy: string | null; + /** The text of the page after hydration. */ + body: string; + /** How many bundles registered a debug-id with the runtime (`globalThis._bugseeDebugIds`). */ + debugIds: number; + /** Next's error overlay / error page text, when it replaced the app. */ + crashed: boolean; +} + +/** `next start` the build and open `/` in headless Chromium: does the app, lazy chunk included, actually RUN? */ +async function openInBrowser(dir: string): Promise { + const port = 43000 + Math.floor(Math.random() * 2000); + const child: ChildProcess = spawn( + process.execPath, + [join(dir, 'node_modules', 'next', 'dist', 'bin', 'next'), 'start', '-p', String(port)], + { + cwd: dir, + env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1', NODE_OPTIONS: `--import ${tsxLoader}` }, + stdio: 'ignore', + }, + ); + const context = await browser.newContext(); + try { + const page = await context.newPage(); + const errors: string[] = []; + const failed: string[] = []; + page.on('console', (m) => { + if (m.type() === 'error' && !m.text().includes('favicon')) errors.push(m.text()); + }); + page.on('pageerror', (e) => errors.push(String(e))); + page.on('response', (r) => { + if (r.status() >= 400 && !r.url().includes('favicon')) + failed.push(`${r.status()} ${r.url()}`); + }); + let loaded = false; + for (let attempt = 0; attempt < 60 && !loaded; attempt++) { + try { + await page.goto(`http://127.0.0.1:${port}/`, { waitUntil: 'load' }); + loaded = true; + } catch { + await new Promise((r) => setTimeout(r, 500)); + } + } + expect(loaded, 'next start never answered').toBe(true); + // Hydrate, then give the lazy chunk its chance to load and run. + await page + .locator('button') + .first() + .click({ timeout: 15_000 }) + .catch(() => undefined); + await page.waitForSelector('#lazy', { timeout: 10_000 }).catch(() => undefined); + const body = await page.evaluate(() => document.body.innerText); + return { + errors, + failed, + lazy: await page + .locator('#lazy') + .textContent({ timeout: 1000 }) + .catch(() => null), + body, + debugIds: await page.evaluate( + () => + Object.keys((globalThis as { _bugseeDebugIds?: object })._bugseeDebugIds ?? {}).length, + ), + crashed: /Application error|This page couldn.t load|Unhandled Runtime Error/.test(body), + }; + } finally { + await context.close(); + child.kill('SIGKILL'); + } +} + +/** The assertions every build that was stamped must satisfy once it is OPEN in a browser. */ +function expectRuns(page: Page, options: { stamped: boolean }): void { + expect(page.failed, 'a request failed (a stale chunk URL 404s)').toEqual([]); + expect(page.errors).toEqual([]); + expect(page.crashed, page.body).toBe(false); + expect(page.lazy, 'the lazy chunk did not load and run').toBe('lazy-ok'); + expect(page.body).toContain('v9.8.7'); + if (options.stamped) { + expect(page.debugIds, 'no bundle registered a debug-id').toBeGreaterThan(0); + } +} + const MATRIX: Spec[] = [ { name: 'next15-webpack', next: 'next', args: [] }, { name: 'next15-turbopack', next: 'next', args: ['--turbopack'] }, @@ -351,6 +445,10 @@ describe.each(MATRIX)('withBugsee — real `next build` ($name)', (spec) => { it('produces a build that still runs', async () => { expect(await runBuild(built.dir, ['/', '/api/hi', '/edge'])).toEqual([200, 200, 200]); }); + + it('runs in a real browser: the lazy chunk loads and executes, debug-ids register, no errors', async () => { + expectRuns(await openInBrowser(built.dir), { stamped: true }); + }); }); describe('withBugsee — Subresource Integrity', () => { @@ -382,6 +480,8 @@ describe('withBugsee — Subresource Integrity', () => { expect(debugIdOf(file), `${src} was not stamped`).toBeDefined(); } expect(built.uploads.length).toBeGreaterThan(0); + // The browser enforces the hashes: the stamped, SRI-pinned page must still run, lazy chunk included. + expectRuns(await openInBrowser(built.dir), { stamped: true }); }); it('turbopack: leaves an SRI build exactly as Next wrote it, and says why', async () => { @@ -399,6 +499,7 @@ describe('withBugsee — Subresource Integrity', () => { for (const bundle of clientBundles(built.dir)) { expect(debugIdOf(bundle), bundle).toBeUndefined(); } + expectRuns(await openInBrowser(built.dir), { stamped: false }); }); }); diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index 59da6854..2887f3a2 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -110,6 +110,7 @@ Things to know: - `withBugsee` turns `productionBrowserSourceMaps` on, so the browser maps are written to `.next/static`, which is served publicly. They are deleted after a confirmed upload. If the upload fails (and `failOnError` is off) they stay there, publicly served, so you can retry. If that is not acceptable, set `failOnError: true` so a failed upload stops the build, or delete `.next/static/**/*.map` in your deploy step. - Next 15's Turbopack builds point two runtime chunks at one shared map. Those chunks are left unstamped and that map is neither uploaded nor deleted: it stays in `.next/static`, public. It contains Turbopack's runtime source, not your code. - `compiler.define` (the baked version and build) needs Next 15.1.0 or later; the Turbopack upload needs 15.4.0 or later. +- `@bugsee/nextjs` depends on `@bugsee/bundler-plugin-core` (which brings `@bugsee/cli`, acorn, magic-string and unplugin) so that `withBugsee` works with no extra install. Only `next.config` loads it; your app bundles never import it. Making it an optional peer would force every user of the config to install it by hand and break `next build` out of the box, so it stays a regular dependency. Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). diff --git a/packages/nextjs/src/config/build-files.test.ts b/packages/nextjs/src/config/build-files.test.ts index ad2b1b4d..f446dd1c 100644 --- a/packages/nextjs/src/config/build-files.test.ts +++ b/packages/nextjs/src/config/build-files.test.ts @@ -70,6 +70,10 @@ describe('mapPointerOf', () => { expect(mapPointerOf('/o/a.js', 'x\n/*# sourceMappingURL=a.js.map */')).toBeUndefined(); }); + it('reads the legacy /*@ */ stylesheet form too', () => { + expect(mapPointerOf('/o/a.css', 'a{}\n/*@ sourceMappingURL=x.css.map*/')).toBe('/o/x.css.map'); + }); + it('has no pointer for a bundle without a comment, or with an inline map', () => { expect(mapPointerOf('/o/a.js', 'no comment')).toBeUndefined(); expect( diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index 8d12f7aa..cbcb8d9c 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -7,8 +7,14 @@ import { type WebpackPluginDeps, } from './webpack-plugin'; +/** + * webpack-sources' RawSource, as far as it matters here: a STRING source is text webpack can still rewrite after + * the stamp (RealContentHashPlugin renames `[contenthash]` references in string sources only), a Buffer source is + * opaque to it. A stamp that hands a Buffer to `updateAsset` leaves lazy-chunk URLs pointing at files that were + * renamed afterwards (measured on real Next builds: ChunkLoadError), so the fake refuses one. + */ class RawSource { - constructor(readonly content: Buffer) {} + constructor(readonly content: string | Buffer) {} } type Processor = () => Promise; @@ -45,7 +51,11 @@ function fakeCompilation( } : undefined, updateAsset: vi.fn((name: string, source: unknown) => { - store.set(name, (source as RawSource).content); + const { content } = source as RawSource; + if (typeof content !== 'string') { + throw new Error(`${name}: a Buffer source cannot be rewritten by RealContentHashPlugin`); + } + store.set(name, Buffer.from(content, 'utf8')); }), }, }; @@ -398,6 +408,36 @@ describe('createNextWebpackPlugin', () => { }); }); +describe('nextAssetStore: sources webpack can still rewrite', () => { + it('updates an asset with a STRING source, never a Buffer', () => { + const { compilation, store } = fakeCompilation({ 'static/a.js': 'old' }); + const assets = nextAssetStore(compilation, RawSource); + assets.names(); + assets.update('static/a.js', Buffer.from('new \u00e9 text', 'utf8')); + expect(compilation.updateAsset).toHaveBeenCalledTimes(1); + const [, source] = compilation.updateAsset.mock.calls[0] as [string, RawSource]; + expect(source.content).toBe('new \u00e9 text'); + expect(store.get('static/a.js')?.toString('utf8')).toBe('new \u00e9 text'); + }); + + it('does not offer an asset whose bytes are not valid UTF-8 (a string source would corrupt it)', () => { + const { compilation, store } = fakeCompilation({ 'a.js': 'ok', 'b.js': 'x' }); + store.set('b.js', Buffer.from([0xff, 0xfe, 0x00, 0x80])); + expect(nextAssetStore(compilation, RawSource).names()).toEqual(['a.js']); + }); + + it('a bundle whose map cannot be offered refuses the whole stamp instead of half-stamping', async () => { + const { compilation, store } = fakeCompilation( + { 'a.js': 'x', 'a.js.map': 'm' }, + { 'a.js': 'a.js.map' }, + ); + store.set('a.js.map', Buffer.from([0xff, 0xfe])); + const assets = nextAssetStore(compilation, RawSource); + const { stampAssets } = await import('@bugsee/bundler-plugin-core'); + await expect(stampAssets(assets, { dryRun: true })).rejects.toThrow(); + }); +}); + describe('nextAssetStore: query-free names and moved maps', () => { it('presents names without their ?query and maps them back to the real asset', () => { const { compilation, store } = fakeCompilation({ diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index c4b035be..9e8e1014 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -56,7 +56,7 @@ export interface CompilerLike { interface WebpackApi { Compilation?: { PROCESS_ASSETS_STAGE_DEV_TOOLING?: number }; - sources?: { RawSource?: new (content: Buffer) => unknown }; + sources?: { RawSource?: new (content: string) => unknown }; } /** Seams for tests. */ @@ -97,6 +97,17 @@ async function fileExists(path: string): Promise { */ const withoutQuery = (name: string): string => name.replace(/\?.*$/, ''); +const strictUtf8 = new TextDecoder('utf-8', { fatal: true }); +/** Whether `bytes` are valid UTF-8 text (an asset with no content counts as text). */ +function isText(bytes: Buffer | undefined): boolean { + try { + strictUtf8.decode(bytes); + return true; + } catch { + return false; + } +} + /** A compilation's asset table as the core's {@link AssetStore}, plus the way back to real asset names. */ export interface NextAssetStore extends AssetStore { /** The real asset name behind a name this store presented. */ @@ -111,7 +122,7 @@ export interface NextAssetStore extends AssetStore { */ export function nextAssetStore( compilation: CompilationLike, - RawSource: new (content: Buffer) => unknown, + RawSource: new (content: string) => unknown, ): NextAssetStore { const up = (name: string): string => name.replace(/^(?:\.\.\/)+/, (dots) => `${UP}/`.repeat(dots.length / 3)); @@ -125,7 +136,14 @@ export function nextAssetStore( } for (const name of names) { const clean = up(withoutQuery(name)); - actual.set(counts.get(clean) === 1 ? clean : up(name), name); + // A string source cannot carry bytes that are not UTF-8 without corrupting them, so such an asset is not + // offered for stamping at all (a map that is not text refuses the whole stamp). + if (isText(compilation.getAsset(name)?.source.buffer())) { + actual.set(counts.get(clean) === 1 ? clean : up(name), name); + } else if (/\.map(\?|$)/.test(name)) { + // A map left out would leave its bundle stamped with an id the map never got. + throw new Error(`${name} is not valid UTF-8, so it cannot be stamped as text`); + } } }; const real = (name: string): string => actual.get(name) ?? name; @@ -135,7 +153,11 @@ export function nextAssetStore( return [...actual.keys()]; }, read: (name) => compilation.getAsset(real(name))?.source.buffer() ?? Buffer.alloc(0), - update: (name, content) => compilation.updateAsset(real(name), new RawSource(content)), + // A STRING source on purpose: the stamp runs before webpack's RealContentHashPlugin renames `[contenthash]` + // chunks, and that plugin rewrites the hashed names inside string sources only. A Buffer would keep the + // pre-rename chunk URLs (measured on real Next builds: every lazy chunk 404s, ChunkLoadError). + update: (name, content) => + compilation.updateAsset(real(name), new RawSource(content.toString('utf8'))), mapOf: (name) => { const related = compilation.getAsset(real(name))?.info?.related?.sourceMap; const map = Array.isArray(related) ? related[0] : related; diff --git a/packages/nextjs/src/config/with-bugsee.test.ts b/packages/nextjs/src/config/with-bugsee.test.ts index 7edd1257..5e4b8afc 100644 --- a/packages/nextjs/src/config/with-bugsee.test.ts +++ b/packages/nextjs/src/config/with-bugsee.test.ts @@ -98,19 +98,27 @@ describe('withBugsee: composition', () => { it('bakes the identity into compiler.define, the app’s own constants winning, never into defineServer', () => { const out = apply( { - compiler: { define: { __BUGSEE_APP_VERSION__: '"mine"', OTHER: '1' }, removeConsole: true }, + compiler: { define: { __BUGSEE_APP_VERSION__: 'mine', OTHER: '1' }, removeConsole: true }, }, deps(), ); expect(out.compiler.define).toEqual({ - __BUGSEE_APP_VERSION__: '"mine"', - __BUGSEE_APP_BUILD__: '"7"', + __BUGSEE_APP_VERSION__: 'mine', + __BUGSEE_APP_BUILD__: '7', OTHER: '1', }); expect(out.compiler.defineServer).toBeUndefined(); expect(out.compiler.removeConsole).toBe(true); }); + it('hands Next the RAW value: Next JSON-encodes every define itself (a JSON string would arrive quoted)', () => { + const out = apply( + {}, + deps(context({ identityDefines: { __BUGSEE_APP_VERSION__: '"a\\"b"', RAW: 'not json' } })), + ); + expect(out.compiler.define).toEqual({ __BUGSEE_APP_VERSION__: 'a"b', RAW: 'not json' }); + }); + it('adds no define when no identity was found', () => { expect(apply({}, deps(context({ identityDefines: {} }))).compiler).toBeUndefined(); }); @@ -278,7 +286,7 @@ describe('withBugsee: Turbopack', () => { expect(runPostBuild).toHaveBeenCalledWith(d.ctx, metadata); // The rest of `compiler`, and the baked identity, survive next to the hook. expect(out.compiler.removeConsole).toBe(true); - expect(out.compiler.define.__BUGSEE_APP_VERSION__).toBe('"1.0.0"'); + expect(out.compiler.define.__BUGSEE_APP_VERSION__).toBe('1.0.0'); }); it('works when the app has no hook of its own', async () => { diff --git a/packages/nextjs/src/config/with-bugsee.ts b/packages/nextjs/src/config/with-bugsee.ts index 3e4b29c1..1a7143ef 100644 --- a/packages/nextjs/src/config/with-bugsee.ts +++ b/packages/nextjs/src/config/with-bugsee.ts @@ -64,6 +64,16 @@ export function versionAtLeast(version: string, min: readonly [number, number, n return true; } +/** A JSON string literal as the string it denotes; anything else as written. */ +function unquote(value: string): string { + try { + const parsed: unknown = JSON.parse(value); + return typeof parsed === 'string' ? parsed : value; + } catch { + return value; + } +} + /** The `version` of the `next` installed for `projectDir`. */ function installedNextVersion(projectDir: string): string | undefined { try { @@ -105,7 +115,13 @@ function extendConfig( (nextVersion === undefined || versionAtLeast(nextVersion, MIN_COMPILER_DEFINE)) ) { const compiler: NextConfigObject = { ...(config.compiler ?? {}) }; - compiler.define = { ...identity, ...(config.compiler?.define ?? {}) }; + // The core hands over JSON string literals (`"1.2.3"`, what a bundler's DefinePlugin takes). Next JSON-encodes + // every `compiler.define` value itself (define-env.js serializeDefineEnv), so a JSON string would reach the + // bundle quoted twice: the raw value is what it wants (measured: `v"9.8.7"` in a real build). + const raw = Object.fromEntries( + Object.entries(identity).map(([key, value]) => [key, unquote(value)]), + ); + compiler.define = { ...raw, ...(config.compiler?.define ?? {}) }; next.compiler = compiler; } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a7ba719e..a65df190 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -974,6 +974,9 @@ importers: next16: specifier: npm:next@16.4.6 version: next@16.4.6(@babel/core@7.29.0)(@opentelemetry/api@1.10.0)(@types/node@22.20.5)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + playwright: + specifier: ^1.64.1 + version: 1.64.1 react: specifier: ^18.3.1 version: 18.3.1 From be09540cea5aacc4db31bdfd382582d6c93405d8 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 14:08:31 +0500 Subject: [PATCH 10/17] refactor(nextjs): use the core's store.check contract for non-text assets; raw-define test Co-Authored-By: Claude Sonnet 5.5 --- .../nextjs/src/config/webpack-plugin.test.ts | 25 ++++++++--------- packages/nextjs/src/config/webpack-plugin.ts | 27 +++++++++---------- .../nextjs/src/config/with-bugsee.test.ts | 12 +++++++-- 3 files changed, 35 insertions(+), 29 deletions(-) diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index cbcb8d9c..f0e4eac8 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -420,21 +420,22 @@ describe('nextAssetStore: sources webpack can still rewrite', () => { expect(store.get('static/a.js')?.toString('utf8')).toBe('new \u00e9 text'); }); - it('does not offer an asset whose bytes are not valid UTF-8 (a string source would corrupt it)', () => { - const { compilation, store } = fakeCompilation({ 'a.js': 'ok', 'b.js': 'x' }); - store.set('b.js', Buffer.from([0xff, 0xfe, 0x00, 0x80])); - expect(nextAssetStore(compilation, RawSource).names()).toEqual(['a.js']); + it('refuses bytes that are not valid UTF-8 up front (a string source would corrupt them)', () => { + const { compilation } = fakeCompilation({ 'a.js': 'ok' }); + const assets = nextAssetStore(compilation, RawSource); + expect(() => assets.check?.('a.js', Buffer.from([0xff, 0xfe, 0x00, 0x80]))).toThrow( + /not valid UTF-8/, + ); + expect(() => assets.update('a.js', Buffer.from([0xff, 0xfe]))).toThrow(/not valid UTF-8/); + expect(compilation.updateAsset).not.toHaveBeenCalled(); + expect(() => assets.check?.('a.js', Buffer.from('fine \u00e9'))).not.toThrow(); }); - it('a bundle whose map cannot be offered refuses the whole stamp instead of half-stamping', async () => { - const { compilation, store } = fakeCompilation( - { 'a.js': 'x', 'a.js.map': 'm' }, - { 'a.js': 'a.js.map' }, - ); - store.set('a.js.map', Buffer.from([0xff, 0xfe])); + it('keeps a byte-order mark instead of dropping it', () => { + const { compilation, store } = fakeCompilation({ 'b.js': 'y' }); const assets = nextAssetStore(compilation, RawSource); - const { stampAssets } = await import('@bugsee/bundler-plugin-core'); - await expect(stampAssets(assets, { dryRun: true })).rejects.toThrow(); + assets.update('b.js', Buffer.from('\ufeffwith bom')); + expect(store.get('b.js')?.toString('utf8')).toBe('\ufeffwith bom'); }); }); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index 9e8e1014..5950283a 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -97,14 +97,15 @@ async function fileExists(path: string): Promise { */ const withoutQuery = (name: string): string => name.replace(/\?.*$/, ''); -const strictUtf8 = new TextDecoder('utf-8', { fatal: true }); -/** Whether `bytes` are valid UTF-8 text (an asset with no content counts as text). */ -function isText(bytes: Buffer | undefined): boolean { +/** Strict, BOM-preserving UTF-8: a lenient decode would silently corrupt an asset. */ +const utf8 = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }); + +/** The text of an asset's bytes, or a refusal: bytes that are not valid UTF-8 never become a source. */ +function asText(name: string, content: Buffer): string { try { - strictUtf8.decode(bytes); - return true; + return utf8.decode(content); } catch { - return false; + throw new Error(`${name} is not valid UTF-8, so it cannot be stamped as a text source`); } } @@ -136,14 +137,7 @@ export function nextAssetStore( } for (const name of names) { const clean = up(withoutQuery(name)); - // A string source cannot carry bytes that are not UTF-8 without corrupting them, so such an asset is not - // offered for stamping at all (a map that is not text refuses the whole stamp). - if (isText(compilation.getAsset(name)?.source.buffer())) { - actual.set(counts.get(clean) === 1 ? clean : up(name), name); - } else if (/\.map(\?|$)/.test(name)) { - // A map left out would leave its bundle stamped with an id the map never got. - throw new Error(`${name} is not valid UTF-8, so it cannot be stamped as text`); - } + actual.set(counts.get(clean) === 1 ? clean : up(name), name); } }; const real = (name: string): string => actual.get(name) ?? name; @@ -156,8 +150,11 @@ export function nextAssetStore( // A STRING source on purpose: the stamp runs before webpack's RealContentHashPlugin renames `[contenthash]` // chunks, and that plugin rewrites the hashed names inside string sources only. A Buffer would keep the // pre-rename chunk URLs (measured on real Next builds: every lazy chunk 404s, ChunkLoadError). + // Asked by the stamp for every asset BEFORE anything is written, so a bad asset refuses the whole stamp + // instead of leaving half of it applied. + check: (name, content) => void asText(name, content), update: (name, content) => - compilation.updateAsset(real(name), new RawSource(content.toString('utf8'))), + compilation.updateAsset(real(name), new RawSource(asText(name, content))), mapOf: (name) => { const related = compilation.getAsset(real(name))?.info?.related?.sourceMap; const map = Array.isArray(related) ? related[0] : related; diff --git a/packages/nextjs/src/config/with-bugsee.test.ts b/packages/nextjs/src/config/with-bugsee.test.ts index 5e4b8afc..c827d151 100644 --- a/packages/nextjs/src/config/with-bugsee.test.ts +++ b/packages/nextjs/src/config/with-bugsee.test.ts @@ -114,9 +114,17 @@ describe('withBugsee: composition', () => { it('hands Next the RAW value: Next JSON-encodes every define itself (a JSON string would arrive quoted)', () => { const out = apply( {}, - deps(context({ identityDefines: { __BUGSEE_APP_VERSION__: '"a\\"b"', RAW: 'not json' } })), + deps( + context({ + identityDefines: { __BUGSEE_APP_VERSION__: '"a\\"b"', RAW: 'not json', NUM: '42' }, + }), + ), ); - expect(out.compiler.define).toEqual({ __BUGSEE_APP_VERSION__: 'a"b', RAW: 'not json' }); + expect(out.compiler.define).toEqual({ + __BUGSEE_APP_VERSION__: 'a"b', + RAW: 'not json', + NUM: '42', + }); }); it('adds no define when no identity was found', () => { From 3869cc7fc259873d9eff896c6f36a8668a25c4b2 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 16:17:12 +0500 Subject: [PATCH 11/17] fix(nextjs): SRI fallback guard, no public maps when no upload is possible, once-per-build notices, packed-dist check - webpack: a failed in-build stamp does not fall back to stamping the written files of an SRI build (experimental.sri or Next's integrity manifest): nothing rewritten, nothing uploaded, notice - productionBrowserSourceMaps is forced on only when this build can upload (not Turbopack + SRI, not Turbopack < 15.4.0); otherwise the app's setting stands and the notice says maps may be public - notices are said once per next build across Next's processes (env marker) - real builds: SRI-webpack fallback (stub CLI refuses only the in-build inject), Turbopack+SRI has no static maps; packed tarballs load through require() and import() - docs: an async webpack function is rejected by Next itself Co-Authored-By: Claude Sonnet 5.5 --- docs/design/source-maps.md | 4 +- packages/nextjs-e2e/test/packed-config.e2e.ts | 115 ++++++++++++++++++ packages/nextjs-e2e/test/source-maps.e2e.ts | 54 +++++++- packages/nextjs/README.md | 6 +- packages/nextjs/src/config/context.test.ts | 19 +++ packages/nextjs/src/config/context.ts | 27 +++- packages/nextjs/src/config/post-build.test.ts | 9 ++ packages/nextjs/src/config/post-build.ts | 21 +--- packages/nextjs/src/config/sri.test.ts | 33 +++++ packages/nextjs/src/config/sri.ts | 53 ++++++++ .../nextjs/src/config/webpack-plugin.test.ts | 48 ++++++++ packages/nextjs/src/config/webpack-plugin.ts | 11 ++ .../src/config/with-bugsee.kind.test.ts | 20 ++- .../nextjs/src/config/with-bugsee.test.ts | 45 +++++++ packages/nextjs/src/config/with-bugsee.ts | 25 ++-- 15 files changed, 454 insertions(+), 36 deletions(-) create mode 100644 packages/nextjs-e2e/test/packed-config.e2e.ts create mode 100644 packages/nextjs/src/config/sri.test.ts create mode 100644 packages/nextjs/src/config/sri.ts diff --git a/docs/design/source-maps.md b/docs/design/source-maps.md index 59aa6a50..b4a69681 100644 --- a/docs/design/source-maps.md +++ b/docs/design/source-maps.md @@ -514,7 +514,9 @@ measured). Only bundles that have a map are stamped on Turbopack, and bundles ar A map carries one debug-ID (the hash of bundle + map), so such bundles are left unstamped (a notice counts them) and their shared map stays on disk, unuploaded; they are Turbopack's runtime, not the app. -**Composition.** The app's `webpack` function runs first (sync or async) and its result is extended; its +**SRI fallback guard.** A webpack in-build stamp that failed falls back (core) to stamping the written files; on an SRI build that rewrites bytes Next already pinned (measured: Chromium blocked every script). The per-compilation plugin therefore skips the fallback and the upload when `experimental.sri` is set or Next's integrity manifest sits next to the output (`sri.ts`, shared with the Turbopack step), with a notice. `productionBrowserSourceMaps` is forced on only when this build can upload (not Turbopack + SRI, not Turbopack < 15.4.0), so an upload that cannot happen never leaves Bugsee-requested public maps. Notices are said once per `next build` across Next's processes (`__BUGSEE_NOTICED` in the environment). + +**Composition.** The app's `webpack` function runs first and its result is extended (Next itself rejects an async one, measured on 16.4.6); its `compiler.runAfterProductionCompile` runs before ours; its `compiler.define` keys win; `productionBrowserSourceMaps` is respected when set. Without a token the integration changes nothing Next emits. diff --git a/packages/nextjs-e2e/test/packed-config.e2e.ts b/packages/nextjs-e2e/test/packed-config.e2e.ts new file mode 100644 index 00000000..044a84a7 --- /dev/null +++ b/packages/nextjs-e2e/test/packed-config.e2e.ts @@ -0,0 +1,115 @@ +// The PUBLISHED shape of `@bugsee/nextjs/config`: packs `@bugsee/nextjs` and every workspace package it depends on +// (pnpm applies each `publishConfig`, so `exports` point at `dist`), unpacks them as an app's node_modules, and +// loads the config entry the way a real next.config does: `require()` from a CJS `next.config.js` and `import` from +// an ESM `next.config.mjs`. In the repo everything resolves to `src`, so this is the only check of the dual build. +import { execFileSync } from 'node:child_process'; +import { + existsSync, + mkdirSync, + mkdtempSync, + readdirSync, + readFileSync, + rmSync, + symlinkSync, + writeFileSync, +} from 'node:fs'; +import { tmpdir } from 'node:os'; +import { dirname, join } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { afterAll, beforeAll, describe, expect, it } from 'vitest'; + +const repo = join(dirname(fileURLToPath(import.meta.url)), '..', '..', '..'); +const packages = join(repo, 'packages'); +let app: string; + +/** `@bugsee/*` workspace packages reachable from `name` through `dependencies`, `name` included. */ +function workspaceClosure(name: string, seen = new Map()): Map { + const dir = join(packages, name.replace('@bugsee/', '')); + if (seen.has(name)) return seen; + seen.set(name, dir); + const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')) as { + dependencies?: Record; + }; + for (const [dep, range] of Object.entries(manifest.dependencies ?? {})) { + if (range.startsWith('workspace:')) workspaceClosure(dep, seen); + } + return seen; +} + +beforeAll(() => { + const closure = workspaceClosure('@bugsee/nextjs'); + const filters = [...closure.keys()].flatMap((n) => ['--filter', n]); + execFileSync('pnpm', ['--dir', repo, ...filters, 'run', '--if-present', 'build'], { + stdio: 'ignore', + }); + app = mkdtempSync(join(tmpdir(), 'bugsee-packed-')); + const modules = join(app, 'node_modules'); + mkdirSync(join(modules, '@bugsee'), { recursive: true }); + // Third-party dependencies: whatever the monorepo installed (pnpm's flat virtual-store directory). + const flat = join(repo, 'node_modules', '.pnpm', 'node_modules'); + for (const entry of readdirSync(flat)) { + if (entry === '@bugsee') continue; + symlinkSync(join(flat, entry), join(modules, entry)); + } + for (const [name, dir] of closure) { + const target = join(modules, name); + mkdirSync(target, { recursive: true }); + const out = mkdtempSync(join(tmpdir(), 'bugsee-pack-')); + execFileSync('pnpm', ['pack', '--pack-destination', out], { cwd: dir, stdio: 'ignore' }); + const tarball = join(out, readdirSync(out)[0] as string); + execFileSync('tar', ['-xzf', tarball, '-C', target, '--strip-components=1']); + rmSync(out, { recursive: true, force: true }); + } + writeFileSync(join(app, 'package.json'), JSON.stringify({ name: 'app', version: '3.2.1' })); +}, 600_000); + +afterAll(() => { + if (app) rmSync(app, { recursive: true, force: true }); +}); + +const probe = ` + const out = withBugsee({ reactStrictMode: true }, { appToken: 't', vcs: false }); + console.log(JSON.stringify({ + kind: typeof withBugsee, + strict: out.reactStrictMode, + maps: out.productionBrowserSourceMaps, + version: out.compiler && out.compiler.define && out.compiler.define.__BUGSEE_APP_VERSION__, + })); +`; +const expected = { kind: 'function', strict: true, maps: true, version: '3.2.1' }; + +describe('the published @bugsee/nextjs/config', () => { + it('exports map to dist, with an import and a require build', () => { + const manifest = JSON.parse( + readFileSync(join(app, 'node_modules', '@bugsee', 'nextjs', 'package.json'), 'utf8'), + ) as { exports: Record }; + const entry = manifest.exports['./config']; + expect(entry?.require.default).toBe('./dist/config.cjs'); + expect(entry?.import.default).toBe('./dist/config.js'); + for (const file of [entry?.require.default, entry?.import.default]) { + expect(existsSync(join(app, 'node_modules', '@bugsee', 'nextjs', file as string))).toBe(true); + } + }); + + it('works from a CommonJS next.config.js (require)', () => { + const out = execFileSync( + process.execPath, + ['-e', `const { withBugsee } = require('@bugsee/nextjs/config');${probe}`], + { cwd: app, encoding: 'utf8', env: { ...process.env, TURBOPACK: '' } }, + ); + expect(JSON.parse(out.trim().split('\n').pop() as string)).toEqual(expected); + }); + + it('works from an ESM next.config.mjs (import)', () => { + writeFileSync( + join(app, 'probe.mjs'), + `import { withBugsee } from '@bugsee/nextjs/config';${probe}`, + ); + const out = execFileSync(process.execPath, ['probe.mjs'], { + cwd: app, + encoding: 'utf8', + env: { ...process.env, TURBOPACK: '' }, + }); + expect(JSON.parse(out.trim().split('\n').pop() as string)).toEqual(expected); + }); +}); diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts index b4af7490..fbd72b7c 100644 --- a/packages/nextjs-e2e/test/source-maps.e2e.ts +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -80,8 +80,17 @@ interface Spec { nextConfig?: string; /** Pre-seed FOREIGN source-map files (stylesheet and declaration maps nothing in this build produced). */ seedForeign?: boolean; + /** Make `bugsee-cli sourcemaps inject` fail for the IN-BUILD stamp only (the post-emit one reaches the real CLI). */ + failInBuildStamp?: boolean; } +/** The real bugsee-cli binary, as the core resolves it. */ +const realCli = ( + createRequire(join(pkgDir, '..', 'bundler-plugin-core', 'package.json'))('@bugsee/cli') as { + binaryPath(): string; + } +).binaryPath(); + /** Where the foreign files are written, relative to the dist dir, and what they contain. */ const FOREIGN = [ ['static', 'foreign.css.map'], @@ -180,6 +189,20 @@ export default withBugsee( ); `, ); + const stub = join(dir, 'cli-stub.js'); + if (spec.failInBuildStamp) { + writeFileSync( + stub, + `const { spawnSync } = require('node:child_process'); +const args = process.argv.slice(2); +if (args[0] === 'sourcemaps' && args[1] === 'inject' && String(args[2]).includes('bugsee-stamp-')) { + process.stderr.write('stub: the in-build inject is refused\\n'); + process.exit(11); +} +process.exit(spawnSync(${JSON.stringify(realCli)}, args, { stdio: 'inherit' }).status ?? 1); +`, + ); + } const before = bodies.length; // Asynchronous on purpose: the mock collector lives in THIS process, and a blocking spawn would starve it. const child = spawn( @@ -187,7 +210,12 @@ export default withBugsee( [join(modules, 'next', 'dist', 'bin', 'next'), 'build', ...spec.args], { cwd: dir, - env: { ...process.env, NEXT_TELEMETRY_DISABLED: '1', NODE_OPTIONS: `--import ${tsxLoader}` }, + env: { + ...process.env, + NEXT_TELEMETRY_DISABLED: '1', + NODE_OPTIONS: `--import ${tsxLoader}`, + ...(spec.failInBuildStamp ? { BUGSEE_CLI_PATH: stub } : {}), + }, }, ); let log = ''; @@ -500,6 +528,30 @@ describe('withBugsee — Subresource Integrity', () => { expect(debugIdOf(bundle), bundle).toBeUndefined(); } expectRuns(await openInBrowser(built.dir), { stamped: false }); + // Bugsee did not turn browser maps on for a build it cannot upload for: none are written, none are public. + expect(maps(join(built.dir, '.next', 'static'))).toEqual([]); + }); + + it('webpack: a failed in-build stamp does NOT fall back to stamping the written files of an SRI build', async () => { + const built = await build({ + name: 'sri-webpack-fallback', + next: 'next16', + args: ['--webpack'], + options: 'failOnError: false,', + nextConfig: "experimental: { sri: { algorithm: 'sha256' } },", + failInBuildStamp: true, + }); + expect(built.status, built.log.split('\n').slice(-40).join('\n')).toBe(0); + expect(built.log).toMatch(/falling back to stamping after emit/); + expect(built.log).toMatch(/stamping after emit.*was skipped/s); + expect(built.uploads).toEqual([]); + // Nothing was rewritten, so the pinned hashes still describe the bytes on disk and the page runs. + for (const bundle of walk(join(built.dir, '.next', 'static')).filter((f) => + f.endsWith('.js'), + )) { + expect(debugIdOf(bundle), bundle).toBeUndefined(); + } + expectRuns(await openInBrowser(built.dir), { stamped: false }); }); }); diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index 2887f3a2..9f9744b4 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -86,13 +86,13 @@ CommonJS works as well: `const { withBugsee } = require("@bugsee/nextjs/config") What it does, for a production build: -- Turns on `productionBrowserSourceMaps` (only when you did not set it) so the browser bundles have maps to upload. +- Turns on `productionBrowserSourceMaps` (only when you did not set it, and only when this build can actually upload: not for Turbopack with `experimental.sri`, not for Turbopack on Next older than 15.4.0) so the browser bundles have maps to upload. Where it cannot upload it leaves the option as you set it and says so. - **webpack**: adds one Bugsee plugin to each of the client, server and edge compilations. Each stamps a debug ID into its bundles inside the build (before Subresource Integrity hashes are taken) and, after emit, uploads the maps of exactly the files that compilation wrote. - **Turbopack**: has no plugin API, so the upload runs from Next's `compiler.runAfterProductionCompile` hook (Next 15.4.0 or later): after Turbopack wrote `.next` and before Next generates the static pages, it stamps the written bundles with the real `bugsee-cli sourcemaps inject` (verified, and undone if a stamp does not verify), uploads the maps and removes them. - Deletes the browser maps (`.next/static/**/*.map`, which `next start` and CDNs serve publicly) after a confirmed upload. Server and edge maps stay on disk (`deleteServerMaps` to remove them). - Bakes `appVersion` / `appBuild` into every bundle (`compiler.define`) for the runtime SDK. -Your own config is kept: your `webpack` function runs first (sync or async) and its result is extended, your `compiler.runAfterProductionCompile` runs before ours, `compiler.define` keys you set win, and `productionBrowserSourceMaps: false` is respected. `next dev`, `next start` and `next export` are not touched. +Your own config is kept: your `webpack` function runs first and its result is extended (Next itself needs a synchronous `webpack` function; an async one fails in Next 16), your `compiler.runAfterProductionCompile` runs before ours, `compiler.define` keys you set win, and `productionBrowserSourceMaps: false` is respected. `next dev`, `next start` and `next export` are not touched. Options are those of the Bugsee bundler plugins (`appToken`, `appVersion`, `appBuild`, `endpoint`, `deleteMaps`, `dryRun`, `failOnError`, `stripSourcesContent`, `disabled`, `vcs`, `commit`, `registerBuild`, `onError`, `onNotice`, see `@bugsee/webpack-plugin`), plus: @@ -112,7 +112,7 @@ Things to know: - `compiler.define` (the baked version and build) needs Next 15.1.0 or later; the Turbopack upload needs 15.4.0 or later. - `@bugsee/nextjs` depends on `@bugsee/bundler-plugin-core` (which brings `@bugsee/cli`, acorn, magic-string and unplugin) so that `withBugsee` works with no extra install. Only `next.config` loads it; your app bundles never import it. Making it an optional peer would force every user of the config to install it by hand and break `next build` out of the box, so it stays a regular dependency. -Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). +Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). On webpack with `experimental.sri`, if the in-build stamp itself fails, the fallback of stamping the written files is skipped (it would invalidate the pinned hashes) and nothing is uploaded for that compilation, with a notice; the browser maps then stay in `.next/static`, publicly served. ## Options diff --git a/packages/nextjs/src/config/context.test.ts b/packages/nextjs/src/config/context.test.ts index 0c12eb8b..a169143d 100644 --- a/packages/nextjs/src/config/context.test.ts +++ b/packages/nextjs/src/config/context.test.ts @@ -130,4 +130,23 @@ describe('createBugseeContext', () => { expect(createBugseeContext({}, dir).resolved.appToken).toBe('ambient'); vi.unstubAllEnvs(); }); + + it('says a notice once across processes that share the environment (Next loads the config in workers)', () => { + const env: Record = {}; + const seen: string[] = []; + const make = () => createBugseeContext({ onNotice: (m) => seen.push(m) }, dir, { env }); + make().say('only once'); + make().say('only once'); + make().say('but this is new'); + expect(seen).toEqual(['[bugsee] only once', '[bugsee] but this is new']); + }); + + it('does not use up a notice that was silenced', () => { + const env: Record = {}; + createBugseeContext({ silent: true }, dir, { env }).say('quiet'); + expect(env.__BUGSEE_NOTICED).toBeUndefined(); + const seen: string[] = []; + createBugseeContext({ onNotice: (m) => seen.push(m) }, dir, { env }).say('quiet'); + expect(seen).toEqual(['[bugsee] quiet']); + }); }); diff --git a/packages/nextjs/src/config/context.ts b/packages/nextjs/src/config/context.ts index 6f6fc348..f04ed725 100644 --- a/packages/nextjs/src/config/context.ts +++ b/packages/nextjs/src/config/context.ts @@ -44,6 +44,8 @@ export interface BugseeNextContext { serverSourceMaps: boolean; /** Whether server/edge maps are deleted after a confirmed upload. */ deleteServerMaps: boolean; + /** The app uses `experimental.sri` (set by `withBugsee` from the Next config it wraps). */ + sri?: boolean; /** A notice said once per distinct text (a no-op when `silent`). */ say(message: string): void; } @@ -53,12 +55,22 @@ export interface ContextDeps { env?: Record; } +/** A short stable key for a notice text (djb2). */ +function noticeKey(text: string): string { + let hash = 5381; + for (const char of text) { + hash = ((hash << 5) + hash + char.charCodeAt(0)) | 0; + } + return (hash >>> 0).toString(36); +} + /** Resolve the integration's context for `projectDir`. Never throws. */ export function createBugseeContext( options: WithBugseeOptions, projectDir: string, deps: ContextDeps = {}, ): BugseeNextContext { + const env = deps.env ?? process.env; const said = new Set(); // `text` already carries the `[bugsee]` prefix: that is what the core hands an `onNotice` sink. const emit = (text: string): void => { @@ -66,6 +78,15 @@ export function createBugseeContext( return; } said.add(text); + // Next loads the config in more than one process (the main one and its build workers), so the same notice + // would print once per process. The environment is inherited by the workers it spawns afterwards, so it + // carries "already said" across them. + const key = noticeKey(text); + const seen = (env.__BUGSEE_NOTICED ?? '').split(','); + if (seen.includes(key)) { + return; + } + env.__BUGSEE_NOTICED = [...seen.filter(Boolean), key].join(','); try { (options.onNotice ?? console.warn)(text); } catch { @@ -78,9 +99,9 @@ export function createBugseeContext( if (problem !== undefined) { sink(problem); } - const env = mergeBuildPluginEnv(deps.env ?? process.env, values); - const base = resolvePluginOptions(options, env); - const identity = resolveIdentity(options, env, projectDir); + const merged = mergeBuildPluginEnv(env, values); + const base = resolvePluginOptions(options, merged); + const identity = resolveIdentity(options, merged, projectDir); return { resolved: { ...base, diff --git a/packages/nextjs/src/config/post-build.test.ts b/packages/nextjs/src/config/post-build.test.ts index 97513996..6e98a420 100644 --- a/packages/nextjs/src/config/post-build.test.ts +++ b/packages/nextjs/src/config/post-build.test.ts @@ -133,6 +133,15 @@ describe('runPostBuild', () => { expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('Subresource Integrity')); }); + it('leaves the build alone, without looking at the disk, when the config says SRI', async () => { + const ctx = context({}, { sri: true }); + const d = deps({ '/app/.next/static': files('c') }); + await runPostBuild(ctx, metadata, d); + expect(d.exists).not.toHaveBeenCalled(); + expect(d.upload).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('publicly served')); + }); + it('uses the real upload, collector and filesystem when none are injected', async () => { const ctx = context(); // Nothing exists under this directory: no SRI manifest, no files, so no upload, only the notice. diff --git a/packages/nextjs/src/config/post-build.ts b/packages/nextjs/src/config/post-build.ts index 4c79b259..70df4351 100644 --- a/packages/nextjs/src/config/post-build.ts +++ b/packages/nextjs/src/config/post-build.ts @@ -8,11 +8,11 @@ // hashes BEFORE this hook runs (measured, Next 16.4.6: appending a byte to a chunk in the hook makes every // `integrity` the page carries wrong), so stamping afterwards would ship a page whose scripts the browser // refuses to run. That build is left exactly as Next wrote it, and the notice says why. -import { stat } from 'node:fs/promises'; import { join, resolve } from 'node:path'; import { type ResolvedPluginOptions, runPluginUpload } from '@bugsee/bundler-plugin-core'; import { type BuildFiles, collectBuildFiles } from './build-files'; import type { BugseeNextContext } from './context'; +import { isFile, SRI_MANIFEST, TURBOPACK_SRI_NOTICE } from './sri'; /** What Next hands `compiler.runAfterProductionCompile`. */ export interface PostBuildMetadata { @@ -27,17 +27,6 @@ export interface PostBuildDeps { exists?: (path: string) => Promise; } -async function fileExists(path: string): Promise { - try { - return (await stat(path)).isFile(); - } catch { - return false; - } -} - -/** Where Next records the integrity hashes it pinned (`experimental.sri`). */ -const SRI_MANIFEST = join('server', 'subresource-integrity-manifest.json'); - /** Stamp, upload and delete for a finished Turbopack build. Skips (and says why) when it cannot be done safely. */ export async function runPostBuild( context: BugseeNextContext, @@ -71,13 +60,11 @@ async function postBuild( const { resolved } = context; const upload = deps.upload ?? runPluginUpload; const collect = deps.collect ?? collectBuildFiles; - const exists = deps.exists ?? fileExists; + const exists = deps.exists ?? isFile; const distDir = resolve(metadata.projectDir, metadata.distDir); - if (await exists(join(distDir, SRI_MANIFEST))) { - context.say( - 'this build uses Subresource Integrity (`experimental.sri`). Turbopack hashes its output before the post-build hook runs, so stamping debug-IDs now would make the browser refuse the scripts. Source maps were NOT uploaded and the build was left unmodified. Build with `next build --webpack` to upload source maps for an SRI build.', - ); + if (context.sri === true || (await exists(join(distDir, SRI_MANIFEST)))) { + context.say(TURBOPACK_SRI_NOTICE); return; } diff --git a/packages/nextjs/src/config/sri.test.ts b/packages/nextjs/src/config/sri.test.ts new file mode 100644 index 00000000..b056eb45 --- /dev/null +++ b/packages/nextjs/src/config/sri.test.ts @@ -0,0 +1,33 @@ +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; +import { describe, expect, it } from 'vitest'; +import { isFile, SRI_MANIFEST, sriManifestNear } from './sri'; + +describe('sriManifestNear', () => { + const only = (path: string) => async (candidate: string) => candidate === path; + + it('finds the manifest from the client, server and edge output directories', async () => { + expect(await sriManifestNear('/o/.next', only(`/o/.next/${SRI_MANIFEST}`))).toBe(true); + const server = '/o/.next/server/subresource-integrity-manifest.json'; + expect(await sriManifestNear('/o/.next/server/chunks', only(server))).toBe(true); + expect(await sriManifestNear('/o/.next/server', only(server))).toBe(true); + }); + + it('finds nothing when there is none', async () => { + expect(await sriManifestNear('/o/.next', async () => false)).toBe(false); + }); + + it('looks on the real disk by default', async () => { + const dir = mkdtempSync(join(tmpdir(), 'bugsee-sri-')); + try { + expect(await sriManifestNear(dir)).toBe(false); + mkdirSync(join(dir, 'server')); + writeFileSync(join(dir, SRI_MANIFEST), '{}'); + expect(await sriManifestNear(dir)).toBe(true); + expect(await isFile(join(dir, 'server'))).toBe(false); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); +}); diff --git a/packages/nextjs/src/config/sri.ts b/packages/nextjs/src/config/sri.ts new file mode 100644 index 00000000..f499ff8a --- /dev/null +++ b/packages/nextjs/src/config/sri.ts @@ -0,0 +1,53 @@ +// Subresource Integrity (`experimental.sri`) and what stamping may do about it, in one place. +// +// Turbopack hashes its output BEFORE the post-build hook runs, so stamping afterwards breaks the page (measured: +// every `integrity` wrong). webpack stamps inside the compilation, before anything hashes, so a stamp that took is +// safe; but a stamp that FAILED and falls back to stamping after emit is not (measured on Next 16.4.6 --webpack: +// the fallback rewrote real bundles and Chromium blocked every script, "Failed to find a valid digest"). The core's +// own SRI scan only sees HTML under the output directory, and Next keeps the integrity manifest elsewhere. +import { stat } from 'node:fs/promises'; +import { dirname, join } from 'node:path'; + +/** Where Next records the integrity hashes it pinned, relative to the dist directory. */ +export const SRI_MANIFEST = join('server', 'subresource-integrity-manifest.json'); + +/** Whether a path is an existing file. */ +export async function isFile(path: string): Promise { + try { + return (await stat(path)).isFile(); + } catch { + return false; + } +} + +/** Whether an integrity manifest sits next to a webpack compilation's output (client `.next`, server `.next/server/chunks`, edge `.next/server`). */ +export async function sriManifestNear( + outDir: string, + exists: (path: string) => Promise = isFile, +): Promise { + const name = 'subresource-integrity-manifest.json'; + for (const candidate of [ + join(outDir, SRI_MANIFEST), + join(outDir, name), + join(dirname(outDir), name), + ]) { + if (await exists(candidate)) { + return true; + } + } + return false; +} + +const PUBLIC_MAPS = + 'Browser source maps, if Next emits any (`productionBrowserSourceMaps`), stay in `.next/static` and are publicly served.'; + +/** Turbopack + SRI: not stampable, so nothing is uploaded. */ +export const TURBOPACK_SRI_NOTICE = `this build uses Subresource Integrity (\`experimental.sri\`). Turbopack hashes its output before the post-build hook runs, so stamping debug-IDs now would make the browser refuse the scripts. Source maps were NOT uploaded and the build was left unmodified. Build with \`next build --webpack\` to upload source maps for an SRI build. ${PUBLIC_MAPS}`; + +/** A webpack in-build stamp failed on an SRI build: the post-emit fallback would break the page. */ +export const FALLBACK_SRI_NOTICE = (kind: string): string => + `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp did not apply, so stamping after emit (which would invalidate the pinned hashes and make the browser refuse the scripts) was skipped. Source maps were NOT uploaded for it. ${PUBLIC_MAPS}`; + +/** Turbopack on a Next without the post-build hook. */ +export const NO_HOOK_NOTICE = (version: string): string => + `Next ${version} builds with Turbopack but has no post-build hook to upload from; source maps were NOT uploaded. Upgrade to Next 15.4.0 or later, or build with webpack. Bugsee did not turn browser source maps on for this build.`; diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index f0e4eac8..556be0b2 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -118,6 +118,7 @@ const deps = (over: WebpackPluginDeps = {}): WebpackPluginDeps => ({ stamp: vi.fn(async () => ({ stamped: [], maps: {}, bundles: 1 })), upload: vi.fn(async () => undefined), exists: vi.fn(async () => true), + hasSriManifest: vi.fn(async () => false), ...over, }); @@ -605,3 +606,50 @@ describe('createNextWebpackPlugin: the new core contract', () => { expect(seen).toEqual(['/out/.next/static/a.js', '/out/.next/static/a.js.map']); }); }); + +describe('createNextWebpackPlugin: the post-emit fallback on an SRI build', () => { + const failing = () => + vi.fn(async () => { + throw new Error('inject broke'); + }); + const run = async (ctx: BugseeNextContext, d: WebpackPluginDeps) => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const fake = fakeCompiler(); + createNextWebpackPlugin(ctx, 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + warn.mockRestore(); + }; + + it('does not stamp the written files when the app uses SRI (the config says so)', async () => { + const ctx = context({}, { sri: true }); + const d = deps({ stamp: failing() }); + await run(ctx, d); + expect(d.upload).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('Subresource Integrity')); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('client build')); + }); + + it('nor when Next\u2019s integrity manifest sits next to the output', async () => { + const ctx = context(); + const d = deps({ stamp: failing(), hasSriManifest: vi.fn(async () => true) }); + await run(ctx, d); + expect(d.upload).not.toHaveBeenCalled(); + expect(d.hasSriManifest).toHaveBeenCalledWith('/out/.next/server/chunks'); + }); + + it('still falls back without SRI', async () => { + const d = deps({ stamp: failing() }); + await run(context(), d); + expect(d.upload).toHaveBeenCalledTimes(1); + }); + + it('uploads a stamp that took, SRI or not (it ran before anything hashed)', async () => { + const d = deps(); + await run(context({}, { sri: true }), d); + expect(d.upload).toHaveBeenCalledTimes(1); + expect(d.hasSriManifest).not.toHaveBeenCalled(); + }); +}); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index 5950283a..60d9168c 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -19,6 +19,7 @@ import { } from '@bugsee/bundler-plugin-core'; import { type BuildFiles, partitionBuildFiles } from './build-files'; import type { BugseeNextContext } from './context'; +import { FALLBACK_SRI_NOTICE, sriManifestNear } from './sri'; /** Which of Next's three webpack compilations a plugin instance serves. */ export type NextCompilationKind = 'client' | 'server' | 'edge'; @@ -65,6 +66,8 @@ export interface WebpackPluginDeps { upload?: typeof runPluginUpload; /** Whether a path exists on disk (default `fs.stat`). */ exists?: (path: string) => Promise; + /** Whether Next's integrity manifest sits next to this output (default: looks on disk). */ + hasSriManifest?: (outDir: string) => Promise; } const PLUGIN = 'bugsee-next'; @@ -173,6 +176,7 @@ export function createNextWebpackPlugin( const stamp = deps.stamp ?? stampAssets; const upload = deps.upload ?? runPluginUpload; const exists = deps.exists ?? fileExists; + const hasSriManifest = deps.hasSriManifest ?? ((dir: string) => sriManifestNear(dir)); const { resolved } = context; // Only the browser compilation registers the build (once per `next build`), and only it follows the client // deletion policy: `.next/static` is public, `.next/server` is not. @@ -254,6 +258,13 @@ export function createNextWebpackPlugin( if (state.abandoned === true) { return; } + // The in-build stamp is SRI-safe (it runs before anything hashes). Its fallback, stamping the written + // files, is not: it would invalidate the hashes Next already pinned, and the browser would refuse the + // scripts (measured). Nothing is rewritten, so nothing is uploaded. + if (!state.preStamped && (context.sri === true || (await hasSriManifest(outDir)))) { + context.say(FALLBACK_SRI_NOTICE(kind)); + return; + } const emitted: string[] = []; for (const { name } of compilation.getAssets()) { // The file on disk has no `?query` (webpack drops it when it writes the file). diff --git a/packages/nextjs/src/config/with-bugsee.kind.test.ts b/packages/nextjs/src/config/with-bugsee.kind.test.ts index 1e3e23bd..29d7a27d 100644 --- a/packages/nextjs/src/config/with-bugsee.kind.test.ts +++ b/packages/nextjs/src/config/with-bugsee.kind.test.ts @@ -5,9 +5,11 @@ import { withBugsee } from './with-bugsee'; // The compilation kind Next's webpack function is called with decides which policy a plugin instance gets // (browser maps are public and deleted, server maps are kept), so it is pinned here at the seam. const created = vi.hoisted(() => [] as string[]); +const contexts = vi.hoisted(() => [] as Array<{ sri?: boolean }>); vi.mock('./webpack-plugin', () => ({ - createNextWebpackPlugin: (_context: unknown, kind: string) => { + createNextWebpackPlugin: (context: { sri?: boolean }, kind: string) => { created.push(kind); + contexts.push(context); return { apply: () => undefined }; }, })); @@ -20,10 +22,10 @@ const context = { } as unknown as BugseeNextContext; type Webpack = (config: object, options: object) => unknown; -const webpackOf = (): Webpack => +const webpackOf = (config: object = {}): Webpack => ( withBugsee( - {}, + config, {}, { env: {}, cwd: () => '/app', createContext: () => context, nextVersion: () => '16.4.6' }, ) as { webpack: Webpack } @@ -42,3 +44,15 @@ describe('withBugsee: which compilation a plugin is made for', () => { expect(created).toEqual([kind]); }); }); + +describe('withBugsee: the SRI flag reaches the plugins', () => { + it('marks the context when the app uses experimental.sri, and only then', () => { + contexts.length = 0; + webpackOf({ experimental: { sri: { algorithm: 'sha256' } } })( + {}, + { dev: false, isServer: false }, + ); + webpackOf()({}, { dev: false, isServer: false }); + expect(contexts.map((c) => c.sri === true)).toEqual([true, false]); + }); +}); diff --git a/packages/nextjs/src/config/with-bugsee.test.ts b/packages/nextjs/src/config/with-bugsee.test.ts index c827d151..0c816613 100644 --- a/packages/nextjs/src/config/with-bugsee.test.ts +++ b/packages/nextjs/src/config/with-bugsee.test.ts @@ -429,3 +429,48 @@ describe('withBugsee: the project directory', () => { expect(d.ctx.say).not.toHaveBeenCalled(); }); }); + +describe('withBugsee: browser maps are forced on only when an upload can happen', () => { + const turbo = (over: WithBugseeDeps = {}, ctx = context()) => + deps(ctx, { env: { TURBOPACK: '1' }, ...over }); + const SRI = { experimental: { sri: { algorithm: 'sha256' } } }; + + it('forces them on for webpack, SRI or not (it stamps inside the build)', () => { + expect(apply({}, deps()).productionBrowserSourceMaps).toBe(true); + expect(apply(SRI, deps()).productionBrowserSourceMaps).toBe(true); + }); + + it('leaves them alone for Turbopack + SRI: nothing would be uploaded, and the maps would be public', () => { + const ctx = context(); + const out = apply(SRI, turbo({}, ctx)); + expect(out.productionBrowserSourceMaps).toBeUndefined(); + expect(out.compiler?.runAfterProductionCompile).toBeUndefined(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('Subresource Integrity')); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('publicly served')); + }); + + it('leaves them alone on a Next that has no post-build hook', () => { + const ctx = context(); + const out = apply({}, turbo({ nextVersion: () => '15.3.8' }, ctx)); + expect(out.productionBrowserSourceMaps).toBeUndefined(); + expect(ctx.say).toHaveBeenCalledWith( + expect.stringContaining('did not turn browser source maps on'), + ); + }); + + it('still forces them on for Turbopack when the upload is possible', () => { + expect(apply({}, turbo()).productionBrowserSourceMaps).toBe(true); + expect(apply({}, turbo({ nextVersion: () => undefined })).productionBrowserSourceMaps).toBe( + true, + ); + }); + + it('keeps what the app set, whatever the build', () => { + expect( + apply({ ...SRI, productionBrowserSourceMaps: true }, turbo()).productionBrowserSourceMaps, + ).toBe(true); + expect(apply({ productionBrowserSourceMaps: false }, turbo()).productionBrowserSourceMaps).toBe( + false, + ); + }); +}); diff --git a/packages/nextjs/src/config/with-bugsee.ts b/packages/nextjs/src/config/with-bugsee.ts index 1a7143ef..de78dd1a 100644 --- a/packages/nextjs/src/config/with-bugsee.ts +++ b/packages/nextjs/src/config/with-bugsee.ts @@ -12,6 +12,7 @@ import { createRequire } from 'node:module'; import { join, resolve } from 'node:path'; import { type BugseeNextContext, createBugseeContext, type WithBugseeOptions } from './context'; import { type PostBuildMetadata, runPostBuild } from './post-build'; +import { NO_HOOK_NOTICE, TURBOPACK_SRI_NOTICE } from './sri'; import { createNextWebpackPlugin, type NextCompilationKind } from './webpack-plugin'; /** The Next config shapes this accepts. Structural: `next` is not a dependency. */ @@ -94,13 +95,20 @@ function compilationKind(next: { isServer?: boolean; nextRuntime?: string }): Ne /** Build the extended config for one resolved context. */ function extendConfig( config: C, - context: BugseeNextContext, + baseContext: BugseeNextContext, turbopack: boolean, nextVersion: string | undefined, projectDir: string, ): C { + const sri = Boolean(config.experimental?.sri); + const context: BugseeNextContext = sri ? { ...baseContext, sri: true } : baseContext; const { resolved } = context; const next: NextConfigObject = { ...config }; + // Whether this build has a way to upload at all: webpack always does (it stamps inside the build, SRI included); + // Turbopack needs the post-build hook (Next >= 15.4.0) and cannot stamp an SRI build. + const noHook = + turbopack && nextVersion !== undefined && !versionAtLeast(nextVersion, MIN_TURBOPACK_HOOK); + const uploadAvailable = !turbopack || (!noHook && !sri); // The app's version and build, baked into every bundle (browser, node, edge) for the runtime SDK to read. // `compiler.define` applies to all three; `defineServer` must NOT repeat the keys (measured, Next 15.5: it @@ -125,9 +133,10 @@ function extendConfig( next.compiler = compiler; } - // Browser maps are what Bugsee symbolicates browser crashes with. Forced on only when nothing says otherwise, - // and only here, where a token means they will be uploaded and then removed from `.next/static`. - if (config.productionBrowserSourceMaps === undefined) { + // Browser maps are what Bugsee symbolicates browser crashes with. Forced on only when nothing says otherwise AND + // an upload is possible for this build: they are written to `.next/static`, which is served publicly, and only a + // confirmed upload removes them. If the upload cannot happen, the app's own setting stands. + if (config.productionBrowserSourceMaps === undefined && uploadAvailable) { next.productionBrowserSourceMaps = true; } @@ -157,10 +166,10 @@ function extendConfig( } if (turbopack) { - if (nextVersion !== undefined && !versionAtLeast(nextVersion, MIN_TURBOPACK_HOOK)) { - context.say( - `Next ${nextVersion} builds with Turbopack but has no post-build hook to upload from; source maps were NOT uploaded. Upgrade to Next 15.4.0 or later, or build with webpack.`, - ); + if (noHook) { + context.say(NO_HOOK_NOTICE(nextVersion as string)); + } else if (sri) { + context.say(TURBOPACK_SRI_NOTICE); } else { const userHook = config.compiler?.runAfterProductionCompile as | ((metadata: PostBuildMetadata) => Promise) From 56f3a6f1fa250d0dad12a89fa0c718adb67e0563 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 16:35:10 +0500 Subject: [PATCH 12/17] fix(nextjs): no public maps Bugsee asked for when nothing is uploaded; one accurate SRI message; clean packed install - webpack: when no upload follows (SRI stamp failure, abandoned stamp) the browser maps Bugsee itself turned on are deleted from this compilation's own files; maps the app enabled stay, and the notice says they are public - a failed in-build stamp is reported once the build knows what follows: on SRI one notice (no 'falling back'), otherwise the fallback message - removed the env notice-dedupe marker (not reproducible on real builds, polluted process.env) - sriManifestNear no longer matches a root file of the same name - real builds: SRI-webpack fallback leaves no static maps; Turbopack+SRI with app-enabled maps keeps them and says so once; packed tarballs installed offline into a clean dir (no monorepo symlinks) Co-Authored-By: Claude Sonnet 5.5 --- docs/design/source-maps.md | 2 +- packages/nextjs-e2e/test/packed-config.e2e.ts | 49 +++--- packages/nextjs-e2e/test/source-maps.e2e.ts | 29 +++- packages/nextjs/README.md | 2 +- packages/nextjs/src/config/context.test.ts | 19 --- packages/nextjs/src/config/context.ts | 23 +-- packages/nextjs/src/config/sri.test.ts | 20 +++ packages/nextjs/src/config/sri.ts | 31 ++-- .../nextjs/src/config/webpack-plugin.test.ts | 144 +++++++++++++++++- packages/nextjs/src/config/webpack-plugin.ts | 88 ++++++++--- .../src/config/with-bugsee.kind.test.ts | 29 +++- .../nextjs/src/config/with-bugsee.test.ts | 5 +- packages/nextjs/src/config/with-bugsee.ts | 15 +- 13 files changed, 359 insertions(+), 97 deletions(-) diff --git a/docs/design/source-maps.md b/docs/design/source-maps.md index b4a69681..df9ec8b2 100644 --- a/docs/design/source-maps.md +++ b/docs/design/source-maps.md @@ -514,7 +514,7 @@ measured). Only bundles that have a map are stamped on Turbopack, and bundles ar A map carries one debug-ID (the hash of bundle + map), so such bundles are left unstamped (a notice counts them) and their shared map stays on disk, unuploaded; they are Turbopack's runtime, not the app. -**SRI fallback guard.** A webpack in-build stamp that failed falls back (core) to stamping the written files; on an SRI build that rewrites bytes Next already pinned (measured: Chromium blocked every script). The per-compilation plugin therefore skips the fallback and the upload when `experimental.sri` is set or Next's integrity manifest sits next to the output (`sri.ts`, shared with the Turbopack step), with a notice. `productionBrowserSourceMaps` is forced on only when this build can upload (not Turbopack + SRI, not Turbopack < 15.4.0), so an upload that cannot happen never leaves Bugsee-requested public maps. Notices are said once per `next build` across Next's processes (`__BUGSEE_NOTICED` in the environment). +**SRI fallback guard.** A webpack in-build stamp that failed falls back (core) to stamping the written files; on an SRI build that rewrites bytes Next already pinned (measured: Chromium blocked every script). The per-compilation plugin therefore skips the fallback and the upload when `experimental.sri` is set or Next's integrity manifest sits next to the output (`sri.ts`, shared with the Turbopack step), with a notice. `productionBrowserSourceMaps` is forced on only when this build can upload (not Turbopack + SRI, not Turbopack < 15.4.0), so an upload that cannot happen never leaves Bugsee-requested public maps. On webpack, when no upload follows (an SRI build whose stamp failed, or an abandoned stamp), the browser maps Bugsee itself turned on are deleted from this compilation's own files; maps the app enabled stay and the notice says they are public. **Composition.** The app's `webpack` function runs first and its result is extended (Next itself rejects an async one, measured on 16.4.6); its `compiler.runAfterProductionCompile` runs before ours; its `compiler.define` keys win; `productionBrowserSourceMaps` diff --git a/packages/nextjs-e2e/test/packed-config.e2e.ts b/packages/nextjs-e2e/test/packed-config.e2e.ts index 044a84a7..b1b03a61 100644 --- a/packages/nextjs-e2e/test/packed-config.e2e.ts +++ b/packages/nextjs-e2e/test/packed-config.e2e.ts @@ -10,7 +10,6 @@ import { readdirSync, readFileSync, rmSync, - symlinkSync, writeFileSync, } from 'node:fs'; import { tmpdir } from 'node:os'; @@ -29,8 +28,10 @@ function workspaceClosure(name: string, seen = new Map()): Map; + optionalDependencies?: Record; }; - for (const [dep, range] of Object.entries(manifest.dependencies ?? {})) { + const wanted = { ...manifest.dependencies, ...manifest.optionalDependencies }; + for (const [dep, range] of Object.entries(wanted)) { if (range.startsWith('workspace:')) workspaceClosure(dep, seen); } return seen; @@ -43,25 +44,37 @@ beforeAll(() => { stdio: 'ignore', }); app = mkdtempSync(join(tmpdir(), 'bugsee-packed-')); - const modules = join(app, 'node_modules'); - mkdirSync(join(modules, '@bugsee'), { recursive: true }); - // Third-party dependencies: whatever the monorepo installed (pnpm's flat virtual-store directory). - const flat = join(repo, 'node_modules', '.pnpm', 'node_modules'); - for (const entry of readdirSync(flat)) { - if (entry === '@bugsee') continue; - symlinkSync(join(flat, entry), join(modules, entry)); - } + const tarballs = join(app, '.tarballs'); + mkdirSync(tarballs); + const overrides: Record = {}; for (const [name, dir] of closure) { - const target = join(modules, name); - mkdirSync(target, { recursive: true }); - const out = mkdtempSync(join(tmpdir(), 'bugsee-pack-')); + const out = mkdtempSync(join(tarballs, 'p-')); execFileSync('pnpm', ['pack', '--pack-destination', out], { cwd: dir, stdio: 'ignore' }); - const tarball = join(out, readdirSync(out)[0] as string); - execFileSync('tar', ['-xzf', tarball, '-C', target, '--strip-components=1']); - rmSync(out, { recursive: true, force: true }); + overrides[name] = `file:${join(out, readdirSync(out)[0] as string)}`; } - writeFileSync(join(app, 'package.json'), JSON.stringify({ name: 'app', version: '3.2.1' })); -}, 600_000); + writeFileSync( + join(app, 'package.json'), + JSON.stringify({ + name: 'app', + version: '3.2.1', + private: true, + dependencies: { '@bugsee/nextjs': overrides['@bugsee/nextjs'] }, + }), + ); + // A CLEAN install of the packed tarballs, as a user gets them: every `@bugsee/*` the packed manifests name is + // redirected to its tarball (they are not on a registry), everything else comes from the offline store. A + // dependency a package forgot to declare is simply not there, instead of being found through the monorepo. + writeFileSync( + join(app, 'pnpm-workspace.yaml'), + `overrides:\n${Object.entries(overrides) + .map(([name, spec]) => ` '${name}': '${spec}'`) + .join('\n')}\n`, + ); + execFileSync('pnpm', ['install', '--offline', '--no-frozen-lockfile', '--ignore-scripts'], { + cwd: app, + stdio: 'pipe', + }); +}, 900_000); afterAll(() => { if (app) rmSync(app, { recursive: true, force: true }); diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts index fbd72b7c..d4561dac 100644 --- a/packages/nextjs-e2e/test/source-maps.e2e.ts +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -542,8 +542,12 @@ describe('withBugsee — Subresource Integrity', () => { failInBuildStamp: true, }); expect(built.status, built.log.split('\n').slice(-40).join('\n')).toBe(0); - expect(built.log).toMatch(/falling back to stamping after emit/); - expect(built.log).toMatch(/stamping after emit.*was skipped/s); + // ONE accurate message: the stamp failed and the fallback was refused. Never "falling back". + expect(built.log).not.toMatch(/falling back to stamping after emit/); + expect(built.log.split('\n').filter((l) => l.includes('Subresource Integrity'))).toHaveLength( + 3, + ); // client, server, edge: one notice each + expect(built.log).toMatch(/nothing was stamped or uploaded/); expect(built.uploads).toEqual([]); // Nothing was rewritten, so the pinned hashes still describe the bytes on disk and the page runs. for (const bundle of walk(join(built.dir, '.next', 'static')).filter((f) => @@ -552,6 +556,27 @@ describe('withBugsee — Subresource Integrity', () => { expect(debugIdOf(bundle), bundle).toBeUndefined(); } expectRuns(await openInBrowser(built.dir), { stamped: false }); + // Bugsee had turned the browser maps on (the app did not ask); with no upload they must not stay public. + expect(maps(join(built.dir, '.next', 'static'))).toEqual([]); + expect(built.log).toMatch(/browser source maps Bugsee had turned on were removed/); + }); + + it('turbopack + SRI + maps the APP asked for: they stay, the notice says they are public, said once', async () => { + const built = await build({ + name: 'sri-turbopack-own-maps', + next: 'next16', + args: [], + nextConfig: + "experimental: { sri: { algorithm: 'sha256' } }, productionBrowserSourceMaps: true,", + options: 'failOnError: false,', + }); + expect(built.status, built.log.split('\n').slice(-40).join('\n')).toBe(0); + expect(built.uploads).toEqual([]); + expect(maps(join(built.dir, '.next', 'static')).length).toBeGreaterThan(0); + const said = built.log.split('\n').filter((l) => l.includes('Subresource Integrity')); + expect(said).toHaveLength(1); + expect(said[0]).toMatch(/publicly served/); + expectRuns(await openInBrowser(built.dir), { stamped: false }); }); }); diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index 9f9744b4..e47410cc 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -112,7 +112,7 @@ Things to know: - `compiler.define` (the baked version and build) needs Next 15.1.0 or later; the Turbopack upload needs 15.4.0 or later. - `@bugsee/nextjs` depends on `@bugsee/bundler-plugin-core` (which brings `@bugsee/cli`, acorn, magic-string and unplugin) so that `withBugsee` works with no extra install. Only `next.config` loads it; your app bundles never import it. Making it an optional peer would force every user of the config to install it by hand and break `next build` out of the box, so it stays a regular dependency. -Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). On webpack with `experimental.sri`, if the in-build stamp itself fails, the fallback of stamping the written files is skipped (it would invalidate the pinned hashes) and nothing is uploaded for that compilation, with a notice; the browser maps then stay in `.next/static`, publicly served. +Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). On webpack with `experimental.sri`, if the in-build stamp itself fails, the fallback of stamping the written files is skipped (it would invalidate the pinned hashes) and nothing is uploaded for that compilation, with a notice. The browser maps Bugsee itself turned on are then deleted again; maps you enabled yourself (`productionBrowserSourceMaps: true`) stay in `.next/static`, publicly served, and the notice says so. ## Options diff --git a/packages/nextjs/src/config/context.test.ts b/packages/nextjs/src/config/context.test.ts index a169143d..0c12eb8b 100644 --- a/packages/nextjs/src/config/context.test.ts +++ b/packages/nextjs/src/config/context.test.ts @@ -130,23 +130,4 @@ describe('createBugseeContext', () => { expect(createBugseeContext({}, dir).resolved.appToken).toBe('ambient'); vi.unstubAllEnvs(); }); - - it('says a notice once across processes that share the environment (Next loads the config in workers)', () => { - const env: Record = {}; - const seen: string[] = []; - const make = () => createBugseeContext({ onNotice: (m) => seen.push(m) }, dir, { env }); - make().say('only once'); - make().say('only once'); - make().say('but this is new'); - expect(seen).toEqual(['[bugsee] only once', '[bugsee] but this is new']); - }); - - it('does not use up a notice that was silenced', () => { - const env: Record = {}; - createBugseeContext({ silent: true }, dir, { env }).say('quiet'); - expect(env.__BUGSEE_NOTICED).toBeUndefined(); - const seen: string[] = []; - createBugseeContext({ onNotice: (m) => seen.push(m) }, dir, { env }).say('quiet'); - expect(seen).toEqual(['[bugsee] quiet']); - }); }); diff --git a/packages/nextjs/src/config/context.ts b/packages/nextjs/src/config/context.ts index f04ed725..a5f6148a 100644 --- a/packages/nextjs/src/config/context.ts +++ b/packages/nextjs/src/config/context.ts @@ -46,6 +46,8 @@ export interface BugseeNextContext { deleteServerMaps: boolean; /** The app uses `experimental.sri` (set by `withBugsee` from the Next config it wraps). */ sri?: boolean; + /** `withBugsee` itself turned `productionBrowserSourceMaps` on (the app did not ask for browser maps). */ + forcedMaps?: boolean; /** A notice said once per distinct text (a no-op when `silent`). */ say(message: string): void; } @@ -55,22 +57,12 @@ export interface ContextDeps { env?: Record; } -/** A short stable key for a notice text (djb2). */ -function noticeKey(text: string): string { - let hash = 5381; - for (const char of text) { - hash = ((hash << 5) + hash + char.charCodeAt(0)) | 0; - } - return (hash >>> 0).toString(36); -} - /** Resolve the integration's context for `projectDir`. Never throws. */ export function createBugseeContext( options: WithBugseeOptions, projectDir: string, deps: ContextDeps = {}, ): BugseeNextContext { - const env = deps.env ?? process.env; const said = new Set(); // `text` already carries the `[bugsee]` prefix: that is what the core hands an `onNotice` sink. const emit = (text: string): void => { @@ -78,15 +70,6 @@ export function createBugseeContext( return; } said.add(text); - // Next loads the config in more than one process (the main one and its build workers), so the same notice - // would print once per process. The environment is inherited by the workers it spawns afterwards, so it - // carries "already said" across them. - const key = noticeKey(text); - const seen = (env.__BUGSEE_NOTICED ?? '').split(','); - if (seen.includes(key)) { - return; - } - env.__BUGSEE_NOTICED = [...seen.filter(Boolean), key].join(','); try { (options.onNotice ?? console.warn)(text); } catch { @@ -99,7 +82,7 @@ export function createBugseeContext( if (problem !== undefined) { sink(problem); } - const merged = mergeBuildPluginEnv(env, values); + const merged = mergeBuildPluginEnv(deps.env ?? process.env, values); const base = resolvePluginOptions(options, merged); const identity = resolveIdentity(options, merged, projectDir); return { diff --git a/packages/nextjs/src/config/sri.test.ts b/packages/nextjs/src/config/sri.test.ts index b056eb45..1080d92c 100644 --- a/packages/nextjs/src/config/sri.test.ts +++ b/packages/nextjs/src/config/sri.test.ts @@ -14,6 +14,26 @@ describe('sriManifestNear', () => { expect(await sriManifestNear('/o/.next/server', only(server))).toBe(true); }); + it('does not mistake a root file of that name for Next\u2019s manifest', async () => { + const root = '/o/.next/subresource-integrity-manifest.json'; + expect(await sriManifestNear('/o/.next/chunks', only(root))).toBe(false); + expect( + await sriManifestNear( + '/o/.next/server/app/x', + only('/o/.next/server/app/subresource-integrity-manifest.json'), + ), + ).toBe(false); + expect(await sriManifestNear('/o/proj', only('/o/subresource-integrity-manifest.json'))).toBe( + false, + ); + }); + + it('a manifest-named file in a plain directory is not Next\u2019s', async () => { + expect( + await sriManifestNear('/o/proj', only('/o/proj/subresource-integrity-manifest.json')), + ).toBe(false); + }); + it('finds nothing when there is none', async () => { expect(await sriManifestNear('/o/.next', async () => false)).toBe(false); }); diff --git a/packages/nextjs/src/config/sri.ts b/packages/nextjs/src/config/sri.ts index f499ff8a..1b1b481a 100644 --- a/packages/nextjs/src/config/sri.ts +++ b/packages/nextjs/src/config/sri.ts @@ -6,7 +6,7 @@ // the fallback rewrote real bundles and Chromium blocked every script, "Failed to find a valid digest"). The core's // own SRI scan only sees HTML under the output directory, and Next keeps the integrity manifest elsewhere. import { stat } from 'node:fs/promises'; -import { dirname, join } from 'node:path'; +import { basename, dirname, join } from 'node:path'; /** Where Next records the integrity hashes it pinned, relative to the dist directory. */ export const SRI_MANIFEST = join('server', 'subresource-integrity-manifest.json'); @@ -26,11 +26,15 @@ export async function sriManifestNear( exists: (path: string) => Promise = isFile, ): Promise { const name = 'subresource-integrity-manifest.json'; - for (const candidate of [ - join(outDir, SRI_MANIFEST), - join(outDir, name), - join(dirname(outDir), name), - ]) { + // The manifest lives in `/server`. A file of that name anywhere else is not Next's. + const candidates = [join(outDir, SRI_MANIFEST)]; + if (basename(outDir) === 'server') { + candidates.push(join(outDir, name)); + } + if (basename(dirname(outDir)) === 'server') { + candidates.push(join(dirname(outDir), name)); + } + for (const candidate of candidates) { if (await exists(candidate)) { return true; } @@ -44,9 +48,18 @@ const PUBLIC_MAPS = /** Turbopack + SRI: not stampable, so nothing is uploaded. */ export const TURBOPACK_SRI_NOTICE = `this build uses Subresource Integrity (\`experimental.sri\`). Turbopack hashes its output before the post-build hook runs, so stamping debug-IDs now would make the browser refuse the scripts. Source maps were NOT uploaded and the build was left unmodified. Build with \`next build --webpack\` to upload source maps for an SRI build. ${PUBLIC_MAPS}`; -/** A webpack in-build stamp failed on an SRI build: the post-emit fallback would break the page. */ -export const FALLBACK_SRI_NOTICE = (kind: string): string => - `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp did not apply, so stamping after emit (which would invalidate the pinned hashes and make the browser refuse the scripts) was skipped. Source maps were NOT uploaded for it. ${PUBLIC_MAPS}`; +/** + * A webpack in-build stamp failed on an SRI build: the post-emit fallback would break the page, so nothing is + * stamped or uploaded. `mapsRemoved`: the browser maps Bugsee itself had turned on were deleted again, so they are + * not left public; otherwise (the app asked for them) they stay, and the notice says so. + */ +export const FALLBACK_SRI_NOTICE = (kind: string, cause: string, mapsRemoved: boolean): string => + `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp failed (${cause}), so nothing was stamped or uploaded: stamping after emit would invalidate the pinned hashes and make the browser refuse the scripts.` + + (kind !== 'client' + ? '' + : mapsRemoved + ? ' The browser source maps Bugsee had turned on were removed from `.next/static`.' + : ` ${PUBLIC_MAPS}`); /** Turbopack on a Next without the post-build hook. */ export const NO_HOOK_NOTICE = (version: string): string => diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index 556be0b2..e73d3dd1 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -4,6 +4,7 @@ import { type CompilerLike, createNextWebpackPlugin, nextAssetStore, + removeFile, type WebpackPluginDeps, } from './webpack-plugin'; @@ -119,6 +120,7 @@ const deps = (over: WebpackPluginDeps = {}): WebpackPluginDeps => ({ upload: vi.fn(async () => undefined), exists: vi.fn(async () => true), hasSriManifest: vi.fn(async () => false), + remove: vi.fn(async () => undefined), ...over, }); @@ -302,7 +304,7 @@ describe('createNextWebpackPlugin', () => { warn.mockRestore(); }); - it('reports a stamp failure through onError', async () => { + it('reports a stamp failure through onError, once the build knows what follows', async () => { const onError = vi.fn(); const d = deps({ stamp: vi.fn(async () => { @@ -314,7 +316,10 @@ describe('createNextWebpackPlugin', () => { const c = fakeCompilation({ 'a.js': 'x' }); fake.startCompilation(c.compilation); await c.run(); + expect(onError).not.toHaveBeenCalled(); + await fake.emit(c.compilation); expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'boom' })); + expect(onError).toHaveBeenCalledTimes(1); }); it('rethrows a stamp failure under failOnError', async () => { @@ -653,3 +658,140 @@ describe('createNextWebpackPlugin: the post-emit fallback on an SRI build', () = expect(d.hasSriManifest).not.toHaveBeenCalled(); }); }); + +describe('createNextWebpackPlugin: no public maps Bugsee asked for when nothing is uploaded', () => { + const failing = () => + vi.fn(async () => { + throw new Error('inject broke'); + }); + const assets = { + 'static/a.js': 'x', + 'static/a.js.map': 'm', + 'static/a.css': 'c', + 'static/a.css.map': 'cm', + }; + const run = async (kind: 'client' | 'server', ctx: BugseeNextContext, d: WebpackPluginDeps) => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + const fake = fakeCompiler({ path: '/out/.next' }); + createNextWebpackPlugin(ctx, kind, d).apply(fake.compiler); + const c = fakeCompilation(assets); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + const warned = warn.mock.calls.map((call) => String(call[0])); + warn.mockRestore(); + return warned; + }; + + it('deletes the browser maps it turned on when an SRI build\u2019s stamp failed (nothing is uploaded)', async () => { + const ctx = context({}, { sri: true, forcedMaps: true }); + const d = deps({ stamp: failing() }); + await run('client', ctx, d); + expect(d.upload).not.toHaveBeenCalled(); + expect(d.remove).toHaveBeenCalledTimes(2); + expect(d.remove).toHaveBeenCalledWith('/out/.next/static/a.js.map'); + expect(d.remove).toHaveBeenCalledWith('/out/.next/static/a.css.map'); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('were removed')); + }); + + it('keeps maps the app asked for, and says they are public', async () => { + const ctx = context({}, { sri: true }); + const d = deps({ stamp: failing() }); + await run('client', ctx, d); + expect(d.remove).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('publicly served')); + }); + + it('never touches a server compilation\u2019s maps (not public)', async () => { + const ctx = context({}, { sri: true, forcedMaps: true }); + const d = deps({ stamp: failing() }); + await run('server', ctx, d); + expect(d.remove).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.not.stringContaining('browser source maps')); + }); + + it('deletes them when the stamp was abandoned (a map outside the output), too', async () => { + const d = deps({ + stamp: vi.fn(async () => { + throw Object.assign(new Error('outside'), { unreachableMap: true }); + }), + }); + await run('client', context({}, { forcedMaps: true }), d); + expect(d.upload).not.toHaveBeenCalled(); + expect(d.remove).toHaveBeenCalledTimes(2); + }); + + it('leaves them alone when the upload runs (it deletes them itself after confirming)', async () => { + const d = deps(); + await run('client', context({}, { forcedMaps: true }), d); + expect(d.upload).toHaveBeenCalledTimes(1); + expect(d.remove).not.toHaveBeenCalled(); + }); + + it('prints ONE accurate message on an SRI build, never "falling back"', async () => { + const onError = vi.fn(); + const ctx = context({ onError }, { sri: true, forcedMaps: true }); + const warned = await run('client', ctx, deps({ stamp: failing() })); + expect(warned.join('\n')).not.toMatch(/falling back/); + expect(ctx.say).toHaveBeenCalledTimes(1); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('inject broke')); + expect(onError).toHaveBeenCalledTimes(1); + }); + + it('on a build without SRI the fallback message is printed, once', async () => { + const warned = await run('client', context(), deps({ stamp: failing() })); + expect(warned.filter((w) => w.includes('falling back to stamping after emit'))).toHaveLength(1); + }); + + it('the default remover tolerates a file that is already gone and reports other errors', async () => { + const { mkdtempSync, rmSync, writeFileSync, existsSync } = await import('node:fs'); + const { tmpdir } = await import('node:os'); + const { join } = await import('node:path'); + const dir = mkdtempSync(join(tmpdir(), 'bugsee-rm-')); + try { + writeFileSync(join(dir, 'a.js'), 'x'); + writeFileSync(join(dir, 'a.js.map'), 'm'); + const ctx = context({}, { sri: true, forcedMaps: true }); + const fake = fakeCompiler({ path: dir }); + createNextWebpackPlugin(ctx, 'client', { + ...deps({ stamp: failing() }), + remove: undefined, + exists: undefined, + }).apply(fake.compiler); + const c = fakeCompilation({ + 'a.js': 'x', + 'a.js.map': 'm', + 'gone.js': 'x', + 'gone.js.map': 'm', + }); + fake.startCompilation(c.compilation); + const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined); + await c.run(); + await fake.emit(c.compilation); + warn.mockRestore(); + expect(existsSync(join(dir, 'a.js.map'))).toBe(false); + expect(existsSync(join(dir, 'a.js'))).toBe(true); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); +}); + +describe('removeFile', () => { + it('deletes a file, ignores one that is gone, and reports anything else', async () => { + const { mkdirSync, mkdtempSync, rmSync, writeFileSync, existsSync } = await import('node:fs'); + const { tmpdir } = await import('node:os'); + const { join } = await import('node:path'); + const dir = mkdtempSync(join(tmpdir(), 'bugsee-rmf-')); + try { + writeFileSync(join(dir, 'a.map'), 'm'); + await removeFile(join(dir, 'a.map')); + expect(existsSync(join(dir, 'a.map'))).toBe(false); + await expect(removeFile(join(dir, 'gone.map'))).resolves.toBeUndefined(); + mkdirSync(join(dir, 'd')); + await expect(removeFile(join(dir, 'd'))).rejects.toThrow(); + } finally { + rmSync(dir, { recursive: true, force: true }); + } + }); +}); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index 60d9168c..366655dd 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -9,7 +9,7 @@ // `.next/server/chunks` with asset names like `../app/page.js` (outside its own output path), so the generic // plugin neither stamped them (an asset name may not escape the staging directory) nor found their maps, and its // directory-wide upload of `.next` swept up the server compilation's half-written files. -import { stat } from 'node:fs/promises'; +import { stat, unlink } from 'node:fs/promises'; import { resolve } from 'node:path'; import { type AssetStore, @@ -68,6 +68,8 @@ export interface WebpackPluginDeps { exists?: (path: string) => Promise; /** Whether Next's integrity manifest sits next to this output (default: looks on disk). */ hasSriManifest?: (outDir: string) => Promise; + /** Delete a file (default `fs.unlink`; a file that is already gone is fine). */ + remove?: (path: string) => Promise; } const PLUGIN = 'bugsee-next'; @@ -80,12 +82,25 @@ interface InBuildStamp { /** The bundles it stamped and their maps, by real asset name, for the on-disk re-check. */ stampedBundles?: string[]; stampedMaps?: Record; + /** Why the in-build stamp failed, reported once the build knows what happens next (fallback or not). */ + failure?: unknown; /** The stamp was refused in a way that makes stamping after emit unsafe too. */ abandoned?: boolean; } /** Stands in for each leading `../` of an asset name inside the staging directory. */ const UP = '__bugsee_up__'; +/** Delete a file; one that is already gone is not an error. */ +export async function removeFile(path: string): Promise { + try { + await unlink(path); + } catch (error) { + if ((error as NodeJS.ErrnoException).code !== 'ENOENT') { + throw error; + } + } +} + async function fileExists(path: string): Promise { try { return (await stat(path)).isFile(); @@ -177,6 +192,7 @@ export function createNextWebpackPlugin( const upload = deps.upload ?? runPluginUpload; const exists = deps.exists ?? fileExists; const hasSriManifest = deps.hasSriManifest ?? ((dir: string) => sriManifestNear(dir)); + const remove = deps.remove ?? removeFile; const { resolved } = context; // Only the browser compilation registers the build (once per `next build`), and only it follows the client // deletion policy: `.next/static` is public, `.next/server` is not. @@ -234,16 +250,20 @@ export function createNextWebpackPlugin( // half-stamp the build, so nothing is stamped or uploaded for it. const abandoned = (error as { unreachableMap?: boolean } | null)?.unreachableMap === true; - ( - resolved.onError ?? - ((e: unknown) => - console.warn( - abandoned - ? `[bugsee] debug-IDs were NOT stamped, and stamping after emit would half-stamp this build: ${String(e)}` - : `[bugsee] in-build debug-ID stamping failed; falling back to stamping after emit: ${String(e)}`, - )) - )(error); - state = { preStamped: false, ...(abandoned ? { abandoned: true } : {}) }; + if (abandoned) { + ( + resolved.onError ?? + ((e: unknown) => + console.warn( + `[bugsee] debug-IDs were NOT stamped, and stamping after emit would half-stamp this build: ${String(e)}`, + )) + )(error); + } + // Said at the end of the build, once it is known whether stamping after emit follows. + state = { + preStamped: false, + ...(abandoned ? { abandoned: true } : { failure: error }), + }; } }, ); @@ -255,25 +275,53 @@ export function createNextWebpackPlugin( if (typeof outDir !== 'string' || outDir === '') { return; } + const emitted: string[] = []; + for (const { name } of compilation.getAssets()) { + // The file on disk has no `?query` (webpack drops it when it writes the file). + const path = resolve(outDir, withoutQuery(name)); + if (await exists(path)) { + emitted.push(path); + } + } + const files: BuildFiles = partitionBuildFiles(emitted); + // No upload will follow: the browser maps Bugsee itself turned on (the app did not ask for them) must not + // be left in `.next/static`, which is served publicly. Only this compilation's own files, only the ones + // Bugsee forced; maps the app enabled stay. + const discardForcedMaps = async (): Promise => { + if (kind !== 'client' || context.forcedMaps !== true) { + return false; + } + for (const map of [...files.maps, ...files.stylesheetMaps]) { + await remove(map); + } + return true; + }; if (state.abandoned === true) { + await discardForcedMaps(); return; } // The in-build stamp is SRI-safe (it runs before anything hashes). Its fallback, stamping the written // files, is not: it would invalidate the hashes Next already pinned, and the browser would refuse the // scripts (measured). Nothing is rewritten, so nothing is uploaded. if (!state.preStamped && (context.sri === true || (await hasSriManifest(outDir)))) { - context.say(FALLBACK_SRI_NOTICE(kind)); + const removed = await discardForcedMaps(); + context.say( + FALLBACK_SRI_NOTICE(kind, String(state.failure ?? 'it did not apply'), removed), + ); + if (state.failure !== undefined) { + resolved.onError?.(state.failure); + } return; } - const emitted: string[] = []; - for (const { name } of compilation.getAssets()) { - // The file on disk has no `?query` (webpack drops it when it writes the file). - const path = resolve(outDir, withoutQuery(name)); - if (await exists(path)) { - emitted.push(path); - } + if (state.failure !== undefined) { + ( + resolved.onError ?? + ((e: unknown) => + console.warn( + `[bugsee] in-build debug-ID stamping failed; falling back to stamping after emit: ${String(e)}`, + )) + )(state.failure); } - const files: BuildFiles = partitionBuildFiles(emitted); if (files.scripts.length === 0) { if (kind === 'client') { context.say( diff --git a/packages/nextjs/src/config/with-bugsee.kind.test.ts b/packages/nextjs/src/config/with-bugsee.kind.test.ts index 29d7a27d..b23b6da6 100644 --- a/packages/nextjs/src/config/with-bugsee.kind.test.ts +++ b/packages/nextjs/src/config/with-bugsee.kind.test.ts @@ -5,9 +5,9 @@ import { withBugsee } from './with-bugsee'; // The compilation kind Next's webpack function is called with decides which policy a plugin instance gets // (browser maps are public and deleted, server maps are kept), so it is pinned here at the seam. const created = vi.hoisted(() => [] as string[]); -const contexts = vi.hoisted(() => [] as Array<{ sri?: boolean }>); +const contexts = vi.hoisted(() => [] as Array<{ sri?: boolean; forcedMaps?: boolean }>); vi.mock('./webpack-plugin', () => ({ - createNextWebpackPlugin: (context: { sri?: boolean }, kind: string) => { + createNextWebpackPlugin: (context: { sri?: boolean; forcedMaps?: boolean }, kind: string) => { created.push(kind); contexts.push(context); return { apply: () => undefined }; @@ -56,3 +56,28 @@ describe('withBugsee: the SRI flag reaches the plugins', () => { expect(contexts.map((c) => c.sri === true)).toEqual([true, false]); }); }); + +describe('withBugsee: whether Bugsee turned the browser maps on', () => { + const forced = (config: object, env: Record = {}): boolean | undefined => { + contexts.length = 0; + const out = withBugsee( + config, + {}, + { + env, + cwd: () => '/app', + createContext: () => context, + nextVersion: () => '16.4.6', + }, + ) as { webpack?: Webpack }; + out.webpack?.({}, { dev: false, isServer: false }); + return contexts[0]?.forcedMaps; + }; + + it('is set only when the app said nothing and an upload is possible', () => { + expect(forced({})).toBe(true); + expect(forced({ productionBrowserSourceMaps: true })).toBeUndefined(); + expect(forced({ productionBrowserSourceMaps: false })).toBeUndefined(); + expect(forced({ experimental: { sri: {} } })).toBe(true); + }); +}); diff --git a/packages/nextjs/src/config/with-bugsee.test.ts b/packages/nextjs/src/config/with-bugsee.test.ts index 0c816613..ecf8123d 100644 --- a/packages/nextjs/src/config/with-bugsee.test.ts +++ b/packages/nextjs/src/config/with-bugsee.test.ts @@ -291,7 +291,10 @@ describe('withBugsee: Turbopack', () => { await out.compiler.runAfterProductionCompile(metadata); expect(order).toEqual(['user', 'bugsee']); expect(user).toHaveBeenCalledWith(metadata); - expect(runPostBuild).toHaveBeenCalledWith(d.ctx, metadata); + expect(runPostBuild).toHaveBeenCalledWith( + expect.objectContaining({ resolved: d.ctx.resolved }), + metadata, + ); // The rest of `compiler`, and the baked identity, survive next to the hook. expect(out.compiler.removeConsole).toBe(true); expect(out.compiler.define.__BUGSEE_APP_VERSION__).toBe('1.0.0'); diff --git a/packages/nextjs/src/config/with-bugsee.ts b/packages/nextjs/src/config/with-bugsee.ts index de78dd1a..8c5d91d5 100644 --- a/packages/nextjs/src/config/with-bugsee.ts +++ b/packages/nextjs/src/config/with-bugsee.ts @@ -101,14 +101,23 @@ function extendConfig( projectDir: string, ): C { const sri = Boolean(config.experimental?.sri); - const context: BugseeNextContext = sri ? { ...baseContext, sri: true } : baseContext; - const { resolved } = context; const next: NextConfigObject = { ...config }; // Whether this build has a way to upload at all: webpack always does (it stamps inside the build, SRI included); // Turbopack needs the post-build hook (Next >= 15.4.0) and cannot stamp an SRI build. const noHook = turbopack && nextVersion !== undefined && !versionAtLeast(nextVersion, MIN_TURBOPACK_HOOK); const uploadAvailable = !turbopack || (!noHook && !sri); + // Bugsee turns browser maps on only when the app said nothing AND an upload is possible. + const forced = + baseContext.resolved.enabled && + config.productionBrowserSourceMaps === undefined && + uploadAvailable; + const context: BugseeNextContext = { + ...baseContext, + ...(sri ? { sri: true } : {}), + ...(forced ? { forcedMaps: true } : {}), + }; + const { resolved } = context; // The app's version and build, baked into every bundle (browser, node, edge) for the runtime SDK to read. // `compiler.define` applies to all three; `defineServer` must NOT repeat the keys (measured, Next 15.5: it @@ -136,7 +145,7 @@ function extendConfig( // Browser maps are what Bugsee symbolicates browser crashes with. Forced on only when nothing says otherwise AND // an upload is possible for this build: they are written to `.next/static`, which is served publicly, and only a // confirmed upload removes them. If the upload cannot happen, the app's own setting stands. - if (config.productionBrowserSourceMaps === undefined && uploadAvailable) { + if (forced) { next.productionBrowserSourceMaps = true; } From 68d2db841810a40e4208266a0113c04d6ef498e7 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 16:42:21 +0500 Subject: [PATCH 13/17] fix(nextjs): the SRI discard path cannot hide a failure, fail the build, or delete on a dry run - the stamp failure's cause goes through onError / console.warn, never the notice sink, so silent cannot swallow it - removing the browser maps Bugsee turned on is contained: reported via onError/console.warn, rethrown only under failOnError - nothing is deleted on a dry run (the notice says so) - README/handoff: maps enabled by a wrapper applied after withBugsee are still treated as Bugsee's; a dangling sourceMappingURL is harmless Co-Authored-By: Claude Sonnet 5.5 --- packages/nextjs/README.md | 2 +- packages/nextjs/src/config/sri.ts | 14 +++- .../nextjs/src/config/webpack-plugin.test.ts | 66 ++++++++++++++++++- packages/nextjs/src/config/webpack-plugin.ts | 40 ++++++++--- 4 files changed, 108 insertions(+), 14 deletions(-) diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index e47410cc..f9d2f177 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -112,7 +112,7 @@ Things to know: - `compiler.define` (the baked version and build) needs Next 15.1.0 or later; the Turbopack upload needs 15.4.0 or later. - `@bugsee/nextjs` depends on `@bugsee/bundler-plugin-core` (which brings `@bugsee/cli`, acorn, magic-string and unplugin) so that `withBugsee` works with no extra install. Only `next.config` loads it; your app bundles never import it. Making it an optional peer would force every user of the config to install it by hand and break `next build` out of the box, so it stays a regular dependency. -Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). On webpack with `experimental.sri`, if the in-build stamp itself fails, the fallback of stamping the written files is skipped (it would invalidate the pinned hashes) and nothing is uploaded for that compilation, with a notice. The browser maps Bugsee itself turned on are then deleted again; maps you enabled yourself (`productionBrowserSourceMaps: true`) stay in `.next/static`, publicly served, and the notice says so. +Turbopack and Subresource Integrity: Turbopack hashes its output (`experimental.sri`) before the post-build hook runs, so stamping afterwards would make the browser refuse your scripts. An SRI build under Turbopack is therefore left exactly as Next wrote it, with a notice, and no maps are uploaded; build with `--webpack` to upload maps for an SRI build (webpack stamps before the hashes are taken). On webpack with `experimental.sri`, if the in-build stamp itself fails, the fallback of stamping the written files is skipped (it would invalidate the pinned hashes) and nothing is uploaded for that compilation, with a notice. The browser maps Bugsee itself turned on are then deleted again; maps you enabled yourself (`productionBrowserSourceMaps: true`) stay in `.next/static`, publicly served, and the notice says so. "Maps you enabled yourself" means `productionBrowserSourceMaps` was set when `withBugsee` ran: if a wrapper applied after `withBugsee` turns it on, Bugsee still counts the maps as its own and removes them in this failure case. A `//# sourceMappingURL` comment may then point at a map that no longer exists (harmless: only devtools ask for it). On a dry run nothing is deleted. ## Options diff --git a/packages/nextjs/src/config/sri.ts b/packages/nextjs/src/config/sri.ts index 1b1b481a..2805e39a 100644 --- a/packages/nextjs/src/config/sri.ts +++ b/packages/nextjs/src/config/sri.ts @@ -53,13 +53,21 @@ export const TURBOPACK_SRI_NOTICE = `this build uses Subresource Integrity (\`ex * stamped or uploaded. `mapsRemoved`: the browser maps Bugsee itself had turned on were deleted again, so they are * not left public; otherwise (the app asked for them) they stay, and the notice says so. */ -export const FALLBACK_SRI_NOTICE = (kind: string, cause: string, mapsRemoved: boolean): string => - `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp failed (${cause}), so nothing was stamped or uploaded: stamping after emit would invalidate the pinned hashes and make the browser refuse the scripts.` + +export const FALLBACK_SRI_NOTICE = ( + kind: string, + mapsRemoved: boolean, + options: { dryRun?: boolean; removalFailed?: boolean } = {}, +): string => + `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp failed (the cause is reported separately), so nothing was stamped or uploaded: stamping after emit would invalidate the pinned hashes and make the browser refuse the scripts.` + (kind !== 'client' ? '' : mapsRemoved ? ' The browser source maps Bugsee had turned on were removed from `.next/static`.' - : ` ${PUBLIC_MAPS}`); + : options.dryRun === true + ? ` Dry run: nothing was deleted. ${PUBLIC_MAPS}` + : options.removalFailed === true + ? ` The browser maps Bugsee turned on could not all be removed. ${PUBLIC_MAPS}` + : ` ${PUBLIC_MAPS}`); /** Turbopack on a Next without the post-build hook. */ export const NO_HOOK_NOTICE = (version: string): string => diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index e73d3dd1..2ee66a6f 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -734,8 +734,72 @@ describe('createNextWebpackPlugin: no public maps Bugsee asked for when nothing const warned = await run('client', ctx, deps({ stamp: failing() })); expect(warned.join('\n')).not.toMatch(/falling back/); expect(ctx.say).toHaveBeenCalledTimes(1); - expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('inject broke')); expect(onError).toHaveBeenCalledTimes(1); + expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'inject broke' })); + }); + + it('the CAUSE is never hidden by `silent`: with no onError it is a console warning, not a notice', async () => { + const ctx = context({}, { sri: true, forcedMaps: true }); + const warned = await run('client', ctx, deps({ stamp: failing() })); + expect(warned).toHaveLength(1); + expect(warned[0]).toMatch(/in-build debug-ID stamping failed: Error: inject broke/); + // The notice does not carry the cause (so a silenced notice cannot be the only place it lives). + expect(vi.mocked(ctx.say).mock.calls[0]?.[0]).not.toContain('inject broke'); + }); + + it('a maps-removal failure never fails the build: reported through onError, then the notice says so', async () => { + const onError = vi.fn(); + const ctx = context({ onError }, { sri: true, forcedMaps: true }); + const d = deps({ + stamp: failing(), + remove: vi.fn(async () => { + throw Object.assign(new Error('EPERM'), { code: 'EPERM' }); + }), + }); + await expect(run('client', ctx, d)).resolves.toBeDefined(); + expect(onError).toHaveBeenCalledWith(expect.objectContaining({ message: 'EPERM' })); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('could not all be removed')); + }); + + it('warns on the console when removal fails and there is no onError', async () => { + const ctx = context({}, { sri: true, forcedMaps: true }); + const d = deps({ + stamp: failing(), + remove: vi.fn(async () => { + throw new Error('EPERM'); + }), + }); + const warned = await run('client', ctx, d); + expect(warned.some((w) => w.includes('could not remove the browser source maps'))).toBe(true); + }); + + it('rethrows a removal failure under failOnError (reachable when nothing could be staged on an SRI build)', async () => { + const ctx = context({ failOnError: true }, { sri: true, forcedMaps: true }); + const d = deps({ + stamp: vi.fn(async () => ({ stamped: [], maps: {}, bundles: 0 })), + remove: vi.fn(async () => { + throw new Error('EPERM'); + }), + }); + await expect(run('client', ctx, d)).rejects.toThrow('EPERM'); + }); + + it('deletes nothing on a dry run, and says so', async () => { + const ctx = context({ dryRun: true }, { sri: true, forcedMaps: true }); + const d = deps({ stamp: failing() }); + await run('client', ctx, d); + expect(d.remove).not.toHaveBeenCalled(); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('Dry run: nothing was deleted')); + }); + + it('an abandoned stamp deletes nothing on a dry run either', async () => { + const d = deps({ + stamp: vi.fn(async () => { + throw Object.assign(new Error('outside'), { unreachableMap: true }); + }), + }); + await run('client', context({ dryRun: true }, { forcedMaps: true }), d); + expect(d.remove).not.toHaveBeenCalled(); }); it('on a build without SRI the fallback message is printed, once', async () => { diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index 366655dd..e3740ace 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -287,14 +287,30 @@ export function createNextWebpackPlugin( // No upload will follow: the browser maps Bugsee itself turned on (the app did not ask for them) must not // be left in `.next/static`, which is served publicly. Only this compilation's own files, only the ones // Bugsee forced; maps the app enabled stay. - const discardForcedMaps = async (): Promise => { - if (kind !== 'client' || context.forcedMaps !== true) { - return false; + // Never throws (a failed upload must not fail the build): reported, and only `failOnError` rethrows. Not on + // a dry run, which deletes nothing (as the core's own upload never does). + const discardForcedMaps = async (): Promise<{ removed: boolean; failed: boolean }> => { + if (kind !== 'client' || context.forcedMaps !== true || resolved.dryRun) { + return { removed: false, failed: false }; } - for (const map of [...files.maps, ...files.stylesheetMaps]) { - await remove(map); + try { + for (const map of [...files.maps, ...files.stylesheetMaps]) { + await remove(map); + } + return { removed: true, failed: false }; + } catch (error) { + if (resolved.failOnError) { + throw error; + } + ( + resolved.onError ?? + ((e: unknown) => + console.warn( + `[bugsee] could not remove the browser source maps Bugsee turned on: ${String(e)}`, + )) + )(error); + return { removed: false, failed: true }; } - return true; }; if (state.abandoned === true) { await discardForcedMaps(); @@ -304,12 +320,18 @@ export function createNextWebpackPlugin( // files, is not: it would invalidate the hashes Next already pinned, and the browser would refuse the // scripts (measured). Nothing is rewritten, so nothing is uploaded. if (!state.preStamped && (context.sri === true || (await hasSriManifest(outDir)))) { - const removed = await discardForcedMaps(); + const { removed, failed } = await discardForcedMaps(); context.say( - FALLBACK_SRI_NOTICE(kind, String(state.failure ?? 'it did not apply'), removed), + FALLBACK_SRI_NOTICE(kind, removed, { dryRun: resolved.dryRun, removalFailed: failed }), ); + // The CAUSE goes through onError / console.warn, never through the notice sink: `silent` mutes notices, + // and a failure must not vanish with them. if (state.failure !== undefined) { - resolved.onError?.(state.failure); + ( + resolved.onError ?? + ((e: unknown) => + console.warn(`[bugsee] in-build debug-ID stamping failed: ${String(e)}`)) + )(state.failure); } return; } From 331f4a3dc7a834596b1e02b639f428165dc1016c Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 16:52:11 +0500 Subject: [PATCH 14/17] fix(nextjs): round-6 lows (nothing-staged reason is reported, accurate dry-run notices, every removal attempted) - an SRI build where nothing could be staged reports a reason through onError / console.warn - the dry-run notice only claims 'nothing was deleted' when maps would have been; an abandoned stamp on a dry run says the forced maps stay public - every forced-map removal is attempted, failures collected and reported; failOnError rethrows the first - real builds: failOnError + failed SRI stamp, silent, dryRun Co-Authored-By: Claude Sonnet 5.5 --- docs/design/source-maps.md | 2 +- packages/nextjs-e2e/test/source-maps.e2e.ts | 33 ++++++++ packages/nextjs/src/config/sri.ts | 2 +- .../nextjs/src/config/webpack-plugin.test.ts | 79 ++++++++++++++++++- packages/nextjs/src/config/webpack-plugin.ts | 57 ++++++++----- 5 files changed, 149 insertions(+), 24 deletions(-) diff --git a/docs/design/source-maps.md b/docs/design/source-maps.md index df9ec8b2..a34593a5 100644 --- a/docs/design/source-maps.md +++ b/docs/design/source-maps.md @@ -514,7 +514,7 @@ measured). Only bundles that have a map are stamped on Turbopack, and bundles ar A map carries one debug-ID (the hash of bundle + map), so such bundles are left unstamped (a notice counts them) and their shared map stays on disk, unuploaded; they are Turbopack's runtime, not the app. -**SRI fallback guard.** A webpack in-build stamp that failed falls back (core) to stamping the written files; on an SRI build that rewrites bytes Next already pinned (measured: Chromium blocked every script). The per-compilation plugin therefore skips the fallback and the upload when `experimental.sri` is set or Next's integrity manifest sits next to the output (`sri.ts`, shared with the Turbopack step), with a notice. `productionBrowserSourceMaps` is forced on only when this build can upload (not Turbopack + SRI, not Turbopack < 15.4.0), so an upload that cannot happen never leaves Bugsee-requested public maps. On webpack, when no upload follows (an SRI build whose stamp failed, or an abandoned stamp), the browser maps Bugsee itself turned on are deleted from this compilation's own files; maps the app enabled stay and the notice says they are public. +**SRI fallback guard.** A webpack in-build stamp that failed falls back (core) to stamping the written files; on an SRI build that rewrites bytes Next already pinned (measured: Chromium blocked every script). The per-compilation plugin therefore skips the fallback and the upload when `experimental.sri` is set or Next's integrity manifest sits next to the output (`sri.ts`, shared with the Turbopack step), with a notice. `productionBrowserSourceMaps` is forced on only when this build can upload (not Turbopack + SRI, not Turbopack < 15.4.0), so an upload that cannot happen never leaves Bugsee-requested public maps. On webpack, when no upload follows (an SRI build whose stamp failed, or an abandoned stamp), the browser maps Bugsee itself turned on are deleted from this compilation's own files; maps the app enabled stay and the notice says they are public. Every removal is attempted and each failure reported through `onError` (console warning without one; `failOnError` rethrows the first); a throwing `onError` aborts like the core's. Nothing is deleted on a dry run. The reason a stamp did not apply is always reported through `onError`/console, never only through the (mutable) notice sink. **Composition.** The app's `webpack` function runs first and its result is extended (Next itself rejects an async one, measured on 16.4.6); its `compiler.runAfterProductionCompile` runs before ours; its `compiler.define` keys win; `productionBrowserSourceMaps` diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts index d4561dac..be1f58cb 100644 --- a/packages/nextjs-e2e/test/source-maps.e2e.ts +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -561,6 +561,39 @@ describe('withBugsee — Subresource Integrity', () => { expect(built.log).toMatch(/browser source maps Bugsee had turned on were removed/); }); + const sriFailing = (name: string, options: string) => + build({ + name, + next: 'next16', + args: ['--webpack'], + options, + nextConfig: "experimental: { sri: { algorithm: 'sha256' } },", + failInBuildStamp: true, + }); + + it('webpack + SRI + failOnError: a failed stamp fails the build, and no maps are left behind', async () => { + const built = await sriFailing('sri-webpack-strict', 'failOnError: true,'); + expect(built.status).not.toBe(0); + expect(built.log).toMatch(/inject/); + expect(maps(join(built.dir, '.next', 'static'))).toEqual([]); + }); + + it('webpack + SRI + silent: the notices are muted, the cause is still audible', async () => { + const built = await sriFailing('sri-webpack-silent', 'failOnError: false, silent: true,'); + expect(built.status, built.log.split('\n').slice(-30).join('\n')).toBe(0); + expect(built.log).not.toMatch(/Subresource Integrity/); + expect(built.log).toMatch(/in-build debug-ID stamping did not apply/); + expect(maps(join(built.dir, '.next', 'static'))).toEqual([]); + }); + + it('webpack + SRI + dryRun: a failed stamp deletes nothing, and says so', async () => { + const built = await sriFailing('sri-webpack-dry', 'failOnError: false, dryRun: true,'); + expect(built.status, built.log.split('\n').slice(-30).join('\n')).toBe(0); + expect(built.uploads).toEqual([]); + expect(maps(join(built.dir, '.next', 'static')).length).toBeGreaterThan(0); + expect(built.log).toMatch(/Dry run: nothing was deleted/); + }); + it('turbopack + SRI + maps the APP asked for: they stay, the notice says they are public, said once', async () => { const built = await build({ name: 'sri-turbopack-own-maps', diff --git a/packages/nextjs/src/config/sri.ts b/packages/nextjs/src/config/sri.ts index 2805e39a..c944cc10 100644 --- a/packages/nextjs/src/config/sri.ts +++ b/packages/nextjs/src/config/sri.ts @@ -58,7 +58,7 @@ export const FALLBACK_SRI_NOTICE = ( mapsRemoved: boolean, options: { dryRun?: boolean; removalFailed?: boolean } = {}, ): string => - `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp failed (the cause is reported separately), so nothing was stamped or uploaded: stamping after emit would invalidate the pinned hashes and make the browser refuse the scripts.` + + `the ${kind} build uses Subresource Integrity (\`experimental.sri\`) and its in-build debug-ID stamp did not apply (the reason is reported separately), so nothing was stamped or uploaded: stamping after emit would invalidate the pinned hashes and make the browser refuse the scripts.` + (kind !== 'client' ? '' : mapsRemoved diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index 2ee66a6f..738ca8e2 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -742,7 +742,7 @@ describe('createNextWebpackPlugin: no public maps Bugsee asked for when nothing const ctx = context({}, { sri: true, forcedMaps: true }); const warned = await run('client', ctx, deps({ stamp: failing() })); expect(warned).toHaveLength(1); - expect(warned[0]).toMatch(/in-build debug-ID stamping failed: Error: inject broke/); + expect(warned[0]).toMatch(/in-build debug-ID stamping did not apply: Error: inject broke/); // The notice does not carry the cause (so a silenced notice cannot be the only place it lives). expect(vi.mocked(ctx.say).mock.calls[0]?.[0]).not.toContain('inject broke'); }); @@ -802,6 +802,83 @@ describe('createNextWebpackPlugin: no public maps Bugsee asked for when nothing expect(d.remove).not.toHaveBeenCalled(); }); + it('an SRI build where nothing could be staged (no thrown cause) still reports through onError / console.warn', async () => { + const nothing = () => vi.fn(async () => ({ stamped: [], maps: {}, bundles: 0 })); + const onError = vi.fn(); + await run( + 'client', + context({ onError }, { sri: true, forcedMaps: true }), + deps({ stamp: nothing() }), + ); + expect(onError).toHaveBeenCalledWith( + expect.objectContaining({ message: expect.stringContaining('could be staged') }), + ); + const warned = await run( + 'client', + context({}, { sri: true, forcedMaps: true }), + deps({ stamp: nothing() }), + ); + expect(warned.some((w) => w.includes('could be staged'))).toBe(true); + }); + + it('tries every removal, then reports each failure (partial removal is reported, not hidden)', async () => { + const onError = vi.fn(); + const remove = vi.fn(async (path: string) => { + if (path.endsWith('a.js.map')) throw new Error(`EPERM ${path}`); + }); + const ctx = context({ onError }, { sri: true, forcedMaps: true }); + await run('client', ctx, deps({ stamp: failing(), remove })); + expect(remove).toHaveBeenCalledTimes(2); + expect(onError).toHaveBeenCalledWith( + expect.objectContaining({ message: expect.stringContaining('a.js.map') }), + ); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('could not all be removed')); + }); + + it('a throwing onError aborts the hook, as the core\u2019s own does', async () => { + const onError = vi.fn(() => { + throw new Error('host logger down'); + }); + const ctx = context({ onError }, { sri: true, forcedMaps: true }); + await expect( + run( + 'client', + ctx, + deps({ + stamp: failing(), + remove: vi.fn(async () => { + throw new Error('EPERM'); + }), + }), + ), + ).rejects.toThrow('host logger down'); + }); + + it('only claims a dry run deleted nothing when something would have been deleted', async () => { + const forced = context({ dryRun: true }, { sri: true, forcedMaps: true }); + await run('client', forced, deps({ stamp: failing() })); + expect(forced.say).toHaveBeenCalledWith( + expect.stringContaining('Dry run: nothing was deleted'), + ); + const own = context({ dryRun: true }, { sri: true }); + await run('client', own, deps({ stamp: failing() })); + expect(own.say).toHaveBeenCalledWith(expect.not.stringContaining('Dry run')); + expect(own.say).toHaveBeenCalledWith(expect.stringContaining('publicly served')); + }); + + it('an abandoned stamp on a dry run says the forced maps remain public', async () => { + const abandon = () => + vi.fn(async () => { + throw Object.assign(new Error('outside'), { unreachableMap: true }); + }); + const forced = context({ dryRun: true }, { forcedMaps: true }); + await run('client', forced, deps({ stamp: abandon() })); + expect(forced.say).toHaveBeenCalledWith(expect.stringContaining('publicly served')); + const own = context({ dryRun: true }); + await run('client', own, deps({ stamp: abandon() })); + expect(own.say).not.toHaveBeenCalled(); + }); + it('on a build without SRI the fallback message is printed, once', async () => { const warned = await run('client', context(), deps({ stamp: failing() })); expect(warned.filter((w) => w.includes('falling back to stamping after emit'))).toHaveLength(1); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index e3740ace..a7c0aafe 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -287,21 +287,26 @@ export function createNextWebpackPlugin( // No upload will follow: the browser maps Bugsee itself turned on (the app did not ask for them) must not // be left in `.next/static`, which is served publicly. Only this compilation's own files, only the ones // Bugsee forced; maps the app enabled stay. - // Never throws (a failed upload must not fail the build): reported, and only `failOnError` rethrows. Not on - // a dry run, which deletes nothing (as the core's own upload never does). + // Every removal is attempted, the failures are collected and reported afterwards (through `onError`, or a + // console warning); only `failOnError` rethrows the first. A throwing `onError` aborts like the core's own + // does. Not on a dry run, which deletes nothing (as the core's own upload never does). + const wouldDiscard = kind === 'client' && context.forcedMaps === true; const discardForcedMaps = async (): Promise<{ removed: boolean; failed: boolean }> => { - if (kind !== 'client' || context.forcedMaps !== true || resolved.dryRun) { + if (!wouldDiscard || resolved.dryRun) { return { removed: false, failed: false }; } - try { - for (const map of [...files.maps, ...files.stylesheetMaps]) { + const failures: unknown[] = []; + for (const map of [...files.maps, ...files.stylesheetMaps]) { + try { await remove(map); + } catch (error) { + failures.push(error); } - return { removed: true, failed: false }; - } catch (error) { - if (resolved.failOnError) { - throw error; - } + } + if (failures.length > 0 && resolved.failOnError) { + throw failures[0]; + } + for (const error of failures) { ( resolved.onError ?? ((e: unknown) => @@ -309,11 +314,16 @@ export function createNextWebpackPlugin( `[bugsee] could not remove the browser source maps Bugsee turned on: ${String(e)}`, )) )(error); - return { removed: false, failed: true }; } + return { removed: failures.length === 0, failed: failures.length > 0 }; }; if (state.abandoned === true) { await discardForcedMaps(); + if (wouldDiscard && resolved.dryRun) { + context.say( + 'dry run: nothing was deleted, so the browser source maps Bugsee turned on stay in `.next/static`, publicly served.', + ); + } return; } // The in-build stamp is SRI-safe (it runs before anything hashes). Its fallback, stamping the written @@ -322,17 +332,22 @@ export function createNextWebpackPlugin( if (!state.preStamped && (context.sri === true || (await hasSriManifest(outDir)))) { const { removed, failed } = await discardForcedMaps(); context.say( - FALLBACK_SRI_NOTICE(kind, removed, { dryRun: resolved.dryRun, removalFailed: failed }), + FALLBACK_SRI_NOTICE(kind, removed, { + dryRun: resolved.dryRun && wouldDiscard, + removalFailed: failed, + }), + ); + // The REASON goes through onError / console.warn, never through the notice sink: `silent` mutes notices, + // and a failure must not vanish with them. Nothing failed when nothing could be staged (no cause was + // thrown), so that case is given one. + ( + resolved.onError ?? + ((e: unknown) => + console.warn(`[bugsee] in-build debug-ID stamping did not apply: ${String(e)}`)) + )( + state.failure ?? + new Error(`none of the ${kind} build's script assets could be staged for stamping`), ); - // The CAUSE goes through onError / console.warn, never through the notice sink: `silent` mutes notices, - // and a failure must not vanish with them. - if (state.failure !== undefined) { - ( - resolved.onError ?? - ((e: unknown) => - console.warn(`[bugsee] in-build debug-ID stamping failed: ${String(e)}`)) - )(state.failure); - } return; } if (state.failure !== undefined) { From 501c9f53e48f9a70cb6ca1bdb39f4734a5cdb515 Mon Sep 17 00:00:00 2001 From: Alexey Karimov Date: Mon, 23 Nov 2026 17:55:22 +0500 Subject: [PATCH 15/17] fix(nextjs): CI-hermetic packed test; review-thread sweep - packed-config e2e no longer runs pnpm install (it failed on a clean CI store): declared third-party deps are linked from the monorepo, the packed @bugsee/* tarballs unpacked; proven with an empty store and a dead registry - build files: no depth cutoff, only ENOENT is 'nothing there' (other read errors reach the failure policy), pointer found from the last 16 KiB instead of reading whole bundles - Turbopack: the server run registers the build when the browser run had nothing to upload; the shared map notice says it stays and is public - webpack: stamped names handed to the core query-free; maps found by the compilation's recorded relationship; the server compilation registers when the app writes no browser maps - withBugsee: not forced on a dry run; the app's own compiler.define version/build labels the upload Co-Authored-By: Claude Sonnet 5.5 --- packages/nextjs-e2e/test/packed-config.e2e.ts | 62 +++++----- packages/nextjs-e2e/test/source-maps.e2e.ts | 6 +- packages/nextjs/README.md | 3 +- .../nextjs/src/config/build-files.test.ts | 34 +++++- packages/nextjs/src/config/build-files.ts | 38 +++++-- packages/nextjs/src/config/context.ts | 2 + packages/nextjs/src/config/post-build.test.ts | 17 +++ packages/nextjs/src/config/post-build.ts | 6 +- .../nextjs/src/config/webpack-plugin.test.ts | 107 ++++++++++++++++++ packages/nextjs/src/config/webpack-plugin.ts | 48 +++++++- .../src/config/with-bugsee.kind.test.ts | 70 +++++++++++- packages/nextjs/src/config/with-bugsee.ts | 16 +++ 12 files changed, 354 insertions(+), 55 deletions(-) diff --git a/packages/nextjs-e2e/test/packed-config.e2e.ts b/packages/nextjs-e2e/test/packed-config.e2e.ts index b1b03a61..5e8bb162 100644 --- a/packages/nextjs-e2e/test/packed-config.e2e.ts +++ b/packages/nextjs-e2e/test/packed-config.e2e.ts @@ -9,7 +9,9 @@ import { mkdtempSync, readdirSync, readFileSync, + realpathSync, rmSync, + symlinkSync, writeFileSync, } from 'node:fs'; import { tmpdir } from 'node:os'; @@ -44,36 +46,42 @@ beforeAll(() => { stdio: 'ignore', }); app = mkdtempSync(join(tmpdir(), 'bugsee-packed-')); - const tarballs = join(app, '.tarballs'); - mkdirSync(tarballs); - const overrides: Record = {}; + const modules = join(app, 'node_modules'); + mkdirSync(join(modules, '@bugsee'), { recursive: true }); + // The packed tarballs, unpacked as an app's node_modules (pnpm applies each `publishConfig`). for (const [name, dir] of closure) { - const out = mkdtempSync(join(tarballs, 'p-')); + const target = join(modules, name); + mkdirSync(target, { recursive: true }); + const out = mkdtempSync(join(tmpdir(), 'bugsee-pack-')); execFileSync('pnpm', ['pack', '--pack-destination', out], { cwd: dir, stdio: 'ignore' }); - overrides[name] = `file:${join(out, readdirSync(out)[0] as string)}`; + execFileSync('tar', [ + '-xzf', + join(out, readdirSync(out)[0] as string), + '-C', + target, + '--strip-components=1', + ]); + rmSync(out, { recursive: true, force: true }); } - writeFileSync( - join(app, 'package.json'), - JSON.stringify({ - name: 'app', - version: '3.2.1', - private: true, - dependencies: { '@bugsee/nextjs': overrides['@bugsee/nextjs'] }, - }), - ); - // A CLEAN install of the packed tarballs, as a user gets them: every `@bugsee/*` the packed manifests name is - // redirected to its tarball (they are not on a registry), everything else comes from the offline store. A - // dependency a package forgot to declare is simply not there, instead of being found through the monorepo. - writeFileSync( - join(app, 'pnpm-workspace.yaml'), - `overrides:\n${Object.entries(overrides) - .map(([name, spec]) => ` '${name}': '${spec}'`) - .join('\n')}\n`, - ); - execFileSync('pnpm', ['install', '--offline', '--no-frozen-lockfile', '--ignore-scripts'], { - cwd: app, - stdio: 'pipe', - }); + // Third-party dependencies, and ONLY the ones the packed manifests DECLARE. No registry, no package store: each + // declared dependency is linked from where the monorepo installed it (its own transitive dependencies resolve from + // that real location). A dependency a package uses but forgot to declare is therefore missing here, exactly as it + // would be for a user, which a monorepo-wide node_modules would hide. + for (const [name] of closure) { + const packed = JSON.parse(readFileSync(join(modules, name, 'package.json'), 'utf8')) as { + dependencies?: Record; + optionalDependencies?: Record; + }; + for (const dep of Object.keys({ ...packed.dependencies, ...packed.optionalDependencies })) { + if (closure.has(dep)) continue; + const installed = join(closure.get(name) as string, 'node_modules', dep); + const link = join(modules, dep); + if (!existsSync(installed) || existsSync(link)) continue; + mkdirSync(dirname(link), { recursive: true }); + symlinkSync(realpathSync(installed), link); + } + } + writeFileSync(join(app, 'package.json'), JSON.stringify({ name: 'app', version: '3.2.1' })); }, 900_000); afterAll(() => { diff --git a/packages/nextjs-e2e/test/source-maps.e2e.ts b/packages/nextjs-e2e/test/source-maps.e2e.ts index be1f58cb..37cf7902 100644 --- a/packages/nextjs-e2e/test/source-maps.e2e.ts +++ b/packages/nextjs-e2e/test/source-maps.e2e.ts @@ -586,12 +586,12 @@ describe('withBugsee — Subresource Integrity', () => { expect(maps(join(built.dir, '.next', 'static'))).toEqual([]); }); - it('webpack + SRI + dryRun: a failed stamp deletes nothing, and says so', async () => { + it('webpack + SRI + dryRun: browser maps are not forced on, so none are written or left public', async () => { const built = await sriFailing('sri-webpack-dry', 'failOnError: false, dryRun: true,'); expect(built.status, built.log.split('\n').slice(-30).join('\n')).toBe(0); expect(built.uploads).toEqual([]); - expect(maps(join(built.dir, '.next', 'static')).length).toBeGreaterThan(0); - expect(built.log).toMatch(/Dry run: nothing was deleted/); + expect(maps(join(built.dir, '.next', 'static'))).toEqual([]); + expect(built.log).not.toMatch(/Dry run: nothing was deleted/); }); it('turbopack + SRI + maps the APP asked for: they stay, the notice says they are public, said once', async () => { diff --git a/packages/nextjs/README.md b/packages/nextjs/README.md index f9d2f177..485293c3 100644 --- a/packages/nextjs/README.md +++ b/packages/nextjs/README.md @@ -86,7 +86,7 @@ CommonJS works as well: `const { withBugsee } = require("@bugsee/nextjs/config") What it does, for a production build: -- Turns on `productionBrowserSourceMaps` (only when you did not set it, and only when this build can actually upload: not for Turbopack with `experimental.sri`, not for Turbopack on Next older than 15.4.0) so the browser bundles have maps to upload. Where it cannot upload it leaves the option as you set it and says so. +- Turns on `productionBrowserSourceMaps` (only when you did not set it, and only when this build can actually upload: not for Turbopack with `experimental.sri`, not for Turbopack on Next older than 15.4.0, not on a `dryRun`) so the browser bundles have maps to upload. Where it cannot upload it leaves the option as you set it and says so. - **webpack**: adds one Bugsee plugin to each of the client, server and edge compilations. Each stamps a debug ID into its bundles inside the build (before Subresource Integrity hashes are taken) and, after emit, uploads the maps of exactly the files that compilation wrote. - **Turbopack**: has no plugin API, so the upload runs from Next's `compiler.runAfterProductionCompile` hook (Next 15.4.0 or later): after Turbopack wrote `.next` and before Next generates the static pages, it stamps the written bundles with the real `bugsee-cli sourcemaps inject` (verified, and undone if a stamp does not verify), uploads the maps and removes them. - Deletes the browser maps (`.next/static/**/*.map`, which `next start` and CDNs serve publicly) after a confirmed upload. Server and edge maps stay on disk (`deleteServerMaps` to remove them). @@ -109,6 +109,7 @@ Things to know: - The config is resolved once, at load, from the working directory: the token file, the app version and the installed Next version are looked up there. Run `next build` from the project directory. For a Turbopack build the hook is told which project Next is building, and prints a notice if that differs (for example `next build apps/web` from a monorepo root). - `withBugsee` turns `productionBrowserSourceMaps` on, so the browser maps are written to `.next/static`, which is served publicly. They are deleted after a confirmed upload. If the upload fails (and `failOnError` is off) they stay there, publicly served, so you can retry. If that is not acceptable, set `failOnError: true` so a failed upload stops the build, or delete `.next/static/**/*.map` in your deploy step. - Next 15's Turbopack builds point two runtime chunks at one shared map. Those chunks are left unstamped and that map is neither uploaded nor deleted: it stays in `.next/static`, public. It contains Turbopack's runtime source, not your code. +- If your own `compiler.define` sets `__BUGSEE_APP_VERSION__` or `__BUGSEE_APP_BUILD__` to a string, that is the value the runtime SDK reports, and the upload and the build registration are labelled with it too. A non-string value is ignored (the resolved version is used). - `compiler.define` (the baked version and build) needs Next 15.1.0 or later; the Turbopack upload needs 15.4.0 or later. - `@bugsee/nextjs` depends on `@bugsee/bundler-plugin-core` (which brings `@bugsee/cli`, acorn, magic-string and unplugin) so that `withBugsee` works with no extra install. Only `next.config` loads it; your app bundles never import it. Making it an optional peer would force every user of the config to install it by hand and break `next build` out of the box, so it stays a regular dependency. diff --git a/packages/nextjs/src/config/build-files.test.ts b/packages/nextjs/src/config/build-files.test.ts index f446dd1c..1fea9fb4 100644 --- a/packages/nextjs/src/config/build-files.test.ts +++ b/packages/nextjs/src/config/build-files.test.ts @@ -1,4 +1,4 @@ -import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; +import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; @@ -229,9 +229,35 @@ describe('collectBuildFiles', () => { }); }); - it('stops at a depth limit instead of walking an unbounded tree', async () => { - bundle(`${Array.from({ length: 14 }, (_, i) => `d${i}`).join('/')}/a.js`); + it('collects deeply nested output: no depth cutoff silently drops a route\u2019s bundle', async () => { + const deep = `${Array.from({ length: 30 }, (_, i) => `d${i}`).join('/')}/page.js`; + bundle(deep); bundle('top.js'); - expect((await collectBuildFiles(root)).scripts).toEqual([join(root, 'top.js')]); + const scripts = (await collectBuildFiles(root)).scripts; + expect(scripts).toHaveLength(2); + expect(scripts).toContain(join(root, deep)); + }); + + it('reads only the END of a bundle to find its pointer', async () => { + // A pointer-looking comment at the START of a large file is not the bundle\u2019s pointer; only the tail counts. + put('big.js', `//# sourceMappingURL=big.js.map\n${'x'.repeat(40_000)}\nend();\n`); + put('big.js.map'); + expect((await collectBuildFiles(root)).scripts).toEqual([]); + put('big2.js', `${'x'.repeat(40_000)}\n//# sourceMappingURL=big2.js.map\n`); + put('big2.js.map'); + expect((await collectBuildFiles(root)).scripts).toEqual([join(root, 'big2.js')]); + }); + + it('reports a directory it cannot read instead of calling it empty', async () => { + put('locked/a.js'); + chmodSync(join(root, 'locked'), 0o000); + try { + if (process.getuid?.() === 0) { + return; // root reads it anyway + } + await expect(collectBuildFiles(root)).rejects.toThrow(/EACCES/); + } finally { + chmodSync(join(root, 'locked'), 0o755); + } }); }); diff --git a/packages/nextjs/src/config/build-files.ts b/packages/nextjs/src/config/build-files.ts index 7d84a630..0dafa9e2 100644 --- a/packages/nextjs/src/config/build-files.ts +++ b/packages/nextjs/src/config/build-files.ts @@ -1,7 +1,7 @@ // Which files of a Next build the upload covers, named explicitly. The upload never walks `.next` and never // takes a directory: it is handed exactly these paths, so it cannot stamp, upload or delete a file that is not // part of the build it is looking at (the webpack compilations and the Turbopack output share `.next`). -import { readdir, readFile } from 'node:fs/promises'; +import { open, readdir } from 'node:fs/promises'; import { dirname, join, resolve } from 'node:path'; /** A build's bundles and the maps that belong to them. */ @@ -17,27 +17,43 @@ export interface BuildFiles { } const SCRIPT = /\.[cm]?js$/i; -const MAX_DEPTH = 12; +/** How much of the END of a file is read to find its source-map comment (the comment is a line or two). */ +const TAIL_BYTES = 16 * 1024; /** Directories that are never build output, wherever they appear (a route may well be called `cache`). */ const SKIP = new Set(['node_modules']); -async function listFiles(dir: string, depth: number): Promise { - if (depth > MAX_DEPTH) { - return []; +/** The last {@link TAIL_BYTES} of a file as text (the whole file when it is smaller). */ +async function readTail(file: string): Promise { + const handle = await open(file, 'r'); + try { + const { size } = await handle.stat(); + const length = Math.min(size, TAIL_BYTES); + const buffer = Buffer.alloc(length); + await handle.read(buffer, 0, length, size - length); + return buffer.toString('utf8'); + } finally { + await handle.close(); } +} + +async function listFiles(dir: string): Promise { let entries: import('node:fs').Dirent[]; try { entries = await readdir(dir, { withFileTypes: true }); - } catch { - // A directory the build did not produce (no `server` output, say) contributes nothing. - return []; + } catch (error) { + // A directory the build did not produce (no `server` output, say) contributes nothing; any other failure + // (EACCES, EIO) is NOT "nothing to upload" and is left to the caller's failure policy. + if ((error as NodeJS.ErrnoException).code === 'ENOENT') { + return []; + } + throw error; } const found: string[] = []; for (const entry of entries) { const full = join(dir, entry.name); if (entry.isDirectory()) { if (!SKIP.has(entry.name)) { - found.push(...(await listFiles(full, depth + 1))); + found.push(...(await listFiles(full))); } } else if (entry.isFile()) { found.push(full); @@ -84,7 +100,7 @@ export function mapPointerOf(file: string, code: string): string | undefined { */ export async function pairByPointer( files: readonly string[], - read: (file: string) => Promise = (file) => readFile(file, 'utf8'), + read: (file: string) => Promise = readTail, ): Promise { const present = new Set(files); const pointers = new Map(); @@ -123,5 +139,5 @@ export async function pairByPointer( /** The build files under `dir` (recursively), paired by pointer; none when `dir` does not exist. */ export async function collectBuildFiles(dir: string): Promise { - return pairByPointer(await listFiles(dir, 0)); + return pairByPointer(await listFiles(dir)); } diff --git a/packages/nextjs/src/config/context.ts b/packages/nextjs/src/config/context.ts index a5f6148a..6a976c97 100644 --- a/packages/nextjs/src/config/context.ts +++ b/packages/nextjs/src/config/context.ts @@ -48,6 +48,8 @@ export interface BugseeNextContext { sri?: boolean; /** `withBugsee` itself turned `productionBrowserSourceMaps` on (the app did not ask for browser maps). */ forcedMaps?: boolean; + /** Browser source maps are written for this build (the app asked for them, or Bugsee turned them on). */ + browserMaps?: boolean; /** A notice said once per distinct text (a no-op when `silent`). */ say(message: string): void; } diff --git a/packages/nextjs/src/config/post-build.test.ts b/packages/nextjs/src/config/post-build.test.ts index 6e98a420..ce8f4da2 100644 --- a/packages/nextjs/src/config/post-build.test.ts +++ b/packages/nextjs/src/config/post-build.test.ts @@ -117,6 +117,23 @@ describe('runPostBuild', () => { expect(d.upload).toHaveBeenCalledTimes(2); }); + it('says the shared map itself stays (and is public) when it is in .next/static', async () => { + const ctx = context(); + const d = deps({ '/app/.next/static': { ...files('c'), shared: ['/d/x.js'] } }); + await runPostBuild(ctx, metadata, d); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('neither uploaded nor deleted')); + expect(ctx.say).toHaveBeenCalledWith(expect.stringContaining('publicly served')); + }); + + it('registers the build from the server run when the browser had nothing to upload', async () => { + const d = deps({ '/app/.next/server': files('s') }); + await runPostBuild(context(), metadata, d); + const [resolved] = (d.upload as ReturnType).mock.calls[0] as [ + Record, + ]; + expect(resolved.registerBuild).toBe('release'); + }); + it('stays quiet about shared maps when there are none', async () => { const ctx = context(); await runPostBuild(ctx, metadata, deps({ '/app/.next/static': files('c') })); diff --git a/packages/nextjs/src/config/post-build.ts b/packages/nextjs/src/config/post-build.ts index 70df4351..a9c10c2a 100644 --- a/packages/nextjs/src/config/post-build.ts +++ b/packages/nextjs/src/config/post-build.ts @@ -79,7 +79,7 @@ async function postBuild( const shared = (client.shared?.length ?? 0) + (server?.shared?.length ?? 0); if (shared > 0) { context.say( - `${shared} bundle(s) share one source map with another bundle (Next 15's Turbopack does this for its runtime chunks), so they were left unstamped: a map carries one debug-ID.`, + `${shared} bundle(s) share one source map with another bundle (Next 15's Turbopack does this for its runtime chunks), so they were left unstamped: a map carries one debug-ID. The shared map itself was neither uploaded nor deleted: if it is in \`.next/static\` it is publicly served (it holds Turbopack's runtime source, not yours).`, ); } @@ -99,7 +99,9 @@ async function postBuild( if (server !== undefined) { await runFor(join(distDir, 'server'), server, { deleteMaps: context.deleteServerMaps, - registerBuild: false, + // The build is registered once. When the browser run had nothing to upload (the app turned browser maps off), + // the server run registers it instead, so the build record is not lost. + ...(client.scripts.length === 0 ? {} : { registerBuild: false }), }); } } diff --git a/packages/nextjs/src/config/webpack-plugin.test.ts b/packages/nextjs/src/config/webpack-plugin.test.ts index 738ca8e2..4585891e 100644 --- a/packages/nextjs/src/config/webpack-plugin.test.ts +++ b/packages/nextjs/src/config/webpack-plugin.test.ts @@ -4,6 +4,7 @@ import { type CompilerLike, createNextWebpackPlugin, nextAssetStore, + pairRecorded, removeFile, type WebpackPluginDeps, } from './webpack-plugin'; @@ -936,3 +937,109 @@ describe('removeFile', () => { } }); }); + +describe('pairRecorded', () => { + const emitted = (names: string[]) => names.map((n) => `/o/${n}`); + + it('pairs a script with the map the compilation recorded for it, wherever that map is', () => { + const { compilation } = fakeCompilation( + { 'static/a.js': 'x', 'maps/a.js.map': 'm', 'static/b.js': 'x', 'static/b.js.map': 'm' }, + { 'static/a.js': 'maps/a.js.map' }, + ); + const files = pairRecorded( + compilation, + '/o', + emitted(['static/a.js', 'maps/a.js.map', 'static/b.js', 'static/b.js.map']), + ); + expect(files.scripts).toEqual(['/o/static/a.js', '/o/static/b.js']); + expect(files.maps).toEqual(['/o/maps/a.js.map', '/o/static/b.js.map']); + }); + + it('accepts a recorded list and a ?query on the recorded map', () => { + const { compilation } = fakeCompilation( + { 'a.js': 'x', 'm/a.js.map?v': 'm' }, + { 'a.js': ['m/a.js.map?v', 'other'] }, + ); + expect(pairRecorded(compilation, '/o', emitted(['a.js', 'm/a.js.map'])).maps).toEqual([ + '/o/m/a.js.map', + ]); + }); + + it('ignores a recorded map that was not emitted, and scripts with none recorded', () => { + const { compilation } = fakeCompilation( + { 'a.js': 'x', 'b.js': 'x', 'c.txt': 'x' }, + { 'a.js': 'gone.js.map' }, + ); + const files = pairRecorded(compilation, '/o', emitted(['a.js', 'b.js', 'c.txt'])); + expect(files.scripts).toEqual([]); + expect(files.maps).toEqual([]); + }); + + it('does not pair a script that was not itself emitted', () => { + const { compilation } = fakeCompilation( + { 'a.js': 'x', 'm/a.js.map': 'm' }, + { 'a.js': 'm/a.js.map' }, + ); + expect(pairRecorded(compilation, '/o', emitted(['m/a.js.map'])).scripts).toEqual([]); + }); +}); + +describe('createNextWebpackPlugin: queries, recorded maps, registration', () => { + it('hands the on-disk re-check query-free names (the file on disk has no ?query)', async () => { + const d = deps({ + stamp: vi.fn(async (store) => { + store.names(); + return { stamped: ['static/a.js'], maps: { 'static/a.js': 'static/a.js.map' }, bundles: 1 }; + }), + }); + const fake = fakeCompiler({ path: '/o' }); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation({ 'static/a.js?v=1': 'x', 'static/a.js.map?v=1': 'm' }); + fake.startCompilation(c.compilation); + await c.run(); + await fake.emit(c.compilation); + const [, , options] = (d.upload as ReturnType).mock.calls[0] as [ + unknown, + unknown, + { stampedBundles: string[]; stampedMaps: Record }, + ]; + expect(options.stampedBundles).toEqual(['static/a.js']); + expect(options.stampedMaps).toEqual({ 'static/a.js': 'static/a.js.map' }); + }); + + it('uploads maps a script\u2019s recorded relationship names even when none sits beside it', async () => { + const d = deps(); + const fake = fakeCompiler({ path: '/o' }); + createNextWebpackPlugin(context(), 'client', d).apply(fake.compiler); + const c = fakeCompilation( + { 'static/a.js': 'x', 'maps/a.js.map': 'm' }, + { 'static/a.js': 'maps/a.js.map' }, + ); + fake.startCompilation(c.compilation); + await fake.emit(c.compilation); + expect(d.upload).toHaveBeenCalledTimes(1); + }); + + it('the server compilation registers the build only when the app writes no browser maps', async () => { + const reg = async (browserMaps: boolean | undefined, kind: 'client' | 'server' | 'edge') => { + const d = deps(); + const fake = fakeCompiler({ path: '/o' }); + createNextWebpackPlugin( + context({}, { ...(browserMaps === undefined ? {} : { browserMaps }) }), + kind, + d, + ).apply(fake.compiler); + const c = fakeCompilation({ 'a.js': 'x', 'a.js.map': 'm' }); + fake.startCompilation(c.compilation); + await fake.emit(c.compilation); + return (d.upload as ReturnType).mock.calls[0]?.[0] as { + registerBuild: unknown; + }; + }; + expect((await reg(false, 'server')).registerBuild).toBe('release'); + expect((await reg(true, 'server')).registerBuild).toBe(false); + expect((await reg(undefined, 'server')).registerBuild).toBe(false); + expect((await reg(false, 'edge')).registerBuild).toBe(false); + expect((await reg(false, 'client')).registerBuild).toBe('release'); + }); +}); diff --git a/packages/nextjs/src/config/webpack-plugin.ts b/packages/nextjs/src/config/webpack-plugin.ts index a7c0aafe..0ca37a72 100644 --- a/packages/nextjs/src/config/webpack-plugin.ts +++ b/packages/nextjs/src/config/webpack-plugin.ts @@ -182,6 +182,39 @@ export function nextAssetStore( }; } +/** + * The emitted scripts paired with their maps: a map named `