Skip to content
Merged
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
6 changes: 6 additions & 0 deletions .changeset/stable-ci-task-cache.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@party-stack/build-config": patch
"@party-stack/tanstack-start-build-config": patch
---

Require Vite+ 1.2 and preserve its built-in plugins when composing caller configuration, enabling automatic pnpm metadata normalization and Vitest cache tracking. Retain only generated-directory input exclusions for CI cache reuse.
2 changes: 1 addition & 1 deletion apps/salesforce-task-manager/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function salesforceDevSessionPlugin(env: Record<string, string>): Plugin {
}

export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), "");
const env = loadEnv(mode, process.cwd(), ["VITE_", "SALESFORCE_"]);
const salesforceInstanceUrl = env.VITE_SALESFORCE_INSTANCE_URL ?? env.SALESFORCE_INSTANCE_URL;
const browserEnv = (name: string) => JSON.stringify(env[`VITE_${name}`] ?? env[name]);
return defineAppConfig({
Expand Down
2 changes: 1 addition & 1 deletion packages/build-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"vite-plus": "catalog:"
},
"peerDependencies": {
"vite-plus": "^1.1.0"
"vite-plus": "^1.2.0"
}
}
22 changes: 18 additions & 4 deletions packages/build-config/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ describe.each([
expect(defineConfig({ resolve: { tsconfigPaths: false } }).resolve?.tsconfigPaths).toBe(false);
expect(defineConfig().resolve?.tsconfigPaths).toBe(true);
});

it("preserves Vite+ cache integration when callers supply plugins", () => {
const plugin = { name: "caller-plugin" };
const config = defineConfig({ plugins: [plugin] });
expect(config.plugins).toContain(plugin);
expect(config.plugins).toEqual(
expect.arrayContaining([
expect.objectContaining({
name: "vite-plus:vitest-cache-paths",
configureVitest: expect.any(Function),
}),
])
);
});
});

