Update to add externalized dependencies for the goods-editor-module

This commit is contained in:
khalid@traclabs.com
2026-05-24 10:56:43 -05:00
parent 846560f81a
commit e4e9459c86
3 changed files with 57 additions and 15 deletions

View File

@@ -119,14 +119,20 @@ export default defineConfig({
// which precaching would undo. They're served via the
// `sticker-library` runtimeCaching rule below instead.
globIgnores: ['**/stickers/**'],
// Note: we deliberately do NOT raise `maximumFileSizeToCacheInBytes`
// We deliberately do NOT raise `maximumFileSizeToCacheInBytes`
// here. The default 2 MiB cap is a useful regression alarm — if
// a future change pushes any chunk past it, the build fails loudly
// and we know to either split further or investigate why a chunk
// grew. Earlier this file overrode the cap to 5 MiB because the
// pre-split bundle was 2.32 MB; that override was removed once
// `build.rollupOptions.output.manualChunks` (below in this config)
// brought every chunk under the default cap.
// grew.
//
// History: this file briefly overrode the cap to 3 MiB when the
// goods-editor module shipped its dist with konva, react-konva,
// use-image, react-filerobot-image-editor, and
// @huggingface/transformers inlined (~2.14 MiB chunk). That
// override was removed when the module externalized those deps
// (goods-editor v0.2.0-alpha.0+) and they became host-resolved
// peer deps, letting the host's manualChunks rules split them
// into separate sub-2-MiB chunks.
runtimeCaching: [
{
urlPattern: /^https:\/\/cdn\.huggingface\.co\/.*/i,
@@ -328,6 +334,15 @@ export default defineConfig({
// used only when the user opens the advanced
// image editor. Worth its own chunk so the
// rest of the app doesn't pay for it.
// goods-editor/ The editor module's own bundle. By far the
// largest single piece of UI code (the entire
// editor surface). Lives in its own chunk so
// host-only deploys don't bust its cache — it
// only changes when we bump the module's tag
// in package.json. Without this split, it sits
// inside `index` and pushes the index chunk
// past 2 MiB, which fails the workbox precache
// check.
// index/ Everything else: app code, react-select,
// styled-components, zod, uuid, plus all
// the small utilities. This stays the
@@ -365,6 +380,7 @@ export default defineConfig({
['konva', 'konva', 'react-konva', 'use-image'],
['react-vendor', 'react', 'react-dom'],
['filerobot', 'react-filerobot-image-editor'],
['goods-editor', 'goods-editor'],
];
for (const [chunk, ...packages] of groups) {
for (const pkg of packages) {