@lwc/babel-plugin-component 2.41.3 → 2.43.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.
Files changed (45) hide show
  1. package/README.md +37 -0
  2. package/dist/index.cjs.js +1145 -0
  3. package/dist/index.cjs.js.map +1 -0
  4. package/dist/index.js +1143 -0
  5. package/dist/index.js.map +1 -0
  6. package/package.json +25 -8
  7. package/types/compiler-version-number.d.ts +3 -0
  8. package/types/component.d.ts +3 -0
  9. package/types/constants.d.ts +26 -0
  10. package/types/decorators/api/index.d.ts +8 -0
  11. package/types/decorators/api/shared.d.ts +3 -0
  12. package/types/decorators/api/transform.d.ts +6 -0
  13. package/types/decorators/api/validate.d.ts +2 -0
  14. package/types/decorators/index.d.ts +21 -0
  15. package/types/decorators/track/index.d.ts +10 -0
  16. package/types/decorators/types.d.ts +20 -0
  17. package/types/decorators/wire/index.d.ts +8 -0
  18. package/types/decorators/wire/shared.d.ts +3 -0
  19. package/types/decorators/wire/transform.d.ts +4 -0
  20. package/types/decorators/wire/validate.d.ts +2 -0
  21. package/types/dedupe-imports.d.ts +4 -0
  22. package/types/dynamic-imports.d.ts +3 -0
  23. package/types/index.d.ts +9 -0
  24. package/types/scope-css-imports.d.ts +3 -0
  25. package/types/types.d.ts +18 -0
  26. package/types/utils.d.ts +21 -0
  27. package/src/compiler-version-number.js +0 -33
  28. package/src/component.js +0 -89
  29. package/src/constants.js +0 -67
  30. package/src/decorators/api/index.js +0 -18
  31. package/src/decorators/api/shared.js +0 -17
  32. package/src/decorators/api/transform.js +0 -95
  33. package/src/decorators/api/validate.js +0 -160
  34. package/src/decorators/index.js +0 -271
  35. package/src/decorators/track/index.js +0 -49
  36. package/src/decorators/wire/index.js +0 -18
  37. package/src/decorators/wire/shared.js +0 -17
  38. package/src/decorators/wire/transform.js +0 -261
  39. package/src/decorators/wire/validate.js +0 -100
  40. package/src/dedupe-imports.js +0 -56
  41. package/src/dynamic-imports.js +0 -70
  42. package/src/index.d.ts +0 -10
  43. package/src/index.js +0 -77
  44. package/src/scope-css-imports.js +0 -23
  45. package/src/utils.js +0 -116
