@lwc/babel-plugin-component 2.38.0 → 2.39.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.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/salesforce/lwc/issues"
12
12
  },
13
- "version": "2.38.0",
13
+ "version": "2.39.0",
14
14
  "main": "src/index.js",
15
15
  "typings": "src/index.d.ts",
16
16
  "license": "MIT",
@@ -21,8 +21,8 @@
21
21
  ],
22
22
  "dependencies": {
23
23
  "@babel/helper-module-imports": "~7.18.6",
24
- "@lwc/errors": "2.38.0",
25
- "@lwc/shared": "2.38.0",
24
+ "@lwc/errors": "2.39.0",
25
+ "@lwc/shared": "2.39.0",
26
26
  "line-column": "~1.0.2"
27
27
  },
28
28
  "peerDependencies": {
package/src/component.js CHANGED
@@ -8,7 +8,12 @@ const { basename, extname } = require('path');
8
8
 
9
9
  const moduleImports = require('@babel/helper-module-imports');
10
10
 
11
- const { LWC_PACKAGE_ALIAS, REGISTER_COMPONENT_ID, TEMPLATE_KEY } = require('./constants');
11
+ const {
12
+ LWC_PACKAGE_ALIAS,
13
+ REGISTER_COMPONENT_ID,
14
+ TEMPLATE_KEY,
15
+ COMPONENT_NAME_KEY,
16
+ } = require('./constants');
12
17
 
13
18
  function getBaseName(classPath) {
14
19
  const ext = extname(classPath);
@@ -32,6 +37,12 @@ function needsComponentRegistration(path) {
32
37
  );
33
38
  }
34
39
 
40
+ function getComponentRegisteredName(t, state) {
41
+ const { namespace, name } = state.opts;
42
+ const componentName = namespace && name ? `${namespace}-${name}` : '';
43
+ return t.stringLiteral(componentName);
44
+ }
45
+
35
46
  module.exports = function ({ types: t }) {
36
47
  function createRegisterComponent(declarationPath, state) {
37
48
  const registerComponentId = moduleImports.addNamed(
@@ -41,6 +52,7 @@ module.exports = function ({ types: t }) {
41
52
  );
42
53
  const templateIdentifier = importDefaultTemplate(declarationPath, state);
43
54
  const statementPath = declarationPath.getStatementParent();
55
+ const componentRegisteredName = getComponentRegisteredName(t, state);
44
56
  let node = declarationPath.node;
45
57
 
46
58
  if (declarationPath.isClassDeclaration()) {
@@ -56,7 +68,10 @@ module.exports = function ({ types: t }) {
56
68
 
57
69
  return t.callExpression(registerComponentId, [
58
70
  node,
59
- t.objectExpression([t.objectProperty(t.identifier(TEMPLATE_KEY), templateIdentifier)]),
71
+ t.objectExpression([
72
+ t.objectProperty(t.identifier(TEMPLATE_KEY), templateIdentifier),
73
+ t.objectProperty(t.identifier(COMPONENT_NAME_KEY), componentRegisteredName),
74
+ ]),
60
75
  ]);
61
76
  }
62
77
 
package/src/constants.js CHANGED
@@ -8,7 +8,7 @@
8
8
  // This set is for attributes that have a camel cased property name
9
9
  // For example, div.tabIndex.
10
10
  // We do not want users to define @api properties with these names
11
- // Because the template will never call them. It'll alawys call the camel
11
+ // Because the template will never call them. It'll always call the camel
12
12
  // cased version.
13
13
  const AMBIGUOUS_PROP_SET = new Map([
14
14
  ['bgcolor', 'bgColor'],
@@ -51,6 +51,7 @@ const DECORATOR_TYPES = {
51
51
  const REGISTER_COMPONENT_ID = 'registerComponent';
52
52
  const REGISTER_DECORATORS_ID = 'registerDecorators';
53
53
  const TEMPLATE_KEY = 'tmpl';
54
+ const COMPONENT_NAME_KEY = 'sel';
54
55
 
55
56
  module.exports = {
56
57
  AMBIGUOUS_PROP_SET,
@@ -62,4 +63,5 @@ module.exports = {
62
63
  REGISTER_COMPONENT_ID,
63
64
  REGISTER_DECORATORS_ID,
64
65
  TEMPLATE_KEY,
66
+ COMPONENT_NAME_KEY,
65
67
  };