rolldown: Windows duplicate importz

When building a project with rolldown using an absolute path import on Windows, the resulting bundle (output.js) contains duplicated modules. Specifically, modules like react.production.js appear twice under different paths, causing inflated bundles and potential runtime issues. This issue does not occur on Linux.

  1. Clone the reproduction repo on a Windows machine: https://github.com/avivkeller/rolldown-repro-5364

  2. Modify the import in entrypoint.jsx to use an absolute path to imported.jsx, e.g.:

    import Imported from "/absolute/path/to/imported";
    
  3. Run:

    npm install
    node repro.mjs
    

The generated output.js file contains duplicated entries for dependencies such as react, with region comments showing both of the following:

//#region \absolute\path\to\node_modules\react\cjs\react.production.js
//#region node_modules/react/cjs/react.production.js

The bundle should deduplicate modules regardless of how they’re imported. Only one instance of react.production.js (and similar) should appear in the output.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 22 (11 by maintainers)

Most upvoted comments

@ovflowd We’ve resolved the issue on the doc-kit end by including the drive letter, however, I wasn’t sure whether this was an issue in Rolldown as well.

esbuild appears to support this format (though it may have issues), but Rollup does not. For now, we align our behavior with Rollup.

We could probably use that knowledge to fix this on our end, but shouldn’t the resolution behavior be the same with D:\\my\\path and \\my\\path?

I’m starting to understand it better now — with this information, I can reproduce the issue too. However, I don’t think treating a path like D:\\my\\path as /my/path on Windows is the correct behavior, but it works. Let me discuss this usage with the rolldown team.

Sorry again for initially being confusing, I know how annoying it is to receive vague bug reports with massive code bases.

Hi! Make you are you are checking out the latest main branch. We had that bug, but we fixed it, which led us to this one. I’m trying my best to make a minimal reproduction, but it’s still fairly complex.

Okay, I understand. I will recheck it.

@shulaoda Could you check this out?