describe("library config composition", () => {
Expand Down Expand Up @@ -50,8 +64,8 @@ describe("library config composition", () => {

it("supports build-only terminal tests without leaking overrides to another package", () => {
const noTests = defineLibraryConfig({ run: { tasks: { test: { command: [] } } } });
expect(noTests.run?.tasks?.test).toEqual({ command: [], dependsOn: ["build"] });
expect(defineLibraryConfig().run?.tasks?.test).toEqual({
expect(noTests.run?.tasks?.test).toMatchObject({ command: [], dependsOn: ["build"] });
expect(defineLibraryConfig().run?.tasks?.test).toMatchObject({
command: "vp test",
dependsOn: ["build"],
});
Expand All @@ -72,7 +86,7 @@ describe("app config composition", () => {
build: { sourcemap: true },
run: { tasks: { dev: { command: "vp dev --host" } } },
});
expect(config.plugins).toEqual([plugin]);
expect(config.plugins).toContain(plugin);
expect(config.pack).toBeUndefined();
expect(config.build).toMatchObject({
target: ["chrome107", "edge107", "firefox104", "safari16"],
Expand All @@ -83,6 +97,6 @@ describe("app config composition", () => {
cache: false,
dependsOn: [{ task: "build", from: ["dependencies", "devDependencies"] }],
});
expect(config.run?.tasks?.test).toEqual({ command: "vp test", dependsOn: ["build"] });
expect(config.run?.tasks?.test).toMatchObject({ command: "vp test", dependsOn: ["build"] });
});
});
25 changes: 15 additions & 10 deletions packages/build-config/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@ export function defineLibraryConfig(config: LibraryConfig = {}): ViteUserConfig
check: {
command: "vp check",
// Track root files without making generated directory entries inputs.
cache: {
input: [{ auto: true }, "!.", "*.{json,jsonc,ts,mts,js,mjs}"],
},
// Still needed in Vite+ 1.2: https://github.com/voidzero-dev/vite-task/issues/504
cache: { input: [{ auto: true }, "!.", "*.{json,jsonc,ts,mts,js,mjs}"] },
dependsOn: [{ task: "build", from: ["dependencies", "devDependencies"] }],
},
build: {
command: "vp pack",
// Generated outputs and package directory listings must not invalidate their own build.
cache: {
input: [{ auto: true }, "!.", "*.{json,jsonc,ts,mts,js,mjs}", "!lib/**"],
},
cache: { input: [{ auto: true }, "!.", "*.{json,jsonc,ts,mts,js,mjs}", "!lib/**"] },
dependsOn: ["check", { task: "build", from: ["dependencies", "devDependencies"] }],
},
test: { command: "vp test", dependsOn: ["build"] },
Expand Down Expand Up @@ -74,8 +71,15 @@ export function defineAppConfig(config: AppConfig = {}): ViteUserConfig {
},
build: {
command: "vp build",
// Shell nesting changed cache fingerprints without changing app outputs.
cache: { untrackedEnv: ["SHLVL"] },
cache: {
input: [
{ auto: true },
"!.",
"*.{json,jsonc,ts,mts,js,mjs}",
"!dist",
"!dist/**",
],
},
dependsOn: ["check", { task: "build", from: ["dependencies", "devDependencies"] }],
},
test: { command: "vp test", dependsOn: ["build"] },
Expand Down Expand Up @@ -109,7 +113,8 @@ function composeConfig(base: ViteUserConfig, config: LibraryConfig): ViteUserCon
tasks[name] = { ...inherited, ...override, command };
}
}
return {
// Vite+ injects its Vitest integrations here; caller plugins must not replace them.
return defineConfig({
...base,
...config,
resolve: { ...base.resolve, ...config.resolve },
Expand All @@ -123,5 +128,5 @@ function composeConfig(base: ViteUserConfig, config: LibraryConfig): ViteUserCon
...(base.build || config.build ? { build: { ...base.build, ...config.build } } : {}),
test: { ...base.test, ...config.test },
run: { ...base.run, ...config.run, tasks },
};
});
}
7 changes: 6 additions & 1 deletion packages/durable-object-ontology/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export default defineLibraryConfig({
},
},

test: { include: ["test/**/*.test.ts"] },
test: {
include: ["test/**/*.test.ts"],
// workerd cannot read Vitest 5.0.4's host module-cache files yet.
// https://github.com/cloudflare/workers-sdk/pull/16163
fsModuleCache: false,
},
plugins: [
cloudflareTest({
wrangler: {
Expand Down
2 changes: 1 addition & 1 deletion packages/tanstack-start-build-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@
},
"peerDependencies": {
"@tanstack/react-start": "^1.167.12",
"vite-plus": "^1.1.0"
"vite-plus": "^1.2.0"
}
}
9 changes: 5 additions & 4 deletions packages/tanstack-start-build-config/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ describe("TanStack Start config", () => {
start: { router: { routesDirectory: "src/pages" } },
});

expect(config.plugins?.[0]).toBe(plugins);
expect(config.plugins?.[1]).toEqual({ name: "worktreeDev" });
expect(config.plugins?.flat()).toContain(plugins[0]);
expect(config.plugins?.flat()).toEqual(expect.arrayContaining([{ name: "worktreeDev" }]));
expect(devtools).toHaveBeenCalledWith({ consolePiping: { enabled: false } });
expect(config.server).toEqual({ port: 3000 });
expect(config.resolve?.tsconfigPaths).toBe(true);
Expand Down Expand Up @@ -52,8 +52,9 @@ describe("TanStack Start config", () => {
vi.stubEnv("VP_RESOLVING_CONFIG_METADATA", "1");
try {
const config = defineAppConfig();
expect(config.plugins).toBeUndefined();
expect(config.run?.tasks?.test).toEqual({ command: "vp test", dependsOn: ["build"] });
expect(worktreeDev).not.toHaveBeenCalled();
expect(devtools).not.toHaveBeenCalled();
expect(config.run?.tasks?.test).toMatchObject({ command: "vp test", dependsOn: ["build"] });
} finally {
vi.unstubAllEnvs();
}
Expand Down
Loading
Loading