Skip to content

Commit 0a64fab

Browse files
committed
fix: prevent named imports from merging into namespace imports in SWC plugin
When injecting `registerComponent` into a module that already has `import * as lwc from 'lwc'`, the import helper was incorrectly appending the named specifier to the namespace import, producing invalid syntax (`import * as lwc{ registerComponent } from 'lwc'`). Guard against this by skipping namespace imports when looking for an existing declaration to extend, and creating a separate import declaration instead. Made-with: Cursor
1 parent 04a8b6d commit 0a64fab

File tree

214 files changed

+6401
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+6401
-150
lines changed

.claude/settings.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"$schema": "https://json.schemastore.org/claude-code-settings.json",
3+
"permissions": {
4+
"defaultMode": "bypassPermissions",
5+
"allow": [
6+
"Edit",
7+
"Write",
8+
"Read",
9+
"Bash",
10+
"WebFetch",
11+
"WebSearch",
12+
"Glob",
13+
"Grep",
14+
"NotebookEdit",
15+
"Skill",
16+
"Agent",
17+
"ExitPlanMode",
18+
"TaskCreate",
19+
"TaskGet",
20+
"TaskList",
21+
"TaskUpdate",
22+
"TaskStop",
23+
"AskUserQuestion",
24+
"TaskOutput",
25+
"KillShell",
26+
"MCPSearch",
27+
"LSP"
28+
]
29+
}
30+
}

packages/@lwc/babel-plugin-component/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
],
66
"name": "@lwc/babel-plugin-component",
77
"version": "9.0.3",
8-
"description": "Babel plugin to transform a LWC module",
8+
"description": "[DEPRECATED] Babel plugin to transform a LWC module — replaced by @lwc/swc-plugin-component",
99
"keywords": [
1010
"lwc"
1111
],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import tmpl from './test.html';
2+
import { LightningElement, registerDecorators, registerComponent } from 'lwc';
3+
const __lwc_component_class_internal = registerComponent(
4+
registerDecorators(
5+
class Test extends LightningElement {
6+
set first(value) {}
7+
get first() {}
8+
get second() {
9+
return this.s;
10+
}
11+
set second(value) {
12+
this.s = value;
13+
}
14+
/*LWC compiler vX.X.X*/
15+
},
16+
{
17+
publicProps: {
18+
first: {
19+
config: 3,
20+
},
21+
second: {
22+
config: 3,
23+
},
24+
},
25+
}
26+
),
27+
{
28+
tmpl: tmpl,
29+
sel: 'lwc-test',
30+
apiVersion: 9999999,
31+
}
32+
);
33+
export default __lwc_component_class_internal;
34+
const Test = __lwc_component_class_internal;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1096: Duplicate @api property \"foo\".",
3+
"filename": "test.js"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1096: Duplicate @api property \"foo\".",
3+
"filename": "test.js"
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1112: @api get something and @api set something detected in class declaration. Only one of the two needs to be decorated with @api.",
3+
"filename": "test.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1110: Invalid property name \"class\". \"class\" is a reserved attribute.",
3+
"filename": "test.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1110: Invalid property name \"is\". \"is\" is a reserved attribute.",
3+
"filename": "test.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1110: Invalid property name \"slot\". \"slot\" is a reserved attribute.",
3+
"filename": "test.js"
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"message": "Error: LWC1110: Invalid property name \"style\". \"style\" is a reserved attribute.",
3+
"filename": "test.js"
4+
}

0 commit comments

Comments
 (0)