Skip to content

Should rollup normalize directory separators in resolveId paths? #2952

@Swatinem

Description

@Swatinem

In Swatinem/rollup-plugin-dts#39, a windows user encountered the problem that a circular import back to the entry module was leading to duplicate definitions.
Essentially, rollup treated …/lawful/src/lawbook.ts and …\lawful\src\lawbook.ts as different modules.

I am not quite sure if it is my responsibility as plugin author to make sure the paths returned from resolveId are platform native (with \ separators on windows), or if rollup should just normalize the paths itself.

Expected Behavior / Situation

Rollup could normalize paths itself to platform-native separators. No matter if a plugin returns paths with / or \, it should not matter to rollup.

Actual Behavior / Situation

Rollup will just use the path returned from resolveId un-normalized, which can potentially lead to duplicate modules (one with / in its path, the other with \ on windows)

Modification Proposal

For my plugin, a simple path.resolve(pathWithForwardSlashes) solved my problems on windows by normalizing the path to use \ instead.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions