Skip to content

Commit 2ba8959

Browse files
committed
feat: thread enablePrivateMethods through rollup plugin and enable in playground
Add enablePrivateMethods to RollupLwcOptions and forward it to the compiler's transformSync call. Enable it in the playground rollup config and add a private method to the counter component for testing. Made-with: Cursor
1 parent 3461010 commit 2ba8959

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

packages/@lwc/rollup-plugin/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export interface RollupLwcOptions {
7474
* @example '@salesforce/featureFlag/name'
7575
*/
7676
componentFeatureFlagModulePath?: string;
77+
enablePrivateMethods?: boolean;
7778
}
7879

7980
const PLUGIN_NAME = 'rollup-plugin-lwc-compiler';
@@ -198,6 +199,7 @@ export default function lwc(pluginOptions: RollupLwcOptions = {}): Plugin {
198199
apiVersion,
199200
defaultModules = DEFAULT_MODULES,
200201
componentFeatureFlagModulePath,
202+
enablePrivateMethods,
201203
} = pluginOptions;
202204

203205
return {
@@ -395,6 +397,7 @@ export default function lwc(pluginOptions: RollupLwcOptions = {}): Plugin {
395397
targetSSR,
396398
ssrMode,
397399
componentFeatureFlagModulePath,
400+
enablePrivateMethods,
398401
});
399402

400403
if (warnings) {

playground/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default (args) => {
2121
'process.env.NODE_ENV': JSON.stringify(__ENV__),
2222
preventAssignment: true,
2323
}),
24-
lwc(),
24+
lwc({ enablePrivateMethods: true }),
2525
args.watch &&
2626
serve({
2727
open: false,

playground/src/modules/x/counter/counter.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ export default class extends LightningElement {
77

88
increment() {
99
this.counter++;
10+
this.#privateMethod();
1011
}
1112
decrement() {
1213
this.counter--;
1314
}
15+
16+
#privateMethod() {
17+
this.counter++;
18+
}
1419
}

0 commit comments

Comments
 (0)