Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Mr-VincentW opened this issue Jan 8, 2025 · 3 comments

Comments

@Mr-VincentW
Copy link

Mr-VincentW commented Jan 8, 2025

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(/[\\/]/)

@cardoso
Copy link
Contributor

cardoso commented Jan 8, 2025

@Mr-VincentW could you submit a PR with your solution so it can be tested in CI?

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

If I'm not mistaken at the point where path.dirname is used the filename is already resolved to an absolute path.

@Mr-VincentW
Copy link
Author

Mr-VincentW commented Jan 9, 2025

PR created.

If I'm not mistaken at the point where path.dirname is used the filename is already resolved to an absolute path.

Not for CSS files referenced by HTML templates. However, I don't think it really impacts the subsequent processes for them.

@cardoso
Copy link
Contributor

cardoso commented Jan 9, 2025

In theory this could be a bug in rollup itself, but looking at the changelogs for 4.29.1 (your version), 4.29.2, 4.30.0, 4.30.1 (latest), there's no clear indication that upgrading your version would fix it.

But just in case, are you able to upgrade to latest and confirm the issue still happens?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants