Skip to content

Factor manifest code to reduce the bundle size#1215

Merged
vicb merged 6 commits intomainfrom
vicb/ext-dedup
Apr 21, 2026
Merged

Factor manifest code to reduce the bundle size#1215
vicb merged 6 commits intomainfrom
vicb/ext-dedup

Conversation

@vicb
Copy link
Copy Markdown
Contributor

@vicb vicb commented Apr 20, 2026

Changes from #1212:

  • remove EmptyEdgeMappings
  • rules do not require a fix any more, remove that
  • use SHA1 prefix instead of full SHA1
  • add tests

supersedes #1186 and #1212

The following manifest:

globalThis.__RSC_MANIFEST = globalThis.__RSC_MANIFEST || {};
globalThis.__RSC_MANIFEST["/dashboard/page"] = {
  moduleLoading: { prefix: "", crossOrigin: null },
  clientModules: {
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/esm/client/components/layout-router.js <module evaluation>":
      {
        id: 3097,
        name: "*",
        chunks: [
          "/_next/static/chunks/33074d3ff5d0cd2d.js",
          "/_next/static/chunks/eb1e789fab5a5185.js",
        ],
        async: false,
      },
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/esm/client/components/layout-router.js":
      {
        id: 3097,
        name: "*",
        chunks: [
          "/_next/static/chunks/33074d3ff5d0cd2d.js",
          "/_next/static/chunks/eb1e789fab5a5185.js",
        ],
        async: false,
      },
      // ...
  },
  ssrModuleMapping: {
    3097: {
      "*": {
        id: 76237,
        name: "*",
        chunks: [
          "server/chunks/ssr/[root-of-the-server]__5a337f56._.js",
          "server/chunks/ssr/b2b3e_next_dist_2953b357._.js",
        ],
        async: false,
      },
    },
    // ...
  },
  edgeSSRModuleMapping: {},
  rscModuleMapping: {
    3097: { "*": { id: 8465, name: "*", chunks: [], async: false } },
    99299: { "*": { id: 37954, name: "*", chunks: [], async: false } },
    // ...
  },
  edgeRscModuleMapping: {},
  entryCSSFiles: {
    "[project]/app/favicon.ico": [],
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error":
      [],
    "[project]/app/dashboard/page": [],
  },
  entryJSFiles: {
    "[project]/app/favicon.ico": [
      "static/chunks/33074d3ff5d0cd2d.js",
      "static/chunks/eb1e789fab5a5185.js",
    ],
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error":
      [],
    "[project]/app/dashboard/page": ["static/chunks/1dd517b60221a725.js"],
  },
};

is transformed to

const vc7a = ["/_next/static/chunks/33074d3ff5d0cd2d.js", "/_next/static/chunks/eb1e789fab5a5185.js"];

const v4dd = {
    "[project]/app/favicon.ico": ["static/chunks/33074d3ff5d0cd2d.js", "static/chunks/eb1e789fab5a5185.js"],
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/client/components/builtin/global-error": [],
    "[project]/app/dashboard/page": ["static/chunks/1dd517b60221a725.js"]
};

const vafa = {
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/esm/client/components/layout-router.js <module evaluation>": {
        "id": 3097,
        "name": "*",
        "chunks": vc7a,
        "async": false
    },
    "[project]/node_modules/.pnpm/next@16.1.6_@babel+core@7.29.0_react-dom@19.2.3_react@19.2.3__react@19.2.3/node_modules/next/dist/esm/client/components/layout-router.js": {
        "id": 3097,
        "name": "*",
        "chunks": vc7a,
        "async": false
    },
    // ...
};

globalThis.__RSC_MANIFEST["/dashboard/page"] = {
    "moduleLoading": {
        "prefix": "",
        "crossOrigin": null
    },
    "clientModules": vafa,
    "ssrModuleMapping": v091,
    "edgeSSRModuleMapping": {},
    "rscModuleMapping": v639,
    "edgeRscModuleMapping": {},
    "entryCSSFiles": v6f8,
    "entryJSFiles": v4dd
};

vicb and others added 5 commits April 10, 2026 13:22
…ry files, and chunks arrays

- Replace empty edgeSSRModuleMapping/edgeRscModuleMapping with shared __EMPTY variable
- Factor entryCSSFiles and entryJSFiles through existing factorManifestValue
- Deduplicate repeated chunks arrays within module mappings into shared c_<hash> variables
Builds on #1186 (vicb/dedup).
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 20, 2026

🦋 Changeset detected

Latest commit: 663d74f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@opennextjs/cloudflare Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@opennextjs/cloudflare@1215

commit: 663d74f

@mgallagher
Copy link
Copy Markdown

For our build, this PR a slightly smaller bundle compared to #1212

Baseline

Next 16.2.4
@opennext/cloudflare 1.19.2

Turbopack:
Total Upload: 58427.44 KiB / gzip: 9224.35 KiB
Webpack:
Total Upload: 66146.16 KiB / gzip: 9213.08 KiB

This PR

Turbopack:
Total Upload: 42842.04 KiB / gzip: 8533.55 KiB
Webpack:
Total Upload: 41919.49 KiB / gzip: 7605.62 KiB

@vicb vicb changed the title Extended dedup (base on #1212) Factor manifest code to reduce the bundle size Apr 21, 2026
Comment thread packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts
Comment thread packages/cloudflare/src/cli/build/patches/plugins/load-manifest.ts
@vicb
Copy link
Copy Markdown
Contributor Author

vicb commented Apr 21, 2026

Thanks for the review @conico974 🙏

@vicb vicb merged commit 608893e into main Apr 21, 2026
7 checks passed
@vicb vicb deleted the vicb/ext-dedup branch April 21, 2026 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants