Skip to content

Commit

Permalink
feat: expose the registered component class as a const declaration to…
Browse files Browse the repository at this point in the history
… allow hmr hooks for class @W-15890472 (#4271)

* feat: export registered component class via an identifier

this allow swapComponent() hooks to be placed

* test: update snapshot in packages/@lwc/babel-plugin-component/src/__tests__/

* fix: ignore two non-component swap calls

* fix: remove lwc-platform as a downstream dependency

* fix: apply class id transformation across the board, no need for APIVersioning

* fix: address feedback

* fix: check exception message
  • Loading branch information
ravijayaramappa authored Jun 11, 2024
1 parent 6bed698 commit 752cc83
Show file tree
Hide file tree
Showing 72 changed files with 261 additions and 135 deletions.
1 change: 0 additions & 1 deletion .nucleus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ branches:
- communities/ui-commerce-components
- communities/webruntime
- lds/lds-plugins
- lwc/lwc-platform
- salesforce-experience-platform-emu/komaci
- salesforce-experience-platform-emu/locker-pentest-app
- salesforce-experience-platform-emu/lwr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ _registerDecorators(Test, {
}
}
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ _registerDecorators(Test, {
}
}
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ _registerDecorators(Test, {
}
}
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ _registerDecorators(Test, {
}
}
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ _registerDecorators(Text, {
publicMethods: ["m1"],
fields: ["privateProp"]
});
export default _registerComponent(Text, {
const __lwc_component_class_internal = _registerComponent(Text, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ _registerDecorators(Outer, {
},
fields: ["a"]
});
export default _registerComponent(Outer, {
const __lwc_component_class_internal = _registerComponent(Outer, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ _registerDecorators(Test, {
},
fields: ["_a", "_b"]
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ _registerDecorators(Test, {
}
}
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ class Test extends LightningElement {
_registerDecorators(Test, {
publicMethods: ["foo"]
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ _registerDecorators(Test, {
}
}
});
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ _registerDecorators(Text, {
},
fields: ["foo"]
});
export default _registerComponent(Text, {
const __lwc_component_class_internal = _registerComponent(Text, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ _registerDecorators(Text, {
}
}
});
export default _registerComponent(Text, {
const __lwc_component_class_internal = _registerComponent(Text, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { LightningElement as Component, registerComponent as _registerComponent
class Test extends Component {
/*LWC compiler vX.X.X*/
}
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import _tmpl from "./test.html";
import { LightningElement, registerComponent as _registerComponent } from "lwc";
export default _registerComponent(class extends LightningElement {
const __lwc_component_class_internal = _registerComponent(class extends LightningElement {
/*LWC compiler vX.X.X*/
}, {
tmpl: _tmpl,
sel: "x-camel-case",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import { Element } from "engine";
class Test extends Element {
/*LWC compiler vX.X.X*/
}
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import lwc, { LightningElement, registerComponent as _registerComponent } from '

// eslint-disable-next-line no-console
console.log(lwc);
export default _registerComponent(class extends LightningElement {
const __lwc_component_class_internal = _registerComponent(class extends LightningElement {
/*LWC compiler vX.X.X*/
}, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import _tmpl from "./test.html";
import { registerComponent as _registerComponent } from "lwc";
import * as lwc from 'lwc';
export default _registerComponent(class extends lwc.LightningElement {
const __lwc_component_class_internal = _registerComponent(class extends lwc.LightningElement {
/*LWC compiler vX.X.X*/
}, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { LightningElement, registerComponent as _registerComponent } from "lwc";
class Test extends LightningElement {
/*LWC compiler vX.X.X*/
}
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ class Test extends LightningElement {
render() {}
/*LWC compiler vX.X.X*/
}
export default _registerComponent(Test, {
const __lwc_component_class_internal = _registerComponent(Test, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ class Test1 extends LightningElement {
class Test2 extends LightningElement {
/*LWC compiler vX.X.X*/
}
export default _registerComponent(Test2, {
const __lwc_component_class_internal = _registerComponent(Test2, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { registerDecorators as _registerDecorators, LightningElement, registerComponent as _registerComponent } from "lwc";
import _tmpl from "./test.html";
export default _registerComponent(_registerDecorators(class extends LightningElement {
const __lwc_component_class_internal = _registerComponent(_registerDecorators(class extends LightningElement {
foo;
/*LWC compiler vX.X.X*/
}, {
Expand All @@ -13,4 +13,5 @@ export default _registerComponent(_registerDecorators(class extends LightningEle
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ const foo = _registerDecorators(class extends LightningElement {
}
}
});
export default _registerComponent(foo, {
const __lwc_component_class_internal = _registerComponent(foo, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { registerComponent as _registerComponent } from "lwc";
const foo = class {
foo;
};
export default _registerComponent(foo, {
const __lwc_component_class_internal = _registerComponent(foo, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { registerComponent as _registerComponent } from "lwc";
class MyClazz {
foo;
}
export default _registerComponent(MyClazz, {
const __lwc_component_class_internal = _registerComponent(MyClazz, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const foo = _registerDecorators(class extends MyCoolMixin {
}
}
});
export default _registerComponent(foo, {
const __lwc_component_class_internal = _registerComponent(foo, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ _registerDecorators(MyElement, {
}
}
});
export default _registerComponent(MyElement, {
const __lwc_component_class_internal = _registerComponent(MyElement, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 9999999
});
});
export default __lwc_component_class_internal;
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const foo = _registerDecorators(class extends MyCoolMixin {
}
}
});
export default _registerComponent(foo, {
const __lwc_component_class_internal = _registerComponent(foo, {
tmpl: _tmpl,
sel: "lwc-test",
apiVersion: 59
});
});
export default __lwc_component_class_internal;
Loading

0 comments on commit 752cc83

Please sign in to comment.