Skip to content

fix(rolldown_plugin_vite_import_glob): normalize resolved alias path to prevent double slashes#9032

Merged
shulaoda merged 1 commit intomainfrom
04-08-fix_rolldown_plugin_vite_import_glob_normalize_resolved_alias_path_to_prevent_double_slashes
Apr 8, 2026
Merged

fix(rolldown_plugin_vite_import_glob): normalize resolved alias path to prevent double slashes#9032
shulaoda merged 1 commit intomainfrom
04-08-fix_rolldown_plugin_vite_import_glob_normalize_resolved_alias_path_to_prevent_double_slashes

Conversation

@shulaoda
Copy link
Copy Markdown
Member

@shulaoda shulaoda commented Apr 8, 2026

Related to vitejs/vite#22124, I will add a test case in vite side.

@netlify
Copy link
Copy Markdown

netlify bot commented Apr 8, 2026

Deploy Preview for rolldown-rs canceled.

Name Link
🔨 Latest commit d81fa11
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69d6120cafba1400086c1532

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Apr 8, 2026

Merging this PR will not alter performance

✅ 4 untouched benchmarks
⏩ 10 skipped benchmarks1


Comparing 04-08-fix_rolldown_plugin_vite_import_glob_normalize_resolved_alias_path_to_prevent_double_slashes (d81fa11) with main (5f38a1b)

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.

@shulaoda shulaoda merged commit 56d4f66 into main Apr 8, 2026
54 of 55 checks passed
@shulaoda shulaoda deleted the 04-08-fix_rolldown_plugin_vite_import_glob_normalize_resolved_alias_path_to_prevent_double_slashes branch April 8, 2026 09:18
.map(|resolved| resolved.id.to_string());
let resolved_id =
rolldown_utils::futures::block_on(future).ok().and_then(Result::ok).map(|resolved| {
PathBuf::from(resolved.id.as_str()).normalize().to_slash_lossy().into_owned()
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.

Vite v7 code:
https://github.com/vitejs/vite/blob/cc383e07b66d4c5a9768fcb570e0af812cb8d999/packages/vite/src/node/plugins/importMetaGlob.ts#L662-L669
https://github.com/vitejs/vite/blob/cc383e07b66d4c5a9768fcb570e0af812cb8d999/packages/vite/src/node/plugins/resolve.ts#L212-L219

v8 code:

if args.specifier.starts_with('#')
&& let Some(resolved_imports) =
(self.resolve_subpath_imports)(&id, args.importer, args.kind == ImportKind::Require, scan)
.await?
{
id = Cow::Owned(resolved_imports);
if args
.custom
.get(&rolldown_plugin_utils::constants::ViteImportGlob)
.is_some_and(|v| v.is_sub_imports_pattern())

https://github.com/vitejs/vite/blob/94fd9e7fe1a7d7970ba5e154d588f88318a72302/packages/vite/src/node/plugins/resolve.ts#L354-L360

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Is this just an explanation of the code, or do I need to make further changes?

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.

It was for me to understand why this change is needed. Would you elaborate why this change is the way to fix vitejs/vite#22124 (#9032 (comment))?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It was for me to understand why this change is needed. Would you elaborate why this change is the way to fix vitejs/vite#22124 (#9032 (comment))?

This is because the normalization only targets subpath imports, and it doesn’t fix alias imports. I suspect it might be an issue with the alias plugin, although I’ve aligned the behavior with Vite’s JS import glob implementation.

Copy link
Copy Markdown
Member Author

@shulaoda shulaoda Apr 8, 2026

Choose a reason for hiding this comment

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

There is a normalizePath here that fixes the issue where alias returns a non-standard path.
https://github.com/vitejs/vite/blob/cc383e07b66d4c5a9768fcb570e0af812cb8d999/packages/vite/src/node/plugins/importMetaGlob.ts#L662

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.

Ah, I see. I overlooked that normalizePath outside.

@sapphi-red
Copy link
Copy Markdown
Member

I'm not sure why this would fix vitejs/vite#22124. Isn't it already normalized at

?
This .normalize call is aligned with https://github.com/vitejs/vite/blob/cc383e07b66d4c5a9768fcb570e0af812cb8d999/packages/vite/src/node/plugins/resolve.ts#L212-L219

@github-actions github-actions bot mentioned this pull request Apr 8, 2026
shulaoda added a commit that referenced this pull request Apr 8, 2026
## [1.0.0-rc.14] - 2026-04-08

### 🚀 Features

- rust: add `disable_panic_hook` feature to disable the panic hook (#9023) by @sapphi-red
- support inlineConst for CJS exports accessed through module.exports (#8976) by @h-a-n-a

### 🐛 Bug Fixes

- rolldown_plugin_vite_import_glob: normalize resolved alias path to prevent double slashes (#9032) by @shulaoda
- rolldown_plugin_vite_import_glob: follow symlinks in file scanning (#9000) by @Copilot
- wrap CJS entry modules for IIFE/UMD when using exports/module (#8999) by @IWANABETHATGUY
- emit separate __toESM bindings for mixed ESM/CJS external imports (#8987) by @IWANABETHATGUY
- tree-shake dead dynamic imports to side-effect-free CJS modules (#8529) by @sapphi-red
- skip inlining stale CJS export constants on module.exports reassignment (#8990) by @IWANABETHATGUY

### 🚜 Refactor

- generator: migrate ecma formatting from npx oxfmt to vp fmt (#9022) by @shulaoda
- generator: replace npx oxfmt with vp fmt for ecma formatting (#9021) by @shulaoda

### 📚 Documentation

- contrib-guide: mention that running tests on older Node.js version will have different stat results (#8996) by @claude

### ⚙️ Miscellaneous Tasks

- deps: update npm packages (#9002) by @renovate[bot]
- deps: update dependency @napi-rs/cli to v3.6.1 (#9034) by @renovate[bot]
- deps: upgrade oxc to 0.124.0 (#9018) by @shulaoda
- deps: update test262 submodule for tests (#9010) by @sapphi-red
- deps: update dependency oxfmt to ^0.44.0 (#9012) by @renovate[bot]
- deps: update dependency vite to v8.0.5 [security] (#9009) by @renovate[bot]
- deps: update dependency vite-plus to v0.1.16 (#9008) by @renovate[bot]
- deps: update rust crates (#9003) by @renovate[bot]
- deps: update github-actions (#9004) by @renovate[bot]
- deps: update dependency lodash-es to v4.18.1 [security] (#8992) by @renovate[bot]
- deps: update crate-ci/typos action to v1.45.0 (#8988) by @renovate[bot]
- upgrade oxc npm packages to 0.123.0 (#8985) by @shulaoda

### ◀️ Revert

- "chore(deps): update dependency oxfmt to ^0.44.0 (#9012)" (#9019) by @shulaoda

Co-authored-by: shulaoda <165626830+shulaoda@users.noreply.github.com>
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.

4 participants