Skip to content

The rollup plugin cannot resolve component namespace and name properly on Windows #5113

Open
@Mr-VincentW

Description

@Mr-VincentW

Description

Here's a snippet grabbed from /packages/@lwc/rollup-plugin/src/index.ts:332

const [namespace, name] =
// Note we do not need to use path.sep here because this filename contains
// a '/' regardless of Windows vs Unix, since it comes from the Rollup `id`
specifier?.split('/') ??  #path.dirname(filename).split('/').slice(-2);

As per the comments, specifiers should only contain / as path delimiters. However, in my case (on Windows), I found them cometimes containing \ as well. Using /[\\/]/ here solves the problem for me.

BTW, extracting namespace and name from path.dirname(filename) also not working for relative filename like ./filename.css.

Steps to Reproduce

Expected Results

No warning messages in the console regarding this reason.

Actual Results

Tons of these messages as each component may prompt one for js, html, and css each.

Version

"@lwc/rollup-plugin": "^8.12.2",
"lwc": "^8.12.2",
"rollup": "^4.29.1"

Possible Solution

Replace .split('/') with .split(/[\\/]/)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions