diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots.toml b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots.toml index 11306be0d3..eab0bae3d0 100644 --- a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots.toml +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots.toml @@ -20,3 +20,28 @@ steps = [ ["vp", "pack"], ["vpt", "print-file", "dist/index.d.mts"], ] + +[[case]] +name = "command_pack_dts_tsrs" +vp = "global" +local-registry = true +comment = "Without typescript, the packed CLI generates inferred declarations with the bundled tsrs. The experimental tsrs notice does not fail --fail-on-warn. pnpm hoist:false keeps undeclared compilers out of reach." +steps = [ + { argv = ["vpt", "json-edit", "package.json", "devDependencies", "{\"vite-plus\":\"latest\"}"], snapshot = false }, + { argv = ["vp", "install", "--ignore-scripts"], snapshot = false }, + ["vp", "pack", "--fail-on-warn"], + ["vpt", "print-file", "dist/index.d.mts"], +] + +[[case]] +name = "command_pack_dts_tsrs_hoisted" +vp = "global" +local-registry = true +comment = "With pnpm's default hoisting and no typescript, no transitive typescript reaches the declaration plugin, so the bundled tsrs generates the declarations." +steps = [ + { argv = ["vpt", "json-edit", "package.json", "devDependencies", "{\"vite-plus\":\"latest\"}"], snapshot = false }, + { argv = ["vpt", "write-file", "pnpm-workspace.yaml", "minimumReleaseAge: 0"], snapshot = false }, + { argv = ["vp", "install", "--ignore-scripts"], snapshot = false }, + ["vp", "pack"], + ["vpt", "print-file", "dist/index.d.mts"], +] diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots/command_pack_dts_tsrs.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots/command_pack_dts_tsrs.md new file mode 100644 index 0000000000..17a525e4f4 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots/command_pack_dts_tsrs.md @@ -0,0 +1,34 @@ +# command_pack_dts_tsrs + +Without typescript, the packed CLI generates inferred declarations with the bundled tsrs. The experimental tsrs notice does not fail --fail-on-warn. pnpm hoist:false keeps undeclared compilers out of reach. + +## `vpt json-edit package.json devDependencies '{"vite-plus":"latest"}'` + + +## `vp install --ignore-scripts` + + +## `vp pack --fail-on-warn` + +``` +VITE+ - The Unified Toolchain for the Web + +ℹ entry: src/index.ts +ℹ tsconfig: tsconfig.json +ℹ Generating declarations with bundled tsrs (experimental) because `typescript` is not installed +ℹ Build start +ℹ Emit types with tsrs +ℹ dist/index.mjs kB │ gzip: kB +ℹ dist/index.d.mts kB │ gzip: kB +ℹ 2 files, total: kB +✔ Build complete in +``` + +## `vpt print-file dist/index.d.mts` + +``` +export declare function greet(name: string): { + message: string; + length: number; +}; +``` diff --git a/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots/command_pack_dts_tsrs_hoisted.md b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots/command_pack_dts_tsrs_hoisted.md new file mode 100644 index 0000000000..abd7d08d63 --- /dev/null +++ b/crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots/command_pack_dts_tsrs_hoisted.md @@ -0,0 +1,37 @@ +# command_pack_dts_tsrs_hoisted + +With pnpm's default hoisting and no typescript, no transitive typescript reaches the declaration plugin, so the bundled tsrs generates the declarations. + +## `vpt json-edit package.json devDependencies '{"vite-plus":"latest"}'` + + +## `vpt write-file pnpm-workspace.yaml 'minimumReleaseAge: 0'` + + +## `vp install --ignore-scripts` + + +## `vp pack` + +``` +VITE+ - The Unified Toolchain for the Web + +ℹ entry: src/index.ts +ℹ tsconfig: tsconfig.json +ℹ Generating declarations with bundled tsrs (experimental) because `typescript` is not installed +ℹ Build start +ℹ Emit types with tsrs +ℹ dist/index.mjs kB │ gzip: kB +ℹ dist/index.d.mts kB │ gzip: kB +ℹ 2 files, total: kB +✔ Build complete in +``` + +## `vpt print-file dist/index.d.mts` + +``` +export declare function greet(name: string): { + message: string; + length: number; +}; +``` diff --git a/docs/guide/pack.md b/docs/guide/pack.md index 2bcc6c8da9..7f0726d603 100644 --- a/docs/guide/pack.md +++ b/docs/guide/pack.md @@ -41,6 +41,24 @@ export default defineConfig({ }); ``` +## Declaration Files + +With `dts` enabled, tsdown selects the declaration generator. It uses the project's `typescript`, or Oxc when the tsconfig enables `isolatedDeclarations`. + +If `typescript` is not installed, `vp pack` generates declarations with the `tsrs` compiler that Vite+ ships for type-aware linting. This support is experimental. tsrs reads compiler options only from the tsconfig file, so `dts.compilerOptions` and `dts.tsconfigRaw` require `typescript`. + +To use tsrs also when the project installs `typescript`, set the generator: + +```ts [vite.config.ts] +import { defineConfig } from 'vite-plus'; + +export default defineConfig({ + pack: { + dts: { generator: 'tsrs' }, + }, +}); +``` + ## Standalone Executables `vp pack` can also build standalone executables through tsdown's experimental [`exe` option](https://tsdown.dev/options/exe#executable). diff --git a/packages/cli/src/__tests__/pack-dts.spec.ts b/packages/cli/src/__tests__/pack-dts.spec.ts new file mode 100644 index 0000000000..84658a07cc --- /dev/null +++ b/packages/cli/src/__tests__/pack-dts.spec.ts @@ -0,0 +1,323 @@ +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; + +import type { ResolvedConfig } from 'vite/pack'; +import { afterEach, describe, expect, it } from 'vitest'; + +import type { DtsGeneratorEnvironment } from '../pack-dts.js'; +import { + hasExplicitDtsGenerator, + readIsolatedDeclarations, + selectDtsGenerator, + TSRS_EXPERIMENTAL_WARNING, + withTsrsWarningSuppressed, +} from '../pack-dts.js'; + +const TSRS_URL = 'file:///bundled/tsrs/lib/version.cjs'; +const TSRS_NOTICE = + 'tsrs support is highly experimental and may change or break without notice. Some options will be unavailable.'; + +const tempDirs: Array = []; + +/** The declaration options of a resolved tsdown config, as `vp pack` passes them. */ +type DtsOptions = Exclude; + +function createProject(files: Record) { + const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'vp-pack-dts-')); + tempDirs.push(dir); + for (const [name, content] of Object.entries(files)) { + const file = path.join(dir, name); + fs.mkdirSync(path.dirname(file), { recursive: true }); + fs.writeFileSync(file, content); + } + return dir; +} + +afterEach(() => { + for (const dir of tempDirs.splice(0, tempDirs.length)) { + fs.rmSync(dir, { recursive: true, force: true }); + } +}); + +function environment(typescriptPath?: string): DtsGeneratorEnvironment { + return { + resolveTypeScript: () => typescriptPath, + tsrsModuleUrl: () => TSRS_URL, + }; +} + +const noTypeScript = environment(); +const PLAIN_TSCONFIG = JSON.stringify({ compilerOptions: { strict: true } }); + +function config(cwd: string, dts: false | DtsOptions, tsconfig: false | string = 'tsconfig.json') { + return { cwd, dts, tsconfig: tsconfig && path.join(cwd, tsconfig) }; +} + +describe('selectDtsGenerator', () => { + it('selects bundled tsrs when typescript does not resolve', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect(selectDtsGenerator(config(cwd, {}), noTypeScript)).toEqual({ + kind: 'tsrs', + dts: { generator: 'tsrs', tsrs: { moduleUrl: TSRS_URL } }, + }); + }); + + it('keeps other declaration options when it selects tsrs', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + const dts = { sourcemap: true, tsrs: { vfs: true } }; + + expect(selectDtsGenerator(config(cwd, dts), noTypeScript).dts).toEqual({ + generator: 'tsrs', + sourcemap: true, + tsrs: { vfs: true, moduleUrl: TSRS_URL }, + }); + expect(dts).toEqual({ sourcemap: true, tsrs: { vfs: true } }); + }); + + it('keeps upstream selection when typescript resolves', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + const dts = {}; + + expect(selectDtsGenerator(config(cwd, dts), environment('/ts/package.json'))).toEqual({ + kind: 'unchanged', + dts, + typescriptPath: '/ts/package.json', + }); + }); + + it('leaves disabled declarations unchanged', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect(selectDtsGenerator(config(cwd, false), noTypeScript)).toEqual({ + kind: 'unchanged', + dts: false, + }); + }); + + it.each<{ name: string; generator: DtsOptions['generator'] }>([ + { name: 'tsc', generator: 'tsc' }, + { name: 'oxc', generator: 'oxc' }, + { name: 'tsgo', generator: 'tsgo' }, + { name: 'custom', generator: { emit: () => ({ code: '' }) } }, + ])('keeps an explicit $name generator', ({ generator }) => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + const dts = { generator }; + + expect(selectDtsGenerator(config(cwd, dts), noTypeScript)).toEqual({ + kind: 'unchanged', + dts, + }); + }); + + it('supplies the bundled tsrs to an explicit tsrs generator', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect( + selectDtsGenerator(config(cwd, { generator: 'tsrs' }), environment('/ts/package.json')), + ).toEqual({ + kind: 'explicit-tsrs', + dts: { generator: 'tsrs', tsrs: { moduleUrl: TSRS_URL } }, + }); + }); + + it('keeps a user tsrs moduleUrl', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + const dts: DtsOptions = { generator: 'tsrs', tsrs: { moduleUrl: 'file:///custom/tsrs.cjs' } }; + + expect(selectDtsGenerator(config(cwd, dts), noTypeScript).dts).toBe(dts); + }); + + it.each([ + ['tsc.vue', { tsc: { vue: true } }], + ['the deprecated vue option', { vue: true }], + ['custom languages', { customLanguages: [{ extensionPatterns: [/\.custom$/] }] }], + ])('keeps upstream selection for %s', (_name, dts) => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect(selectDtsGenerator(config(cwd, dts), noTypeScript).kind).toBe('unchanged'); + }); + + it('keeps upstream selection when no tsconfig is used', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect(selectDtsGenerator(config(cwd, {}, false), noTypeScript).kind).toBe('unchanged'); + expect(selectDtsGenerator(config(cwd, { tsconfig: false }), noTypeScript).kind).toBe( + 'unchanged', + ); + expect(selectDtsGenerator(config(cwd, { tsconfig: 'missing.json' }), noTypeScript).kind).toBe( + 'unchanged', + ); + }); + + it('reads the tsconfig that dts.tsconfig selects, relative to dts.cwd', () => { + const cwd = createProject({ + 'tsconfig.json': PLAIN_TSCONFIG, + 'pkg/tsconfig.build.json': JSON.stringify({ + compilerOptions: { isolatedDeclarations: true }, + }), + }); + const dts = { cwd: path.join(cwd, 'pkg'), tsconfig: 'tsconfig.build.json' }; + + expect(selectDtsGenerator(config(cwd, dts), noTypeScript).kind).toBe('unchanged'); + }); + + it('discovers the nearest tsconfig from dts.cwd when dts.tsconfig is true', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ compilerOptions: { isolatedDeclarations: true } }), + }); + const dts = { cwd: path.join(cwd, 'src', 'nested'), tsconfig: true }; + fs.mkdirSync(dts.cwd, { recursive: true }); + + expect(selectDtsGenerator(config(cwd, dts, false), noTypeScript).kind).toBe('unchanged'); + }); + + it('keeps Oxc for isolated declarations', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ compilerOptions: { isolatedDeclarations: true } }), + }); + + expect(selectDtsGenerator(config(cwd, {}), noTypeScript).kind).toBe('unchanged'); + }); + + it('keeps Oxc when dts.compilerOptions enables isolated declarations', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + const dts = { compilerOptions: { isolatedDeclarations: true } }; + + expect(selectDtsGenerator(config(cwd, dts), noTypeScript).kind).toBe('unchanged'); + }); + + it('keeps upstream selection when the tsconfig cannot be read', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ extends: './missing.json' }), + }); + + expect(selectDtsGenerator(config(cwd, {}), noTypeScript).kind).toBe('unchanged'); + }); + + it.each([ + ['dts.compilerOptions', { compilerOptions: { stripInternal: true } }], + ['dts.tsconfigRaw', { tsconfigRaw: { include: ['src'] } }], + ])('rejects %s without typescript', (name, dts) => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect(() => selectDtsGenerator(config(cwd, dts), noTypeScript)).toThrow( + `\`${name}\` cannot be used without \`typescript\`. The bundled tsrs declaration generator reads compiler options only from the tsconfig file. Move these options into ${path.join(cwd, 'tsconfig.json')}, or install \`typescript\`.`, + ); + }); + + it('accepts empty compiler option overrides', () => { + const cwd = createProject({ 'tsconfig.json': PLAIN_TSCONFIG }); + + expect( + selectDtsGenerator(config(cwd, { compilerOptions: {}, tsconfigRaw: {} }), noTypeScript).kind, + ).toBe('tsrs'); + }); +}); + +describe('readIsolatedDeclarations', () => { + it('reads JSONC', () => { + const cwd = createProject({ + 'tsconfig.json': `{ + // comment + "compilerOptions": { "isolatedDeclarations": true, }, +}`, + }); + + expect(readIsolatedDeclarations(path.join(cwd, 'tsconfig.json'))).toBe(true); + }); + + it('follows relative extends without the .json extension', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ extends: './configs/base' }), + 'configs/base.json': JSON.stringify({ compilerOptions: { isolatedDeclarations: true } }), + }); + + expect(readIsolatedDeclarations(path.join(cwd, 'tsconfig.json'))).toBe(true); + }); + + it('follows package extends', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ extends: '@scope/tsconfig' }), + 'node_modules/@scope/tsconfig/package.json': JSON.stringify({ name: '@scope/tsconfig' }), + 'node_modules/@scope/tsconfig/tsconfig.json': JSON.stringify({ + compilerOptions: { isolatedDeclarations: true }, + }), + }); + + expect(readIsolatedDeclarations(path.join(cwd, 'tsconfig.json'))).toBe(true); + }); + + it('lets later extends entries and the file itself override earlier values', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ extends: ['./on.json', './off.json'] }), + 'override.json': JSON.stringify({ + extends: './on.json', + compilerOptions: { isolatedDeclarations: false }, + }), + 'reset.json': JSON.stringify({ + extends: './on.json', + compilerOptions: { isolatedDeclarations: null }, + }), + 'on.json': JSON.stringify({ compilerOptions: { isolatedDeclarations: true } }), + 'off.json': JSON.stringify({ compilerOptions: { isolatedDeclarations: false } }), + }); + + expect(readIsolatedDeclarations(path.join(cwd, 'tsconfig.json'))).toBe(false); + expect(readIsolatedDeclarations(path.join(cwd, 'override.json'))).toBe(false); + expect(readIsolatedDeclarations(path.join(cwd, 'reset.json'))).toBe(false); + }); + + it('reads a base that several extends entries share', () => { + const cwd = createProject({ + 'tsconfig.json': JSON.stringify({ extends: ['./a.json', './b.json'] }), + 'a.json': JSON.stringify({ extends: './base.json' }), + 'b.json': JSON.stringify({ extends: './base.json' }), + 'base.json': JSON.stringify({ compilerOptions: { strict: true } }), + }); + + expect(readIsolatedDeclarations(path.join(cwd, 'tsconfig.json'))).toBe(false); + }); + + it('returns undefined for an unreadable chain', () => { + const cwd = createProject({ + 'invalid.json': '{', + 'cycle-a.json': JSON.stringify({ extends: './cycle-b.json' }), + 'cycle-b.json': JSON.stringify({ extends: './cycle-a.json' }), + 'missing-package.json': JSON.stringify({ extends: '@scope/missing' }), + }); + + for (const file of ['invalid.json', 'cycle-a.json', 'missing-package.json']) { + expect(readIsolatedDeclarations(path.join(cwd, file)), file).toBeUndefined(); + } + }); +}); + +describe('warning suppression', () => { + it('matches the declaration plugin notice for tsrs only', () => { + expect(TSRS_EXPERIMENTAL_WARNING.test(TSRS_NOTICE)).toBe(true); + expect(TSRS_EXPERIMENTAL_WARNING.test('TypeScript Go is experimental.')).toBe(false); + }); + + it('keeps user entries', () => { + expect(withTsrsWarningSuppressed(undefined)).toBe(TSRS_EXPERIMENTAL_WARNING); + expect(withTsrsWarningSuppressed('custom')).toEqual(['custom', TSRS_EXPERIMENTAL_WARNING]); + expect(withTsrsWarningSuppressed([/a/, 'b'])).toEqual([/a/, 'b', TSRS_EXPERIMENTAL_WARNING]); + + const suppress = withTsrsWarningSuppressed((message) => message === 'custom'); + if (typeof suppress !== 'function') { + throw new TypeError('Expected a suppressWarnings function'); + } + expect(suppress('custom')).toBe(true); + expect(suppress(TSRS_NOTICE)).toBe(true); + expect(suppress('other')).toBe(false); + }); + + it('detects an explicit generator', () => { + expect(hasExplicitDtsGenerator({ generator: 'tsc' })).toBe(true); + expect(hasExplicitDtsGenerator({})).toBe(false); + expect(hasExplicitDtsGenerator(true)).toBe(false); + expect(hasExplicitDtsGenerator(undefined)).toBe(false); + }); +}); diff --git a/packages/cli/src/pack-bin.ts b/packages/cli/src/pack-bin.ts index f7ccba25ba..b480fa4992 100644 --- a/packages/cli/src/pack-bin.ts +++ b/packages/cli/src/pack-bin.ts @@ -6,6 +6,13 @@ import { cac } from 'cac'; import type { InlineConfig, ResolvedConfig, TsdownHandle } from 'vite/pack'; import { buildWithConfigs, resolveUserConfig, globalLogger, enableDebug } from 'vite/pack'; +import { + bundledTsrsVersion, + createDtsGeneratorEnvironment, + hasExplicitDtsGenerator, + selectDtsGenerator, + withTsrsWarningSuppressed, +} from './pack-dts.ts'; import { resolveViteConfig } from './resolve-vite-config.ts'; // Matches a `.d.ts` / `.d.mts` / `.d.cts` importer. @@ -151,19 +158,48 @@ cli const packConfigs = Array.isArray(viteConfig?.pack) ? viteConfig.pack : [viteConfig?.pack ?? {}]; + const dtsEnvironment = createDtsGeneratorEnvironment(); + // The first config that uses bundled tsrs, and the `typescript` path that kept upstream selection. + let tsrsConfig: ResolvedConfig | undefined; + let typescriptPath: string | undefined; for (const packConfig of packConfigs) { const merged = { ...packConfig, ...flags }; // Default after merging so `pack.envPrefix` from the config file is kept. merged.envPrefix ??= DEFAULT_ENV_PREFIXES; + // Vite+ can select tsrs below. Its experimental notice must not fail a + // `failOnWarn` build, and an info line replaces it. tsdown builds its + // logger during resolution, so add the entry before resolution. + if (!hasExplicitDtsGenerator(merged.dts)) { + merged.suppressWarnings = withTsrsWarningSuppressed(merged.suppressWarnings); + } // Keep postcss/lightningcss external to the dts bundle (see plugin doc) if (merged.dts) { const existingPlugins = Array.isArray(merged.plugins) ? merged.plugins : []; merged.plugins = [...existingPlugins, externalDtsTypeOnlyPlugin()]; } const resolvedConfig = await resolveUserConfig(merged, flags, configDeps); - resolvedConfig.forEach((config) => config.configDeps.forEach((dep) => configDeps.add(dep))); + for (const config of resolvedConfig) { + config.configDeps.forEach((dep) => configDeps.add(dep)); + // tsdown has resolved declaration enablement, including inference from package.json. + const selection = selectDtsGenerator(config, dtsEnvironment); + config.dts = selection.dts; + if (selection.kind === 'tsrs') { + tsrsConfig ??= config; + } else if (selection.kind === 'unchanged') { + typescriptPath ??= selection.typescriptPath; + } + } configs.push(...resolvedConfig); } + if (tsrsConfig) { + tsrsConfig.logger.info( + `Generating declarations with bundled tsrs v${bundledTsrsVersion()} (experimental) because \`typescript\` is not installed`, + ); + } else if (typescriptPath && cli.options.debug) { + globalLogger.info( + `Declarations use the default generator selection because \`typescript\` resolves to ${typescriptPath}`, + ); + } return buildWithConfigs(configs, configDeps, runBuild); } diff --git a/packages/cli/src/pack-dts.ts b/packages/cli/src/pack-dts.ts new file mode 100644 index 0000000000..ccb446d804 --- /dev/null +++ b/packages/cli/src/pack-dts.ts @@ -0,0 +1,321 @@ +/** + * Declaration generator selection for `vp pack`. + * + * When a build needs declarations and the declaration plugin cannot load + * `typescript`, select the `tsrs` generator with the `tsrs` package that + * `vite-plus` ships for `vp lint` and `vp check`. Upstream reports "TypeScript + * is not installed" in that case, so builds that work today are unchanged. + * Every other case keeps the upstream selection. See + * `rfcs/tsdown-native-declarations.md`. + */ + +import fs from 'node:fs'; +import { createRequire } from 'node:module'; +import path from 'node:path'; +import { pathToFileURL } from 'node:url'; + +import type { ParseError } from 'jsonc-parser'; +import { parse as parseJsonc } from 'jsonc-parser'; + +import { resolveBundled } from './utils/constants.ts'; +import type { JsonValue } from './utils/json-value.ts'; +import { isJsonObject, isObjectValue, parseJsonObject } from './utils/json-value.ts'; + +/** + * The declaration plugin prints this notice the first time it runs `tsrs`. + * Under `failOnWarn` it fails a build that emitted correctly, so it is + * suppressed when Vite+ selects `tsrs`. An info line replaces it. + */ +export const TSRS_EXPERIMENTAL_WARNING = /^tsrs support is highly experimental\b/; + +export type SuppressWarnings = + | string + | RegExp + | Array + | ((message: string) => boolean); + +/** + * The declaration plugin options that the selection reads or sets. The bundled + * plugin's own types describe the full set. + */ +export interface DtsGeneratorOptions { + generator?: unknown; + cwd?: string; + tsconfig?: string | boolean; + compilerOptions?: { isolatedDeclarations?: unknown }; + tsconfigRaw?: object; + customLanguages?: ReadonlyArray; + tsc?: { vue?: unknown }; + /** Deprecated alias of `tsc.vue`. */ + vue?: unknown; + tsrs?: { moduleUrl?: string }; +} + +/** The resolved tsdown config fields that the selection reads. */ +export interface DtsGeneratorConfig { + cwd: string; + tsconfig: false | string; + dts: false | T; +} + +export interface DtsGeneratorEnvironment { + /** Returns the path of `typescript` as the declaration plugin resolves it, if it resolves. */ + resolveTypeScript(): string | undefined; + /** Returns the `file://` URL of the `tsrs` package that `vite-plus` ships. */ + tsrsModuleUrl(): string; +} + +export type DtsGeneratorSelection = + /** Declarations are off, or upstream keeps its selection. */ + | { kind: 'unchanged'; dts: false | T; typescriptPath?: string } + /** The user selected `tsrs`. Only a missing `moduleUrl` was filled. */ + | { kind: 'explicit-tsrs'; dts: T } + /** Vite+ selected `tsrs` because `typescript` did not resolve. */ + | { kind: 'tsrs'; dts: T }; + +/** + * The environment of the installed `vite-plus`. The declaration plugin is + * bundled into core's `vite/pack` and resolves `typescript` relative to + * itself, so the lookup starts there and not at the project root. + */ +export function createDtsGeneratorEnvironment(): DtsGeneratorEnvironment { + return { + resolveTypeScript() { + const require = createRequire(import.meta.resolve('vite/pack')); + for (const specifier of ['typescript/package.json', 'typescript']) { + try { + return require.resolve(specifier); + } catch { + // Try the next specifier. TypeScript 7 may not export `package.json`. + } + } + return undefined; + }, + tsrsModuleUrl() { + return pathToFileURL(resolveBundled('tsrs')).href; + }, + }; +} + +/** The version of the `tsrs` package that `vite-plus` ships. */ +export function bundledTsrsVersion(): string { + const file = resolveBundled('tsrs/package.json'); + const { version } = parseJsonObject(fs.readFileSync(file, 'utf8'), file); + if (typeof version !== 'string') { + throw new TypeError(`Expected a version in ${file}`); + } + return version; +} + +/** Whether a `pack.dts` value sets `generator` itself. */ +export function hasExplicitDtsGenerator( + dts: boolean | string | DtsGeneratorOptions | undefined, +): boolean { + return typeof dts === 'object' && dts.generator !== undefined; +} + +/** Adds {@link TSRS_EXPERIMENTAL_WARNING} to a `suppressWarnings` value and keeps its entries. */ +export function withTsrsWarningSuppressed( + suppressWarnings: SuppressWarnings | undefined, +): SuppressWarnings { + if (suppressWarnings === undefined) { + return TSRS_EXPERIMENTAL_WARNING; + } + if (typeof suppressWarnings === 'function') { + return (message) => TSRS_EXPERIMENTAL_WARNING.test(message) || suppressWarnings(message); + } + return [ + ...(Array.isArray(suppressWarnings) ? suppressWarnings : [suppressWarnings]), + TSRS_EXPERIMENTAL_WARNING, + ]; +} + +function withTsrsModuleUrl(dts: T, env: DtsGeneratorEnvironment): T { + if (dts.tsrs?.moduleUrl !== undefined) { + return dts; + } + return { ...dts, tsrs: { ...dts.tsrs, moduleUrl: env.tsrsModuleUrl() } }; +} + +/** + * Selects the declaration generator for one resolved tsdown config. + * + * Throws when Vite+ would select `tsrs` but the config sets compiler options + * that native generators do not apply to the program. + */ +export function selectDtsGenerator( + config: DtsGeneratorConfig, + env: DtsGeneratorEnvironment, +): DtsGeneratorSelection { + const { dts } = config; + if (dts === false) { + return { kind: 'unchanged', dts }; + } + if (dts.generator === 'tsrs') { + return { kind: 'explicit-tsrs', dts: withTsrsModuleUrl(dts, env) }; + } + if (dts.generator !== undefined || usesCustomLanguages(dts)) { + return { kind: 'unchanged', dts }; + } + + const typescriptPath = env.resolveTypeScript(); + if (typescriptPath !== undefined) { + return { kind: 'unchanged', dts, typescriptPath }; + } + + // Native generators need a tsconfig file. Without one, keep the upstream error. + const tsconfigPath = resolveDtsTsconfig(config, dts); + if (tsconfigPath === undefined) { + return { kind: 'unchanged', dts }; + } + + // Upstream selects Oxc for isolated declarations, which works without TypeScript. + const isolatedDeclarations = + dts.compilerOptions?.isolatedDeclarations ?? readIsolatedDeclarations(tsconfigPath); + // `undefined` means that the tsconfig chain could not be read. Upstream reports that error. + if (isolatedDeclarations !== false) { + return { kind: 'unchanged', dts }; + } + + const overrides = (['compilerOptions', 'tsconfigRaw'] as const).filter( + (key) => Object.keys(dts[key] ?? {}).length > 0, + ); + if (overrides.length > 0) { + const names = overrides.map((key) => `\`dts.${key}\``).join(' and '); + throw new Error( + `${names} cannot be used without \`typescript\`. ` + + 'The bundled tsrs declaration generator reads compiler options only from the tsconfig file. ' + + `Move these options into ${tsconfigPath}, or install \`typescript\`.`, + ); + } + + return { kind: 'tsrs', dts: withTsrsModuleUrl({ ...dts, generator: 'tsrs' }, env) }; +} + +function usesCustomLanguages(dts: DtsGeneratorOptions): boolean { + return !!dts.tsc?.vue || !!dts.vue || (dts.customLanguages?.length ?? 0) > 0; +} + +/** + * Returns the tsconfig file that the declaration plugin loads. tsdown passes + * its resolved `tsconfig` to the plugin, and `dts.tsconfig` overrides it. + */ +function resolveDtsTsconfig( + config: Pick, 'cwd' | 'tsconfig'>, + dts: DtsGeneratorOptions, +): string | undefined { + const cwd = dts.cwd ?? config.cwd; + const tsconfig = dts.tsconfig ?? config.tsconfig; + if (tsconfig === false) { + return undefined; + } + if (typeof tsconfig === 'string') { + const file = path.resolve(cwd, tsconfig); + return fs.existsSync(file) ? file : undefined; + } + return findTsconfig(cwd); +} + +function findTsconfig(dir: string): string | undefined { + let current = path.resolve(dir); + while (true) { + const file = path.join(current, 'tsconfig.json'); + if (fs.existsSync(file)) { + return file; + } + const parent = path.dirname(current); + if (parent === current) { + return undefined; + } + current = parent; + } +} + +/** + * Reads the effective `compilerOptions.isolatedDeclarations` of a tsconfig, + * including `extends`. Returns `undefined` when a file in the chain cannot be + * read or resolved, or when the chain has a cycle. + */ +export function readIsolatedDeclarations(tsconfigPath: string): boolean | undefined { + const value = readOption(tsconfigPath, new Set()); + return value === UNREADABLE ? undefined : value === true; +} + +const UNREADABLE = Symbol('unreadable'); + +type OptionValue = boolean | undefined | typeof UNREADABLE; + +/** `ancestors` holds the files on the current `extends` path, so a shared base is not a cycle. */ +function readOption(file: string, ancestors: Set): OptionValue { + if (ancestors.has(file)) { + return UNREADABLE; + } + ancestors.add(file); + const value = readOwnOrInheritedOption(file, ancestors); + ancestors.delete(file); + return value; +} + +function readOwnOrInheritedOption(file: string, ancestors: Set): OptionValue { + const errors: Array = []; + let tsconfig: unknown; + try { + tsconfig = parseJsonc(fs.readFileSync(file, 'utf8'), errors, { allowTrailingComma: true }); + } catch { + return UNREADABLE; + } + if (errors.length > 0 || !isJsonObject(tsconfig)) { + return UNREADABLE; + } + + const { compilerOptions } = tsconfig; + if (isObjectValue(compilerOptions)) { + const value = compilerOptions.isolatedDeclarations; + // `null` resets an inherited value to the default, which is `false`. + if (typeof value === 'boolean' || value === null) { + return value === true; + } + } + + const extendsValue = tsconfig.extends; + const parents: Array = + typeof extendsValue === 'string' + ? [extendsValue] + : Array.isArray(extendsValue) + ? extendsValue + : []; + // Later entries in an `extends` array override earlier ones. + for (const specifier of parents.toReversed()) { + const parent = typeof specifier === 'string' ? resolveExtends(specifier, file) : undefined; + if (parent === undefined) { + return UNREADABLE; + } + const value = readOption(parent, ancestors); + if (value !== undefined) { + return value; + } + } + return undefined; +} + +function resolveExtends(specifier: string, fromFile: string): string | undefined { + const dir = path.dirname(fromFile); + if (path.isAbsolute(specifier) || specifier.startsWith('.')) { + const file = path.resolve(dir, specifier); + for (const candidate of [file, `${file}.json`]) { + if (fs.existsSync(candidate) && fs.statSync(candidate).isFile()) { + return candidate; + } + } + return undefined; + } + const require = createRequire(fromFile); + for (const candidate of [specifier, `${specifier}.json`, `${specifier}/tsconfig.json`]) { + try { + return require.resolve(candidate); + } catch { + // Try the next form. TypeScript resolves these forms for package `extends`. + } + } + return undefined; +} diff --git a/rfcs/tsdown-native-declarations.md b/rfcs/tsdown-native-declarations.md new file mode 100644 index 0000000000..0eb1b6e1e4 --- /dev/null +++ b/rfcs/tsdown-native-declarations.md @@ -0,0 +1,149 @@ +# RFC: Native declaration generation for `vp pack` + +Status: Proposed, experimental. Researched on 2026-11-19 against `main` at `1fbe723e9`. Updated on 2026-11-23 for [#3511](https://github.com/voidzero-dev/vite-plus/pull/3511). + +## Decision + +When a `vp pack` build needs declarations and the project does not provide `typescript`, generate them with the `tsrs` package that `vite-plus` already ships for `vp lint` and `vp check`. In all other cases, keep the generator that tsdown and `rolldown-plugin-dts` (the declaration plugin) select today. + +Today this case fails with "TypeScript is not installed". The change turns that error into a working build. It does not change the output of a build that works today, because every other selection stays upstream. + +The declaration plugin never selects `tsrs` automatically, even when it is installed. Its documentation says so, and the probe below confirms it. Vite+ therefore owns this default. [Generator option](https://github.com/sxzz/rolldown-plugin-dts/blob/v0.30.2/src/options.ts#L40-L58) + +The change does not replace `tsc` tasks, the editor's compiler, Vue/Volar integrations, or tools that use the classic TypeScript API. It does not remove `typescript` from existing projects. It does not change the default of the programmatic `build()` from `vite-plus/pack`. Upstream marks `tsrs` as highly experimental, and TypeScript 7.1 is still a beta. The default therefore ships as experimental. + +## Baseline + +| Component | `main` | After [#3511](https://github.com/voidzero-dev/vite-plus/pull/3511) | +| ----------------------------------------- | ----------------------------- | ------------------------------------------------------------------ | +| `tsdown`, `@tsdown/css`, `@tsdown/exe` | `0.23.4` | `0.23.7` | +| Declaration plugin bundled through tsdown | `0.28.8`, no `tsrs` generator | `0.30.2`. The `tsrs` generator first ships in `0.29.0`. | +| `tsrs`, a CLI dependency used by lint | `=7.1.0-beta.tsrs4` | Unchanged, and also used by pack | +| Bundled Rolldown | `1.2.19` | `1.3.3`, which tsdown `0.23.7` requires (`~1.3.0`) | +| Bundled Vite | `8.3.8` | `8.4.0-beta.2` | + +[#3511](https://github.com/voidzero-dev/vite-plus/pull/3511) performs this upgrade. It is a prerequisite, not part of this design, and this change merges after it. See [Out of scope](#out-of-scope) for the upstream changes that it handles and the ones that stay open. + +tsdown `0.23.7` and the declaration plugin `0.30.2` require Node `^22.18.0 || ^24.11.0 || >=26.0.0`, the same range as `packages/cli`. `packages/core` still advertises Node 20, but its bundled tsdown `0.23.4` already requires `^22.18.0`. Fix that metadata separately. + +### `tsrs` version coupling + +The declaration plugin supports "only the latest `tsrs` release", but its own repository pins `tsrs@0.24.0-ts7.1.0-beta` at `v0.30.2`. Vite+ updates `tsrs` on its own schedule for lint. One `tsrs` version serves lint and pack. [Plugin tsrs pin](https://github.com/sxzz/rolldown-plugin-dts/blob/v0.30.2/pnpm-workspace.yaml#L35) + +- Treat each `tsrs` update and each declaration-plugin update as a pack change. +- The upgrade-deps PR must pass the declaration fixtures below. +- If an update breaks declaration emit, hold the update for both lint and pack. Do not ship a second `tsrs` for pack. + +## Selection rule + +Apply the rule to each resolved config in `packages/cli/src/pack-bin.ts`, after `resolveUserConfig()` and before `buildWithConfigs()`. At that point tsdown has resolved declaration enablement, including inference from `types`, `typings`, `exports.types`, and `compilerOptions.declaration`. The rule runs again on watch reloads because `runBuild` resolves the configs again. [tsdown dts inference](https://github.com/rolldown/tsdown/blob/v0.23.7/src/config/options.ts#L154-L166) + +Select `generator: 'tsrs'` only when all of these conditions are true: + +1. `config.dts` is an object, so declarations are enabled. +2. The user did not set `dts.generator`. +3. The effective tsconfig does not set `compilerOptions.isolatedDeclarations`. Upstream selects Oxc there, which works without TypeScript. +4. The config does not use Vue or other custom languages. Vue and other Volar languages need the classic API, and upstream reports that requirement. Other custom languages need `tsrs.vfs`, which only the user can opt into. +5. `typescript` does not resolve from the declaration plugin's location. + +Condition 5 uses the same lookup as the plugin, from the bundled tsdown in `@voidzero-dev/vite-plus-core`. It does not use the project root. The plugin loads the classic compiler with `createRequire(import.meta.url)` and the native API with `import.meta.resolve('typescript')`. A different origin can disagree with the plugin. [Classic loader](https://github.com/sxzz/rolldown-plugin-dts/blob/v0.30.2/src/require.ts#L5), [native loader](https://github.com/sxzz/rolldown-plugin-dts/blob/v0.30.2/src/tsgo.ts#L30-L42) + +If all conditions are true but the config sets `dts.compilerOptions` or `dts.tsconfigRaw`, do not select `tsrs`. Fail with a diagnostic that names the options and two fixes: move them into a tsconfig, or install `typescript`. Native generators do not apply these options to the compiler program. In the probe, `dts.compilerOptions.stripInternal: true` had no effect and gave no warning. The build fails today in this case, so a clear error keeps the current result and does not publish different types. + +If no tsconfig exists, do not select `tsrs`, because native generators require one. Keep the upstream error. + +In every other case, leave the config unchanged. An explicit generator string or a custom `Generator` object stays as it is. Do not retry a failed check or emit with another compiler, because that can change published types and hide errors. + +### Compiler location + +Pass `dts.tsrs.moduleUrl` as the file URL of the CLI's own `tsrs`, from `resolveBundled('tsrs')` in `packages/cli/src/utils/constants.ts`. Do this when Vite+ selects `tsrs`, and also when the user selects `generator: 'tsrs'` without a `moduleUrl`. A user value for `dts.tsrs.moduleUrl` stays as it is. + +The plugin loads `tsrs/async` relative to that URL. Lint and pack then use the same binary, and `@voidzero-dev/vite-plus-core` needs no new dependency. Without this URL, the plugin's default `import.meta.resolve('tsrs')` from core can fail in strict layouts, because core does not depend on `tsrs`. + +### Hoisting + +Condition 5 depends on the install layout. A transitive `typescript` that resolves from core, for example through npm's flat layout or pnpm's hidden hoisting, makes upstream select `tsc` or `tsgo`. That is unchanged upstream behavior, but the generator for one project can change when its dependency tree changes. This pnpm behavior is expected, not tested. + +- When Vite+ selects `tsrs`, print one info line per build with the generator, the `tsrs` version, and the reason. +- Print the `typescript` path that was found in debug output. +- Document explicit `generator: 'tsrs'` for projects that need a fixed generator. + +## Experimental warning + +The declaration plugin warns one time per process: "tsrs support is highly experimental and may change or break without notice." With `failOnWarn: true`, or `'ci-only'` in CI, this warning makes the process exit with status 1 after a successful emit. + +`vp pack` itself defaults to `failOnWarn: false`, the tsdown default. The `--fail-on-warn` help text says `default: true`, which is a separate bug. The CLI command sets `ignoreOptionDefaultValue`, so that default is not applied. + +When the user did not set `dts.generator`, add the exact warning to `suppressWarnings` before `resolveUserConfig()`. Keep the user's entries. tsdown builds its logger during resolution, so the entry cannot be added later. The warning fires only when `tsrs` runs, so the entry has no effect when Vite+ does not select `tsrs`. The info line above replaces the warning. When the user selects `tsrs` explicitly, keep the upstream warning. [tsdown suppressWarnings](https://github.com/rolldown/tsdown/blob/v0.23.7/src/config/types.ts#L495-L507) + +## Packaging + +The local `vite-plus` package owns this behavior. The global CLI continues to delegate to the project's `vite-plus`, and it does not supply a compiler. + +1. Keep the `tsrs` dependency in `packages/cli` only. Do not add it to core. +2. Keep the optional `tsrs: "*"` peer that #3511 declares in core. It serves direct core users who select `tsrs` programmatically. +3. Show the declaration plugin version and the TypeScript version that `tsrs` targets in toolchain metadata, next to the existing `tsrs` entry. + +## Compatibility limits + +- Native generators read program options only from the tsconfig file on disk. Declaration maps also need `compilerOptions.declarationMap` in that file. [Native option notes](https://github.com/sxzz/rolldown-plugin-dts/blob/v0.30.2/src/options.ts#L100-L122) +- Vue/Volar and classic API consumers keep TypeScript 5/6. +- Non-Volar custom languages need `tsrs.vfs`. Content mappers need the `runExternalCode` opt-in and cannot combine with VFS. Keep `runExternalCode: false`. +- `tsrs` follows TypeScript 7.1 beta. Diagnostics and emitted declarations can differ from TypeScript 5/6. A library that uses newer declaration syntax can need a newer TypeScript in its consumers. +- The rule does not change `target`, `lib`, module resolution, polyfills, or editor settings. + +## Release gates + +| Area | Required evidence | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| No project compiler | Packed CLI and core tarballs emit inferred and explicit declarations with no `typescript` and no project `tsrs`. Check npm, pnpm with default hoisting and `hoist: false`, Yarn PnP, and Bun. | +| Selection | No TypeScript selects `tsrs`. TypeScript 5.9 and 6.0 keep `tsc`. TypeScript 7.1 beta keeps `tsgo`. `isolatedDeclarations` keeps Oxc. An explicit generator stays. `dts.compilerOptions` without TypeScript fails with the diagnostic. | +| Exit codes | Automatic `tsrs` with `failOnWarn: true` exits 0. Explicit `tsrs` keeps the upstream warning. Type errors with `typecheck: true` still fail. | +| Lifecycle | Watch rebuilds after edits and config changes. No `tsrs` process remains after exit or cancellation. | +| Platforms | macOS x64/ARM64, Linux x64/ARM64 glibc and musl, Windows x64/ARM64. `tsrs` ships a package for each of these eight targets. Check `yuku` on musl. | +| Updates | The upgrade-deps PR runs the declaration fixtures for each `tsrs` or declaration-plugin update. | + +Add the cases to [`command_pack_dts_compat`](../crates/vp_cli_snapshots/tests/cli_snapshots/fixtures/command_pack_dts_compat/snapshots.toml) with the local registry, and add unit coverage for the rule in [`pack.spec.ts`](../packages/cli/src/__tests__/pack.spec.ts). + +The experimental release does not need performance or memory benchmarks, parity runs against TypeScript 5/6, VFS or content-mapper coverage, or several compiler versions in one process. + +## Upstream requests + +1. tsdown: allow changes to `dts` in `tsdownConfigResolved`, or add a hook before the declaration plugin starts. The programmatic `build()` can then get the same default without the CLI seam. Today the hook documentation says that changes "are not supported". [tsdown plugin hooks](https://github.com/rolldown/tsdown/blob/v0.23.7/src/features/plugin.ts#L40-L51) +2. Declaration plugin: test against the latest `tsrs` release, or declare a supported `tsrs` range. +3. Declaration plugin: give the experimental warning a stable code, so suppression does not depend on its text. + +## Out of scope + +- **Dependency upgrade.** [#3511](https://github.com/voidzero-dev/vite-plus/pull/3511) upgrades tsdown, the declaration plugin, Rolldown, and Vite. It handles these upstream changes: + - `@typescript/native-preview` is no longer supported ([plugin 0.29.0](https://github.com/sxzz/rolldown-plugin-dts/releases/tag/v0.29.0)). #3511 removes its core peer and development dependency. `vp migrate` moves TypeScript 5/6 packages that select it to `typescript@7.1.0-beta`, not to `tsrs`. The `command_pack_dts_native_preview` snapshot case becomes `command_pack_dts_typescript_5` and the `migration_pack_native_preview` regression. + - `tsgo.path` selects an API server executable on TypeScript 7.1. `vp migrate` reports a custom `tsgo.path` for review. + - The merged `typescript` peer range in `mergePackageJson()` admits the plugin's TypeScript 7.1 prereleases. + - The plugin depends on `yuku` instead of `yuku-parser@0.19.0`. Core keeps `yuku@0.28.1` external as a dependency. +- **Upgrade follow-ups.** These upstream changes stay open after #3511: + - `dts.entry` only filters build entries, and a matching file that is not an entry no longer gets a declaration. Its patterns resolve from tsdown's `cwd`. `dts.emitDtsOnly` and `dts.dtsInput` are deprecated aliases of `dts.dtsOnly`. ([tsdown 0.23.7](https://github.com/rolldown/tsdown/releases/tag/v0.23.7)) + - Top-level `dts.vue`, `build`, `incremental`, `parallel`, `eager`, and `newContext` are deprecated. The plugin moves them under `dts.tsc` at runtime with a warning, so migration only needs to remove warnings. [Plugin deprecations](https://github.com/sxzz/rolldown-plugin-dts/blob/v0.30.2/src/options.ts#L411-L435) + - `@yuku-toolchain/*` publishes no musl package, so check `yuku` loading on musl. +- **Migration.** Rewrites that change the output layout, such as a separate declaration-only pack config or a generated pack tsconfig, start as report-only findings. +- **Templates.** Remove `typescript` from plain TypeScript templates only after the gates pass, and only when their scripts, editor setup, and framework dependencies permit it. +- **Programmatic default** for `build()` from `vite-plus/pack`, until upstream request 1 lands. +- **Several TypeScript versions in one process.** The plugin caches one classic compiler per process. + +## Design probe + +On macOS ARM64 with Node `24.22.3`, isolated npm installs of `tsdown@0.23.7`, `rolldown-plugin-dts@0.30.2`, and `rolldown@1.3.3` gave these results. The installs disabled lifecycle scripts and automatic peers. + +| Case | Result | +| -------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | +| `dts: true`, no `typescript` | Fails: "TypeScript is not installed". | +| `dts: true`, `tsrs` installed, no `typescript` | Same failure. Upstream does not select `tsrs`. | +| `isolatedDeclarations`, no `typescript` | Oxc emits declarations. | +| Explicit `tsrs`, with `7.1.0-beta.tsrs2`, `7.1.0-beta.tsrs3`, and `7.1.0-beta.tsrs4` | Emits declarations, JSDoc, and declaration maps. | +| `tsrs.moduleUrl` that points to a separate install, with no `tsrs` near the plugin | Emits declarations. | +| `typecheck: true` with a type error | The build fails. | +| `dts.compilerOptions.stripInternal: true` | Ignored without a warning. The `@internal` export stays. | +| `failOnWarn: true` | Emits, then exits with status 1 because of the experimental warning. | +| `failOnWarn: true` with the warning in `suppressWarnings` | Exits 0. | +| `resolveUserConfig()`, then set the generator, then `buildWithConfigs()`, with dts inferred from `types` | Resolved `dts` is `{}`. The build emits declarations and exits 0 with the suppression. No `tsrs` process remains. | + +These results check the upstream premises and the CLI seam. They do not validate the Vite+ implementation, other package managers, or other platforms.