@lwc/babel-plugin-component 2.12.0 → 2.13.1
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 +3 -3
- package/src/constants.js +0 -22
- package/src/decorators/api/index.js +3 -2
- package/src/decorators/api/transform.js +2 -1
- package/src/decorators/api/validate.js +3 -2
- package/src/decorators/index.js +4 -4
- package/src/decorators/wire/index.js +3 -2
- package/src/decorators/wire/transform.js +2 -1
- package/src/decorators/wire/validate.js +2 -1
- package/src/index.js +1 -15
- package/src/utils.js +10 -28
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.
|
|
13
|
+
"version": "2.13.1",
|
|
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.16.7",
|
|
24
|
-
"@lwc/errors": "2.
|
|
25
|
-
"@lwc/shared": "2.
|
|
24
|
+
"@lwc/errors": "2.13.1",
|
|
25
|
+
"@lwc/shared": "2.13.1",
|
|
26
26
|
"line-column": "~1.0.2"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
package/src/constants.js
CHANGED
|
@@ -34,27 +34,6 @@ const LWC_PACKAGE_EXPORTS = {
|
|
|
34
34
|
WIRE_DECORATOR: 'wire',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const LWC_SUPPORTED_APIS = new Set([
|
|
38
|
-
// From "@lwc/engine-core"
|
|
39
|
-
...Object.values(LWC_PACKAGE_EXPORTS),
|
|
40
|
-
'getComponentDef',
|
|
41
|
-
'getComponentConstructor',
|
|
42
|
-
'isComponentConstructor',
|
|
43
|
-
'createContextProvider',
|
|
44
|
-
'readonly',
|
|
45
|
-
'register',
|
|
46
|
-
'setFeatureFlagForTest',
|
|
47
|
-
'unwrap',
|
|
48
|
-
|
|
49
|
-
// From "@lwc/engine-dom"
|
|
50
|
-
'hydrateComponent',
|
|
51
|
-
'buildCustomElementConstructor',
|
|
52
|
-
'createElement',
|
|
53
|
-
|
|
54
|
-
// From "@lwc/engine-server"
|
|
55
|
-
'renderComponent',
|
|
56
|
-
]);
|
|
57
|
-
|
|
58
37
|
const LWC_COMPONENT_PROPERTIES = {
|
|
59
38
|
PUBLIC_PROPS: 'publicProps',
|
|
60
39
|
PUBLIC_METHODS: 'publicMethods',
|
|
@@ -79,7 +58,6 @@ module.exports = {
|
|
|
79
58
|
DISALLOWED_PROP_SET,
|
|
80
59
|
LWC_PACKAGE_ALIAS,
|
|
81
60
|
LWC_PACKAGE_EXPORTS,
|
|
82
|
-
LWC_SUPPORTED_APIS,
|
|
83
61
|
LWC_COMPONENT_PROPERTIES,
|
|
84
62
|
REGISTER_COMPONENT_ID,
|
|
85
63
|
REGISTER_DECORATORS_ID,
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
const validate = require('./validate');
|
|
8
|
-
const transform = require('./transform');
|
|
9
7
|
const {
|
|
10
8
|
LWC_PACKAGE_EXPORTS: { API_DECORATOR },
|
|
11
9
|
} = require('../../constants');
|
|
12
10
|
|
|
11
|
+
const validate = require('./validate');
|
|
12
|
+
const transform = require('./transform');
|
|
13
|
+
|
|
13
14
|
module.exports = {
|
|
14
15
|
name: API_DECORATOR,
|
|
15
16
|
validate,
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
const { isApiDecorator } = require('./shared');
|
|
8
7
|
const {
|
|
9
8
|
DECORATOR_TYPES,
|
|
10
9
|
LWC_COMPONENT_PROPERTIES: { PUBLIC_METHODS, PUBLIC_PROPS },
|
|
11
10
|
} = require('../../constants');
|
|
12
11
|
|
|
12
|
+
const { isApiDecorator } = require('./shared');
|
|
13
|
+
|
|
13
14
|
const PUBLIC_PROP_BIT_MASK = {
|
|
14
15
|
PROPERTY: 0,
|
|
15
16
|
GETTER: 1,
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
7
|
const { DecoratorErrors } = require('@lwc/errors');
|
|
8
|
-
|
|
8
|
+
|
|
9
|
+
const { generateError } = require('../../utils');
|
|
9
10
|
const {
|
|
10
11
|
AMBIGUOUS_PROP_SET,
|
|
11
12
|
DISALLOWED_PROP_SET,
|
|
@@ -13,7 +14,7 @@ const {
|
|
|
13
14
|
DECORATOR_TYPES,
|
|
14
15
|
} = require('../../constants');
|
|
15
16
|
|
|
16
|
-
const {
|
|
17
|
+
const { isApiDecorator } = require('./shared');
|
|
17
18
|
|
|
18
19
|
function validateConflict(path, decorators) {
|
|
19
20
|
const isPublicFieldTracked = decorators.some(
|
package/src/decorators/index.js
CHANGED
|
@@ -7,10 +7,6 @@
|
|
|
7
7
|
const moduleImports = require('@babel/helper-module-imports');
|
|
8
8
|
const { DecoratorErrors } = require('@lwc/errors');
|
|
9
9
|
|
|
10
|
-
const api = require('./api');
|
|
11
|
-
const wire = require('./wire');
|
|
12
|
-
const track = require('./track');
|
|
13
|
-
|
|
14
10
|
const { DECORATOR_TYPES, LWC_PACKAGE_ALIAS, REGISTER_DECORATORS_ID } = require('../constants');
|
|
15
11
|
const {
|
|
16
12
|
generateError,
|
|
@@ -19,6 +15,10 @@ const {
|
|
|
19
15
|
isGetterClassMethod,
|
|
20
16
|
} = require('../utils');
|
|
21
17
|
|
|
18
|
+
const api = require('./api');
|
|
19
|
+
const wire = require('./wire');
|
|
20
|
+
const track = require('./track');
|
|
21
|
+
|
|
22
22
|
const DECORATOR_TRANSFORMS = [api, wire, track];
|
|
23
23
|
const AVAILABLE_DECORATORS = DECORATOR_TRANSFORMS.map((transform) => transform.name).join(', ');
|
|
24
24
|
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
const validate = require('./validate');
|
|
8
|
-
const transform = require('./transform');
|
|
9
7
|
const {
|
|
10
8
|
LWC_PACKAGE_EXPORTS: { WIRE_DECORATOR },
|
|
11
9
|
} = require('../../constants');
|
|
12
10
|
|
|
11
|
+
const validate = require('./validate');
|
|
12
|
+
const transform = require('./transform');
|
|
13
|
+
|
|
13
14
|
module.exports = {
|
|
14
15
|
name: WIRE_DECORATOR,
|
|
15
16
|
validate,
|
|
@@ -4,9 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
const { isWireDecorator } = require('./shared');
|
|
8
7
|
const { LWC_COMPONENT_PROPERTIES } = require('../../constants');
|
|
9
8
|
|
|
9
|
+
const { isWireDecorator } = require('./shared');
|
|
10
|
+
|
|
10
11
|
const WIRE_PARAM_PREFIX = '$';
|
|
11
12
|
const WIRE_CONFIG_ARG_NAME = '$cmp';
|
|
12
13
|
|
|
@@ -5,12 +5,13 @@
|
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
7
|
const { DecoratorErrors } = require('@lwc/errors');
|
|
8
|
-
const { isWireDecorator } = require('./shared');
|
|
9
8
|
const {
|
|
10
9
|
LWC_PACKAGE_EXPORTS: { WIRE_DECORATOR, TRACK_DECORATOR, API_DECORATOR },
|
|
11
10
|
} = require('../../constants');
|
|
12
11
|
const { generateError } = require('../../utils');
|
|
13
12
|
|
|
13
|
+
const { isWireDecorator } = require('./shared');
|
|
14
|
+
|
|
14
15
|
function validateWireParameters(path) {
|
|
15
16
|
const [id, config] = path.get('expression.arguments');
|
|
16
17
|
|
package/src/index.js
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
const { LWCClassErrors } = require('@lwc/errors');
|
|
8
|
-
|
|
9
7
|
const component = require('./component');
|
|
10
|
-
const { LWC_SUPPORTED_APIS } = require('./constants');
|
|
11
8
|
const {
|
|
12
9
|
decorators,
|
|
13
10
|
removeImportedDecoratorSpecifiers,
|
|
@@ -16,7 +13,7 @@ const {
|
|
|
16
13
|
const dedupeImports = require('./dedupe-imports');
|
|
17
14
|
const dynamicImports = require('./dynamic-imports');
|
|
18
15
|
const compilerVersionNumber = require('./compiler-version-number');
|
|
19
|
-
const {
|
|
16
|
+
const { getEngineImportSpecifiers } = require('./utils');
|
|
20
17
|
|
|
21
18
|
/**
|
|
22
19
|
* The transform is done in 2 passes:
|
|
@@ -44,17 +41,6 @@ module.exports = function LwcClassTransform(api) {
|
|
|
44
41
|
enter(path) {
|
|
45
42
|
const engineImportSpecifiers = getEngineImportSpecifiers(path);
|
|
46
43
|
|
|
47
|
-
// Validate what is imported from 'lwc'. This validation will eventually be moved out from the compiler
|
|
48
|
-
// and into a lint rule.
|
|
49
|
-
engineImportSpecifiers.forEach(({ name }) => {
|
|
50
|
-
if (!LWC_SUPPORTED_APIS.has(name)) {
|
|
51
|
-
throw generateError(path, {
|
|
52
|
-
errorInfo: LWCClassErrors.INVALID_IMPORT_PROHIBITED_API,
|
|
53
|
-
messageArgs: [name],
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
44
|
// Validate the usage of LWC decorators.
|
|
59
45
|
validateImportedLwcDecoratorUsage(engineImportSpecifiers);
|
|
60
46
|
},
|
package/src/utils.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
const {
|
|
7
|
+
const { generateErrorMessage } = require('@lwc/errors');
|
|
8
8
|
const lineColumn = require('line-column');
|
|
9
9
|
|
|
10
|
-
const { LWC_PACKAGE_ALIAS
|
|
10
|
+
const { LWC_PACKAGE_ALIAS } = require('./constants');
|
|
11
11
|
|
|
12
12
|
function isClassMethod(classMethod, properties = {}) {
|
|
13
13
|
const { kind = 'method', name } = properties;
|
|
@@ -51,34 +51,16 @@ function getEngineImportsStatements(path) {
|
|
|
51
51
|
|
|
52
52
|
function getEngineImportSpecifiers(path) {
|
|
53
53
|
const imports = getEngineImportsStatements(path);
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
.reduce((acc, importStatement) => {
|
|
54
|
+
return (
|
|
55
|
+
imports
|
|
57
56
|
// Flat-map the specifier list for each import statement
|
|
58
|
-
|
|
59
|
-
}, [])
|
|
60
|
-
.reduce((acc, specifier) => {
|
|
61
|
-
// Validate engine import specifier
|
|
62
|
-
if (specifier.isImportNamespaceSpecifier()) {
|
|
63
|
-
throw generateError(specifier, {
|
|
64
|
-
errorInfo: LWCClassErrors.INVALID_IMPORT_NAMESPACE_IMPORTS_NOT_ALLOWED,
|
|
65
|
-
messageArgs: [
|
|
66
|
-
LWC_PACKAGE_ALIAS,
|
|
67
|
-
LWC_PACKAGE_EXPORTS.BASE_COMPONENT,
|
|
68
|
-
LWC_PACKAGE_ALIAS,
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
} else if (specifier.isImportDefaultSpecifier()) {
|
|
72
|
-
throw generateError(specifier, {
|
|
73
|
-
errorInfo: LWCClassErrors.INVALID_IMPORT_MISSING_DEFAULT_EXPORT,
|
|
74
|
-
messageArgs: [LWC_PACKAGE_ALIAS],
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
|
|
57
|
+
.flatMap((importStatement) => importStatement.get('specifiers'))
|
|
78
58
|
// Get the list of specifiers with their name
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
59
|
+
.map((specifier) => {
|
|
60
|
+
const imported = specifier.get('imported').node.name;
|
|
61
|
+
return { name: imported, path: specifier };
|
|
62
|
+
})
|
|
63
|
+
);
|
|
82
64
|
}
|
|
83
65
|
|
|
84
66
|
function normalizeFilename(source) {
|