From ba87df0463fe8ea954e25c913530216b13132295 Mon Sep 17 00:00:00 2001 From: "Vincent W." <54405631+Mr-VincentW@users.noreply.github.com> Date: Thu, 9 Jan 2025 13:53:47 +1300 Subject: [PATCH 1/2] Fix a component namespace and name parsing issue The original approach cannot correctly parse `namespace` and `name` from file path in Windows as the path may contain `\` as delimeters. It doesn't work well for relative paths start with './' either which derives from implicit reference to CSS files. --- packages/@lwc/rollup-plugin/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@lwc/rollup-plugin/src/index.ts b/packages/@lwc/rollup-plugin/src/index.ts index 6004939ad1..e638f7ef5a 100644 --- a/packages/@lwc/rollup-plugin/src/index.ts +++ b/packages/@lwc/rollup-plugin/src/index.ts @@ -332,7 +332,7 @@ export default function lwc(pluginOptions: RollupLwcOptions = {}): Plugin { 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); + specifier?.split('/') ?? /(?:([^\\/]+?)[\\/])?([^\\/]+?)(?:[\\/]\2)?(?:\.scoped)?\.[^.]+$/.exec(filename)?.slice(1); /* v8 ignore next */ if (!namespace || !name) { From d62ce4c9d71ca2cfd35bd6916cf27043e89566f9 Mon Sep 17 00:00:00 2001 From: "Vincent W." <54405631+Mr-VincentW@users.noreply.github.com> Date: Fri, 10 Jan 2025 11:14:30 +1300 Subject: [PATCH 2/2] Simplified the fix Simplified the fix as only having replaced the path delimiter for parsing `namespace` and `name` from filenames. --- packages/@lwc/rollup-plugin/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@lwc/rollup-plugin/src/index.ts b/packages/@lwc/rollup-plugin/src/index.ts index e638f7ef5a..6712395a4b 100644 --- a/packages/@lwc/rollup-plugin/src/index.ts +++ b/packages/@lwc/rollup-plugin/src/index.ts @@ -332,7 +332,7 @@ export default function lwc(pluginOptions: RollupLwcOptions = {}): Plugin { 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('/') ?? /(?:([^\\/]+?)[\\/])?([^\\/]+?)(?:[\\/]\2)?(?:\.scoped)?\.[^.]+$/.exec(filename)?.slice(1); + specifier?.split('/') ?? path.dirname(filename).split(/[\\/]/).slice(-2); /* v8 ignore next */ if (!namespace || !name) {