@@ -1,95 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const {
8
- DECORATOR_TYPES,
9
- LWC_COMPONENT_PROPERTIES: { PUBLIC_METHODS, PUBLIC_PROPS },
10
- } = require('../../constants');
11
-
12
- const { isApiDecorator } = require('./shared');
13
-
14
- const PUBLIC_PROP_BIT_MASK = {
15
- PROPERTY: 0,
16
- GETTER: 1,
17
- SETTER: 2,
18
- };
19
-
20
- function getPropertyBitmask(type) {
21
- switch (type) {
22
- case DECORATOR_TYPES.GETTER:
23
- return PUBLIC_PROP_BIT_MASK.GETTER;
24
-
25
- case DECORATOR_TYPES.SETTER:
26
- return PUBLIC_PROP_BIT_MASK.SETTER;
27
-
28
- default:
29
- return PUBLIC_PROP_BIT_MASK.PROPERTY;
30
- }
31
- }
32
-
33
- function getSiblingGetSetPairType(propertyName, type, classBodyItems) {
34
- const siblingKind = type === DECORATOR_TYPES.GETTER ? 'set' : 'get';
35
- const siblingNode = classBodyItems.find((classBodyItem) => {
36
- const isClassMethod = classBodyItem.isClassMethod({ kind: siblingKind });
37
- const isSamePropertyName = classBodyItem.node.key.name === propertyName;
38
- return isClassMethod && isSamePropertyName;
39
- });
40
- if (siblingNode) {
41
- return siblingKind === 'get' ? DECORATOR_TYPES.GETTER : DECORATOR_TYPES.SETTER;
42
- }
43
- }
44
-
45
- function computePublicPropsConfig(publicPropertyMetas, classBodyItems) {
46
- return publicPropertyMetas.reduce((acc, { propertyName, decoratedNodeType }) => {
47
- if (!(propertyName in acc)) {
48
- acc[propertyName] = {};
49
- }
50
- acc[propertyName].config |= getPropertyBitmask(decoratedNodeType);
51
-
52
- if (
53
- decoratedNodeType === DECORATOR_TYPES.GETTER ||
54
- decoratedNodeType === DECORATOR_TYPES.SETTER
55
- ) {
56
- // With the latest decorator spec, only one of the getter/setter pair needs a decorator.
57
- // We need to add the proper bitmask for the sibling getter/setter if it exists.
58
- const pairType = getSiblingGetSetPairType(
59
- propertyName,
60
- decoratedNodeType,
61
- classBodyItems
62
- );
63
- if (pairType) {
64
- acc[propertyName].config |= getPropertyBitmask(pairType);
65
- }
66
- }
67
-
68
- return acc;
69
- }, {});
70
- }
71
-
72
- module.exports = function transform(t, decoratorMetas, classBodyItems) {
73
- const objectProperties = [];
74
- const apiDecoratorMetas = decoratorMetas.filter(isApiDecorator);
75
- const publicPropertyMetas = apiDecoratorMetas.filter(
76
- ({ decoratedNodeType }) => decoratedNodeType !== DECORATOR_TYPES.METHOD
77
- );
78
- if (publicPropertyMetas.length) {
79
- const propsConfig = computePublicPropsConfig(publicPropertyMetas, classBodyItems);
80
- objectProperties.push(
81
- t.objectProperty(t.identifier(PUBLIC_PROPS), t.valueToNode(propsConfig))
82
- );
83
- }
84
-
85
- const publicMethodMetas = apiDecoratorMetas.filter(
86
- ({ decoratedNodeType }) => decoratedNodeType === DECORATOR_TYPES.METHOD
87
- );
88
- if (publicMethodMetas.length) {
89
- const methodNames = publicMethodMetas.map(({ propertyName }) => propertyName);
90
- objectProperties.push(
91
- t.objectProperty(t.identifier(PUBLIC_METHODS), t.valueToNode(methodNames))
92
- );
93
- }
94
- return objectProperties;
95
- };
@@ -1,160 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const { DecoratorErrors } = require('@lwc/errors');
8
-
9
- const { generateError } = require('../../utils');
10
- const {
11
- AMBIGUOUS_PROP_SET,
12
- DISALLOWED_PROP_SET,
13
- LWC_PACKAGE_EXPORTS: { TRACK_DECORATOR },
14
- DECORATOR_TYPES,
15
- } = require('../../constants');
16
-
17
- const { isApiDecorator } = require('./shared');
18
-
19
- function validateConflict(path, decorators) {
20
- const isPublicFieldTracked = decorators.some(
21
- (decorator) =>
22
- decorator.name === TRACK_DECORATOR &&
23
- decorator.path.parentPath.node === path.parentPath.node
24
- );
25
-
26
- if (isPublicFieldTracked) {
27
- throw generateError(path, {
28
- errorInfo: DecoratorErrors.API_AND_TRACK_DECORATOR_CONFLICT,
29
- });
30
- }
31
- }
32
-
33
- function isBooleanPropDefaultTrue(property) {
34
- const propertyValue = property.node.value;
35
- return propertyValue && propertyValue.type === 'BooleanLiteral' && propertyValue.value;
36
- }
37
-
38
- function validatePropertyValue(property) {
39
- if (isBooleanPropDefaultTrue(property)) {
40
- throw generateError(property, {
41
- errorInfo: DecoratorErrors.INVALID_BOOLEAN_PUBLIC_PROPERTY,
42
- });
43
- }
44
- }
45
-
46
- function validatePropertyName(property) {
47
- if (property.node.computed) {
48
- throw generateError(property, {
49
- errorInfo: DecoratorErrors.PROPERTY_CANNOT_BE_COMPUTED,
50
- });
51
- }
52
-
53
- const propertyName = property.get('key.name').node;
54
-
55
- if (propertyName === 'part') {
56
- throw generateError(property, {
57
- errorInfo: DecoratorErrors.PROPERTY_NAME_PART_IS_RESERVED,
58
- messageArgs: [propertyName],
59
- });
60
- } else if (propertyName.startsWith('on')) {
61
- throw generateError(property, {
62
- errorInfo: DecoratorErrors.PROPERTY_NAME_CANNOT_START_WITH_ON,
63
- messageArgs: [propertyName],
64
- });
65
- } else if (propertyName.startsWith('data') && propertyName.length > 4) {
66
- throw generateError(property, {
67
- errorInfo: DecoratorErrors.PROPERTY_NAME_CANNOT_START_WITH_DATA,
68
- messageArgs: [propertyName],
69
- });
70
- } else if (DISALLOWED_PROP_SET.has(propertyName)) {
71
- throw generateError(property, {
72
- errorInfo: DecoratorErrors.PROPERTY_NAME_IS_RESERVED,
73
- messageArgs: [propertyName],
74
- });
75
- } else if (AMBIGUOUS_PROP_SET.has(propertyName)) {
76
- const camelCased = AMBIGUOUS_PROP_SET.get(propertyName);
77
- throw generateError(property, {
78
- errorInfo: DecoratorErrors.PROPERTY_NAME_IS_AMBIGUOUS,
79
- messageArgs: [propertyName, camelCased],
80
- });
81
- }
82
- }
83
-
84
- function validateSingleApiDecoratorOnSetterGetterPair(decorators) {
85
- // keep track of visited class methods
86
- const visitedMethods = new Set();
87
-
88
- decorators.forEach((decorator) => {
89
- const { path, decoratedNodeType } = decorator;
90
-
91
- // since we are validating get/set we only look at @api methods
92
- if (
93
- isApiDecorator(decorator) &&
94
- (decoratedNodeType === DECORATOR_TYPES.GETTER ||
95
- decoratedNodeType === DECORATOR_TYPES.SETTER)
96
- ) {
97
- const methodPath = path.parentPath;
98
- const methodName = methodPath.get('key.name').node;
99
-
100
- if (visitedMethods.has(methodName)) {
101
- throw generateError(methodPath, {
102
- errorInfo: DecoratorErrors.SINGLE_DECORATOR_ON_SETTER_GETTER_PAIR,
103
- messageArgs: [methodName],
104
- });
105
- }
106
-
107
- visitedMethods.add(methodName);
108
- }
109
- });
110
- }
111
-
112
- function validateUniqueness(decorators) {
113
- const apiDecorators = decorators.filter(isApiDecorator);
114
- for (let i = 0; i < apiDecorators.length; i++) {
115
- const { path: currentPath, type: currentType } = apiDecorators[i];
116
- const currentPropertyName = currentPath.parentPath.get('key.name').node;
117
-
118
- for (let j = 0; j < apiDecorators.length; j++) {
119
- const { path: comparePath, type: compareType } = apiDecorators[j];
120
- const comparePropertyName = comparePath.parentPath.get('key.name').node;
121
-
122
- // We will throw if the considered properties have the same name, and when their
123
- // are not part of a pair of getter/setter.
124
- const haveSameName = currentPropertyName === comparePropertyName;
125
- const isDifferentProperty = currentPath !== comparePath;
126
- const isGetterSetterPair =
127
- (currentType === DECORATOR_TYPES.GETTER &&
128
- compareType === DECORATOR_TYPES.SETTER) ||
129
- (currentType === DECORATOR_TYPES.SETTER && compareType === DECORATOR_TYPES.GETTER);
130
-
131
- if (haveSameName && isDifferentProperty && !isGetterSetterPair) {
132
- throw generateError(comparePath, {
133
- errorInfo: DecoratorErrors.DUPLICATE_API_PROPERTY,
134
- messageArgs: [currentPropertyName],
135
- });
136
- }
137
- }
138
- }
139
- }
140
-
141
- module.exports = function validate(decorators) {
142
- const apiDecorators = decorators.filter(isApiDecorator);
143
- if (apiDecorators.length === 0) {
144
- return;
145
- }
146
-
147
- apiDecorators.forEach(({ path, decoratedNodeType }) => {
148
- validateConflict(path, decorators);
149
-
150
- if (decoratedNodeType !== DECORATOR_TYPES.METHOD) {
151
- const property = path.parentPath;
152
-
153
- validatePropertyName(property);
154
- validatePropertyValue(property);
155
- }
156
- });
157
-
158
- validateSingleApiDecoratorOnSetterGetterPair(decorators);
159
- validateUniqueness(decorators);
160
- };
@@ -1,271 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const moduleImports = require('@babel/helper-module-imports');
8
- const { DecoratorErrors } = require('@lwc/errors');
9
-
10
- const { DECORATOR_TYPES, LWC_PACKAGE_ALIAS, REGISTER_DECORATORS_ID } = require('../constants');
11
- const {
12
- generateError,
13
- isClassMethod,
14
- isSetterClassMethod,
15
- isGetterClassMethod,
16
- } = require('../utils');
17
-
18
- const api = require('./api');
19
- const wire = require('./wire');
20
- const track = require('./track');
21
-
22
- const DECORATOR_TRANSFORMS = [api, wire, track];
23
- const AVAILABLE_DECORATORS = DECORATOR_TRANSFORMS.map((transform) => transform.name).join(', ');
24
-
25
- function isLwcDecoratorName(name) {
26
- return DECORATOR_TRANSFORMS.some((transform) => transform.name === name);
27
- }
28
-
29
- /** Returns a list of all the references to an identifier */
30
- function getReferences(identifier) {
31
- return identifier.scope.getBinding(identifier.node.name).referencePaths;
32
- }
33
-
34
- /** Returns the type of decorator depdending on the property or method if get applied to */
35
- function getDecoratedNodeType(decoratorPath) {
36
- const propertyOrMethod = decoratorPath.parentPath;
37
- if (isClassMethod(propertyOrMethod)) {
38
- return DECORATOR_TYPES.METHOD;
39
- } else if (isGetterClassMethod(propertyOrMethod)) {
40
- return DECORATOR_TYPES.GETTER;
41
- } else if (isSetterClassMethod(propertyOrMethod)) {
42
- return DECORATOR_TYPES.SETTER;
43
- } else if (propertyOrMethod.isClassProperty()) {
44
- return DECORATOR_TYPES.PROPERTY;
45
- } else {
46
- throw generateError(propertyOrMethod, {
47
- errorInfo: DecoratorErrors.INVALID_DECORATOR_TYPE,
48
- });
49
- }
50
- }
51
-
52
- function validateImportedLwcDecoratorUsage(engineImportSpecifiers) {
53
- engineImportSpecifiers
54
- .filter(({ name }) => isLwcDecoratorName(name))
55
- .reduce((acc, { name, path }) => {
56
- // Get a list of all the local references
57
- const local = path.get('imported');
58
- const references = getReferences(local).map((reference) => ({
59
- name,
60
- reference,
61
- }));
62
-
63
- return [...acc, ...references];
64
- }, [])
65
- .forEach(({ name, reference }) => {
66
- // Get the decorator from the identifier
67
- // If the the decorator is:
68
- // - an identifier @track : the decorator is the parent of the identifier
69
- // - a call expression @wire("foo") : the decorator is the grand-parent of the identifier
70
- const decorator = reference.parentPath.isDecorator()
71
- ? reference.parentPath
72
- : reference.parentPath.parentPath;
73
-
74
- if (!decorator.isDecorator()) {
75
- throw generateError(decorator, {
76
- errorInfo: DecoratorErrors.IS_NOT_DECORATOR,
77
- messageArgs: [name],
78
- });
79
- }
80
-
81
- const propertyOrMethod = decorator.parentPath;
82
- if (!propertyOrMethod.isClassProperty() && !propertyOrMethod.isClassMethod()) {
83
- throw generateError(propertyOrMethod, {
84
- errorInfo: DecoratorErrors.IS_NOT_CLASS_PROPERTY_OR_CLASS_METHOD,
85
- messageArgs: [name],
86
- });
87
- }
88
- });
89
- }
90
-
91
- function isImportedFromLwcSource(decoratorBinding) {
92
- const bindingPath = decoratorBinding.path;
93
- return bindingPath.isImportSpecifier() && bindingPath.parent.source.value === 'lwc';
94
- }
95
-
96
- /** Validate the usage of decorator by calling each validation function */
97
- function validate(decorators) {
98
- for (const { name, path } of decorators) {
99
- const binding = path.scope.getBinding(name);
100
- if (binding === undefined || !isImportedFromLwcSource(binding)) {
101
- throw generateInvalidDecoratorError(path);
102
- }
103
- }
104
- DECORATOR_TRANSFORMS.forEach(({ validate }) => validate(decorators));
105
- }
106
-
107
- /** Remove import specifiers. It also removes the import statement if the specifier list becomes empty */
108
- function removeImportedDecoratorSpecifiers(engineImportSpecifiers) {
109
- engineImportSpecifiers
110
- .filter(({ name }) => isLwcDecoratorName(name))
111
- .forEach(({ path }) => {
112
- const importStatement = path.parentPath;
113
- path.remove();
114
- if (importStatement.get('specifiers').length === 0) {
115
- importStatement.remove();
116
- }
117
- });
118
- }
119
-
120
- function generateInvalidDecoratorError(path) {
121
- const expressionPath = path.get('expression');
122
- const { node } = path;
123
- const { expression } = node;
124
-
125
- let name;
126
- if (expressionPath.isIdentifier()) {
127
- name = expression.name;
128
- } else if (expressionPath.isCallExpression()) {
129
- name = expression.callee.name;
130
- }
131
-
132
- if (name) {
133
- return generateError(path.parentPath, {
134
- errorInfo: DecoratorErrors.INVALID_DECORATOR_WITH_NAME,
135
- messageArgs: [name, AVAILABLE_DECORATORS, LWC_PACKAGE_ALIAS],
136
- });
137
- } else {
138
- return generateError(path.parentPath, {
139
- errorInfo: DecoratorErrors.INVALID_DECORATOR,
140
- messageArgs: [AVAILABLE_DECORATORS, LWC_PACKAGE_ALIAS],
141
- });
142
- }
143
- }
144
-
145
- function collectDecoratorPaths(bodyItems) {
146
- return bodyItems.reduce((acc, bodyItem) => {
147
- const decorators = bodyItem.get('decorators');
148
- if (decorators && decorators.length) {
149
- acc.push(...decorators);
150
- }
151
- return acc;
152
- }, []);
153
- }
154
-
155
- function getDecoratorMetadata(decoratorPath) {
156
- const expressionPath = decoratorPath.get('expression');
157
-
158
- let name;
159
- if (expressionPath.isIdentifier()) {
160
- name = expressionPath.node.name;
161
- } else if (expressionPath.isCallExpression()) {
162
- name = expressionPath.node.callee.name;
163
- } else {
164
- throw generateInvalidDecoratorError(decoratorPath);
165
- }
166
-
167
- const propertyName = decoratorPath.parent.key.name;
168
- const decoratedNodeType = getDecoratedNodeType(decoratorPath);
169
-
170
- return {
171
- name,
172
- propertyName,
173
- path: decoratorPath,
174
- decoratedNodeType,
175
- };
176
- }
177
-
178
- function getMetadataObjectPropertyList(t, decoratorMetas, classBodyItems) {
179
- const list = [
180
- ...api.transform(t, decoratorMetas, classBodyItems),
181
- ...track.transform(t, decoratorMetas),
182
- ...wire.transform(t, decoratorMetas),
183
- ];
184
-
185
- const fieldNames = classBodyItems
186
- .filter((field) => field.isClassProperty({ computed: false, static: false }))
187
- .filter((field) => !field.node.decorators)
188
- .map((field) => field.node.key.name);
189
- if (fieldNames.length) {
190
- list.push(t.objectProperty(t.identifier('fields'), t.valueToNode(fieldNames)));
191
- }
192
-
193
- return list;
194
- }
195
-
196
- function decorators({ types: t }) {
197
- function createRegisterDecoratorsCallExpression(path, classExpression, props) {
198
- const id = moduleImports.addNamed(path, REGISTER_DECORATORS_ID, LWC_PACKAGE_ALIAS);
199
- return t.callExpression(id, [classExpression, t.objectExpression(props)]);
200
- }
201
-
202
- // Babel reinvokes visitors for node reinsertion so we use this to avoid an infinite loop.
203
- const visitedClasses = new WeakSet();
204
-
205
- return {
206
- Class(path) {
207
- const { node } = path;
208
-
209
- if (visitedClasses.has(node)) {
210
- return;
211
- }
212
- visitedClasses.add(node);
213
-
214
- const classBodyItems = path.get('body.body');
215
- if (classBodyItems.length === 0) {
216
- return;
217
- }
218
-
219
- const decoratorPaths = collectDecoratorPaths(classBodyItems);
220
- const decoratorMetas = decoratorPaths.map(getDecoratorMetadata);
221
-
222
- validate(decoratorMetas);
223
-
224
- const metaPropertyList = getMetadataObjectPropertyList(
225
- t,
226
- decoratorMetas,
227
- classBodyItems
228
- );
229
- if (metaPropertyList.length === 0) {
230
- return;
231
- }
232
-
233
- decoratorPaths.forEach((path) => path.remove());
234
-
235
- const isAnonymousClassDeclaration =
236
- path.isClassDeclaration() && !path.get('id').isIdentifier();
237
- const shouldTransformAsClassExpression =
238
- path.isClassExpression() || isAnonymousClassDeclaration;
239
-
240
- if (shouldTransformAsClassExpression) {
241
- // Example:
242
- // export default class extends LightningElement {}
243
- // Output:
244
- // export default registerDecorators(class extends LightningElement {});
245
- // if it does not have an id, we can treat it as a ClassExpression
246
- const classExpression = t.toExpression(node);
247
- path.replaceWith(
248
- createRegisterDecoratorsCallExpression(path, classExpression, metaPropertyList)
249
- );
250
- } else {
251
- // Example: export default class NamedClass extends LightningElement {}
252
- // Output:
253
- // export default class NamedClass extends LightningElement {}
254
- // registerDecorators(NamedClass);
255
- // Note: This will be further transformed
256
- const statementPath = path.getStatementParent();
257
- statementPath.insertAfter(
258
- t.expressionStatement(
259
- createRegisterDecoratorsCallExpression(path, node.id, metaPropertyList)
260
- )
261
- );
262
- }
263
- },
264
- };
265
- }
266
-
267
- module.exports = {
268
- decorators,
269
- removeImportedDecoratorSpecifiers,
270
- validateImportedLwcDecoratorUsage,
271
- };
@@ -1,49 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const { DecoratorErrors } = require('@lwc/errors');
8
- const {
9
- LWC_COMPONENT_PROPERTIES,
10
- LWC_PACKAGE_EXPORTS: { TRACK_DECORATOR },
11
- } = require('../../constants');
12
- const { generateError } = require('../../utils');
13
-
14
- const TRACK_PROPERTY_VALUE = 1;
15
-
16
- function isTrackDecorator(decorator) {
17
- return decorator.name === TRACK_DECORATOR;
18
- }
19
-
20
- function validate(decorators) {
21
- decorators.filter(isTrackDecorator).forEach(({ path }) => {
22
- if (!path.parentPath.isClassProperty()) {
23
- throw generateError(path, {
24
- errorInfo: DecoratorErrors.TRACK_ONLY_ALLOWED_ON_CLASS_PROPERTIES,
25
- });
26
- }
27
- });
28
- }
29
-
30
- function transform(t, decoratorMetas) {
31
- const objectProperties = [];
32
- const trackDecoratorMetas = decoratorMetas.filter(isTrackDecorator);
33
- if (trackDecoratorMetas.length) {
34
- const config = trackDecoratorMetas.reduce((acc, meta) => {
35
- acc[meta.propertyName] = TRACK_PROPERTY_VALUE;
36
- return acc;
37
- }, {});
38
- objectProperties.push(
39
- t.objectProperty(t.identifier(LWC_COMPONENT_PROPERTIES.TRACK), t.valueToNode(config))
40
- );
41
- }
42
- return objectProperties;
43
- }
44
-
45
- module.exports = {
46
- name: TRACK_DECORATOR,
47
- transform,
48
- validate,
49
- };
@@ -1,18 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const {
8
- LWC_PACKAGE_EXPORTS: { WIRE_DECORATOR },
9
- } = require('../../constants');
10
-
11
- const validate = require('./validate');
12
- const transform = require('./transform');
13
-
14
- module.exports = {
15
- name: WIRE_DECORATOR,
16
- validate,
17
- transform,
18
- };
@@ -1,17 +0,0 @@
1
- /*
2
- * Copyright (c) 2018, salesforce.com, inc.
3
- * All rights reserved.
4
- * SPDX-License-Identifier: MIT
5
- * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6
- */
7
- const {
8
- LWC_PACKAGE_EXPORTS: { WIRE_DECORATOR },
9
- } = require('../../constants');
10
-
11
- function isWireDecorator(decorator) {
12
- return decorator.name === WIRE_DECORATOR;
13
- }
14
-
15
- module.exports = {
16
- isWireDecorator,
17
- };