Skip to content

fix: keep the with clause on bare external imports - #11100

Merged
IWANABETHATGUY merged 3 commits into
mainfrom
fix/bare-external-import-attributes
Oct 6, 2026
Merged

IWANABETHATGUY merged 3 commits into
mainfrom
fix/bare-external-import-attributes

Conversation

@IWANABETHATGUY

@IWANABETHATGUY IWANABETHATGUY commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

A side-effect-only import of an external dropped its import attributes, so import 'x' with { type: 'json' } became import "x";. The import now keeps the clause of the first static record in its chunk that has one. The only snapshot change is comment_preservation_import_assertions, which now keeps its assert clause.

@IWANABETHATGUY IWANABETHATGUY changed the title fix/bare external import attributes fix: keep the with clause on bare external imports Oct 5, 2026
@netlify

netlify Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 114a8d5
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/6ac4b56b0d8a060008e842eb
😎 Deploy Preview https://deploy-preview-11100--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.

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

A side-effect-only import of an external dropped its import attributes,
so `import 'x' with { type: 'json' }` became `import "x";`. The import
now keeps the clause of the first static record in its chunk that has
one.
@IWANABETHATGUY
IWANABETHATGUY force-pushed the fix/bare-external-import-attributes branch from ef6c4cc to de17d41 Compare October 5, 2026 02:47
Import attribute keys and values were wrapped in quotes without escaping,
so `with { custom: 'a"b' }` rendered as the invalid `custom: "a"b"`. With
DCE enabled, re-parsing that output failed and the chunk came out empty.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@IWANABETHATGUY
IWANABETHATGUY marked this pull request as ready for review October 5, 2026 03:12
@codspeed

codspeed Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing fix/bare-external-import-attributes (114a8d5) with main (9ecd474)2

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (a849909) during the generation of this report, so 9ecd474 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

@IWANABETHATGUY
IWANABETHATGUY merged commit b0098ee into main Oct 6, 2026
37 checks passed
@IWANABETHATGUY
IWANABETHATGUY deleted the fix/bare-external-import-attributes branch October 6, 2026 08:56
@rolldown-guard rolldown-guard Bot mentioned this pull request Oct 7, 2026
shulaoda added a commit that referenced this pull request Oct 7, 2026
## [1.2.13] - 2026-10-07

### 🚀 Features

