[Feat]: Inline `rolldown:runtime` for each chunk instead of share it
Reproduction link or steps
When using advancedChunks.groups the highest priority chunk will get the rolldown:runtime and others will import from it.
What is expected?
//#region rolldown:runtime
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
//#region rolldown:runtime
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
What is actually happening?
//#region rolldown:runtime
var __esmMin = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
import { __esmMin } from "./chunk-one.js";
System Info
Rolldown 0.14.0
Any additional comments?
No response
Shared runtime helper in multiple chunks will reduce amount of code size, can you elaborate why do you need to inline all the runtime helper function?
rolldown:runtime is like a normal module. There will be only one instance during the build. So if any chunk rely on it, it will imported it from where it exist.
Shared runtime helper in multiple chunks will reduce amount of code size, can you elaborate why do you need to inline all the runtime helper function?
You're creating new dependencies between chunks that nullifies my chunking strategy because I use [name]-[hash] for chunk names.
rolldown:runtime is like a normal module. There will be only one instance during the build. So if any chunk rely on it, it will imported it from where it exist.
Yes, this is exactly the issue. Whenever a chunk containing the implementation of a rollup runtime helper changes, the filename changes, and then ALL other chunks have to change to update their import path since ALL chunks depend on the runtime code. This happens regardless of my chunk's dependencies.
A workaround for now is to extract the runtime chunk. However, this is rather silly because the chunk is so small. I'd rather just have it inlined into each of my other chunks, and I'd argue this should be rollup's default strategy up until (runtime size x number of chunks) > a single HTTP request overhead.
I suppose I'm asking for a generic feature to inline chunks, and for rolldown's runtime to use that feature by default.
Ran into this again today. I'd love to eliminate one more tiny HTTP request!
FWIW, tsc and babel by default resort to inlining their helpers and require manual configuration to import them instead. I find this good behavior.