Skip to content

Comments

fix: use directory name as-is for the variable name even if the name contained .#8029

Merged
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-variable-name-issues
Jan 23, 2026
Merged

fix: use directory name as-is for the variable name even if the name contained .#8029
graphite-app[bot] merged 1 commit intomainfrom
copilot/fix-variable-name-issues

Conversation

Copy link
Contributor

Copilot AI commented Jan 23, 2026

Module IDs with dots (e.g., foo.bar) generated incorrect wrapper variable names due to Path::file_stem() treating dots as extension separators.

Before:

var require_foo = __commonJSMin(((exports) => { /* ... */ }));
var import_foo = __toESM(require_foo());

After:

var require_foo_bar = __commonJSMin(((exports) => { /* ... */ }));
var import_foo_bar = __toESM(require_foo_bar());

Changes

  • representative_file_name(): Changed from file_stem() to file_name() when extracting parent directory names for index.js files, preserving dots in directory names
  • Added unit test for directory names with dots
  • Added integration test for CJS wrapper generation with dotted module IDs
Original prompt

This section details on the original issue you should resolve

<issue_title>[Bug]: use a better variable name for require_* / import_* with id's including .</issue_title>
<issue_description>### Reproduction link or steps

https://repl.rolldown.rs/#eNqFUVtqwzAQvMqiHydg7H+BD9Az1KWo0cqoyNqgRxowunslP7AJCdGPZl+a0c7EFOMT01bivfn1BVvG97hmlxKOV3IBFBEoRyNUGTU/wlW96+2FrCeDjaHhlPPnkstzyHhwEVPNHBkj6c82uVPp4UDzpLIQ4n0mlKhENAGm8ibA1cRBW8/hc4lhK5RjxYgcKodZzA1dVe+lNfchT1qejzMAWkFOQtd1+6ceWsp8iM5C1VqS+D2SjAZ9u7a3267mZWwjaQ/SQYkh8UbEG46X2paN+aZ41EHP8t2zl5I2uIKvcs14MU4J4zFl627ZCyMC+sDSP8M3rVM=

What is expected?

The output to be like

//#region node_modules/foo.bar/index.js
var require_foo_bar = /* @__PURE__ */ __commonJSMin(((exports) => {
	exports.foo = "foo";
}));

//#endregion
//#region index.js
var import_foo_bar = /* @__PURE__ */ __toESM(require_foo_bar());

What is actually happening?

The output is

//#region node_modules/foo.bar/index.js
var require_foo = /* @__PURE__ */ __commonJSMin(((exports) => {
	exports.foo = "foo";
}));

//#endregion
//#region index.js
var import_foo = /* @__PURE__ */ __toESM(require_foo());

System Info

REPL 1.0.0-rc.1

Any additional comments?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@netlify
Copy link

netlify bot commented Jan 23, 2026

Deploy Preview for rolldown-rs ready!

Name Link
🔨 Latest commit 90a8ca8
🔍 Latest deploy log https://app.netlify.com/projects/rolldown-rs/deploys/69734fd9129efa000829b94f
😎 Deploy Preview https://deploy-preview-8029--rolldown-rs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

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

Copilot AI changed the title [WIP] Fix variable names for require and import with IDs Fix variable naming for module IDs containing dots Jan 23, 2026
Copilot AI requested a review from sapphi-red January 23, 2026 08:13
@sapphi-red sapphi-red changed the title Fix variable naming for module IDs containing dots fix: use directory name as-is for the variable name even if the name contained . Jan 23, 2026
@sapphi-red sapphi-red marked this pull request as ready for review January 23, 2026 09:50
Copilot AI review requested due to automatic review settings January 23, 2026 09:50
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes incorrect generated wrapper variable names (require_* / import_*) for index.* modules whose parent directory contains dots (e.g. foo.bar/index.js), by preserving the directory name instead of treating the part after . as an “extension”.

Changes:

  • Update representative_file_name() to use Path::file_name() (not file_stem()) when deriving names from parent directories for index/mod modules.
  • Add a unit test covering dotted directory names.
  • Add an integration test fixture + snapshot to verify CJS wrapper generation with dotted module IDs; update the global filename-hash snapshot accordingly.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/rolldown_std_utils/src/path_ext.rs Preserve dots in parent directory names for index/mod representative names; add unit test.
crates/rolldown/tests/snapshots/integration_rolldown__filename_with_hash.snap Snapshot update to include the new integration test output filename mapping.
crates/rolldown/tests/rolldown/topics/deconflict/module_id_with_dots/main.js New integration test entry importing a module from a dotted directory.
crates/rolldown/tests/rolldown/topics/deconflict/module_id_with_dots/foo.bar/index.js New CJS fixture module located in a dotted directory.
crates/rolldown/tests/rolldown/topics/deconflict/module_id_with_dots/artifacts.snap Snapshot asserting require_foo_bar / import_foo_bar generation.
crates/rolldown/tests/rolldown/topics/deconflict/module_id_with_dots/_config.json Test config file (empty/default config).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link
Contributor

Benchmarks Rust

group                                                        pr                                     target
-----                                                        --                                     ------
bundle/bundle@multi-duplicated-top-level-symbol              1.00     67.4±1.73ms        ? ?/sec    1.02     69.1±2.90ms        ? ?/sec
bundle/bundle@multi-duplicated-top-level-symbol-sourcemap    1.00     73.5±1.45ms        ? ?/sec    1.02     74.7±2.09ms        ? ?/sec
bundle/bundle@rome_ts                                        1.00     99.0±2.98ms        ? ?/sec    1.01    100.5±1.86ms        ? ?/sec
bundle/bundle@rome_ts-sourcemap                              1.00    111.5±1.77ms        ? ?/sec    1.01    112.6±2.02ms        ? ?/sec
bundle/bundle@threejs                                        1.00     34.8±1.03ms        ? ?/sec    1.03     36.0±1.93ms        ? ?/sec
bundle/bundle@threejs-sourcemap                              1.00     40.2±1.18ms        ? ?/sec    1.01     40.6±0.92ms        ? ?/sec
bundle/bundle@threejs10x                                     1.00    364.7±3.39ms        ? ?/sec    1.00    363.9±3.19ms        ? ?/sec
bundle/bundle@threejs10x-sourcemap                           1.00    419.2±4.33ms        ? ?/sec    1.00    421.1±4.25ms        ? ?/sec
scan/scan@rome_ts                                            1.00     79.6±2.59ms        ? ?/sec    1.00     79.6±2.22ms        ? ?/sec
scan/scan@threejs                                            1.00     27.9±1.66ms        ? ?/sec    1.00     27.9±1.69ms        ? ?/sec
scan/scan@threejs10x                                         1.00    283.5±4.40ms        ? ?/sec    1.00    284.5±4.68ms        ? ?/sec

Copy link
Member

hyf0 commented Jan 23, 2026

Merge activity

  • Jan 23, 10:38 AM UTC: The merge label 'graphite: merge-when-ready' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jan 23, 10:38 AM UTC: hyf0 added this pull request to the Graphite merge queue.
  • Jan 23, 10:49 AM UTC: Merged by the Graphite merge queue.

…contained `.` (#8029)

Module IDs with dots (e.g., `foo.bar`) generated incorrect wrapper variable names due to `Path::file_stem()` treating dots as extension separators.

**Before:**
```js
var require_foo = __commonJSMin(((exports) => { /* ... */ }));
var import_foo = __toESM(require_foo());
```

**After:**
```js
var require_foo_bar = __commonJSMin(((exports) => { /* ... */ }));
var import_foo_bar = __toESM(require_foo_bar());
```

## Changes

- `representative_file_name()`: Changed from `file_stem()` to `file_name()` when extracting parent directory names for `index.js` files, preserving dots in directory names
- Added unit test for directory names with dots
- Added integration test for CJS wrapper generation with dotted module IDs

<!-- START COPILOT ORIGINAL PROMPT -->

<details>

<summary>Original prompt</summary>

>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>[Bug]: use a better variable name for `require_*` / `import_*` with id's including `.`</issue_title>
> <issue_description>### Reproduction link or steps
>
> https://repl.rolldown.rs/#eNqFUVtqwzAQvMqiHydg7H+BD9Az1KWo0cqoyNqgRxowunslP7AJCdGPZl+a0c7EFOMT01bivfn1BVvG97hmlxKOV3IBFBEoRyNUGTU/wlW96+2FrCeDjaHhlPPnkstzyHhwEVPNHBkj6c82uVPp4UDzpLIQ4n0mlKhENAGm8ibA1cRBW8/hc4lhK5RjxYgcKodZzA1dVe+lNfchT1qejzMAWkFOQtd1+6ceWsp8iM5C1VqS+D2SjAZ9u7a3267mZWwjaQ/SQYkh8UbEG46X2paN+aZ41EHP8t2zl5I2uIKvcs14MU4J4zFl627ZCyMC+sDSP8M3rVM=
>
> ### What is expected?
>
> The output to be like
> ```js
> //#region node_modules/foo.bar/index.js
> var require_foo_bar = /* @__PURE__ */ __commonJSMin(((exports) => {
> 	exports.foo = "foo";
> }));
>
> //#endregion
> //#region index.js
> var import_foo_bar = /* @__PURE__ */ __toESM(require_foo_bar());
> ```
>
> ### What is actually happening?
>
> The output is
> ```js
> //#region node_modules/foo.bar/index.js
> var require_foo = /* @__PURE__ */ __commonJSMin(((exports) => {
> 	exports.foo = "foo";
> }));
>
> //#endregion
> //#region index.js
> var import_foo = /* @__PURE__ */ __toESM(require_foo());
> ```
>
> ### System Info
>
> ```Shell
> REPL 1.0.0-rc.1
> ```
>
> ### Any additional comments?
>
> _No response_</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>

</details>

<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes #8028

<!-- START COPILOT CODING AGENT TIPS -->
---

💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey).
@graphite-app graphite-app bot force-pushed the copilot/fix-variable-name-issues branch from f3e567e to 90a8ca8 Compare January 23, 2026 10:39
@graphite-app graphite-app bot merged commit 90a8ca8 into main Jan 23, 2026
34 checks passed
@graphite-app graphite-app bot deleted the copilot/fix-variable-name-issues branch January 23, 2026 10:49
This was referenced Jan 28, 2026
shulaoda added a commit that referenced this pull request Jan 28, 2026
## [1.0.0-rc.2] - 2026-01-28

⚡ Lazy Barrel Optimization

- Skips compilation of unused re-export modules in side-effect-free barrel modules
- Particularly beneficial for projects importing from large component libraries

For large component libraries like Ant Design, when you import just one component:

```js
import { Button } from 'antd';
Button;
```

| Metric                    | Without lazy barrel | With lazy barrel |
| -------------------- | --------------------- | ---------------- |
| Modules compiled | 2986                       | 250              |
| Build time               | ~210ms                  | ~50ms            |

By enabling lazy barrel, Rolldown reduces the number of compiled modules by 90% and speeds up the build by 2-4x. 

Enable it in your config:

```js
export default {
  experimental: {
    lazyBarrel: true,
  },
};
```

For more details, see the https://rolldown.rs/in-depth/lazy-barrel-optimization

### 💥 BREAKING CHANGES

