Skip to content

perf: don't load consola when importing rolldown - #11257

Merged
IWANABETHATGUY merged 3 commits into
rolldown:mainfrom
magurotuna:perf/lazy-load-cli-logger
Oct 22, 2026
Merged

IWANABETHATGUY merged 3 commits into
rolldown:mainfrom
magurotuna:perf/lazy-load-cli-logger

Conversation

@magurotuna

@magurotuna magurotuna commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

rolldown's CLI logger loads consola. consola bundles string-width, which creates an Intl.Segmenter when it loads, so import('rolldown') pays for consola even when nothing is printed (about 120 M instructions per process on x86_64).

This PR imports the logger with await import() only when an output option that can produce a warning is set. The import happens once, before the options are converted, so the warnings keep their format and order, also when build([...]) runs several builds at once.

image

This PR was prepared with AI assistance (Claude Opus 5.5).

@magurotuna
magurotuna marked this pull request as ready for review October 21, 2026 08:15

@IWANABETHATGUY IWANABETHATGUY left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build([...]) and watch() with several outputs run createBundlerOptions concurrently, so the await before each warning now lets the warnings of different builds interleave. On main, each build's warnings print together.

await build([
  { input, write: false, output: { legalComments: 'inline', advancedChunks: { groups: [] } } },
  { input, write: false, output: { inlineDynamicImports: true } },
]);

main prints the legalComments, advancedChunks, inlineDynamicImports warnings in that order. This PR prints legalComments, inlineDynamicImports, advancedChunks, so the second config's warning lands between the first config's two.

IWANABETHATGUY
IWANABETHATGUY approved these changes Oct 22, 2026 •
magurotuna and others added 3 commits October 22, 2026 13:53
`bindingifyOutputOptions` printed its output option warnings with the
CLI logger, which it imported statically. The logger loads consola.
consola bundles `string-width`, which creates an `Intl.Segmenter` when
it loads. So every `import('rolldown')` paid for consola, even when no
warning was printed.

Import the logger with `await import()` when a warning is printed. The
warnings keep their format and order.

Co-authored-by: Claude Opus 5.5 <[email protected]>
An `await` before each warning let outputs that `build([...])` and
`watch()` convert concurrently print their warnings in between.

Import the logger once, before the conversion, and only when one of
the four options that can produce a warning is set. The conversion
after it is synchronous again, as on main.

Add the example from the review as a test, plus a warning followed by
an `onLog` warning and a warning followed by an error.

Claude-Session: https://claude.ai/code/session_01RRnjESQ91ZYtFhfbmeL3Vu
@IWANABETHATGUY
IWANABETHATGUY force-pushed the perf/lazy-load-cli-logger branch from 721bb91 to 313d449 Compare October 22, 2026 05:53
@IWANABETHATGUY
IWANABETHATGUY enabled auto-merge (squash) October 22, 2026 05:53
@netlify

netlify Bot commented Oct 22, 2026

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 313d449
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6ad9a4d79ec8744f80847290
😎 Deploy Preview https://deploy-preview-11257--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@IWANABETHATGUY
IWANABETHATGUY merged commit 970f65f into rolldown:main Oct 22, 2026
34 checks passed
@magurotuna
magurotuna deleted the perf/lazy-load-cli-logger branch October 22, 2026 06:02
IWANABETHATGUY added a commit that referenced this pull request Oct 25, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 25, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 25, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 26, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 27, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 27, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 28, 2026
…umer's entries load

The runtime merge picks a bitset host by the runtime module's link-time bits. Facade
elimination can later make a chunk outside those bits a runtime consumer, and that consumer
then imports helpers from a chunk its entries never load, which runs the host's side effects.

This broke the packed `@rolldown/browser` CLI. After #11257 made `src/cli/logger` a dynamic
entry, its chunk imported `__exportAll` from the `binding-*.d.mts` chunk, and Node refused to
strip types under `node_modules` (ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING).

Widen the bits with each consumer entry that a host with the link-time bits has not already
loaded. A dynamic entry counts as loaded when every included `import()` of it is in a chunk
that only loaded entries load, so the hosts that the dynamic-entry pruning allows stay as they
are, and no existing snapshot changes.
IWANABETHATGUY added a commit that referenced this pull request Oct 28, 2026
…umer's entries load (#11293)

The runtime could be placed in a chunk that a runtime consumer's entries
never load, so loading that consumer also ran the host chunk. After
#11257, the `src/cli/logger` chunk of `@rolldown/browser` imported
`__exportAll` from the `binding-*.d.mts` chunk, which broke the
WebContainer suite ([CI
run](https://github.com/rolldown/rolldown/actions/runs/39795658288/job/119912668403?pr=11268)):

```
Error [ERR_UNSUPPORTED_NODE_MODULES_TYPE_STRIPPING]: Stripping types is currently unsupported for files under node_modules, for "file:///home/n2ixzueuvg3ulsv6tc9vnscfoy40oq-aurr/node_modules/.pnpm/file+rolldown-browser.tgz/node_modules/@rolldown/browser/dist/shared/binding-DPNoioF9.d.mts"
```

The two `perf(rolldown_utils)` commits make `BitSet::is_subset` faster,
because the new check calls it in a loop.

requires #11298
refs #11268
This was referenced Oct 29, 2026
shulaoda added a commit that referenced this pull request Oct 29, 2026
## [1.2.16] - 2026-10-29

### 🚀 Features

- perf-kit: check rendered output against the original build (#11140) by @IWANABETHATGUY
- perf-kit: node/deno server startup mode (#10601) by @IWANABETHATGUY
- perf-kit: browser page-load perf harness for coding agents (#10365) by @IWANABETHATGUY
- devtools: report mode - agent-readable build metrics report (#10364) by @IWANABETHATGUY
- inline-common-chunks: print record factories parenthesized so they compile eagerly (#11282) by @mattlewis92
- fold `'key' in ns` on namespace imports with statically known exports (#11333) by @danielroe
- inline-common-chunks: inline chunks using `import.meta.hot` in dev mode (#11339) by @hyfdev
- support `experimentalInlineCommonChunks` in dev mode (#11335) by @hyfdev
- use `INVALID_TLA_FORMAT` error for Rollup compatibility (#11266) by @sapphi-red

### 🐛 Bug Fixes

- await bundle.close() in loadConfig and clean up every generated config file (#10347) by @Brooooooklyn
- deps: update mimalloc-safe to 0.1.69 (#11376) by @shulaoda
- transform: don't crash when the working directory has been deleted (#11352) by @shulaoda
- import-glob: follow directory symlinks on the wasm binding (#10624) by @hyfdev
- tree-shaking: preserve exported rest bindings from dynamic imports (#11365) by @shuvroroy
- transform: report `tsconfigFilePaths` for a tsconfig resolved through `TsconfigCache` (#11346) by @cainrus
- tsconfig: don't apply tsconfig when resolving imports from virtual modules (#11089) by @rubas
- code-splitting: handle emitted entries the same as `input` entries when placing the runtime (#11353) by @IWANABETHATGUY
- error: make Diagnostic::add_file idempotent (#10610) by @Nic-Polumeyv
- avoid retaining callable builtin callback owners (#10961) by @IWANABETHATGUY
- code-splitting: only host the runtime in a chunk that every consumer's entries load (#11293) by @IWANABETHATGUY
- code-splitting: keep the source order of chunk imports (#11298) by @IWANABETHATGUY
- dev: don't treat a wrapped module's init as a no-op in dev mode (#11334) by @hyfdev
- treat `cwd` as a literal path in relative glob filters (#11291) by @onmax
- deps: update emnapi to 2.0.0-beta.2 and pin `@napi-rs/wasm-runtime` to 1.2.6 (#11292) by @IWANABETHATGUY
- chunk-import-map: hash stable module ids so keys don't depend on the build folder (#11277) by @mandyheg
- respect CPU limits when sizing native runtime workers (#11280) by @Brooooooklyn
- deconflict the namespace of a module without module syntax (#11256) by @IWANABETHATGUY
- code-splitting: rebuild an absorbed dynamic entry's namespace from what its imports read (#11200) by @mattlewis92
- escape line terminators in debug-info comments (#11258) by @IWANABETHATGUY

### 🚜 Refactor

- extract callable builtin hook wrapper (#10964) by @IWANABETHATGUY

### 📚 Documentation

- add an in-depth explanation for inline common chunks (#11239) by @hyfdev

### ⚡ Performance

- incremental cycle check for `avoidRedundantChunkLoads` (#11320) by @IWANABETHATGUY
- avoid copying module code for `renderedLength` and share `chunk.code` across plugins (#11342) by @IWANABETHATGUY
- count UTF-16 lengths with `simd-utf16-len` (#11259) by @IWANABETHATGUY
- don't load consola when importing rolldown (#11257) by @magurotuna

### 🧪 Testing

- dev: cover hot updates that need modules the tab never received (#9647) by @matthewdavis-oai
- dev: add dynamic import rebuild test (#7123) by @sapphi-red
- code-splitting: import file URLs in fresh-process runtime host tests on Windows (#11354) by @shulaoda
- esbuild: mark loader_data_url_base64_invalid_utf8 as an intentional difference (#10790) by @CoderSerio
- watch: fix flaky `watch buildDelay` (#11175) by @Brooooooklyn

### ⚙️ Miscellaneous Tasks

- install `cmake-core` instead of the `cmake` metapackage on FreeBSD (#11361) by @shulaoda
- deps: update oxc to 0.156.0 (#11326) by @Dunqing
- stop the Discord notification when the metric workflow fails (#11357) by @IWANABETHATGUY
- connect to the Void platform before the docs deploy (#11350) by @shulaoda
- deps: update rust crates (#11297) by @renovate[bot]
- deps: update dependency vite-plus to v1.4.0 (#11288) by @renovate[bot]
- deps: update npm packages (#11296) by @renovate[bot]
- deps: update napi (#11287) by @renovate[bot]
- deps: update rollup submodule for tests to v4.65.1 (#11331) by @rolldown-guard[bot]
- deps: update test262 submodule for tests (#11332) by @rolldown-guard[bot]
- deps: update dependency rolldown-plugin-dts to v0.28.8 (#11286) by @renovate[bot]
- deps: bump tokio to 1.53.3 (#11317) by @Brooooooklyn

### ❤️ New Contributors

* @mattlewis92 made their first contribution in [#11282](#11282)
* @shuvroroy made their first contribution in [#11365](#11365)
* @cainrus made their first contribution in [#11346](#11346)
* @matthewdavis-oai made their first contribution in [#9647](#9647)
* @rubas made their first contribution in [#11089](#11089)
* @danielroe made their first contribution in [#11333](#11333)
* @onmax made their first contribution in [#11291](#11291)
* @mandyheg made their first contribution in [#11277](#11277)
* @magurotuna made their first contribution in [#11257](#11257)

Co-authored-by: shulaoda <[email protected]>
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.

2 participants