Skip to content

fix(error): name the resolved specifier in unresolved import diagnostics - #11014

Merged
IWANABETHATGUY merged 4 commits into
rolldown:mainfrom
linyiru:fix/11013-unresolved-import-specifier
Sep 28, 2026
Merged

IWANABETHATGUY merged 4 commits into
rolldown:mainfrom
linyiru:fix/11013-unresolved-import-specifier

Conversation

@linyiru

@linyiru linyiru commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

fixes #11013

UNRESOLVED_IMPORT built the specifier by dropping the first and last character of the import span, assuming they were quotes around a string literal. Pre-scan const folding replaces import(id) with a string literal that keeps the identifier's span, so the message sliced the identifier instead of naming the value that failed to resolve. A one-character identifier panicked (byte range starts at 1 but ends at 0).

The diagnostic now stores that resolved specifier. The span is only used to underline the import in the original source.

Reproduced on the previous implementation, then confirmed the fixtures fail there and pass with this change:

Source Before After
import(id) where id = "no-such-pkg-a" '' no-such-pkg-a
import(longerName) ongerNam no-such-pkg-b
import("no-such-pkg-c") no-such-pkg-c no-such-pkg-c
import(a) (one character) panic no-such-pkg-d
require(required) equire no-such-pkg-e
template literal `no-such-pkg-f` no-such-pkg-f no-such-pkg-f
import("no-such-" + "pkg-g") no-such-" + "pkg-g no-such-pkg-g
import("no-such-\u0070kg-h") no-such-\u0070kg-h no-such-pkg-h
import(missing) where missing = "./no-such-file.js" issin ./no-such-file.js

The underline still points at the identifier, template, or expression as written. An escaped literal is named by the decoded specifier resolution used (p, not the source spelling \u0070). import of a const that points at a real file still bundles that file and emits no warning.

Rust integration fixtures are the coverage the testing guide asks for on diagnostics. Existing unresolved-import fixtures still pass.

Prepared with an AI coding tool. The reproduction above was run against the unmodified diagnostic, and the fixtures were checked after the change.

@linyiru
linyiru marked this pull request as ready for review September 28, 2026 03:57
@codspeed

codspeed Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 7 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing linyiru:fix/11013-unresolved-import-specifier (91abfc5) with main (30c7703)

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. ↩

@netlify

netlify Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for rolldown-rs ready!

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

Copy link
Copy Markdown
Member

I’ll make a few small changes directly on your branch to avoid unnecessary back-and-forth and help move this forward more efficiently.

  1. Remove some test cases that test duplicate scenarios.

linyiru and others added 4 commits September 28, 2026 16:24
UNRESOLVED_IMPORT recovered the specifier by dropping the first and last
character of the import span, on the assumption that those characters were
quotes. Const folding keeps the identifier span, so `id` was reported as
`''`, `longerName` as `ongerNam`, and a one-character name panicked.

Use the specifier that resolution actually used. The span only underlines
the import.

fixes rolldown#11013
autofix rewrote the fixture strings to single quotes. The diagnostic
underline copies that source, so the snapshot has to match or CI fails.
@IWANABETHATGUY
IWANABETHATGUY enabled auto-merge (squash) September 28, 2026 08:24
@IWANABETHATGUY
IWANABETHATGUY force-pushed the fix/11013-unresolved-import-specifier branch from b67fb14 to 91abfc5 Compare September 28, 2026 08:24
@IWANABETHATGUY
IWANABETHATGUY merged commit b600223 into rolldown:main Sep 28, 2026
34 of 35 checks passed
@rolldown-guard rolldown-guard Bot mentioned this pull request Sep 30, 2026
shulaoda added a commit that referenced this pull request Sep 30, 2026
## [1.2.12] - 2026-09-30

### 🚀 Features

- inline common chunks containing import() and deduplicate shared code in lazy chunks (#11034) by @hyfdev
- experimental `inlineCommonChunks` support (#10899) by @hyfdev
- dev: ship imported bindings for HMR partial accept (#10856) by @h-a-n-a

### 🐛 Bug Fixes

- chunking: re-derive chunk exec orders after the runtime leaves its host chunk (#11005) by @hyfdev
- code-splitting: gate member-read init paths on the reading statement (#11039) by @hyfdev
- code-splitting: retain initialization paths through re-exported namespaces (#11037) by @hyfdev
- dev: reject non-ESM output formats in dev mode (#11038) by @h-a-n-a
- dev: align `import.meta.hot.accept` deps with Vite (#10997) by @h-a-n-a
- dev: clear the resolver cache when a file is created or deleted (#10986) by @waltuov
- error: name the resolved specifier in unresolved import diagnostics (#11014) by @linyiru
- make entries-aware chunk merging deterministic (#11002) by @hyfdev
- watch: avoid restarting macOS watcher for unchanged paths (#10992) by @sep2

### 🚜 Refactor

- dev: ship the dev runtime entry as one file (#10998) by @h-a-n-a
- binding: remove `__internalForcePanic` (#10989) by @IWANABETHATGUY

### 📚 Documentation

- fix cloudflare preview builds (#10996) by @sapphi-red
- fix build config loader warning (#10994) by @sapphi-red
- deps: use Vite 8 (#10993) by @sapphi-red

### ⚡ Performance

- dev: only ship rows with dynamic edges in registerGraph (#11019) by @h-a-n-a

### 🧪 Testing

- code-splitting: cover more re-exported namespace shapes (#11042) by @hyfdev
- webcontainer: cover the WebContainer download fallback in plain Node (#10966) by @shulaoda
- dev: pin the runtime entry file layout that Vite serves (#10983) by @h-a-n-a

### ⚙️ Miscellaneous Tasks

- pin VOID_API_URL for the docs deploy (#11041) by @shulaoda
- opt into the WebContainer smoke test for napi bumps and loader changes (#10967) by @shulaoda
- deps: upgrade oxc to 0.152.0 (#11018) by @camc314
- deps: update rust crates (#11012) by @renovate[bot]
- deps: update npm packages (#11011) by @renovate[bot]
- deps: update crate-ci/typos action to v1.50.3 (#11023) by @renovate[bot]
- deps: update test262 submodule for tests (#11022) by @rolldown-guard[bot]
- deps: update rollup submodule for tests to v4.63.5 (#11021) by @rolldown-guard[bot]
- deps: update dependency vite-plus to v1 (#11017) by @renovate[bot]
- deps: update github actions (#11010) by @renovate[bot]
- remove `CLAUDE.md` (#10925) by @iiio2
- verify release debug info by matching file IDs (#10988) by @IWANABETHATGUY
- deps: update rollup submodule for tests to v4.63.4 (#10940) by @rolldown-guard[bot]

### ❤️ New Contributors

* @waltuov made their first contribution in [#10986](#10986)
* @linyiru made their first contribution in [#11014](#11014)
* @sep2 made their first contribution in [#10992](#10992)

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.

[Bug]: UNRESOLVED_IMPORT shows the identifier's text minus its first/last char when a dynamic import's specifier is a const

2 participants