Repository navigation
feat(vite): bundle meta.gen stub + drop crashing chunk splits + add .deco.studio - #108
Merged
Merged
Conversation
…deco.studio
Three small extensions to decoVitePlugin() that absorb boilerplate
both real-world Deco sites (casaevideo-storefront, baggagio-tanstack)
were keeping in their own vite.config.ts.
1. **meta.gen client stub** — `server/admin/meta.gen.json` is the admin
schema bundle. It's server-only (the client receives pre-resolved
blocks via the SSR payload) but Vite's dependency graph would still
pull it into the browser bundle by default, adding 0.5-5 MB of dead
weight. The framework now stubs `meta.gen.json` / `meta.gen.ts` to
`export default {};` on the client.
Match is end-of-id, scoped to non-entry imports (requires `importer`),
so it can't accidentally stub a build target that points at meta.gen
directly. Both site implementations had this exact plugin inline,
with casaevideo's even commenting "TODO: move into decoVitePlugin in
next @decocms/start release."
2. **Drop @decocms/start / @decocms/apps chunk splits** — Rollup's
`manualChunks` had `vendor-deco` and `vendor-commerce` rules that
pushed framework + apps packages into separate chunks. They have
circular re-exports (apps imports start/sdk/cachedLoader; start
admin imports from apps), and splitting them produces a chunk-load
order that crashes at runtime ("undefined is not a function").
Both sites worked around this by overriding `manualChunks` in their
own configs. Removing the broken rules from the framework default
lets Rollup bundle them with the importing chunk (or a default
vendor catch-all), matching what every site already runs in production.
3. **Add .deco.studio to allowedHosts** — The new admin frontend domain.
Both sites duplicated the list to include it; bundling here removes
that duplication.
Verification:
- `node --check src/vite/plugin.js`: syntax OK
- vitest: 104/104 pass
- No new exports; pure plugin-internal change
Sites can drop after this lands + releases:
- `deco-stub-meta-gen` inline plugin (entire block)
- `site-manual-chunks` inline plugin (entire block)
- `.deco.studio` from their own allowedHosts list (additive change makes
it framework-managed; site can remove its copy if they want)
Together that removes ~50 LOC of boilerplate per site.
Made-with: Cursor
vibe-dex
added a commit
that referenced
this pull request
May 1, 2026
…checklist (#109) Two stale areas in the deco-to-tanstack-migration skill, plus one brand-new reference distilling battle-tested cleanup patterns. ## Changes ### `templates/vite-config.md` — drop ~80 lines of stub duplication The old template inlined the entire `deco-server-only-stubs` plugin (react-dom/server, node:async_hooks, node:stream, node:stream/web, tanstack-head-scripts) — ~60 lines that exactly mirror what `@decocms/start/vite`'s `decoVitePlugin()` already does. The new template uses `decoVitePlugin()` and adds the production-grade boilerplate that real sites actually need (and that the old version omitted): VTEX dev proxy, CSP frame-ancestors header, build sourcemap, PLUGIN_WARNING filter, react-compiler config, `pure: ["console.log"]`, and the full `dedupe` list including `@decocms/start` + `@decocms/apps`. ### `references/vite-config/README.md` — fix "minimal" config that was broken The "post-migration minimal config" was missing `decoVitePlugin()` entirely. Without it, the client bundle crashes on transitively imported server modules. Added the plugin + the minimum dedupe list, and cross-referenced the full template. ### `references/post-migration-cleanup.md` — NEW Dedicated reference distilling the cleanup work that surfaces on every real migration: 1. Detect + delete unused `src/lib/*` shims (with a copy-paste detection script). Real-world data: baggagio-tanstack had 11 generated shims and 0 actual users; casaevideo had 11 generated and 1 used. 2. Drop the `site-manual-chunks` and `deco-stub-meta-gen` inline plugins that are now framework-provided in `@decocms/start >= 2.5.0`. 3. Drop the `runtime.ts` `invoke` shim — `@decocms/start/sdk` exports both `invoke` (singleton) and `createAppInvoke` (typed factory). 4. Drop site-local `withSiteGlobals` workaround — framework helper is now opt-in and tested. 5. Verify VTEX util imports point direct at `@decocms/apps/vtex/...`, not at dead `~/lib/vtex-*` shims (the migration script's stale `phase-cleanup.rewriteVtexUtilImports` was silently regressing them). 6. Search for orphan `TODO: move into framework` comments and either migrate, file an issue, or delete. Plus a verification checklist. ## Why now Validated in this session against three reference sites (casaevideo-storefront, baggagio-tanstack, casaevideo). Each cleanup step has a corresponding shipped or in-flight PR (#103/#106/#107/#108 on framework, #5/#6/#7 on baggagio-tanstack), so the checklist isn't speculative. ## Scope discipline This PR only edits skill content; no source/runtime changes. Both `.agents/skills/` and `.cursor/skills/` copies stay in sync. Made-with: Cursor
|
🎉 This PR is included in version 2.5.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three small extensions to `decoVitePlugin()` that absorb boilerplate both real-world Deco sites (casaevideo-storefront, baggagio-tanstack) were keeping in their own `vite.config.ts`.
Detail
1. `meta.gen` client stub
`server/admin/meta.gen.json` is the admin schema bundle. It's server-only (the client receives pre-resolved blocks via the SSR payload), but Vite's dependency graph would still pull it into the browser bundle by default, adding 0.5-5 MB of dead weight.
Match is end-of-id (`endsWith`), scoped to non-entry imports (requires `importer`), so it can't accidentally stub a build target that points at meta.gen directly.
Casaevideo's inline plugin even has a comment:
This is that release.
2. Drop `@decocms/start` / `@decocms/apps` chunk splits
Rollup's `manualChunks` had `vendor-deco` and `vendor-commerce` rules that pushed framework + apps packages into separate chunks. They have circular re-exports (`apps` imports `start/sdk/cachedLoader`; `start/admin` imports from `apps`), and splitting them produces a chunk-load order that crashes at runtime ("undefined is not a function").
Both sites worked around this by overriding `manualChunks` in their own configs (with explicit comments calling out the circular-dep crash). Removing the broken rules from the framework default lets Rollup bundle them with the importing chunk (or a default vendor catch-all), matching what every site already runs in production.
3. Add `.deco.studio` to `allowedHosts`
The new admin frontend domain. Both sites duplicated the existing `[".deco.host", ".decocdn.com"]` list to add this third entry. Bundling here removes that duplication; sites can drop their own copy.
Risk analysis
Verification
Site cleanup that becomes possible after this lands + releases
```diff
```
Plus the `.deco.studio` entry in each site's `allowedHosts`. Approximately 50 LOC of boilerplate per site.
Test plan
Made with Cursor