Skip to content

[Bug]: Invalid path handling with CSS, when preserveModules is true on Windows #4934

@stevebeauge

Description

@stevebeauge

Reproduction link or steps

https://github.com/stevebeauge/tsdown-css-windows-repro

pnpm build => KO (wrong CSS outpath)

What is expected?

When using output/preserveModule parameter, and CSS files, the emitted CSS files should be inside dist folder.

  • src/MyComponent.module.css should output dist\MyComponent.module-BlAtsAg0.css (or whatever hash)

What is actually happening?

Using Windows, the output path is src\MyComponent.module-BlAtsAg0.css (inside the src folder).

Full console output:

pnpm build                                                                                       ─╯

> @repro/sharedui@1.0.0 build D:\code\repro\tsdown-css-windows-repro
> rolldown -c

<DIR>/D:\code\repro\tsdown-css-windows-repro\src\MyComponent.module-Cbibx9P8.css               asset │ size:  0.09 kB
<DIR>/src/index.js                                                                             chunk │ size:  0.07 kB
<DIR>/src/MyComponent.module.js                                                                chunk │ size:  0.14 kB
<DIR>/node_modules/.pnpm/react@19.1.0/node_modules/react/index.js                              chunk │ size:  0.47 kB
<DIR>/src/MyComponent.js                                                                       chunk │ size:  0.53 kB
<DIR>/node_modules/.pnpm/react@19.1.0/node_modules/react/jsx-runtime.js                        chunk │ size:  0.54 kB
<DIR>/_virtual/rolldown_runtime.js                                                             chunk │ size:  1.16 kB
<DIR>/node_modules/.pnpm/react@19.1.0/node_modules/react/cjs/react-jsx-runtime.development.js  chunk │ size: 10.28 kB
<DIR>/node_modules/.pnpm/react@19.1.0/node_modules/react/cjs/react.development.js              chunk │ size: 36.11 kB

✔ Finished in 20.44 ms

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (22) x64 Intel(R) Core(TM) Ultra 7 155H
    Memory: 6.74 GB / 31.46 GB
  Binaries:
    Node: 22.14.0 - C:\Program Files\nodejs\node.EXE
    npm: 11.1.0 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.12.1 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (136.0.3240.50)
  npmPackages:
    rolldown: 1.0.0-beta.15 => 1.0.0-beta.15

Any additional comments?

Seems there's something missing in path normalization

Originally posted as tsdown issue rolldown/tsdown#319

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions