@lwc/babel-plugin-component 8.12.5 → 8.12.6
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.
- package/dist/index.cjs.js +31 -22
- package/dist/index.js +31 -22
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -474,38 +474,47 @@ function validateWireId(id, path, state) {
|
|
|
474
474
|
errorInfo: errors.DecoratorErrors.ADAPTER_SHOULD_BE_FIRST_PARAMETER,
|
|
475
475
|
}, state);
|
|
476
476
|
}
|
|
477
|
-
|
|
478
|
-
if (
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}, state);
|
|
477
|
+
let adapter;
|
|
478
|
+
if (id.isIdentifier()) {
|
|
479
|
+
// @wire(adapter)
|
|
480
|
+
adapter = id;
|
|
482
481
|
}
|
|
483
|
-
if (id.isMemberExpression(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
482
|
+
else if (id.isMemberExpression()) {
|
|
483
|
+
if (id.node.computed) {
|
|
484
|
+
// @wire(adapter[computed])
|
|
485
|
+
throw generateError(id, {
|
|
486
|
+
errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_COMPUTED_PROPS,
|
|
487
|
+
}, state);
|
|
488
|
+
}
|
|
489
|
+
const object = id.get('object');
|
|
490
|
+
if (object.isIdentifier()) {
|
|
491
|
+
// @wire(adapter.foo)
|
|
492
|
+
adapter = object;
|
|
493
|
+
}
|
|
494
|
+
else {
|
|
495
|
+
// @wire(adapter.foo.bar)
|
|
496
|
+
throw generateError(id, {
|
|
497
|
+
errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_NESTED_MEMBER_EXRESSIONS,
|
|
498
|
+
}, state);
|
|
499
|
+
}
|
|
487
500
|
}
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
if (isMemberExpression && !id.get('object').isIdentifier()) {
|
|
501
|
+
else {
|
|
502
|
+
// @wire(1), @wire('adapter'), @wire(function adapter() {}), etc.
|
|
491
503
|
throw generateError(id, {
|
|
492
|
-
errorInfo: errors.DecoratorErrors.
|
|
504
|
+
errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
|
|
493
505
|
}, state);
|
|
494
506
|
}
|
|
495
|
-
// TODO [#3444]: improve member expression computed typechecking
|
|
496
507
|
// Ensure wire adapter is imported (check for member expression or identifier)
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
if (!path.scope.getBinding(wireBinding)) {
|
|
508
|
+
const adapterBinding = path.scope.getBinding(adapter.node.name);
|
|
509
|
+
if (!adapterBinding) {
|
|
500
510
|
throw generateError(id, {
|
|
501
511
|
errorInfo: errors.DecoratorErrors.WIRE_ADAPTER_SHOULD_BE_IMPORTED,
|
|
502
|
-
messageArgs: [
|
|
512
|
+
messageArgs: [adapter.node.name],
|
|
503
513
|
}, state);
|
|
504
514
|
}
|
|
505
515
|
// ensure wire adapter is a first parameter
|
|
506
|
-
if (
|
|
507
|
-
!
|
|
508
|
-
!path.scope.getBinding(wireBinding).path.isImportDefaultSpecifier()) {
|
|
516
|
+
if (!adapterBinding.path.isImportSpecifier() &&
|
|
517
|
+
!adapterBinding.path.isImportDefaultSpecifier()) {
|
|
509
518
|
throw generateError(id, {
|
|
510
519
|
errorInfo: errors.DecoratorErrors.IMPORTED_FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
|
|
511
520
|
}, state);
|
|
@@ -1276,5 +1285,5 @@ function LwcClassTransform(api) {
|
|
|
1276
1285
|
}
|
|
1277
1286
|
|
|
1278
1287
|
exports.default = LwcClassTransform;
|
|
1279
|
-
/** version: 8.12.
|
|
1288
|
+
/** version: 8.12.6 */
|
|
1280
1289
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.js
CHANGED
|
@@ -470,38 +470,47 @@ function validateWireId(id, path, state) {
|
|
|
470
470
|
errorInfo: DecoratorErrors.ADAPTER_SHOULD_BE_FIRST_PARAMETER,
|
|
471
471
|
}, state);
|
|
472
472
|
}
|
|
473
|
-
|
|
474
|
-
if (
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
}, state);
|
|
473
|
+
let adapter;
|
|
474
|
+
if (id.isIdentifier()) {
|
|
475
|
+
// @wire(adapter)
|
|
476
|
+
adapter = id;
|
|
478
477
|
}
|
|
479
|
-
if (id.isMemberExpression(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
478
|
+
else if (id.isMemberExpression()) {
|
|
479
|
+
if (id.node.computed) {
|
|
480
|
+
// @wire(adapter[computed])
|
|
481
|
+
throw generateError(id, {
|
|
482
|
+
errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_COMPUTED_PROPS,
|
|
483
|
+
}, state);
|
|
484
|
+
}
|
|
485
|
+
const object = id.get('object');
|
|
486
|
+
if (object.isIdentifier()) {
|
|
487
|
+
// @wire(adapter.foo)
|
|
488
|
+
adapter = object;
|
|
489
|
+
}
|
|
490
|
+
else {
|
|
491
|
+
// @wire(adapter.foo.bar)
|
|
492
|
+
throw generateError(id, {
|
|
493
|
+
errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_NESTED_MEMBER_EXRESSIONS,
|
|
494
|
+
}, state);
|
|
495
|
+
}
|
|
483
496
|
}
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
if (isMemberExpression && !id.get('object').isIdentifier()) {
|
|
497
|
+
else {
|
|
498
|
+
// @wire(1), @wire('adapter'), @wire(function adapter() {}), etc.
|
|
487
499
|
throw generateError(id, {
|
|
488
|
-
errorInfo: DecoratorErrors.
|
|
500
|
+
errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
|
|
489
501
|
}, state);
|
|
490
502
|
}
|
|
491
|
-
// TODO [#3444]: improve member expression computed typechecking
|
|
492
503
|
// Ensure wire adapter is imported (check for member expression or identifier)
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
if (!path.scope.getBinding(wireBinding)) {
|
|
504
|
+
const adapterBinding = path.scope.getBinding(adapter.node.name);
|
|
505
|
+
if (!adapterBinding) {
|
|
496
506
|
throw generateError(id, {
|
|
497
507
|
errorInfo: DecoratorErrors.WIRE_ADAPTER_SHOULD_BE_IMPORTED,
|
|
498
|
-
messageArgs: [
|
|
508
|
+
messageArgs: [adapter.node.name],
|
|
499
509
|
}, state);
|
|
500
510
|
}
|
|
501
511
|
// ensure wire adapter is a first parameter
|
|
502
|
-
if (
|
|
503
|
-
!
|
|
504
|
-
!path.scope.getBinding(wireBinding).path.isImportDefaultSpecifier()) {
|
|
512
|
+
if (!adapterBinding.path.isImportSpecifier() &&
|
|
513
|
+
!adapterBinding.path.isImportDefaultSpecifier()) {
|
|
505
514
|
throw generateError(id, {
|
|
506
515
|
errorInfo: DecoratorErrors.IMPORTED_FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
|
|
507
516
|
}, state);
|
|
@@ -1272,5 +1281,5 @@ function LwcClassTransform(api) {
|
|
|
1272
1281
|
}
|
|
1273
1282
|
|
|
1274
1283
|
export { LwcClassTransform as default };
|
|
1275
|
-
/** version: 8.12.
|
|
1284
|
+
/** version: 8.12.6 */
|
|
1276
1285
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
|
|
5
5
|
],
|
|
6
6
|
"name": "@lwc/babel-plugin-component",
|
|
7
|
-
"version": "8.12.
|
|
7
|
+
"version": "8.12.6",
|
|
8
8
|
"description": "Babel plugin to transform a LWC module",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"lwc"
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@babel/helper-module-imports": "7.25.9",
|
|
50
|
-
"@lwc/errors": "8.12.
|
|
51
|
-
"@lwc/shared": "8.12.
|
|
50
|
+
"@lwc/errors": "8.12.6",
|
|
51
|
+
"@lwc/shared": "8.12.6",
|
|
52
52
|
"line-column": "~1.0.2"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|