- expose `\0rolldown/runtime` in transform hook (#8068) by @hyf0
- rename `rolldown:runtime` to `\0rolldown/runtime.js` (#8067) by @hyf0

### 🚀 Features

- remove inlined constants in smart mode (#8085) by @sapphi-red
- allow more options for `this.emitFile` with `type: 'prebuilt-chunk'` (#8062) by @sapphi-red
- warn when both code and postBanner contain shebang (#8039) by @Copilot

### 🐛 Bug Fixes

- update the links to Rolldown docs in the error messages (#8103) by @sapphi-red
- handle tsconfig.json load errors (#8105) by @sapphi-red
- include inlined constants in namespace object (#8099) by @sapphi-red
- vite test ci (#8084) by @IWANABETHATGUY
- renamer: nested binding shadowing external module namespace in UMD/IIFE formats (#8083) by @Dunqing
- deduplicate ESM chunk imports by canonical symbol (#8059) by @IWANABETHATGUY
- refine side-effect detection for BigInt and RegExp (#8060) by @IWANABETHATGUY
- rust: use string literal span for `new URL` error diagnostic (#8043) by @valadaptive
- rust: use ModuleType::Asset for `new URL` imports (#8035) by @valadaptive
- CJS-ESM interop - property assignment on CJS module exports (#8006) by @IWANABETHATGUY
- eliminate the facade chunk if the dynamic entry module has been merged into common chunk (#8046) by @IWANABETHATGUY
- Inlining dynamic imports broken with multiple entry points (#8037) by @IWANABETHATGUY
- devtools: revert `Chunk#id` to `Chunk#chunk_id` (#8040) by @hyf0
- invert `__exportAll` parameter logic to reduce default output size (#8036) by @Copilot
- `</script` tag search should be case insensitive (#8033) by @IWANABETHATGUY
- use directory name as-is for the variable name even if the name contained `.` (#8029) by @Copilot
- dev/lazy: remove unnecessary rewrite from top level `this` to `undefined` (#8020) by @hyf0
- dev/lazy: should keep lazy entries imports for patch file (#8019) by @hyf0
- `output.generatedCode.preset: 'es2015'` was not set by default (#8026) by @sapphi-red
- node: align option validator to types (#8023) by @sapphi-red
- node: allow `output.strictExecutionOrder` by the option validator (#8022) by @sapphi-red
- types: return `this` from on / off methods of `RolldownWatcher` (#8015) by @sapphi-red

### 🚜 Refactor

- rolldown_plugin_vite_dynamic_import_vars: remove v1 implementation (#8096) by @shulaoda
- rolldown_plugin_vite_import_glob: remove v1 implementation (#8095) by @shulaoda
- lazy-barrel: restructure lazy barrel implementation (#8070) by @shulaoda
- remove `use_built_ins` and `use_spread` from internal JSX options (#8079) by @sapphi-red
- remove `experimental.transformHiresSourcemap` (#8055) by @Copilot
- rust: use `is_data_url` more consistently (#8042) by @valadaptive
- use `FxIndexMap` to store EntryPoint (#8032) by @IWANABETHATGUY
- node: add type checks that ensures validator schema is up to date with types (#8024) by @sapphi-red

### 📚 Documentation

- link to vite plugin registry (#8086) by @sapphi-red
- lazy-barrel: improve documentation and enable in sidebar (#8072) by @shulaoda
- add more examples and details (#8054) by @sapphi-red
- in-depth: add dead code elimination page (#8007) by @sapphi-red
- update status from beta to release candidate (#8012) by @shulaoda

### ⚡ Performance

- run inline-const pass for modules that are affected by inlining (#8064) by @sapphi-red

### 🧪 Testing

- lazy-barrel: use package.json sideEffects instead of plugin hook (#8077) by @shulaoda
- lazy-barrel: enable tests and add treeshake-behavior cases (#8071) by @shulaoda

### ⚙️ Miscellaneous Tasks

- deps: update crate-ci/typos action to v1.42.3 (#8087) by @renovate[bot]
- deps: update rollup submodule for tests to v4.56.0 (#8073) by @sapphi-red
- deps: update oxc to v0.111.0 (#8063) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.21.6 (#8076) by @renovate[bot]
- deps: update test262 submodule for tests (#8074) by @sapphi-red
- deps: update crate-ci/typos action to v1.42.2 (#8069) by @renovate[bot]
- deps: update oxc apps (#8066) by @renovate[bot]
- remove `{@include ./foo.md}` from d.ts files (#8056) by @sapphi-red
- deps: update dependency oxlint-tsgolint to v0.11.2 (#8057) by @renovate[bot]
- deps: update github-actions (#8050) by @renovate[bot]
- deps: update npm packages (#8051) by @renovate[bot]
- deps: update rust crates (#8049) by @renovate[bot]
- debug: add IdxExt debug trait for human-readable index debugging (#8045) by @IWANABETHATGUY
- deps: update dependency rolldown-plugin-dts to v0.21.5 (#8034) by @renovate[bot]
- deps: update oxc resolver to v11.16.4 (#8031) by @renovate[bot]
- deps: update dependency rolldown-plugin-dts to v0.21.4 (#8030) by @renovate[bot]
- deps: update dependency rust to v1.93.0 (#8018) by @renovate[bot]
- archive 2025 beta changelog (#8014) by @shulaoda
- update release workflow version pattern from beta to rc (#8013) by @shulaoda

### ❤️ New Contributors

* @valadaptive made their first contribution in [#8043](#8043)

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]: use a better variable name for require_* / import_* with id's including .

3 participants