Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/.vitepress/theme/data/fetch-trusted-stack-stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function parseNpmDownloadsJson(data: unknown, pkg: string): number {
if (typeof data !== 'object' || data === null || !('downloads' in data)) {
throw new Error(`npm API ${pkg}: unexpected payload`);
}
const downloads = (data as { downloads: unknown }).downloads;
const downloads = data.downloads;
if (typeof downloads !== 'number') {
throw new Error(`npm API ${pkg}: unexpected payload`);
}
Expand All @@ -71,7 +71,7 @@ function parseGithubRepoJson(data: unknown, repo: string): number {
if (typeof data !== 'object' || data === null || !('stargazers_count' in data)) {
throw new Error(`GitHub API ${repo}: unexpected payload`);
}
const count = (data as { stargazers_count: unknown }).stargazers_count;
const count = data.stargazers_count;
if (typeof count !== 'number') {
throw new Error(`GitHub API ${repo}: unexpected payload`);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ async function createConditionalShim(
entries.push(['default', `./dist/test/${shimBaseName}.js`]);
}

return Object.fromEntries(entries) as ExportValue;
return Object.fromEntries(entries);
}

/**
Expand Down
7 changes: 1 addition & 6 deletions packages/cli/src/__tests__/define-config-plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,7 @@ const RESOLVER_PLUGIN_NAME = 'vite-plus:vitest-resolver';
const COVERAGE_GUARD_PLUGIN_NAME = 'vite-plus:coverage-version-guard';

function pluginName(p: unknown): string | undefined {
if (
p &&
typeof p === 'object' &&
'name' in p &&
typeof (p as { name: unknown }).name === 'string'
) {
if (p && typeof p === 'object' && 'name' in p && typeof p.name === 'string') {
return (p as { name: string }).name;
}
return undefined;
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/define-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ function injectPluginIntoInlineConfig<
vitePlusCoverageVersionGuardPlugin(),
...(config.plugins ?? []),
],
} as T;
};
}

/**
Expand Down Expand Up @@ -710,12 +710,12 @@ export function defineConfig(config: ViteUserConfigExport): ViteUserConfigExport
*/
function injectPluginIntoProjectExport(config: UserProjectConfigExport): UserProjectConfigExport {
if (typeof config === 'function') {
return ((env: ConfigEnv) => {
return (env: ConfigEnv) => {
const result = config(env);
return result instanceof Promise
? result.then(injectPluginIntoInlineConfig)
: injectPluginIntoInlineConfig(result);
}) as UserProjectConfigFn;
};
}
if (config instanceof Promise) {
return config.then(injectPluginIntoInlineConfig);
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/migration/migrator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ function pruneLegacyWrapperAliases(record: Record<string, unknown> | undefined):
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
if (pruneLegacyWrapperAliases(value as Record<string, unknown>)) {
mutated = true;
if (Object.keys(value as Record<string, unknown>).length === 0) {
if (Object.keys(value).length === 0) {
delete record[key];
}
}
Expand Down Expand Up @@ -830,7 +830,7 @@ function collectJsPluginPackageNames(projectPath: string): Set<string> {
}
let config: OxlintConfig;
try {
config = readJsonFile(oxlintConfigPath, true) as OxlintConfig;
config = readJsonFile(oxlintConfigPath, true);
} catch {
return out;
}
Expand Down Expand Up @@ -2129,7 +2129,7 @@ function readPackageJsonIfExists(packageJsonPath: string): DependencyBag | undef
return undefined;
}
try {
return readJsonFile(packageJsonPath) as DependencyBag;
return readJsonFile(packageJsonPath);
} catch {
return undefined;
}
Expand Down Expand Up @@ -5680,7 +5680,7 @@ export function detectIncompatibleEslintIntegration(
}
let pkg: { devDependencies?: Record<string, string>; dependencies?: Record<string, string> };
try {
pkg = readJsonFile(pkgJsonPath) as typeof pkg;
pkg = readJsonFile(pkgJsonPath);
} catch {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/utils/approve-builds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ export function addYarnBuiltDependenciesMeta(
for (const name of packages) {
const current = meta[name];
meta[name] = {
...(current && typeof current === 'object' ? (current as Record<string, unknown>) : {}),
...(current && typeof current === 'object' ? current : {}),
built: true,
};
}
Expand Down
21 changes: 16 additions & 5 deletions packages/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -617,14 +617,17 @@ async function wireBundledTsdownExtensions() {
// - `importWithError("@tsdown/exe")` dynamically imports a runtime string,
// which rolldown cannot follow, so rewrite the call site to the chunk.
// - `pkgExists("@tsdown/css")` resolves the top-level package at runtime;
// since it is bundled now, force it on and point the import at the chunk.
// since it is bundled now, force it on so the CSS plugin always loads.
// `@tsdown/css` still imports `lightningcss` (a native module that cannot be
// bundled), which resolves to core's own `lightningcss` dependency.
let exeWired = false;
let cssWired = false;
// The `import("@tsdown/css")` call site may already be deduped to the bundled
// entry by rolldown; track whether the bundled load ends up referenced either
// way so a silent miss (no rewrite and no dedup) fails the build.
// The `import("@tsdown/css")` call site is bundled by rolldown into a local
// chunk and rewritten either to a stable `./tsdown-css.js` entry or to a
// content-hashed `./dist-*.js` chunk (newer tsdown/rolldown dedupes the
// dynamic import straight onto the bundled `CssPlugin`). Track whether the
// bundled load ends up referenced via any of these forms so a silent miss
// (the bare `@tsdown/css` specifier left in place) fails the build.
let cssLoadWired = false;
for (const chunkFile of chunkFiles) {
let content = await readFile(chunkFile, 'utf-8');
Expand All @@ -643,7 +646,15 @@ async function wireBundledTsdownExtensions() {
content = content.replaceAll('import("@tsdown/css")', 'import("./tsdown-css.js")');
changed = true;
}
if (content.includes('import("./tsdown-css.js")')) {
// The css load counts as "wired" once it resolves to any local chunk:
// - our rewrite target (`./tsdown-css.js`), or
// - a chunk that newer tsdown/rolldown deduped `@tsdown/css` straight into
// (`{ CssPlugin } = await import("./dist-*.js")`), where the bare
// specifier never appears and no rewrite is needed.
if (
content.includes('import("./tsdown-css.js")') ||
/\{\s*CssPlugin\s*\}\s*=\s*await import\("\.\//.test(content)
) {
cssLoadWired = true;
}
if (changed) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@
"node": "^20.19.0 || ^22.18.0 || >=24.11.0"
},
"bundledVersions": {
"vite": "8.1.0",
"vite": "8.1.2",
"rolldown": "1.1.3",
"tsdown": "0.22.3"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tools/.upstream-versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"vite": {
"repo": "https://github.com/vitejs/vite.git",
"branch": "main",
"hash": "63b14898598fc242ac2d3dd37dafeb39c864befa"
"hash": "ba3119397d0110952f29965774c627a3017d7292"
}
}
2 changes: 1 addition & 1 deletion packages/tools/src/sync-remote-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ export function mergeWorkspaceYaml(
return yaml.stringify(merged, stringifyOptions);
}

reconcileMap(mainDoc.contents, merged as Record<string, unknown>, yaml);
reconcileMap(mainDoc.contents, merged, yaml);

return mainDoc.toString(stringifyOptions);
}
Expand Down
Loading
Loading