- rolldown_plugin_vite_import_glob: follow file creation and deletion via hotUpdate (#10550) by @shulaoda
- inline-common-chunks: deduplicate shared code along known loading paths (#11093) by @hyfdev
- rolldown_plugin_vite_import_glob: record a matcher per glob call in dev (#10592) by @shulaoda
- rolldown_plugin_vite_import_glob: watch the directory each glob reads (#10549) by @shulaoda
- watch: hand watch.exclude to notify as its ignore filter (#11008) by @shulaoda
- dev: add `experimental.devMode.hotUpdate` option (#11123) by @h-a-n-a

### 🐛 Bug Fixes

- renamer: check the printed name of namespace-alias imports for captures (#11129) by @IWANABETHATGUY
- devtools: honor `devtools.sessionId` by @Brooooooklyn
- renamer: keep a renamed nested binding off its module's top-level bindings (#11128) by @IWANABETHATGUY
- dev: keep `this` undefined when calling an imported function in HMR patches and lazy chunks (#11126) by @h-a-n-a
- dev: read string-named imports correctly in HMR patches and lazy chunks (#11127) by @h-a-n-a
- sanitize preserveModules chunk names after resolving the relative path (#11087) by @waltuov
- keep the `with` clause on bare external imports (#11100) by @IWANABETHATGUY
- generator: filter DISABLE_JS_HOOK bits from generated HookUsage (#10346) by @Brooooooklyn
- dev: make the module factory async for top-level await (#11118) by @h-a-n-a
- node: give each renderChunk call its own meta object (#11115) by @Brooooooklyn
- honor `externalLiveBindings` for imported exports (#11048) by @camc314
- dev: keep a late payload from replacing newer module code (#11030) by @h-a-n-a
- binding: use-after-free in async `transform` with a `TsconfigCache` (#11080) by @shulaoda
- fail on chunk syntax errors and escape export names once (#11051) by @hyfdev
- dev: ship newly imported modules the client never received (#11029) by @h-a-n-a
- code-splitting: avoid cycles from redundant re-export initialization (#11073) by @hyfdev
- link: treat re-exports of the same external binding as one export (#11069) by @IWANABETHATGUY
- escape namespace properties in IIFE and UMD output (#11085) by @hyfdev
- escape dependency paths in CJS and UMD output (#11084) by @hyfdev
- use computed access for arbitrary import names (#11083) by @hyfdev
- generate valid bindings for shimmed exports (#11082) by @hyfdev
- dev: reload the page when an HMR update fails after merging its edit (#11031) by @h-a-n-a
- dev/lazy: ship the deps of a module that a patch shipped but never ran (#11028) by @h-a-n-a
- code-splitting: don't move init calls in front of unwrapped JSON modules (#11062) by @IWANABETHATGUY
- escape export names in `defineProperty` calls (#11047) by @camc314

### 📚 Documentation

- say the CLI bundles multiple configs one after another (#11111) by @Brooooooklyn
- add `renderChunk` hook filter docs (#11065) by @sapphi-red

### ⚡ Performance

- use `concat_string!` instead of `format!` for plain string joins (#11139) by @IWANABETHATGUY
- utils: evaluate each `concat_string!` argument once (#11105) by @IWANABETHATGUY
- json: escape `JSON.parse` string with `json-escape-simd` (#11104) by @IWANABETHATGUY
- unwrap JSON modules with a non-object root (#11066) by @IWANABETHATGUY

### 🧪 Testing

- inline-common-chunks: fix flaky inlineCommonChunks concurrent imports (#11088) by @hyfdev

### ⚙️ Miscellaneous Tasks

- deps: upgrade oxc to 0.153.0 (#11109) by @camc314
- update pnpm to v12 (#10876) by @btea
- deps: update pnpm to v11.28.0 (#11049) by @renovate[bot]
- deps: update rollup submodule for tests to v4.64.0 (#11116) by @rolldown-guard[bot]
- deps: update napi (#11137) by @renovate[bot]
- scripts: spawn the rolldown CLI without a shell in setup-vite (#10875) by @Brooooooklyn
- deps: bump `@napi-rs/wasm-runtime` to `~1.2.5` (#11117) by @shulaoda
- deps: update napi (#11108) by @renovate[bot]
- deps: update taiki-e/install-action action to v2.87.22 (#11096) by @renovate[bot]
- deps: update npm packages (#11095) by @renovate[bot]
- deps: update rust crates (#11097) by @renovate[bot]
- deps: update napi (#11063) by @renovate[bot]
- deps: update dependency rust to v1.99.0 (#11071) by @renovate[bot]
- deps: update dependency vite-plus to v1 (#11056) by @renovate[bot]

Co-authored-by: shulaoda <[email protected]>
shulaoda added a commit that referenced this pull request Oct 26, 2026
…l external with clause support

BREAKING CHANGE: without `experimental.importAttributes`, the `with` clause of
an import of an external module is no longer kept in the output. It warns with
the new `INVALID_IMPORT_ATTRIBUTE` event (`checks.invalidImportAttribute`) and
names the option to enable. Keeping the clause as written (#5794, #9796,
#11100) was a partial import attributes implementation without module
identity: two imports of one external with different attributes were one
module and only the first clause survived. The next PRs of the stack make the
attributes part of module identity and render them from the module itself, so
with the option on every import that only used attributes on externals gets
the same output as before. The legacy `assert` keyword is not supported in
either mode: it gives no attributes, is dropped and warns.

The model: `ImportAttributes` keeps the attributes of an import in the order
`JSON.stringify` emits them, `ModuleId::with_attributes` composes the Rollup 5
id `rawId?attributes=<encodeURIComponent(JSON.stringify(sorted))>` and keeps
`raw_id()` reachable, `ResolvedId.attributes` carries the attributes a
resolution ends with, `ImportRecord.attributes` holds what the scanner read
from a static clause, and the Rust options accept
`experimental.importAttributes`, which nothing composes ids with yet. The
`ImportAttribute` side table and `import_attribute_map` go away.

RFC: #11217
shulaoda added a commit that referenced this pull request Nov 3, 2026
… import record (#11301)

Part 1 of 11 of the import attributes stack. RFC: #11217. Full proof of
concept: #11254.

Adds the data model for import attributes, aligned with Rollup 5.
Nothing reads the new option yet, so builds behave as before, except for
the legacy `assert` keyword below.

- `ImportAttributes`: the attributes of one import, kept in the order
`JSON.stringify` emits them, so equal attributes always compare and hash
the same.
- `ModuleId::with_attributes`: builds the Rollup 5 id
`rawId?attributes=<encoded JSON>` and keeps `raw_id()` for path
operations.
- `ResolvedId.attributes` and `ImportRecord.attributes`: carry the
attributes through resolution and keep what the scanner read from a
`with` clause.
- `experimental.importAttributes`: accepted by the Rust options, used by
the next PRs.
- Tests: `configVariants` accept `importAttributes`, so a fixture can
run in both modes.

Until now Rolldown supported import attributes only partially: the
`ImportAttribute` side table (#5794, #9796, #11100) kept the `with`
clause of an external import as written and picked one clause per chunk,
while attributes took no part in module identity. That side table is
gone. In this PR the `with` clause of an external is rendered from the
import record's attributes instead, so the output does not change,
except that keys are sorted and duplicates are removed. #11303 then
renders it from the module's own attributes.

The legacy `assert` keyword is deprecated. It is treated as `with`, so
its attributes are kept and an external renders a `with` clause. The
build warns with the new `DEPRECATED_IMPORT_ASSERTION` code
(`checks.deprecatedImportAssertion`). Use `with` instead. Earlier
versions kept the `assert` clause as written, which Node 22 rejects.
shulaoda added a commit that referenced this pull request Nov 3, 2026
…om their module identity (#11303)

Part 3 of 11 of the import attributes stack. RFC: #11217. Full proof of
concept: #11254.

External modules now render their `with` clause from their own
attributes. Externals carry their attributes in their module id with or
without `experimental.importAttributes`, so the clause is always kept.

- ESM output: every static import and re-export of an external renders
`ExternalModule.attributes`, including the `import * as` emitted for a
namespace re-export. The record based search in `esm.rs` is removed.
- `import()`: the options of `import()` of an external are rewritten to
the final attributes, so a `resolveId` override shows up in the output.
- `import()` path: `import()` of an external gets the same path as a
static import, and stays an `import()` while it has options, because
`require()` cannot carry them.
- `assert` in `import()` options: engines ignore it, so every `import()`
left in the output gets the key rewritten to `with`, including one with
a computed specifier. It warns `DEPRECATED_IMPORT_ASSERTION` with or
without the option, like a static `assert` clause.
- Raw id: `output.globals` and the CJS `require()` of a re-exported
external use the raw id.

The old behavior (#5794, #9796, #11100) had no module identity. Two
imports of one external with different attributes were one module, and
only one clause survived. For example, `import 'ext'; import 'ext' with
{ type: 'json' }` rendered only the second import. Now they are two
externals, each with its own clause. Without the option, an external
with attributes now has a composite id in `getModuleInfo()` and
`moduleIds`.
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