Skip to content

[Bug]: sanitizeFileName is ignored for JS chunks when preserveModules: true with object-form entry #8761

Description

@ef81sp

Reproduction link or steps

https://github.com/ef81sp/rolldown-sanitize-filename-repro

pnpm install
pnpm build

What is expected?

JS chunk filenames should be sanitized (? and & replaced with _):

dist/components/TestComp.vue_vue_type_script_setup_true_lang.js

What is actually happening?

dist/components/TestComp.vue?vue&type=script&setup=true&lang.js

Custom sanitizeFileName in output options is also ignored for these chunks. CSS filenames are correctly sanitized in the same build.

This occurs when entry is object-form ({ index: './src/index.ts' }). With string-form entry ('./src/index.ts'), preserveModules does not preserve the directory structure at all, so the issue does not surface.

System Info

System:
    OS: macOS 26.3.1
    CPU: (8) arm64 Apple M1
    Memory: 102.55 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 25.5.0 - /opt/homebrew/bin/node
    pnpm: 10.28.0
  npmPackages:
    vite: 8.0.0 (rolldown 1.0.0-rc.9)

Any additional comments?

#7554 fixed sanitizeFileName for preserveModules, but only when entry is string-form. With object-form entry, sanitizeFileName is still not applied to JS chunk filenames.

Workaround: using entryFileNames as a function to manually sanitize works.

Metadata

Metadata

Assignees

No one assigned

    Type

    Fields

    Priority

    None yet

    Effort

    None yet

    Projects

    Status
    In progress

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions