@decocms/start 2.4.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/skills/deco-to-tanstack-migration/SKILL.md +1 -0
- package/.agents/skills/deco-to-tanstack-migration/references/post-migration-cleanup.md +163 -0
- package/.agents/skills/deco-to-tanstack-migration/references/vite-config/README.md +27 -2
- package/.agents/skills/deco-to-tanstack-migration/templates/vite-config.md +143 -68
- package/.cursor/skills/deco-to-tanstack-migration/SKILL.md +1 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/post-migration-cleanup.md +163 -0
- package/.cursor/skills/deco-to-tanstack-migration/references/vite-config/README.md +27 -2
- package/.cursor/skills/deco-to-tanstack-migration/templates/vite-config.md +143 -68
- package/package.json +1 -1
- package/scripts/deco-migrate-cli.ts +1 -1
- package/scripts/migrate/analyzers/island-classifier.ts +2 -2
- package/scripts/migrate/analyzers/loader-inventory.ts +2 -2
- package/scripts/migrate/analyzers/section-metadata.ts +2 -2
- package/scripts/migrate/analyzers/theme-extractor.ts +2 -2
- package/scripts/migrate/phase-analyze.ts +6 -6
- package/scripts/migrate/phase-cleanup.ts +31 -35
- package/scripts/migrate/phase-report.ts +2 -2
- package/scripts/migrate/phase-scaffold.ts +20 -20
- package/scripts/migrate/phase-transform.ts +9 -9
- package/scripts/migrate/phase-verify.ts +2 -2
- package/scripts/migrate/templates/app-css.ts +2 -2
- package/scripts/migrate/templates/cache-config.ts +1 -1
- package/scripts/migrate/templates/commerce-loaders.ts +1 -1
- package/scripts/migrate/templates/hooks.ts +1 -1
- package/scripts/migrate/templates/lib-utils.ts +1 -1
- package/scripts/migrate/templates/package-json.ts +1 -1
- package/scripts/migrate/templates/routes.ts +1 -1
- package/scripts/migrate/templates/sdk-gen.ts +1 -1
- package/scripts/migrate/templates/section-loaders.ts +1 -1
- package/scripts/migrate/templates/server-entry.ts +1 -1
- package/scripts/migrate/templates/setup.ts +1 -1
- package/scripts/migrate/templates/types-gen.ts +1 -1
- package/scripts/migrate/templates/ui-components.ts +1 -1
- package/scripts/migrate/templates/vite-config.ts +1 -1
- package/scripts/migrate/templates/wrangler.ts +1 -1
- package/scripts/migrate/transforms/dead-code.ts +1 -1
- package/scripts/migrate/transforms/deno-isms.ts +1 -1
- package/scripts/migrate/transforms/fresh-apis.ts +1 -1
- package/scripts/migrate/transforms/imports.ts +1 -1
- package/scripts/migrate/transforms/jsx.ts +1 -1
- package/scripts/migrate/transforms/section-conventions.ts +1 -1
- package/scripts/migrate/transforms/tailwind.ts +1 -1
- package/scripts/migrate.ts +8 -8
- package/src/admin/decofile.ts +3 -3
- package/src/admin/meta.ts +2 -2
- package/src/cms/loader.ts +1 -1
- package/src/cms/sectionLoaders.test.ts +4 -1
- package/src/daemon/fs.ts +1 -1
- package/src/daemon/index.ts +8 -8
- package/src/daemon/middleware.ts +4 -4
- package/src/sdk/cachedLoader.ts +1 -1
- package/src/vite/plugin.js +47 -10
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import type { MigrationContext } from "../types
|
|
3
|
+
import type { MigrationContext } from "../types";
|
|
4
4
|
|
|
5
5
|
function discoverFonts(ctx: MigrationContext): string[] {
|
|
6
6
|
// Check public/fonts (post-move)
|
package/scripts/migrate.ts
CHANGED
|
@@ -25,14 +25,14 @@
|
|
|
25
25
|
|
|
26
26
|
import * as path from "node:path";
|
|
27
27
|
import { execSync } from "node:child_process";
|
|
28
|
-
import { createContext, logPhase } from "./migrate/types
|
|
29
|
-
import { analyze } from "./migrate/phase-analyze
|
|
30
|
-
import { scaffold } from "./migrate/phase-scaffold
|
|
31
|
-
import { transform } from "./migrate/phase-transform
|
|
32
|
-
import { cleanup } from "./migrate/phase-cleanup
|
|
33
|
-
import { report } from "./migrate/phase-report
|
|
34
|
-
import { verify } from "./migrate/phase-verify
|
|
35
|
-
import { banner, stat, red, green, yellow } from "./migrate/colors
|
|
28
|
+
import { createContext, logPhase } from "./migrate/types";
|
|
29
|
+
import { analyze } from "./migrate/phase-analyze";
|
|
30
|
+
import { scaffold } from "./migrate/phase-scaffold";
|
|
31
|
+
import { transform } from "./migrate/phase-transform";
|
|
32
|
+
import { cleanup } from "./migrate/phase-cleanup";
|
|
33
|
+
import { report } from "./migrate/phase-report";
|
|
34
|
+
import { verify } from "./migrate/phase-verify";
|
|
35
|
+
import { banner, stat, red, green, yellow } from "./migrate/colors";
|
|
36
36
|
|
|
37
37
|
function parseArgs(args: string[]): {
|
|
38
38
|
source: string;
|
package/src/admin/decofile.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getRevision, loadBlocks, setBlocks } from "../cms/loader
|
|
2
|
-
import { clearLoaderCache } from "../sdk/cachedLoader
|
|
3
|
-
import { invalidateMetaCache } from "./meta
|
|
1
|
+
import { getRevision, loadBlocks, setBlocks } from "../cms/loader";
|
|
2
|
+
import { clearLoaderCache } from "../sdk/cachedLoader";
|
|
3
|
+
import { invalidateMetaCache } from "./meta";
|
|
4
4
|
|
|
5
5
|
export function handleDecofileRead(): Response {
|
|
6
6
|
const blocks = loadBlocks();
|
package/src/admin/meta.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { djb2Hex } from "../sdk/djb2
|
|
2
|
-
import { composeMeta, type MetaResponse } from "./schema
|
|
1
|
+
import { djb2Hex } from "../sdk/djb2";
|
|
2
|
+
import { composeMeta, type MetaResponse } from "./schema";
|
|
3
3
|
|
|
4
4
|
// Use globalThis to share meta state across module instances.
|
|
5
5
|
// The daemon middleware imports this module via native import() (outside Vite SSR),
|
package/src/cms/loader.ts
CHANGED
|
@@ -24,7 +24,10 @@ const makeSection = (component: string, props: Record<string, unknown> = {}): Re
|
|
|
24
24
|
|
|
25
25
|
describe("runSingleSectionLoader — page context injection", () => {
|
|
26
26
|
it("injects __pageUrl and __pagePath into loader props", async () => {
|
|
27
|
-
|
|
27
|
+
// Two-arg signature so loader.mock.calls[0] types as [props, req].
|
|
28
|
+
const loader = vi.fn(
|
|
29
|
+
async (props: Record<string, unknown>, _req: Request) => props,
|
|
30
|
+
);
|
|
28
31
|
registerSectionLoader("site/sections/SearchBanner.tsx", loader);
|
|
29
32
|
|
|
30
33
|
const section = makeSection("site/sections/SearchBanner.tsx", { foo: "bar" });
|
package/src/daemon/fs.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { join, resolve, sep } from "node:path";
|
|
|
11
11
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
12
12
|
import fjp from "fast-json-patch";
|
|
13
13
|
import type { Operation } from "fast-json-patch";
|
|
14
|
-
import { inferMetadata, broadcastFSEvent, type Metadata } from "./watch
|
|
14
|
+
import { inferMetadata, broadcastFSEvent, type Metadata } from "./watch";
|
|
15
15
|
|
|
16
16
|
const cwd = process.cwd();
|
|
17
17
|
const toPosix = (p: string) => p.replaceAll(sep, "/");
|
package/src/daemon/index.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { startTunnel } from "./tunnel
|
|
2
|
-
export type { TunnelOptions, TunnelConnection } from "./tunnel
|
|
3
|
-
export { createAuthMiddleware, verifyAdminJwt, tokenIsValid } from "./auth
|
|
4
|
-
export type { JwtPayload } from "./auth
|
|
5
|
-
export { createDaemonMiddleware } from "./middleware
|
|
6
|
-
export type { DaemonOptions } from "./middleware
|
|
7
|
-
export { createVolumesHandler } from "./volumes
|
|
8
|
-
export { createWatchHandler, watchFS, broadcastFSEvent } from "./watch
|
|
1
|
+
export { startTunnel } from "./tunnel";
|
|
2
|
+
export type { TunnelOptions, TunnelConnection } from "./tunnel";
|
|
3
|
+
export { createAuthMiddleware, verifyAdminJwt, tokenIsValid } from "./auth";
|
|
4
|
+
export type { JwtPayload } from "./auth";
|
|
5
|
+
export { createDaemonMiddleware } from "./middleware";
|
|
6
|
+
export type { DaemonOptions } from "./middleware";
|
|
7
|
+
export { createVolumesHandler } from "./volumes";
|
|
8
|
+
export { createWatchHandler, watchFS, broadcastFSEvent } from "./watch";
|
package/src/daemon/middleware.ts
CHANGED
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
* Ported from: deco-cx/deco daemon/daemon.ts
|
|
11
11
|
*/
|
|
12
12
|
import type { IncomingMessage, ServerResponse, Server as HttpServer } from "node:http";
|
|
13
|
-
import { createAuthMiddleware } from "./auth
|
|
14
|
-
import { createFSHandler } from "./fs
|
|
15
|
-
import { createVolumesHandler } from "./volumes
|
|
16
|
-
import { createWatchHandler, watchFS } from "./watch
|
|
13
|
+
import { createAuthMiddleware } from "./auth";
|
|
14
|
+
import { createFSHandler } from "./fs";
|
|
15
|
+
import { createVolumesHandler } from "./volumes";
|
|
16
|
+
import { createWatchHandler, watchFS } from "./watch";
|
|
17
17
|
|
|
18
18
|
const DAEMON_API_SPECIFIER = "x-daemon-api";
|
|
19
19
|
const HYPERVISOR_API_SPECIFIER = "x-hypervisor-api";
|
package/src/sdk/cachedLoader.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* (e.g. "product") which derives timing from the unified profile system.
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import { loaderCacheOptions, type CacheProfileName } from "./cacheHeaders
|
|
14
|
+
import { loaderCacheOptions, type CacheProfileName } from "./cacheHeaders";
|
|
15
15
|
|
|
16
16
|
export type CachePolicy = "no-store" | "no-cache" | "stale-while-revalidate";
|
|
17
17
|
|
package/src/vite/plugin.js
CHANGED
|
@@ -13,6 +13,18 @@
|
|
|
13
13
|
* file, and this plugin intercepts the .ts import to return JSON.parse(...)
|
|
14
14
|
* — V8's JSON parser is 2-10x faster than the JS parser for large data.
|
|
15
15
|
*
|
|
16
|
+
* meta.gen handling:
|
|
17
|
+
* The admin schema bundle (`server/admin/meta.gen.json`) is server-only;
|
|
18
|
+
* the client receives pre-resolved blocks via the SSR payload. Stubbing
|
|
19
|
+
* it on the client cuts a typically-large module out of the browser bundle.
|
|
20
|
+
* Match is done by substring on the import id, so any path style works.
|
|
21
|
+
*
|
|
22
|
+
* manualChunks:
|
|
23
|
+
* `@decocms/start` and `@decocms/apps` are intentionally NOT split into
|
|
24
|
+
* their own chunks. They have circular re-exports that produce a load-order
|
|
25
|
+
* crash when chunked separately. Rollup's default bundling (group with
|
|
26
|
+
* importer or vendor catch-all) avoids that.
|
|
27
|
+
*
|
|
16
28
|
* Usage:
|
|
17
29
|
* ```ts
|
|
18
30
|
* import { decoVitePlugin } from "@decocms/start/vite";
|
|
@@ -62,6 +74,11 @@ const STUB_SOURCE = {
|
|
|
62
74
|
|
|
63
75
|
"\0stub:tanstack-head-scripts":
|
|
64
76
|
"export const injectedHeadScripts = undefined;",
|
|
77
|
+
|
|
78
|
+
// The admin schema bundle is server-only — the client receives pre-resolved
|
|
79
|
+
// blocks via the SSR payload. Stubbing it on the client cuts a large module
|
|
80
|
+
// (typically 0.5-5 MB) out of the browser bundle.
|
|
81
|
+
"\0stub:meta-gen": "export default {};",
|
|
65
82
|
};
|
|
66
83
|
|
|
67
84
|
/** @returns {import("vite").PluginOption} */
|
|
@@ -71,10 +88,23 @@ export function decoVitePlugin() {
|
|
|
71
88
|
name: "deco-server-only-stubs",
|
|
72
89
|
enforce: "pre",
|
|
73
90
|
|
|
74
|
-
resolveId(id,
|
|
91
|
+
resolveId(id, importer, options) {
|
|
75
92
|
// Server builds keep the real modules.
|
|
76
93
|
if (options?.ssr) return undefined;
|
|
77
|
-
|
|
94
|
+
// Bare-specifier exact-match stubs (react-dom/server, node:stream, etc.).
|
|
95
|
+
if (CLIENT_STUBS[id]) return CLIENT_STUBS[id];
|
|
96
|
+
// meta.gen.{json,ts} — the admin schema bundle. Server-only; client
|
|
97
|
+
// receives pre-resolved blocks. Matches both file extensions so the
|
|
98
|
+
// plugin works whether `setup.ts` imports the .json directly (current)
|
|
99
|
+
// or a future variant routes through a generated .ts wrapper.
|
|
100
|
+
// Requires `importer` so we don't accidentally stub the entry module.
|
|
101
|
+
if (
|
|
102
|
+
importer &&
|
|
103
|
+
(id.endsWith("meta.gen.json") || id.endsWith("meta.gen.ts"))
|
|
104
|
+
) {
|
|
105
|
+
return "\0stub:meta-gen";
|
|
106
|
+
}
|
|
107
|
+
return undefined;
|
|
78
108
|
},
|
|
79
109
|
|
|
80
110
|
load(id, options) {
|
|
@@ -163,9 +193,14 @@ export function decoVitePlugin() {
|
|
|
163
193
|
/** @type {import("vite").UserConfig} */
|
|
164
194
|
const cfg = {};
|
|
165
195
|
|
|
166
|
-
// Allow tunnel domains through Vite's host check
|
|
196
|
+
// Allow tunnel domains through Vite's host check.
|
|
197
|
+
// .deco.studio is the new admin frontend; both real-world Deco sites
|
|
198
|
+
// (casaevideo-storefront, baggagio-tanstack) duplicated this list to
|
|
199
|
+
// include it — bundling it here removes that boilerplate.
|
|
167
200
|
if (process.env.DECO_SITE_NAME) {
|
|
168
|
-
cfg.server = {
|
|
201
|
+
cfg.server = {
|
|
202
|
+
allowedHosts: [".deco.host", ".decocdn.com", ".deco.studio"],
|
|
203
|
+
};
|
|
169
204
|
}
|
|
170
205
|
|
|
171
206
|
// Only split chunks for production builds — dev uses unbundled ESM.
|
|
@@ -219,12 +254,14 @@ export function decoVitePlugin() {
|
|
|
219
254
|
if (id.includes("@tanstack/react-query")) {
|
|
220
255
|
return "vendor-query";
|
|
221
256
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
257
|
+
// Intentionally NOT splitting @decocms/start or @decocms/apps:
|
|
258
|
+
// they have circular re-exports (e.g. apps imports from
|
|
259
|
+
// start/sdk/cachedLoader, start admin imports from apps).
|
|
260
|
+
// Splitting them into separate chunks produces a Rollup
|
|
261
|
+
// chunk-load order that crashes at runtime ("undefined is not
|
|
262
|
+
// a function") — both real-world sites worked around this by
|
|
263
|
+
// overriding manualChunks. Letting Rollup bundle them together
|
|
264
|
+
// (or with the importing chunk) is correct.
|
|
228
265
|
},
|
|
229
266
|
},
|
|
230
267
|
},
|