Conversation
size-limit report 📦
|
64ea470 to
bf6f465
Compare
1f4024d to
7d12000
Compare
e3dab2d to
5104f9a
Compare
|
This pull request has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you apply the label |
7e9a9c6 to
c823474
Compare
868607b to
44691af
Compare
Co-Authored-By: Codex <codex@openai.com>
The dedicated `Build Lambda layer` CI job runs `build:layer` itself, so having `build:transpile` chain it too built the layer twice per run.
Rolldown compiles each bundled CJS dependency into `var require_x = __commonJSMin(...)`
and has consumers pull it in with `import { require_x } from './body.js'`. That named
import is used, so nothing downstream can drop it, which dragged the parse/query/generate
chain (meriyah, astring, source-map, esquery) into every consumer's runtime bundle.
`@rollup/plugin-commonjs` split each CJS module into a tiny virtual module holding the
exports plus a body imported only for its side effects, which `sideEffects: false` lets a
downstream bundler drop. Reproduce that split for the transformer chain.
…n bundled The orchestrion transformer chain is deliberately split so a downstream bundler can drop it (server-utils' `makeCjsExportsSplitPlugin`). Two ways that split can go wrong and both fail silently at build time: splitting a module whose export is called at module-evaluation time, and reading the container in a way that throws when the body was dropped. Bundle to ESM with tree-shaking and run `init()` to catch either.
rolldown 1.2.6 ships oxc's property mangler (rolldown/rolldown#10374), so the terser config the rollup build used can be ported back: `mangle.reserved` and the `/^_[^_]/` property regex with its reserved list. The option is `minify.mangleProps`, not `minify.mangle.properties` - the latter is the oxc-level interface the reference docs describe and rolldown ignores it silently.
PROVISIONAL - pushed to see the full size picture in CI, not to ship as-is. Feedback's npm build bundles to a single file, so the CDN build has to rely on intra-module DCE to strip the lazily-loaded modal/screenshot code and Preact from a module it only needs `core` from. Rolldown does that less aggressively than rollup: Preact's renderer stayed in, costing ~9 kB in the feedback CDN bundles. Preserving modules lets ordinary module-level tree-shaking handle it, dropping Preact entirely (feedback CDN bundle goes from +8,963 to -1,993 vs develop). The tradeoff is that the published package becomes 31 modules instead of one bundled file, which needs a decision before this ships.
The rolldown commit rewrote this template's default re-export and dropped the suppression on the placeholder side-effect import along with it, which fails lint:types.
This reverts commit 044308a. preserveModules emits preact as a relative import into a node_modules directory that does not exist in the published package, so every app that ships the browser SDK dies at startup on build/npm/esm/node_modules/preact/dist/preact.module.js. That broke the four solidstart E2E apps and debug-id-sourcemaps.
Rolldown infers platform 'browser' for the ESM half of every npm build, and that platform defines process.env.NODE_ENV. Every `process.env.NODE_ENV !== 'development'` guard folded to a constant and DCE deleted the branch behind it, so the ESM output of the vite integrations shipped without the orchestrion code-transformer, the source-map plugin and the custom vite plugins, while the CJS half kept all three. That is why react-router-7's build-injection tests saw mysql and ioredis left external, react-router-sourcemaps found no debug IDs in a client chunk, and the db-span assertions failed across astro, tanstackstart and react-router-cloudflare. Mapping the key to itself keeps the runtime lookup, so the guard is evaluated by the consumer as it always was. Verified across all eight packages that reference it: ESM now matches CJS matches source.
…check resolveShimFile() branched on `typeof require === 'function'` to tell the CJS build from the ESM one. Rolldown renames a bare `require` to its own `__require` polyfill, a Proxy over a function that throws, so in the ESM build the typeof check passed, `__require.resolve` was undefined, and calling it threw straight into the catch. resolveShimFile() returned undefined, the _HANDLER redirect was skipped, and the Lambda ran completely uninstrumented - silently, since the catch only logs in debug builds. That is why every aws-serverless test timed out waiting for envelopes rather than failing an assertion. createRequire(import.meta.url) already works in both halves: the CJS output rewrites import.meta.url to a pathToFileURL(__filename) equivalent. Verified the redirect now fires in both formats, and the ESM build no longer pulls in the rolldown runtime at all.
The package was split out of server-utils on develop while it still built with rollup and @rollup/plugin-commonjs. Move the builtin-require shim, debug node alias and esquery CJS alias into rollup-utils so both packages that vendor the orchestrion chain share them.
44691af to
3b79d0f
Compare
…e when bundled Share the CJS exports split plugin from rollup-utils so server-runtime-injection gets the same treatment as server-utils. Without it, the parse/query/generate chain could not be tree-shaken out of @sentry/node consumers (+54 kB).
Rolldown folds the aliased property read back into `Effect.ErrorReporter`, which webpack rejects when bundling against Effect v3.
Rolldown emits namespace re-exports with non-configurable getters, so observe the bfcache metric through the processMetric hook instead of spying. Its CJS output also uses double-quoted requires.
|
@logaretm do we still want to do this ? This PR has been open for quite a while now, maybe we can close it and track this via the issue in Linear? |
|
@andreiborza I'm still working on this whenever rolldown fixes a blocking bug, last activity is 2 days ago. Right now I'm doing a whack-a-mole with CJS issues in rolldown if it drags more beyond this issue i will close it. |
Refreshed what we had in #18156 with the latest rolldown and let's see if we can get this one out.