@lwc/sfdc-lwc-compiler 13.2.17 → 13.2.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,729 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const common_tags_1 = require("common-tags");
4
+ const apexLoggingRollupPlugin_1 = require("../compiler/plugins/apexLoggingRollupPlugin");
5
+ const main_1 = require("../main");
6
+ const MODULE_NAMESPACE = 'x';
7
+ const MODULE_NAME = 'foo';
8
+ function compileApexLogging(bundleConfig) {
9
+ return (0, main_1.compile)({
10
+ bundle: {
11
+ namespace: MODULE_NAMESPACE,
12
+ name: MODULE_NAME,
13
+ type: 'platform',
14
+ files: {},
15
+ options: {
16
+ enableLwcPluginImperativeApexLogging: true,
17
+ },
18
+ ...bundleConfig,
19
+ },
20
+ });
21
+ }
22
+ function transformWithLuvioPlugin(src, overrideTransformOptions = {}) {
23
+ return (0, apexLoggingRollupPlugin_1.transformSync)(src, 'foo.js', {
24
+ sourcemap: true,
25
+ name: MODULE_NAME,
26
+ namespace: MODULE_NAMESPACE,
27
+ ...overrideTransformOptions,
28
+ });
29
+ }
30
+ // Normalize version numbers to avoid snapshot failures on version updates
31
+ function normalizeVersion(code) {
32
+ return code.replace(/v\d+\.\d+\.\d+/g, 'vX.X.X');
33
+ }
34
+ describe('babel transform with luvio plugin', () => {
35
+ describe('apex logging transform', () => {
36
+ test('injects tagName for default Apex import with 0 args', () => {
37
+ const src = (0, common_tags_1.stripIndents) `
38
+ import { LightningElement } from 'lwc';
39
+ import methodA from '@salesforce/apex/MyClass.methodA';
40
+
41
+ export default class Test extends LightningElement {
42
+ connectedCallback() {
43
+ methodA();
44
+ }
45
+ }
46
+ `;
47
+ const result = transformWithLuvioPlugin(src);
48
+ expect(result.code).toMatchInlineSnapshot(`
49
+ "import { LightningElement } from 'lwc';
50
+ import methodA from '@salesforce/apex/MyClass.methodA';
51
+ export default class Test extends LightningElement {
52
+ connectedCallback() {
53
+ methodA(undefined, {
54
+ sourceContext: {
55
+ tagName: "x/foo"
56
+ }
57
+ });
58
+ }
59
+ }"
60
+ `);
61
+ });
62
+ test('injects tagName for default Apex import with 1 arg', () => {
63
+ const src = (0, common_tags_1.stripIndents) `
64
+ import { LightningElement } from 'lwc';
65
+ import methodA from '@salesforce/apex/MyClass.methodA';
66
+
67
+ export default class Test extends LightningElement {
68
+ connectedCallback() {
69
+ methodA({ abc: 123 });
70
+ }
71
+ }
72
+ `;
73
+ const result = transformWithLuvioPlugin(src);
74
+ expect(result.code).toMatchInlineSnapshot(`
75
+ "import { LightningElement } from 'lwc';
76
+ import methodA from '@salesforce/apex/MyClass.methodA';
77
+ export default class Test extends LightningElement {
78
+ connectedCallback() {
79
+ methodA({
80
+ abc: 123
81
+ }, {
82
+ sourceContext: {
83
+ tagName: "x/foo"
84
+ }
85
+ });
86
+ }
87
+ }"
88
+ `);
89
+ });
90
+ test('does not modify when 2 args are present', () => {
91
+ const src = (0, common_tags_1.stripIndents) `
92
+ import { LightningElement } from 'lwc';
93
+ import methodA from '@salesforce/apex/MyClass.methodA';
94
+
95
+ export default class Test extends LightningElement {
96
+ connectedCallback() {
97
+ methodA({ abc: 123 }, { extraData: 'foo'});
98
+ }
99
+ }
100
+ `;
101
+ const result = transformWithLuvioPlugin(src);
102
+ expect(result.code).toMatchInlineSnapshot(`
103
+ "import { LightningElement } from 'lwc';
104
+ import methodA from '@salesforce/apex/MyClass.methodA';
105
+ export default class Test extends LightningElement {
106
+ connectedCallback() {
107
+ methodA({
108
+ abc: 123
109
+ }, {
110
+ extraData: 'foo'
111
+ });
112
+ }
113
+ }"
114
+ `);
115
+ expect(result.code).not.toContain("'x/foo'");
116
+ });
117
+ test('does not modify when more than 2 args are present', () => {
118
+ const src = (0, common_tags_1.stripIndents) `
119
+ import { LightningElement } from 'lwc';
120
+ import methodA from '@salesforce/apex/MyClass.methodA';
121
+
122
+ export default class Test extends LightningElement {
123
+ connectedCallback() {
124
+ methodA({ abc: 123 }, { extraData: 'foo'}, { extraData: 'bar'});
125
+ }
126
+ }
127
+ `;
128
+ const result = transformWithLuvioPlugin(src);
129
+ expect(result.code).toMatchInlineSnapshot(`
130
+ "import { LightningElement } from 'lwc';
131
+ import methodA from '@salesforce/apex/MyClass.methodA';
132
+ export default class Test extends LightningElement {
133
+ connectedCallback() {
134
+ methodA({
135
+ abc: 123
136
+ }, {
137
+ extraData: 'foo'
138
+ }, {
139
+ extraData: 'bar'
140
+ });
141
+ }
142
+ }"
143
+ `);
144
+ expect(result.code).not.toContain("'x/foo'");
145
+ });
146
+ test('does not modify when using a spread operator', () => {
147
+ const src = (0, common_tags_1.stripIndents) `
148
+ import { LightningElement } from 'lwc';
149
+ import methodA from '@salesforce/apex/MyClass.methodA';
150
+ const args = { abc: 123 };
151
+ const args2 = { extraData: 'foo' };
152
+ export default class Test extends LightningElement {
153
+ connectedCallback() {
154
+ methodA(...args, ...args2);
155
+ }
156
+ }
157
+ `;
158
+ const result = transformWithLuvioPlugin(src);
159
+ expect(result.code).toMatchInlineSnapshot(`
160
+ "import { LightningElement } from 'lwc';
161
+ import methodA from '@salesforce/apex/MyClass.methodA';
162
+ const args = {
163
+ abc: 123
164
+ };
165
+ const args2 = {
166
+ extraData: 'foo'
167
+ };
168
+ export default class Test extends LightningElement {
169
+ connectedCallback() {
170
+ methodA(...args, ...args2);
171
+ }
172
+ }"
173
+ `);
174
+ expect(result.code).not.toContain("'x/foo'");
175
+ });
176
+ test('resolves module for unnamed default class export', () => {
177
+ const src = (0, common_tags_1.stripIndents) `
178
+ import { LightningElement } from 'lwc';
179
+ import methodA from '@salesforce/apex/MyClass.methodA';
180
+
181
+ export default class extends LightningElement {
182
+ connectedCallback() {
183
+ methodA();
184
+ }
185
+ }
186
+ `;
187
+ const result = transformWithLuvioPlugin(src);
188
+ expect(result.code).toMatchInlineSnapshot(`
189
+ "import { LightningElement } from 'lwc';
190
+ import methodA from '@salesforce/apex/MyClass.methodA';
191
+ export default class extends LightningElement {
192
+ connectedCallback() {
193
+ methodA(undefined, {
194
+ sourceContext: {
195
+ tagName: "x/foo"
196
+ }
197
+ });
198
+ }
199
+ }"
200
+ `);
201
+ });
202
+ test('resolves component class name from default export identifier bound to named class expression', () => {
203
+ const src = (0, common_tags_1.stripIndents) `
204
+ import { LightningElement } from 'lwc';
205
+ import methodA from '@salesforce/apex/MyClass.methodA';
206
+
207
+ const Comp = class NamedComp extends LightningElement {
208
+ connectedCallback() {
209
+ methodA();
210
+ }
211
+ };
212
+
213
+ export default Comp;
214
+ `;
215
+ const result = transformWithLuvioPlugin(src);
216
+ expect(result.code).toMatchInlineSnapshot(`
217
+ "import { LightningElement } from 'lwc';
218
+ import methodA from '@salesforce/apex/MyClass.methodA';
219
+ const Comp = class NamedComp extends LightningElement {
220
+ connectedCallback() {
221
+ methodA(undefined, {
222
+ sourceContext: {
223
+ tagName: "x/foo"
224
+ }
225
+ });
226
+ }
227
+ };
228
+ export default Comp;"
229
+ `);
230
+ });
231
+ test('injects tagName for apexContinuation import', () => {
232
+ const src = (0, common_tags_1.stripIndents) `
233
+ import { LightningElement } from 'lwc';
234
+ import cont from '@salesforce/apexContinuation/MyClass.methodB';
235
+
236
+ export default class Test extends LightningElement {
237
+ connectedCallback() {
238
+ cont();
239
+ }
240
+ }
241
+ `;
242
+ const result = transformWithLuvioPlugin(src);
243
+ expect(result.code).toMatchInlineSnapshot(`
244
+ "import { LightningElement } from 'lwc';
245
+ import cont from '@salesforce/apexContinuation/MyClass.methodB';
246
+ export default class Test extends LightningElement {
247
+ connectedCallback() {
248
+ cont(undefined, {
249
+ sourceContext: {
250
+ tagName: "x/foo"
251
+ }
252
+ });
253
+ }
254
+ }"
255
+ `);
256
+ });
257
+ test('injects tagName for non default exported functions', () => {
258
+ const src = (0, common_tags_1.stripIndents) `
259
+ import foo from '@salesforce/apex/ns.class.fooMethod';
260
+ import bar from '@salesforce/apex/ns.class.barMethod';
261
+
262
+ export function callFoo() {
263
+ foo();
264
+ }
265
+
266
+ export function callBar() {
267
+ bar();
268
+ }
269
+ `;
270
+ const result = transformWithLuvioPlugin(src);
271
+ expect(result.code).toMatchInlineSnapshot(`
272
+ "import foo from '@salesforce/apex/ns.class.fooMethod';
273
+ import bar from '@salesforce/apex/ns.class.barMethod';
274
+ export function callFoo() {
275
+ foo(undefined, {
276
+ sourceContext: {
277
+ tagName: "x/foo"
278
+ }
279
+ });
280
+ }
281
+ export function callBar() {
282
+ bar(undefined, {
283
+ sourceContext: {
284
+ tagName: "x/foo"
285
+ }
286
+ });
287
+ }"
288
+ `);
289
+ });
290
+ test('injects tagName for default imported function', () => {
291
+ const src = (0, common_tags_1.stripIndents) `
292
+ import { LightningElement } from 'lwc';
293
+ import { default as methodA } from '@salesforce/apex/MyClass.methodA';
294
+
295
+ export default class Test extends LightningElement {
296
+ connectedCallback() {
297
+ methodA({ abc: 123 });
298
+ }
299
+ }
300
+ `;
301
+ const result = transformWithLuvioPlugin(src);
302
+ expect(result.code).toMatchInlineSnapshot(`
303
+ "import { LightningElement } from 'lwc';
304
+ import { default as methodA } from '@salesforce/apex/MyClass.methodA';
305
+ export default class Test extends LightningElement {
306
+ connectedCallback() {
307
+ methodA({
308
+ abc: 123
309
+ }, {
310
+ sourceContext: {
311
+ tagName: "x/foo"
312
+ }
313
+ });
314
+ }
315
+ }"
316
+ `);
317
+ });
318
+ test('injects tagName for non default exported functions with 1 arg', () => {
319
+ const src = (0, common_tags_1.stripIndents) `
320
+ import foo from '@salesforce/apex/ns.class.fooMethod';
321
+ import bar from '@salesforce/apex/ns.class.barMethod';
322
+
323
+ export function callFoo() {
324
+ foo({ abc: 123 });
325
+ }
326
+
327
+ export function callBar() {
328
+ bar({ abc: 123 });
329
+ }
330
+ `;
331
+ const result = transformWithLuvioPlugin(src);
332
+ expect(result.code).toMatchInlineSnapshot(`
333
+ "import foo from '@salesforce/apex/ns.class.fooMethod';
334
+ import bar from '@salesforce/apex/ns.class.barMethod';
335
+ export function callFoo() {
336
+ foo({
337
+ abc: 123
338
+ }, {
339
+ sourceContext: {
340
+ tagName: "x/foo"
341
+ }
342
+ });
343
+ }
344
+ export function callBar() {
345
+ bar({
346
+ abc: 123
347
+ }, {
348
+ sourceContext: {
349
+ tagName: "x/foo"
350
+ }
351
+ });
352
+ }"
353
+ `);
354
+ });
355
+ test('does not inject tagName for non default exported functions with 2 args', () => {
356
+ const src = (0, common_tags_1.stripIndents) `
357
+ import foo from '@salesforce/apex/ns.class.fooMethod';
358
+ import bar from '@salesforce/apex/ns.class.barMethod';
359
+
360
+ export function callFoo() {
361
+ foo({ abc: 123 }, { extraData: 'foo'});
362
+ }
363
+
364
+ export function callBar() {
365
+ bar({ abc: 123 }, { extraData: 'foo'});
366
+ }
367
+ `;
368
+ const result = transformWithLuvioPlugin(src);
369
+ expect(result.code).toMatchInlineSnapshot(`
370
+ "import foo from '@salesforce/apex/ns.class.fooMethod';
371
+ import bar from '@salesforce/apex/ns.class.barMethod';
372
+ export function callFoo() {
373
+ foo({
374
+ abc: 123
375
+ }, {
376
+ extraData: 'foo'
377
+ });
378
+ }
379
+ export function callBar() {
380
+ bar({
381
+ abc: 123
382
+ }, {
383
+ extraData: 'foo'
384
+ });
385
+ }"
386
+ `);
387
+ });
388
+ test('does not inject tagName for non default exported functions with 2 empty args', () => {
389
+ const src = (0, common_tags_1.stripIndents) `
390
+ import foo from '@salesforce/apex/ns.class.fooMethod';
391
+ import bar from '@salesforce/apex/ns.class.barMethod';
392
+
393
+ export function callFoo() {
394
+ foo({}, {});
395
+ }
396
+
397
+ export function callBar() {
398
+ bar({}, {});
399
+ }
400
+ `;
401
+ const result = transformWithLuvioPlugin(src);
402
+ expect(result.code).toMatchInlineSnapshot(`
403
+ "import foo from '@salesforce/apex/ns.class.fooMethod';
404
+ import bar from '@salesforce/apex/ns.class.barMethod';
405
+ export function callFoo() {
406
+ foo({}, {});
407
+ }
408
+ export function callBar() {
409
+ bar({}, {});
410
+ }"
411
+ `);
412
+ });
413
+ test('does not inject tagName for re-exported apex function', () => {
414
+ const src = (0, common_tags_1.stripIndents) `
415
+ import foo from '@salesforce/apex/ns.class.fooMethod';
416
+ export const fooAsBar = foo;
417
+ `;
418
+ const result = transformWithLuvioPlugin(src);
419
+ expect(result.code).toMatchInlineSnapshot(`
420
+ "import foo from '@salesforce/apex/ns.class.fooMethod';
421
+ export const fooAsBar = foo;"
422
+ `);
423
+ });
424
+ test('does not inject tagName for exported function with parameter shadowing', () => {
425
+ const src = (0, common_tags_1.stripIndents) `
426
+ import foo from '@salesforce/apex/ns.class.fooMethod';
427
+
428
+ export function callFoo() {
429
+ foo();
430
+ }
431
+
432
+ export function callBar(foo) {
433
+ foo({abc: 123});
434
+ }
435
+ `;
436
+ const result = transformWithLuvioPlugin(src);
437
+ expect(result.code).toMatchInlineSnapshot(`
438
+ "import foo from '@salesforce/apex/ns.class.fooMethod';
439
+ export function callFoo() {
440
+ foo(undefined, {
441
+ sourceContext: {
442
+ tagName: "x/foo"
443
+ }
444
+ });
445
+ }
446
+ export function callBar(foo) {
447
+ foo({
448
+ abc: 123
449
+ });
450
+ }"
451
+ `);
452
+ });
453
+ test('does not inject tagName for exported function with parameter shadowing, variation 1', () => {
454
+ const src = (0, common_tags_1.stripIndents) `
455
+ import getContactList from '@salesforce/apex/ContactController.getContactList';
456
+
457
+ export default class ApexWireMethodToProperty extends LightningElement {
458
+
459
+ foo() {
460
+ function getContactList() {}
461
+ getContactList(); // should not be transformed
462
+ }
463
+ @wire(getContactList, {
464
+ abc: 123
465
+ })
466
+ contacts;
467
+ }
468
+ `;
469
+ const result = transformWithLuvioPlugin(src);
470
+ expect(result.code).toMatchInlineSnapshot(`
471
+ "import getContactList from '@salesforce/apex/ContactController.getContactList';
472
+ export default class ApexWireMethodToProperty extends LightningElement {
473
+ foo() {
474
+ function getContactList() {}
475
+ getContactList(); // should not be transformed
476
+ }
477
+ @wire(getContactList, {
478
+ abc: 123
479
+ })
480
+ contacts;
481
+ }"
482
+ `);
483
+ });
484
+ test('does not inject tagName for exported function with parameter shadowing, variation 2', () => {
485
+ const src = (0, common_tags_1.stripIndents) `
486
+ import getContactList from '@salesforce/apex/ContactController.getContactList';
487
+
488
+ export default class ApexWireMethodToProperty extends LightningElement {
489
+
490
+ foo() {
491
+ function getContactList() {}
492
+ getContactList(); // should not be transformed
493
+ }
494
+ @wire(getContactList, {
495
+ abc: 123
496
+ })
497
+ contacts;
498
+ }
499
+ `;
500
+ const result = transformWithLuvioPlugin(src);
501
+ expect(result.code).toMatchInlineSnapshot(`
502
+ "import getContactList from '@salesforce/apex/ContactController.getContactList';
503
+ export default class ApexWireMethodToProperty extends LightningElement {
504
+ foo() {
505
+ function getContactList() {}
506
+ getContactList(); // should not be transformed
507
+ }
508
+ @wire(getContactList, {
509
+ abc: 123
510
+ })
511
+ contacts;
512
+ }"
513
+ `);
514
+ });
515
+ test('does not inject for refreshApex usages', () => {
516
+ const src = (0, common_tags_1.stripIndents) `
517
+ // Example of refreshing data for a wired property
518
+ // after you update data via imperative Apex.
519
+ import { LightningElement, wire } from 'lwc';
520
+ import { refreshApex } from '@salesforce/apex';
521
+ import { notifyRecordUpdateAvailable } from 'lightning/uiRecordApi';
522
+ import getOpptyOverAmount from '@salesforce/apex/OpptyController.getOpptyOverAmount';
523
+ import apexUpdateRecord from '@salesforce/apex/Controller.apexUpdateRecord';
524
+
525
+ export default class RefreshDataImperativeExample extends LightningElement {
526
+ @wire(getOpptyOverAmount, { amount: '$amount' })
527
+ opptiesOverAmount;
528
+
529
+ // Update the record in Apex, such as via a button click
530
+ // Refresh Apex data that the wire service provisioned
531
+ async handler() {
532
+ try {
533
+ await apexUpdateRecord(recordIds);
534
+ refreshApex(this.opptiesOverAmount);
535
+ notifyRecordUpdateAvailable(recordIds); // Refresh the Lightning Data Service cache
536
+ } catch (error) {
537
+ this.error = error;
538
+ }
539
+ }
540
+ }
541
+ `;
542
+ const result = transformWithLuvioPlugin(src);
543
+ expect(result.code).toMatchInlineSnapshot(`
544
+ "// Example of refreshing data for a wired property
545
+ // after you update data via imperative Apex.
546
+ import { LightningElement, wire } from 'lwc';
547
+ import { refreshApex } from '@salesforce/apex';
548
+ import { notifyRecordUpdateAvailable } from 'lightning/uiRecordApi';
549
+ import getOpptyOverAmount from '@salesforce/apex/OpptyController.getOpptyOverAmount';
550
+ import apexUpdateRecord from '@salesforce/apex/Controller.apexUpdateRecord';
551
+ export default class RefreshDataImperativeExample extends LightningElement {
552
+ @wire(getOpptyOverAmount, {
553
+ amount: '$amount'
554
+ })
555
+ opptiesOverAmount;
556
+
557
+ // Update the record in Apex, such as via a button click
558
+ // Refresh Apex data that the wire service provisioned
559
+ async handler() {
560
+ try {
561
+ await apexUpdateRecord(recordIds, {
562
+ sourceContext: {
563
+ tagName: "x/foo"
564
+ }
565
+ });
566
+ refreshApex(this.opptiesOverAmount);
567
+ notifyRecordUpdateAvailable(recordIds); // Refresh the Lightning Data Service cache
568
+ } catch (error) {
569
+ this.error = error;
570
+ }
571
+ }
572
+ }"
573
+ `);
574
+ });
575
+ test('does not inject for non-apex imports', () => {
576
+ const src = (0, common_tags_1.stripIndents) `
577
+ import { LightningElement } from 'lwc';
578
+ import doThing from 'c/someModule';
579
+
580
+ export default class Test extends LightningElement {
581
+ connectedCallback() {
582
+ doThing();
583
+ }
584
+ }
585
+ `;
586
+ const result = transformWithLuvioPlugin(src);
587
+ expect(result.code).toMatchInlineSnapshot(`
588
+ "import { LightningElement } from 'lwc';
589
+ import doThing from 'c/someModule';
590
+ export default class Test extends LightningElement {
591
+ connectedCallback() {
592
+ doThing();
593
+ }
594
+ }"
595
+ `);
596
+ });
597
+ test('does not inject for @wire apex usages', () => {
598
+ const src = (0, common_tags_1.stripIndents) `
599
+ import { LightningElement, wire } from 'lwc';
600
+ import getContactList from '@salesforce/apex/ContactController.getContactList';
601
+
602
+ export default class ApexWireMethodToProperty extends LightningElement {
603
+ @wire(getContactList, { abc: 123 }) contacts;
604
+ }
605
+ `;
606
+ const result = transformWithLuvioPlugin(src);
607
+ expect(result.code).toMatchInlineSnapshot(`
608
+ "import { LightningElement, wire } from 'lwc';
609
+ import getContactList from '@salesforce/apex/ContactController.getContactList';
610
+ export default class ApexWireMethodToProperty extends LightningElement {
611
+ @wire(getContactList, {
612
+ abc: 123
613
+ })
614
+ contacts;
615
+ }"
616
+ `);
617
+ });
618
+ });
619
+ });
620
+ describe('rollup compilation with luvio plugin enabled', () => {
621
+ test('verify the correctness of the compiler output on a valid source foo.js', async () => {
622
+ const res = await compileApexLogging({
623
+ type: 'platform',
624
+ files: {
625
+ 'foo.js': (0, common_tags_1.stripIndents) `
626
+ import { LightningElement } from 'lwc';
627
+ import methodA from '@salesforce/apex/MyClass.methodA';
628
+
629
+ export default class Test extends LightningElement {
630
+ connectedCallback() {
631
+ methodA();
632
+ }
633
+ }
634
+ `,
635
+ },
636
+ namespaceMapping: {
637
+ x: 'ns',
638
+ },
639
+ });
640
+ const { success, results, diagnostics } = res;
641
+ expect(success).toBe(true);
642
+ expect(diagnostics.length).toBe(0);
643
+ expect(normalizeVersion(results[0].code)).toMatchInlineSnapshot(`
644
+ "define('ns/foo', ['lwc', '@salesforce/apex/MyClass.methodA'], (function (lwc, methodA) {
645
+
646
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
647
+
648
+ var methodA__default = /*#__PURE__*/_interopDefaultCompat(methodA);
649
+
650
+ var _tmpl = void 0;
651
+
652
+ class Test extends lwc.LightningElement {
653
+ connectedCallback() {
654
+ methodA__default.default(undefined, {
655
+ sourceContext: {
656
+ tagName: "ns/foo"
657
+ }
658
+ });
659
+ }
660
+ /*LWC compiler vX.X.X*/
661
+ }
662
+ const __lwc_component_class_internal = lwc.registerComponent(Test, {
663
+ tmpl: _tmpl,
664
+ sel: "x-foo",
665
+ apiVersion: 66
666
+ });
667
+
668
+ return __lwc_component_class_internal;
669
+
670
+ }));
671
+ "
672
+ `);
673
+ });
674
+ test('verify the correctness of the compiler output on a valid source foo.ts', async () => {
675
+ const res = await compileApexLogging({
676
+ type: 'internal',
677
+ files: {
678
+ 'foo.ts': (0, common_tags_1.stripIndents) `
679
+ import { LightningElement } from 'lwc';
680
+ import methodA from '@salesforce/apex/MyClass.methodA';
681
+
682
+ export default class Test extends LightningElement {
683
+ connectedCallback() {
684
+ methodA();
685
+ }
686
+ }
687
+ `,
688
+ },
689
+ namespaceMapping: {
690
+ x: 'ns',
691
+ },
692
+ });
693
+ const { success, results, diagnostics } = res;
694
+ expect(success).toBe(true);
695
+ expect(diagnostics.length).toBe(0);
696
+ expect(normalizeVersion(results[0].code)).toMatchInlineSnapshot(`
697
+ "define('ns/foo', ['lwc', '@salesforce/apex/MyClass.methodA'], (function (lwc, methodA) {
698
+
699
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
700
+
701
+ var methodA__default = /*#__PURE__*/_interopDefaultCompat(methodA);
702
+
703
+ var _tmpl = void 0;
704
+
705
+ class Test extends lwc.LightningElement {
706
+ connectedCallback() {
707
+ methodA__default.default(undefined, {
708
+ sourceContext: {
709
+ tagName: "ns/foo"
710
+ }
711
+ });
712
+ }
713
+ /*LWC compiler vX.X.X*/
714
+ }
715
+ const __lwc_component_class_internal = lwc.registerComponent(Test, {
716
+ tmpl: _tmpl,
717
+ sel: "x-foo",
718
+ apiVersion: 66,
719
+ enableSyntheticElementInternals: true
720
+ });
721
+
722
+ return __lwc_component_class_internal;
723
+
724
+ }));
725
+ "
726
+ `);
727
+ });
728
+ });
729
+ //# sourceMappingURL=compile-apex-logging.spec.js.map