@lwc/babel-plugin-component 8.12.6 → 8.12.7-alpha.0

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.
@@ -1,4 +1,3 @@
1
1
  import type { Visitor } from '@babel/core';
2
2
  import type { BabelAPI, LwcBabelPluginPass } from './types';
3
3
  export default function compilerVersionNumber({ types: t }: BabelAPI): Visitor<LwcBabelPluginPass>;
4
- //# sourceMappingURL=compiler-version-number.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { Visitor } from '@babel/core';
2
2
  import type { BabelAPI, LwcBabelPluginPass } from './types';
3
3
  export default function ({ types: t }: BabelAPI): Visitor<LwcBabelPluginPass>;
4
- //# sourceMappingURL=component.d.ts.map
@@ -26,4 +26,3 @@ declare const COMPONENT_NAME_KEY = "sel";
26
26
  declare const API_VERSION_KEY = "apiVersion";
27
27
  declare const COMPONENT_CLASS_ID = "__lwc_component_class_internal";
28
28
  export { AMBIGUOUS_PROP_SET, DECORATOR_TYPES, DISALLOWED_PROP_SET, LWC_PACKAGE_ALIAS, LWC_PACKAGE_EXPORTS, LWC_COMPONENT_PROPERTIES, REGISTER_COMPONENT_ID, REGISTER_DECORATORS_ID, TEMPLATE_KEY, COMPONENT_NAME_KEY, API_VERSION_KEY, COMPONENT_CLASS_ID, };
29
- //# sourceMappingURL=constants.d.ts.map
@@ -6,4 +6,3 @@ declare const _default: {
6
6
  transform: typeof transform;
7
7
  };
8
8
  export default _default;
9
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { DecoratorMeta } from '../index';
2
2
  declare function isApiDecorator(decorator: DecoratorMeta): boolean;
3
3
  export { isApiDecorator };
4
- //# sourceMappingURL=shared.d.ts.map
@@ -3,4 +3,3 @@ import type { DecoratorMeta } from '../index';
3
3
  import type { BabelTypes } from '../../types';
4
4
  import type { ClassBodyItem } from '../types';
5
5
  export default function transform(t: BabelTypes, decoratorMetas: DecoratorMeta[], classBodyItems: NodePath<ClassBodyItem>[]): types.ObjectProperty[];
6
- //# sourceMappingURL=transform.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { LwcBabelPluginPass } from '../../types';
2
2
  import type { DecoratorMeta } from '../index';
3
3
  export default function validate(decorators: DecoratorMeta[], state: LwcBabelPluginPass): void;
4
- //# sourceMappingURL=validate.d.ts.map
@@ -21,4 +21,3 @@ declare function removeImportedDecoratorSpecifiers(engineImportSpecifiers: {
21
21
  }[]): void;
22
22
  declare function decorators({ types: t }: BabelAPI): Visitor<LwcBabelPluginPass>;
23
23
  export { decorators, removeImportedDecoratorSpecifiers, validateImportedLwcDecoratorUsage };
24
- //# sourceMappingURL=index.d.ts.map
@@ -8,4 +8,3 @@ declare const _default: {
8
8
  validate: typeof validate;
9
9
  };
10
10
  export default _default;
11
- //# sourceMappingURL=index.d.ts.map
@@ -16,4 +16,3 @@ export type BindingOptions = {
16
16
  };
17
17
  export type ClassBodyItem = types.ClassMethod | types.ClassPrivateMethod | types.ClassProperty | types.ClassPrivateProperty | types.ClassAccessorProperty | types.StaticBlock;
18
18
  export type LwcDecoratorName = 'api' | 'track' | 'wire';
19
- //# sourceMappingURL=types.d.ts.map
@@ -6,4 +6,3 @@ declare const _default: {
6
6
  transform: typeof transform;
7
7
  };
8
8
  export default _default;
9
- //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { DecoratorMeta } from '../index';
2
2
  declare function isWireDecorator(decorator: DecoratorMeta): boolean;
3
3
  export { isWireDecorator };
4
- //# sourceMappingURL=shared.d.ts.map
@@ -2,4 +2,3 @@ import type { types } from '@babel/core';
2
2
  import type { DecoratorMeta } from '../index';
3
3
  import type { BabelTypes } from '../../types';
4
4
  export default function transform(t: BabelTypes, decoratorMetas: DecoratorMeta[]): types.ObjectProperty[];
5
- //# sourceMappingURL=transform.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { LwcBabelPluginPass } from '../../types';
2
2
  import type { DecoratorMeta } from '../index';
3
3
  export default function validate(decorators: DecoratorMeta[], state: LwcBabelPluginPass): void;
4
- //# sourceMappingURL=validate.d.ts.map
@@ -1,4 +1,3 @@
1
1
  import type { types, NodePath } from '@babel/core';
2
2
  import type { BabelAPI } from './types';
3
3
  export default function ({ types: t }: BabelAPI): (path: NodePath<types.Program>) => void;
4
- //# sourceMappingURL=dedupe-imports.d.ts.map
@@ -5,4 +5,3 @@ import type { LwcBabelPluginPass } from './types';
5
5
  * { dynamicImports: { loader: string, strictSpecifier: boolean } }
6
6
  */
7
7
  export default function (): Visitor<LwcBabelPluginPass>;
8
- //# sourceMappingURL=dynamic-imports.d.ts.map
package/dist/index.cjs.js CHANGED
@@ -474,47 +474,38 @@ function validateWireId(id, path, state) {
474
474
  errorInfo: errors.DecoratorErrors.ADAPTER_SHOULD_BE_FIRST_PARAMETER,
475
475
  }, state);
476
476
  }
477
- let adapter;
478
- if (id.isIdentifier()) {
479
- // @wire(adapter)
480
- adapter = id;
477
+ const isMemberExpression = id.isMemberExpression();
478
+ if (!id.isIdentifier() && !isMemberExpression) {
479
+ throw generateError(id, {
480
+ errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
481
+ }, state);
481
482
  }
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
- }
483
+ if (id.isMemberExpression({ computed: true })) {
484
+ throw generateError(id, {
485
+ errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_COMPUTED_PROPS,
486
+ }, state);
500
487
  }
501
- else {
502
- // @wire(1), @wire('adapter'), @wire(function adapter() {}), etc.
488
+ // TODO [#3444]: improve member expression computed typechecking
489
+ // @ts-expect-error type narrowing incorrectly reduces id to `never`
490
+ if (isMemberExpression && !id.get('object').isIdentifier()) {
503
491
  throw generateError(id, {
504
- errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
492
+ errorInfo: errors.DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_NESTED_MEMBER_EXRESSIONS,
505
493
  }, state);
506
494
  }
495
+ // TODO [#3444]: improve member expression computed typechecking
507
496
  // Ensure wire adapter is imported (check for member expression or identifier)
508
- const adapterBinding = path.scope.getBinding(adapter.node.name);
509
- if (!adapterBinding) {
497
+ // @ts-expect-error type narrowing incorrectly reduces id to `never`
498
+ const wireBinding = isMemberExpression ? id.node.object.name : id.node.name;
499
+ if (!path.scope.getBinding(wireBinding)) {
510
500
  throw generateError(id, {
511
501
  errorInfo: errors.DecoratorErrors.WIRE_ADAPTER_SHOULD_BE_IMPORTED,
512
- messageArgs: [adapter.node.name],
502
+ messageArgs: [id.node.name],
513
503
  }, state);
514
504
  }
515
505
  // ensure wire adapter is a first parameter
516
- if (!adapterBinding.path.isImportSpecifier() &&
517
- !adapterBinding.path.isImportDefaultSpecifier()) {
506
+ if (wireBinding &&
507
+ !path.scope.getBinding(wireBinding).path.isImportSpecifier() &&
508
+ !path.scope.getBinding(wireBinding).path.isImportDefaultSpecifier()) {
518
509
  throw generateError(id, {
519
510
  errorInfo: errors.DecoratorErrors.IMPORTED_FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
520
511
  }, state);
@@ -1285,5 +1276,5 @@ function LwcClassTransform(api) {
1285
1276
  }
1286
1277
 
1287
1278
  exports.default = LwcClassTransform;
1288
- /** version: 8.12.6 */
1279
+ /** version: 8.12.2 */
1289
1280
  //# sourceMappingURL=index.cjs.js.map
package/dist/index.d.ts CHANGED
@@ -8,4 +8,3 @@ export type { LwcBabelPluginOptions } from './types';
8
8
  * @param api
9
9
  */
10
10
  export default function LwcClassTransform(api: BabelAPI): PluginObj<LwcBabelPluginPass>;
11
- //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -470,47 +470,38 @@ function validateWireId(id, path, state) {
470
470
  errorInfo: DecoratorErrors.ADAPTER_SHOULD_BE_FIRST_PARAMETER,
471
471
  }, state);
472
472
  }
473
- let adapter;
474
- if (id.isIdentifier()) {
475
- // @wire(adapter)
476
- adapter = id;
473
+ const isMemberExpression = id.isMemberExpression();
474
+ if (!id.isIdentifier() && !isMemberExpression) {
475
+ throw generateError(id, {
476
+ errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
477
+ }, state);
477
478
  }
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
- }
479
+ if (id.isMemberExpression({ computed: true })) {
480
+ throw generateError(id, {
481
+ errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_COMPUTED_PROPS,
482
+ }, state);
496
483
  }
497
- else {
498
- // @wire(1), @wire('adapter'), @wire(function adapter() {}), etc.
484
+ // TODO [#3444]: improve member expression computed typechecking
485
+ // @ts-expect-error type narrowing incorrectly reduces id to `never`
486
+ if (isMemberExpression && !id.get('object').isIdentifier()) {
499
487
  throw generateError(id, {
500
- errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
488
+ errorInfo: DecoratorErrors.FUNCTION_IDENTIFIER_CANNOT_HAVE_NESTED_MEMBER_EXRESSIONS,
501
489
  }, state);
502
490
  }
491
+ // TODO [#3444]: improve member expression computed typechecking
503
492
  // Ensure wire adapter is imported (check for member expression or identifier)
504
- const adapterBinding = path.scope.getBinding(adapter.node.name);
505
- if (!adapterBinding) {
493
+ // @ts-expect-error type narrowing incorrectly reduces id to `never`
494
+ const wireBinding = isMemberExpression ? id.node.object.name : id.node.name;
495
+ if (!path.scope.getBinding(wireBinding)) {
506
496
  throw generateError(id, {
507
497
  errorInfo: DecoratorErrors.WIRE_ADAPTER_SHOULD_BE_IMPORTED,
508
- messageArgs: [adapter.node.name],
498
+ messageArgs: [id.node.name],
509
499
  }, state);
510
500
  }
511
501
  // ensure wire adapter is a first parameter
512
- if (!adapterBinding.path.isImportSpecifier() &&
513
- !adapterBinding.path.isImportDefaultSpecifier()) {
502
+ if (wireBinding &&
503
+ !path.scope.getBinding(wireBinding).path.isImportSpecifier() &&
504
+ !path.scope.getBinding(wireBinding).path.isImportDefaultSpecifier()) {
514
505
  throw generateError(id, {
515
506
  errorInfo: DecoratorErrors.IMPORTED_FUNCTION_IDENTIFIER_SHOULD_BE_FIRST_PARAMETER,
516
507
  }, state);
@@ -1281,5 +1272,5 @@ function LwcClassTransform(api) {
1281
1272
  }
1282
1273
 
1283
1274
  export { LwcClassTransform as default };
1284
- /** version: 8.12.6 */
1275
+ /** version: 8.12.2 */
1285
1276
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,3 @@
1
1
  import type { NodePath } from '@babel/core';
2
2
  import type { BabelAPI } from './types';
3
3
  export default function ({ types: t }: BabelAPI, path: NodePath): void;
4
- //# sourceMappingURL=scope-css-imports.d.ts.map
package/dist/types.d.ts CHANGED
@@ -19,4 +19,3 @@ export interface LwcBabelPluginPass extends PluginPass {
19
19
  dynamicImports?: string[];
20
20
  loaderRef?: types.Identifier;
21
21
  }
22
- //# sourceMappingURL=types.d.ts.map
package/dist/utils.d.ts CHANGED
@@ -21,4 +21,3 @@ declare function getEngineImportSpecifiers(path: NodePath): ImportSpecifier[];
21
21
  declare function generateError(source: NodePath<types.Node>, { errorInfo, messageArgs }: DecoratorErrorOptions, state: LwcBabelPluginPass): Error;
22
22
  declare function incrementMetricCounter(metric: CompilerMetrics, state: LwcBabelPluginPass): void;
23
23
  export { isClassMethod, isGetterClassMethod, isSetterClassMethod, generateError, getEngineImportSpecifiers, incrementMetricCounter, };
24
- //# sourceMappingURL=utils.d.ts.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.6",
7
+ "version": "8.12.7-alpha.0",
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.6",
51
- "@lwc/shared": "8.12.6",
50
+ "@lwc/errors": "8.12.7-alpha.0",
51
+ "@lwc/shared": "8.12.7-alpha.0",
52
52
  "line-column": "~1.0.2"
53
53
  },
54
54
  "devDependencies": {
@@ -58,4 +58,4 @@
58
58
  "peerDependencies": {
59
59
  "@babel/core": "^7"
60
60
  }
61
- }
61
+ }