@lwc/ssr-compiler 8.13.1-alpha.0 → 8.13.2
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/compile-js/decorators/api/index.d.ts +7 -0
- package/dist/compile-js/decorators/api/validate.d.ts +12 -0
- package/dist/compile-js/decorators/index.d.ts +3 -0
- package/dist/compile-js/decorators/track.d.ts +7 -0
- package/dist/compile-js/decorators/wire.d.ts +13 -0
- package/dist/compile-js/errors.d.ts +2 -2
- package/dist/compile-js/types.d.ts +5 -3
- package/dist/index.cjs.js +192 -97
- package/dist/index.js +191 -96
- package/package.json +7 -7
- package/dist/compile-js/wire.d.ts +0 -6
- package/dist/compile-template/comment.d.ts +0 -3
- package/dist/compile-template/component.d.ts +0 -3
- package/dist/compile-template/element.d.ts +0 -3
- package/dist/compile-template/for-each.d.ts +0 -3
- package/dist/compile-template/if.d.ts +0 -4
- package/dist/compile-template/text.d.ts +0 -3
- package/dist/compile-template/transformers/component.d.ts +0 -3
- package/dist/compile-template/transformers/if.d.ts +0 -4
- package/dist/compile-template/transformers/lwc-component.d.ts +0 -3
- package/dist/optimize-imports.d.ts +0 -8
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ComponentMetaState } from '../../types';
|
|
2
|
+
import type { Identifier, MethodDefinition, PropertyDefinition } from 'estree';
|
|
3
|
+
export type ApiMethodDefinition = MethodDefinition & {
|
|
4
|
+
key: Identifier;
|
|
5
|
+
};
|
|
6
|
+
export type ApiPropertyDefinition = PropertyDefinition & {
|
|
7
|
+
key: Identifier;
|
|
8
|
+
};
|
|
9
|
+
export type ApiDefinition = ApiPropertyDefinition | ApiMethodDefinition;
|
|
10
|
+
export declare function validateApiProperty(node: ApiPropertyDefinition, state: ComponentMetaState): void;
|
|
11
|
+
export declare function validateApiMethod(node: ApiMethodDefinition, state: ComponentMetaState): void;
|
|
12
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { NodePath } from 'estree-toolkit';
|
|
2
|
+
import type { PropertyDefinition, MethodDefinition, Identifier, BlockStatement, Decorator, CallExpression } from 'estree';
|
|
3
|
+
import type { ComponentMetaState, WireAdapter } from '../types';
|
|
4
|
+
export declare function catalogWireAdapters(path: NodePath<PropertyDefinition | MethodDefinition>, state: ComponentMetaState): void;
|
|
5
|
+
export declare function bWireAdaptersPlumbing(adapters: WireAdapter[]): BlockStatement[];
|
|
6
|
+
export declare function isWireDecorator(decorator: Decorator | undefined): decorator is Decorator & {
|
|
7
|
+
expression: CallExpression & {
|
|
8
|
+
callee: Identifier & {
|
|
9
|
+
name: 'wire';
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type LWCErrorInfo } from '@lwc/errors';
|
|
2
|
-
import type {
|
|
2
|
+
import type { BaseNodeWithoutComments } from 'estree';
|
|
3
3
|
type ExtractArguments<T extends string, Numbers extends number = never, Args extends string[] = []> = T extends `${string}{${infer N extends number}}${infer R}` ? N extends Numbers ? ExtractArguments<R, Numbers, Args> : ExtractArguments<R, N | Numbers, [string, ...Args]> : Args;
|
|
4
|
-
export declare function generateError<const T extends LWCErrorInfo>(node:
|
|
4
|
+
export declare function generateError<const T extends LWCErrorInfo>(node: BaseNodeWithoutComments, error: T, ...messageArgs: ExtractArguments<T['message']>): import("@lwc/errors").CompilerError;
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { type traverse } from 'estree-toolkit';
|
|
1
2
|
import type { ImportManager } from '../imports';
|
|
2
3
|
import type { ComponentTransformOptions } from '../shared';
|
|
3
|
-
import type { traverse } from 'estree-toolkit';
|
|
4
4
|
import type { Identifier, MemberExpression, MethodDefinition, Node, ObjectExpression, PropertyDefinition } from 'estree';
|
|
5
5
|
export type Visitors = Parameters<typeof traverse<Node, ComponentMetaState>>[1];
|
|
6
6
|
export interface WireAdapter {
|
|
@@ -20,8 +20,10 @@ export interface ComponentMetaState {
|
|
|
20
20
|
tmplExplicitImports: Map<string, string> | null;
|
|
21
21
|
cssExplicitImports: Map<string, string> | null;
|
|
22
22
|
staticStylesheetIds: Set<string> | null;
|
|
23
|
-
publicProperties:
|
|
24
|
-
|
|
23
|
+
publicProperties: Map<string, (MethodDefinition | PropertyDefinition) & {
|
|
24
|
+
key: Identifier;
|
|
25
|
+
}>;
|
|
26
|
+
privateProperties: Set<string>;
|
|
25
27
|
wireAdapters: WireAdapter[];
|
|
26
28
|
experimentalDynamicComponent: ComponentTransformOptions['experimentalDynamicComponent'];
|
|
27
29
|
importManager: ImportManager;
|
package/dist/index.cjs.js
CHANGED
|
@@ -9,10 +9,10 @@ var shared = require('@lwc/shared');
|
|
|
9
9
|
var astring = require('astring');
|
|
10
10
|
var estreeToolkit = require('estree-toolkit');
|
|
11
11
|
var meriyah = require('meriyah');
|
|
12
|
-
var errors = require('@lwc/errors');
|
|
13
12
|
var immer = require('immer');
|
|
14
13
|
var node_path = require('node:path');
|
|
15
14
|
var acorn = require('acorn');
|
|
15
|
+
var errors = require('@lwc/errors');
|
|
16
16
|
var templateCompiler = require('@lwc/template-compiler');
|
|
17
17
|
var builders = require('estree-toolkit/dist/builders');
|
|
18
18
|
var types = require('@babel/types');
|
|
@@ -729,6 +729,11 @@ function bWireAdaptersPlumbing(adapters) {
|
|
|
729
729
|
return bWireAdapterPlumbing(adapterId, actionUponNewValue, config);
|
|
730
730
|
});
|
|
731
731
|
}
|
|
732
|
+
function isWireDecorator(decorator) {
|
|
733
|
+
return (estreeToolkit.is.callExpression(decorator?.expression) &&
|
|
734
|
+
estreeToolkit.is.identifier(decorator.expression.callee) &&
|
|
735
|
+
decorator.expression.callee.name === 'wire');
|
|
736
|
+
}
|
|
732
737
|
|
|
733
738
|
/*
|
|
734
739
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
@@ -742,7 +747,14 @@ const bGenerateMarkup = (esTemplate `
|
|
|
742
747
|
const __lwcPublicProperties__ = new Set(${ /*public properties*/estreeToolkit.is.arrayExpression}.concat(__lwcSuperPublicProperties__));
|
|
743
748
|
const __lwcPrivateProperties__ = new Set(${ /*private properties*/estreeToolkit.is.arrayExpression});
|
|
744
749
|
|
|
745
|
-
|
|
750
|
+
Object.defineProperty(
|
|
751
|
+
${ /* component class */0},
|
|
752
|
+
__SYMBOL__GENERATE_MARKUP,
|
|
753
|
+
{
|
|
754
|
+
configurable: false,
|
|
755
|
+
enumerable: false,
|
|
756
|
+
writable: false,
|
|
757
|
+
value: async function* generateMarkup(
|
|
746
758
|
tagName,
|
|
747
759
|
props,
|
|
748
760
|
attrs,
|
|
@@ -752,56 +764,75 @@ const bGenerateMarkup = (esTemplate `
|
|
|
752
764
|
parent,
|
|
753
765
|
scopeToken,
|
|
754
766
|
contextfulParent
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
767
|
+
) {
|
|
768
|
+
tagName = tagName ?? ${ /*component tag name*/estreeToolkit.is.literal};
|
|
769
|
+
attrs = attrs ?? Object.create(null);
|
|
770
|
+
props = props ?? Object.create(null);
|
|
771
|
+
const instance = new ${ /* Component class */0}({
|
|
772
|
+
tagName: tagName.toUpperCase(),
|
|
773
|
+
});
|
|
774
|
+
|
|
775
|
+
__establishContextfulRelationship(contextfulParent, instance);
|
|
776
|
+
${ /*connect wire*/estreeToolkit.is.statement}
|
|
777
|
+
|
|
778
|
+
instance[__SYMBOL__SET_INTERNALS](
|
|
779
|
+
props,
|
|
780
|
+
attrs,
|
|
781
|
+
__lwcPublicProperties__,
|
|
782
|
+
__lwcPrivateProperties__,
|
|
783
|
+
);
|
|
784
|
+
instance.isConnected = true;
|
|
785
|
+
if (instance.connectedCallback) {
|
|
786
|
+
__mutationTracker.enable(instance);
|
|
787
|
+
instance.connectedCallback();
|
|
788
|
+
__mutationTracker.disable(instance);
|
|
789
|
+
}
|
|
790
|
+
// If a render() function is defined on the class or any of its superclasses, then that takes priority.
|
|
791
|
+
// Next, if the class or any of its superclasses has an implicitly-associated template, then that takes
|
|
792
|
+
// second priority (e.g. a foo.html file alongside a foo.js file). Finally, there is a fallback empty template.
|
|
793
|
+
const tmplFn = instance.render?.() ?? ${ /*component class*/0}[__SYMBOL__DEFAULT_TEMPLATE] ?? __fallbackTmpl;
|
|
794
|
+
yield \`<\${tagName}\`;
|
|
795
|
+
|
|
796
|
+
const hostHasScopedStylesheets =
|
|
797
|
+
tmplFn.hasScopedStylesheets ||
|
|
798
|
+
hasScopedStaticStylesheets(${ /*component class*/0});
|
|
799
|
+
const hostScopeToken = hostHasScopedStylesheets ? tmplFn.stylesheetScopeToken + "-host" : undefined;
|
|
800
|
+
|
|
801
|
+
yield* __renderAttrs(instance, attrs, hostScopeToken, scopeToken);
|
|
802
|
+
yield '>';
|
|
803
|
+
yield* tmplFn(
|
|
804
|
+
shadowSlottedContent,
|
|
805
|
+
lightSlottedContent,
|
|
806
|
+
scopedSlottedContent,
|
|
807
|
+
${ /*component class*/0},
|
|
808
|
+
instance
|
|
809
|
+
);
|
|
810
|
+
yield \`</\${tagName}>\`;
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
Object.defineProperty(
|
|
814
|
+
${ /* component class */0},
|
|
815
|
+
'__lwcPublicProperties__',
|
|
816
|
+
{
|
|
817
|
+
configurable: false,
|
|
818
|
+
enumerable: false,
|
|
819
|
+
writable: false,
|
|
820
|
+
value: __lwcPublicProperties__
|
|
821
|
+
}
|
|
822
|
+
);
|
|
801
823
|
`);
|
|
802
824
|
const bExposeTemplate = (esTemplate `
|
|
803
825
|
if (${ /*template*/estreeToolkit.is.identifier}) {
|
|
804
|
-
|
|
826
|
+
Object.defineProperty(
|
|
827
|
+
${ /* component class */estreeToolkit.is.identifier},
|
|
828
|
+
__SYMBOL__DEFAULT_TEMPLATE,
|
|
829
|
+
{
|
|
830
|
+
configurable: false,
|
|
831
|
+
enumerable: false,
|
|
832
|
+
writable: false,
|
|
833
|
+
value: ${ /*template*/0}
|
|
834
|
+
}
|
|
835
|
+
);
|
|
805
836
|
}
|
|
806
837
|
`);
|
|
807
838
|
/**
|
|
@@ -847,12 +878,72 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
847
878
|
SYMBOL__SET_INTERNALS: '__SYMBOL__SET_INTERNALS',
|
|
848
879
|
establishContextfulRelationship: '__establishContextfulRelationship',
|
|
849
880
|
}));
|
|
850
|
-
program.body.push(...bGenerateMarkup(classIdentifier, estreeToolkit.builders.arrayExpression(publicProperties.map(estreeToolkit.builders.literal)), estreeToolkit.builders.arrayExpression(privateProperties.map(estreeToolkit.builders.literal)), defaultTagName, connectWireAdapterCode));
|
|
881
|
+
program.body.push(...bGenerateMarkup(classIdentifier, estreeToolkit.builders.arrayExpression([...publicProperties.keys()].map(estreeToolkit.builders.literal)), estreeToolkit.builders.arrayExpression([...privateProperties].map(estreeToolkit.builders.literal)), defaultTagName, connectWireAdapterCode));
|
|
851
882
|
if (exposeTemplateBlock) {
|
|
852
883
|
program.body.push(exposeTemplateBlock);
|
|
853
884
|
}
|
|
854
885
|
}
|
|
855
886
|
|
|
887
|
+
/*
|
|
888
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
889
|
+
* All rights reserved.
|
|
890
|
+
* SPDX-License-Identifier: MIT
|
|
891
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
892
|
+
*/
|
|
893
|
+
function validateName(definition) {
|
|
894
|
+
if (definition.computed) {
|
|
895
|
+
throw generateError(definition, errors.DecoratorErrors.PROPERTY_CANNOT_BE_COMPUTED);
|
|
896
|
+
}
|
|
897
|
+
const propertyName = definition.key.name;
|
|
898
|
+
switch (true) {
|
|
899
|
+
case propertyName === 'part':
|
|
900
|
+
throw generateError(definition, errors.DecoratorErrors.PROPERTY_NAME_PART_IS_RESERVED, propertyName);
|
|
901
|
+
case propertyName.startsWith('on'):
|
|
902
|
+
throw generateError(definition, errors.DecoratorErrors.PROPERTY_NAME_CANNOT_START_WITH_ON, propertyName);
|
|
903
|
+
case propertyName.startsWith('data') && propertyName.length > 4:
|
|
904
|
+
throw generateError(definition, errors.DecoratorErrors.PROPERTY_NAME_CANNOT_START_WITH_DATA, propertyName);
|
|
905
|
+
case shared.DISALLOWED_PROP_SET.has(propertyName):
|
|
906
|
+
throw generateError(definition, errors.DecoratorErrors.PROPERTY_NAME_IS_RESERVED, propertyName);
|
|
907
|
+
case shared.AMBIGUOUS_PROP_SET.has(propertyName):
|
|
908
|
+
throw generateError(definition, errors.DecoratorErrors.PROPERTY_NAME_IS_AMBIGUOUS, propertyName, shared.AMBIGUOUS_PROP_SET.get(propertyName));
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
function validatePropertyValue(property) {
|
|
912
|
+
if (estreeToolkit.is.literal(property.value) && property.value.value === true) {
|
|
913
|
+
throw generateError(property, errors.DecoratorErrors.INVALID_BOOLEAN_PUBLIC_PROPERTY);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
function validatePropertyUnique(node, state) {
|
|
917
|
+
if (state.publicProperties.has(node.key.name)) {
|
|
918
|
+
throw generateError(node, errors.DecoratorErrors.DUPLICATE_API_PROPERTY, node.key.name);
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
function validateApiProperty(node, state) {
|
|
922
|
+
validatePropertyUnique(node, state);
|
|
923
|
+
validateName(node);
|
|
924
|
+
validatePropertyValue(node);
|
|
925
|
+
}
|
|
926
|
+
function validateUniqueMethod(node, state) {
|
|
927
|
+
const field = state.publicProperties.get(node.key.name);
|
|
928
|
+
if (!field) {
|
|
929
|
+
return;
|
|
930
|
+
}
|
|
931
|
+
if (field.type === 'MethodDefinition' &&
|
|
932
|
+
(field.kind === 'get' || field.kind === 'set') &&
|
|
933
|
+
(node.kind === 'get' || node.kind === 'set')) {
|
|
934
|
+
throw generateError(node, errors.DecoratorErrors.SINGLE_DECORATOR_ON_SETTER_GETTER_PAIR, node.key.name);
|
|
935
|
+
}
|
|
936
|
+
throw generateError(node, errors.DecoratorErrors.DUPLICATE_API_PROPERTY, node.key.name);
|
|
937
|
+
}
|
|
938
|
+
function validateApiMethod(node, state) {
|
|
939
|
+
validateUniqueMethod(node, state);
|
|
940
|
+
validateName(node);
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
function isApiDecorator(decorator) {
|
|
944
|
+
return decorator?.expression.type === 'Identifier' && decorator.expression.name === 'api';
|
|
945
|
+
}
|
|
946
|
+
|
|
856
947
|
/*
|
|
857
948
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
858
949
|
* All rights reserved.
|
|
@@ -872,6 +963,36 @@ function removeDecoratorImport(path) {
|
|
|
872
963
|
}
|
|
873
964
|
}
|
|
874
965
|
|
|
966
|
+
function isTrackDecorator(decorator) {
|
|
967
|
+
return decorator?.expression.type === 'Identifier' && decorator.expression.name === 'track';
|
|
968
|
+
}
|
|
969
|
+
|
|
970
|
+
/*
|
|
971
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
972
|
+
* All rights reserved.
|
|
973
|
+
* SPDX-License-Identifier: MIT
|
|
974
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
975
|
+
*/
|
|
976
|
+
function validateUniqueDecorator(decorators) {
|
|
977
|
+
if (decorators.length < 2) {
|
|
978
|
+
return;
|
|
979
|
+
}
|
|
980
|
+
const wire = decorators.find(isWireDecorator);
|
|
981
|
+
const api = decorators.find(isApiDecorator);
|
|
982
|
+
const track = decorators.find(isTrackDecorator);
|
|
983
|
+
if (wire) {
|
|
984
|
+
if (api) {
|
|
985
|
+
throw generateError(wire, errors.DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'api');
|
|
986
|
+
}
|
|
987
|
+
if (track) {
|
|
988
|
+
throw generateError(wire, errors.DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'track');
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
if (api && track) {
|
|
992
|
+
throw generateError(api, errors.DecoratorErrors.API_AND_TRACK_DECORATOR_CONFLICT);
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
875
996
|
/*
|
|
876
997
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
877
998
|
* All rights reserved.
|
|
@@ -957,27 +1078,21 @@ const visitors = {
|
|
|
957
1078
|
// Seems to occur for `@wire() [symbol];` -- not sure why
|
|
958
1079
|
throw new Error('Unknown state: property definition has no key');
|
|
959
1080
|
}
|
|
960
|
-
if (!
|
|
1081
|
+
if (!isKeyIdentifier(node)) {
|
|
961
1082
|
return;
|
|
962
1083
|
}
|
|
963
1084
|
const { decorators } = node;
|
|
964
1085
|
validateUniqueDecorator(decorators);
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
state.publicProperties.
|
|
1086
|
+
if (isApiDecorator(decorators[0])) {
|
|
1087
|
+
validateApiProperty(node, state);
|
|
1088
|
+
state.publicProperties.set(node.key.name, node);
|
|
968
1089
|
}
|
|
969
|
-
else if (
|
|
970
|
-
estreeToolkit.is.identifier(decoratedExpression.callee) &&
|
|
971
|
-
decoratedExpression.callee.name === 'wire') {
|
|
972
|
-
if (node.computed) {
|
|
973
|
-
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
|
|
974
|
-
throw new Error('@wire cannot be used on computed properties in SSR context.');
|
|
975
|
-
}
|
|
1090
|
+
else if (isWireDecorator(decorators[0])) {
|
|
976
1091
|
catalogWireAdapters(path, state);
|
|
977
|
-
state.privateProperties.
|
|
1092
|
+
state.privateProperties.add(node.key.name);
|
|
978
1093
|
}
|
|
979
1094
|
else {
|
|
980
|
-
state.privateProperties.
|
|
1095
|
+
state.privateProperties.add(node.key.name);
|
|
981
1096
|
}
|
|
982
1097
|
if (node.static &&
|
|
983
1098
|
node.key.name === 'stylesheets' &&
|
|
@@ -988,7 +1103,7 @@ const visitors = {
|
|
|
988
1103
|
},
|
|
989
1104
|
MethodDefinition(path, state) {
|
|
990
1105
|
const node = path.node;
|
|
991
|
-
if (!
|
|
1106
|
+
if (!isKeyIdentifier(node)) {
|
|
992
1107
|
return;
|
|
993
1108
|
}
|
|
994
1109
|
// If we mutate any class-methods that are piped through this compiler, then we'll be
|
|
@@ -998,17 +1113,16 @@ const visitors = {
|
|
|
998
1113
|
}
|
|
999
1114
|
const { decorators } = node;
|
|
1000
1115
|
validateUniqueDecorator(decorators);
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
// not a getter/setter
|
|
1007
|
-
const isRealMethod = node.kind === 'method';
|
|
1116
|
+
if (isApiDecorator(decorators[0])) {
|
|
1117
|
+
validateApiMethod(node, state);
|
|
1118
|
+
state.publicProperties.set(node.key.name, node);
|
|
1119
|
+
}
|
|
1120
|
+
else if (isWireDecorator(decorators[0])) {
|
|
1008
1121
|
if (node.computed) {
|
|
1009
1122
|
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
|
|
1010
|
-
throw new Error(
|
|
1123
|
+
throw new Error('@wire cannot be used on computed properties in SSR context.');
|
|
1011
1124
|
}
|
|
1125
|
+
const isRealMethod = node.kind === 'method';
|
|
1012
1126
|
// Getters and setters are methods in the AST, but treated as properties by @wire
|
|
1013
1127
|
// Note that this means that their implementations are ignored!
|
|
1014
1128
|
if (!isRealMethod) {
|
|
@@ -1024,13 +1138,6 @@ const visitors = {
|
|
|
1024
1138
|
catalogWireAdapters(path, state);
|
|
1025
1139
|
}
|
|
1026
1140
|
}
|
|
1027
|
-
else if (estreeToolkit.is.identifier(decoratedExpression) && decoratedExpression.name === 'api') {
|
|
1028
|
-
if (state.publicProperties.includes(node.key.name)) {
|
|
1029
|
-
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
|
|
1030
|
-
throw new Error(`LWC1112: @api get ${node.key.name} and @api set ${node.key.name} detected in class declaration. Only one of the two needs to be decorated with @api.`);
|
|
1031
|
-
}
|
|
1032
|
-
state.publicProperties.push(node.key.name);
|
|
1033
|
-
}
|
|
1034
1141
|
switch (node.key.name) {
|
|
1035
1142
|
case 'constructor':
|
|
1036
1143
|
// add our own custom arg after any pre-existing constructor args
|
|
@@ -1092,21 +1199,6 @@ const visitors = {
|
|
|
1092
1199
|
}
|
|
1093
1200
|
},
|
|
1094
1201
|
};
|
|
1095
|
-
function validateUniqueDecorator(decorators) {
|
|
1096
|
-
if (decorators.length < 2) {
|
|
1097
|
-
return;
|
|
1098
|
-
}
|
|
1099
|
-
const expressions = decorators.map(({ expression }) => expression);
|
|
1100
|
-
const wire = expressions.find((expr) => estreeToolkit.is.callExpression(expr) && estreeToolkit.is.identifier(expr.callee, { name: 'wire' }));
|
|
1101
|
-
const api = expressions.find((expr) => estreeToolkit.is.identifier(expr, { name: 'api' }));
|
|
1102
|
-
if (wire && api) {
|
|
1103
|
-
throw generateError(wire, errors.DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'api');
|
|
1104
|
-
}
|
|
1105
|
-
const track = expressions.find((expr) => estreeToolkit.is.identifier(expr, { name: 'track' }));
|
|
1106
|
-
if (wire && track) {
|
|
1107
|
-
throw generateError(wire, errors.DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'track');
|
|
1108
|
-
}
|
|
1109
|
-
}
|
|
1110
1202
|
function compileJS(src, filename, tagName, options, compilationMode) {
|
|
1111
1203
|
let ast = meriyah.parseModule(src, {
|
|
1112
1204
|
module: true,
|
|
@@ -1127,8 +1219,8 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1127
1219
|
tmplExplicitImports: null,
|
|
1128
1220
|
cssExplicitImports: null,
|
|
1129
1221
|
staticStylesheetIds: null,
|
|
1130
|
-
publicProperties:
|
|
1131
|
-
privateProperties:
|
|
1222
|
+
publicProperties: new Map(),
|
|
1223
|
+
privateProperties: new Set(),
|
|
1132
1224
|
wireAdapters: [],
|
|
1133
1225
|
experimentalDynamicComponent: options.experimentalDynamicComponent,
|
|
1134
1226
|
importManager: new ImportManager(),
|
|
@@ -1154,6 +1246,9 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1154
1246
|
}),
|
|
1155
1247
|
};
|
|
1156
1248
|
}
|
|
1249
|
+
function isKeyIdentifier(node) {
|
|
1250
|
+
return estreeToolkit.is.identifier(node?.key);
|
|
1251
|
+
}
|
|
1157
1252
|
|
|
1158
1253
|
/*
|
|
1159
1254
|
* Copyright (c) 2024, Salesforce, Inc.
|
|
@@ -2459,5 +2554,5 @@ function compileTemplateForSSR(src, filename, options, mode = shared.DEFAULT_SSR
|
|
|
2459
2554
|
|
|
2460
2555
|
exports.compileComponentForSSR = compileComponentForSSR;
|
|
2461
2556
|
exports.compileTemplateForSSR = compileTemplateForSSR;
|
|
2462
|
-
/** version: 8.13.
|
|
2557
|
+
/** version: 8.13.2 */
|
|
2463
2558
|
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Copyright (c) 2025 Salesforce, Inc.
|
|
3
3
|
*/
|
|
4
|
-
import { LWC_VERSION_COMMENT, normalizeStyleAttributeValue, StringReplace, StringTrim, entries, isUndefined, HTML_NAMESPACE, isVoidElement, isBooleanAttribute, DEFAULT_SSR_MODE, generateCustomElementTagName } from '@lwc/shared';
|
|
4
|
+
import { AMBIGUOUS_PROP_SET, DISALLOWED_PROP_SET, LWC_VERSION_COMMENT, normalizeStyleAttributeValue, StringReplace, StringTrim, entries, isUndefined, HTML_NAMESPACE, isVoidElement, isBooleanAttribute, DEFAULT_SSR_MODE, generateCustomElementTagName } from '@lwc/shared';
|
|
5
5
|
import { generate } from 'astring';
|
|
6
6
|
import { builders, traverse, is } from 'estree-toolkit';
|
|
7
7
|
import { parseModule } from 'meriyah';
|
|
8
|
-
import { generateCompilerError, DecoratorErrors } from '@lwc/errors';
|
|
9
8
|
import { produce } from 'immer';
|
|
10
9
|
import { parse as parse$1 } from 'node:path';
|
|
11
10
|
import { parse } from 'acorn';
|
|
11
|
+
import { generateCompilerError, DecoratorErrors } from '@lwc/errors';
|
|
12
12
|
import { generateScopeTokens, toPropertyName, kebabcaseToCamelcase, parse as parse$2 } from '@lwc/template-compiler';
|
|
13
13
|
import { builders as builders$1 } from 'estree-toolkit/dist/builders';
|
|
14
14
|
import { isValidES3Identifier } from '@babel/types';
|
|
@@ -725,6 +725,11 @@ function bWireAdaptersPlumbing(adapters) {
|
|
|
725
725
|
return bWireAdapterPlumbing(adapterId, actionUponNewValue, config);
|
|
726
726
|
});
|
|
727
727
|
}
|
|
728
|
+
function isWireDecorator(decorator) {
|
|
729
|
+
return (is.callExpression(decorator?.expression) &&
|
|
730
|
+
is.identifier(decorator.expression.callee) &&
|
|
731
|
+
decorator.expression.callee.name === 'wire');
|
|
732
|
+
}
|
|
728
733
|
|
|
729
734
|
/*
|
|
730
735
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
@@ -738,7 +743,14 @@ const bGenerateMarkup = (esTemplate `
|
|
|
738
743
|
const __lwcPublicProperties__ = new Set(${ /*public properties*/is.arrayExpression}.concat(__lwcSuperPublicProperties__));
|
|
739
744
|
const __lwcPrivateProperties__ = new Set(${ /*private properties*/is.arrayExpression});
|
|
740
745
|
|
|
741
|
-
|
|
746
|
+
Object.defineProperty(
|
|
747
|
+
${ /* component class */0},
|
|
748
|
+
__SYMBOL__GENERATE_MARKUP,
|
|
749
|
+
{
|
|
750
|
+
configurable: false,
|
|
751
|
+
enumerable: false,
|
|
752
|
+
writable: false,
|
|
753
|
+
value: async function* generateMarkup(
|
|
742
754
|
tagName,
|
|
743
755
|
props,
|
|
744
756
|
attrs,
|
|
@@ -748,56 +760,75 @@ const bGenerateMarkup = (esTemplate `
|
|
|
748
760
|
parent,
|
|
749
761
|
scopeToken,
|
|
750
762
|
contextfulParent
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
763
|
+
) {
|
|
764
|
+
tagName = tagName ?? ${ /*component tag name*/is.literal};
|
|
765
|
+
attrs = attrs ?? Object.create(null);
|
|
766
|
+
props = props ?? Object.create(null);
|
|
767
|
+
const instance = new ${ /* Component class */0}({
|
|
768
|
+
tagName: tagName.toUpperCase(),
|
|
769
|
+
});
|
|
758
770
|
|
|
759
|
-
|
|
760
|
-
|
|
771
|
+
__establishContextfulRelationship(contextfulParent, instance);
|
|
772
|
+
${ /*connect wire*/is.statement}
|
|
761
773
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
774
|
+
instance[__SYMBOL__SET_INTERNALS](
|
|
775
|
+
props,
|
|
776
|
+
attrs,
|
|
777
|
+
__lwcPublicProperties__,
|
|
778
|
+
__lwcPrivateProperties__,
|
|
779
|
+
);
|
|
780
|
+
instance.isConnected = true;
|
|
781
|
+
if (instance.connectedCallback) {
|
|
782
|
+
__mutationTracker.enable(instance);
|
|
783
|
+
instance.connectedCallback();
|
|
784
|
+
__mutationTracker.disable(instance);
|
|
785
|
+
}
|
|
786
|
+
// If a render() function is defined on the class or any of its superclasses, then that takes priority.
|
|
787
|
+
// Next, if the class or any of its superclasses has an implicitly-associated template, then that takes
|
|
788
|
+
// second priority (e.g. a foo.html file alongside a foo.js file). Finally, there is a fallback empty template.
|
|
789
|
+
const tmplFn = instance.render?.() ?? ${ /*component class*/0}[__SYMBOL__DEFAULT_TEMPLATE] ?? __fallbackTmpl;
|
|
790
|
+
yield \`<\${tagName}\`;
|
|
791
|
+
|
|
792
|
+
const hostHasScopedStylesheets =
|
|
793
|
+
tmplFn.hasScopedStylesheets ||
|
|
794
|
+
hasScopedStaticStylesheets(${ /*component class*/0});
|
|
795
|
+
const hostScopeToken = hostHasScopedStylesheets ? tmplFn.stylesheetScopeToken + "-host" : undefined;
|
|
796
|
+
|
|
797
|
+
yield* __renderAttrs(instance, attrs, hostScopeToken, scopeToken);
|
|
798
|
+
yield '>';
|
|
799
|
+
yield* tmplFn(
|
|
800
|
+
shadowSlottedContent,
|
|
801
|
+
lightSlottedContent,
|
|
802
|
+
scopedSlottedContent,
|
|
803
|
+
${ /*component class*/0},
|
|
804
|
+
instance
|
|
805
|
+
);
|
|
806
|
+
yield \`</\${tagName}>\`;
|
|
807
|
+
}
|
|
808
|
+
});
|
|
809
|
+
Object.defineProperty(
|
|
810
|
+
${ /* component class */0},
|
|
811
|
+
'__lwcPublicProperties__',
|
|
812
|
+
{
|
|
813
|
+
configurable: false,
|
|
814
|
+
enumerable: false,
|
|
815
|
+
writable: false,
|
|
816
|
+
value: __lwcPublicProperties__
|
|
817
|
+
}
|
|
818
|
+
);
|
|
797
819
|
`);
|
|
798
820
|
const bExposeTemplate = (esTemplate `
|
|
799
821
|
if (${ /*template*/is.identifier}) {
|
|
800
|
-
|
|
822
|
+
Object.defineProperty(
|
|
823
|
+
${ /* component class */is.identifier},
|
|
824
|
+
__SYMBOL__DEFAULT_TEMPLATE,
|
|
825
|
+
{
|
|
826
|
+
configurable: false,
|
|
827
|
+
enumerable: false,
|
|
828
|
+
writable: false,
|
|
829
|
+
value: ${ /*template*/0}
|
|
830
|
+
}
|
|
831
|
+
);
|
|
801
832
|
}
|
|
802
833
|
`);
|
|
803
834
|
/**
|
|
@@ -843,12 +874,72 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
843
874
|
SYMBOL__SET_INTERNALS: '__SYMBOL__SET_INTERNALS',
|
|
844
875
|
establishContextfulRelationship: '__establishContextfulRelationship',
|
|
845
876
|
}));
|
|
846
|
-
program.body.push(...bGenerateMarkup(classIdentifier, builders.arrayExpression(publicProperties.map(builders.literal)), builders.arrayExpression(privateProperties.map(builders.literal)), defaultTagName, connectWireAdapterCode));
|
|
877
|
+
program.body.push(...bGenerateMarkup(classIdentifier, builders.arrayExpression([...publicProperties.keys()].map(builders.literal)), builders.arrayExpression([...privateProperties].map(builders.literal)), defaultTagName, connectWireAdapterCode));
|
|
847
878
|
if (exposeTemplateBlock) {
|
|
848
879
|
program.body.push(exposeTemplateBlock);
|
|
849
880
|
}
|
|
850
881
|
}
|
|
851
882
|
|
|
883
|
+
/*
|
|
884
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
885
|
+
* All rights reserved.
|
|
886
|
+
* SPDX-License-Identifier: MIT
|
|
887
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
888
|
+
*/
|
|
889
|
+
function validateName(definition) {
|
|
890
|
+
if (definition.computed) {
|
|
891
|
+
throw generateError(definition, DecoratorErrors.PROPERTY_CANNOT_BE_COMPUTED);
|
|
892
|
+
}
|
|
893
|
+
const propertyName = definition.key.name;
|
|
894
|
+
switch (true) {
|
|
895
|
+
case propertyName === 'part':
|
|
896
|
+
throw generateError(definition, DecoratorErrors.PROPERTY_NAME_PART_IS_RESERVED, propertyName);
|
|
897
|
+
case propertyName.startsWith('on'):
|
|
898
|
+
throw generateError(definition, DecoratorErrors.PROPERTY_NAME_CANNOT_START_WITH_ON, propertyName);
|
|
899
|
+
case propertyName.startsWith('data') && propertyName.length > 4:
|
|
900
|
+
throw generateError(definition, DecoratorErrors.PROPERTY_NAME_CANNOT_START_WITH_DATA, propertyName);
|
|
901
|
+
case DISALLOWED_PROP_SET.has(propertyName):
|
|
902
|
+
throw generateError(definition, DecoratorErrors.PROPERTY_NAME_IS_RESERVED, propertyName);
|
|
903
|
+
case AMBIGUOUS_PROP_SET.has(propertyName):
|
|
904
|
+
throw generateError(definition, DecoratorErrors.PROPERTY_NAME_IS_AMBIGUOUS, propertyName, AMBIGUOUS_PROP_SET.get(propertyName));
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
function validatePropertyValue(property) {
|
|
908
|
+
if (is.literal(property.value) && property.value.value === true) {
|
|
909
|
+
throw generateError(property, DecoratorErrors.INVALID_BOOLEAN_PUBLIC_PROPERTY);
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
function validatePropertyUnique(node, state) {
|
|
913
|
+
if (state.publicProperties.has(node.key.name)) {
|
|
914
|
+
throw generateError(node, DecoratorErrors.DUPLICATE_API_PROPERTY, node.key.name);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
function validateApiProperty(node, state) {
|
|
918
|
+
validatePropertyUnique(node, state);
|
|
919
|
+
validateName(node);
|
|
920
|
+
validatePropertyValue(node);
|
|
921
|
+
}
|
|
922
|
+
function validateUniqueMethod(node, state) {
|
|
923
|
+
const field = state.publicProperties.get(node.key.name);
|
|
924
|
+
if (!field) {
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
if (field.type === 'MethodDefinition' &&
|
|
928
|
+
(field.kind === 'get' || field.kind === 'set') &&
|
|
929
|
+
(node.kind === 'get' || node.kind === 'set')) {
|
|
930
|
+
throw generateError(node, DecoratorErrors.SINGLE_DECORATOR_ON_SETTER_GETTER_PAIR, node.key.name);
|
|
931
|
+
}
|
|
932
|
+
throw generateError(node, DecoratorErrors.DUPLICATE_API_PROPERTY, node.key.name);
|
|
933
|
+
}
|
|
934
|
+
function validateApiMethod(node, state) {
|
|
935
|
+
validateUniqueMethod(node, state);
|
|
936
|
+
validateName(node);
|
|
937
|
+
}
|
|
938
|
+
|
|
939
|
+
function isApiDecorator(decorator) {
|
|
940
|
+
return decorator?.expression.type === 'Identifier' && decorator.expression.name === 'api';
|
|
941
|
+
}
|
|
942
|
+
|
|
852
943
|
/*
|
|
853
944
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
854
945
|
* All rights reserved.
|
|
@@ -868,6 +959,36 @@ function removeDecoratorImport(path) {
|
|
|
868
959
|
}
|
|
869
960
|
}
|
|
870
961
|
|
|
962
|
+
function isTrackDecorator(decorator) {
|
|
963
|
+
return decorator?.expression.type === 'Identifier' && decorator.expression.name === 'track';
|
|
964
|
+
}
|
|
965
|
+
|
|
966
|
+
/*
|
|
967
|
+
* Copyright (c) 2024, Salesforce, Inc.
|
|
968
|
+
* All rights reserved.
|
|
969
|
+
* SPDX-License-Identifier: MIT
|
|
970
|
+
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
971
|
+
*/
|
|
972
|
+
function validateUniqueDecorator(decorators) {
|
|
973
|
+
if (decorators.length < 2) {
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
const wire = decorators.find(isWireDecorator);
|
|
977
|
+
const api = decorators.find(isApiDecorator);
|
|
978
|
+
const track = decorators.find(isTrackDecorator);
|
|
979
|
+
if (wire) {
|
|
980
|
+
if (api) {
|
|
981
|
+
throw generateError(wire, DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'api');
|
|
982
|
+
}
|
|
983
|
+
if (track) {
|
|
984
|
+
throw generateError(wire, DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'track');
|
|
985
|
+
}
|
|
986
|
+
}
|
|
987
|
+
if (api && track) {
|
|
988
|
+
throw generateError(api, DecoratorErrors.API_AND_TRACK_DECORATOR_CONFLICT);
|
|
989
|
+
}
|
|
990
|
+
}
|
|
991
|
+
|
|
871
992
|
/*
|
|
872
993
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
873
994
|
* All rights reserved.
|
|
@@ -953,27 +1074,21 @@ const visitors = {
|
|
|
953
1074
|
// Seems to occur for `@wire() [symbol];` -- not sure why
|
|
954
1075
|
throw new Error('Unknown state: property definition has no key');
|
|
955
1076
|
}
|
|
956
|
-
if (!
|
|
1077
|
+
if (!isKeyIdentifier(node)) {
|
|
957
1078
|
return;
|
|
958
1079
|
}
|
|
959
1080
|
const { decorators } = node;
|
|
960
1081
|
validateUniqueDecorator(decorators);
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
state.publicProperties.
|
|
1082
|
+
if (isApiDecorator(decorators[0])) {
|
|
1083
|
+
validateApiProperty(node, state);
|
|
1084
|
+
state.publicProperties.set(node.key.name, node);
|
|
964
1085
|
}
|
|
965
|
-
else if (
|
|
966
|
-
is.identifier(decoratedExpression.callee) &&
|
|
967
|
-
decoratedExpression.callee.name === 'wire') {
|
|
968
|
-
if (node.computed) {
|
|
969
|
-
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
|
|
970
|
-
throw new Error('@wire cannot be used on computed properties in SSR context.');
|
|
971
|
-
}
|
|
1086
|
+
else if (isWireDecorator(decorators[0])) {
|
|
972
1087
|
catalogWireAdapters(path, state);
|
|
973
|
-
state.privateProperties.
|
|
1088
|
+
state.privateProperties.add(node.key.name);
|
|
974
1089
|
}
|
|
975
1090
|
else {
|
|
976
|
-
state.privateProperties.
|
|
1091
|
+
state.privateProperties.add(node.key.name);
|
|
977
1092
|
}
|
|
978
1093
|
if (node.static &&
|
|
979
1094
|
node.key.name === 'stylesheets' &&
|
|
@@ -984,7 +1099,7 @@ const visitors = {
|
|
|
984
1099
|
},
|
|
985
1100
|
MethodDefinition(path, state) {
|
|
986
1101
|
const node = path.node;
|
|
987
|
-
if (!
|
|
1102
|
+
if (!isKeyIdentifier(node)) {
|
|
988
1103
|
return;
|
|
989
1104
|
}
|
|
990
1105
|
// If we mutate any class-methods that are piped through this compiler, then we'll be
|
|
@@ -994,17 +1109,16 @@ const visitors = {
|
|
|
994
1109
|
}
|
|
995
1110
|
const { decorators } = node;
|
|
996
1111
|
validateUniqueDecorator(decorators);
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
// not a getter/setter
|
|
1003
|
-
const isRealMethod = node.kind === 'method';
|
|
1112
|
+
if (isApiDecorator(decorators[0])) {
|
|
1113
|
+
validateApiMethod(node, state);
|
|
1114
|
+
state.publicProperties.set(node.key.name, node);
|
|
1115
|
+
}
|
|
1116
|
+
else if (isWireDecorator(decorators[0])) {
|
|
1004
1117
|
if (node.computed) {
|
|
1005
1118
|
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
|
|
1006
|
-
throw new Error(
|
|
1119
|
+
throw new Error('@wire cannot be used on computed properties in SSR context.');
|
|
1007
1120
|
}
|
|
1121
|
+
const isRealMethod = node.kind === 'method';
|
|
1008
1122
|
// Getters and setters are methods in the AST, but treated as properties by @wire
|
|
1009
1123
|
// Note that this means that their implementations are ignored!
|
|
1010
1124
|
if (!isRealMethod) {
|
|
@@ -1020,13 +1134,6 @@ const visitors = {
|
|
|
1020
1134
|
catalogWireAdapters(path, state);
|
|
1021
1135
|
}
|
|
1022
1136
|
}
|
|
1023
|
-
else if (is.identifier(decoratedExpression) && decoratedExpression.name === 'api') {
|
|
1024
|
-
if (state.publicProperties.includes(node.key.name)) {
|
|
1025
|
-
// TODO [#5032]: Harmonize errors thrown in `@lwc/ssr-compiler`
|
|
1026
|
-
throw new Error(`LWC1112: @api get ${node.key.name} and @api set ${node.key.name} detected in class declaration. Only one of the two needs to be decorated with @api.`);
|
|
1027
|
-
}
|
|
1028
|
-
state.publicProperties.push(node.key.name);
|
|
1029
|
-
}
|
|
1030
1137
|
switch (node.key.name) {
|
|
1031
1138
|
case 'constructor':
|
|
1032
1139
|
// add our own custom arg after any pre-existing constructor args
|
|
@@ -1088,21 +1195,6 @@ const visitors = {
|
|
|
1088
1195
|
}
|
|
1089
1196
|
},
|
|
1090
1197
|
};
|
|
1091
|
-
function validateUniqueDecorator(decorators) {
|
|
1092
|
-
if (decorators.length < 2) {
|
|
1093
|
-
return;
|
|
1094
|
-
}
|
|
1095
|
-
const expressions = decorators.map(({ expression }) => expression);
|
|
1096
|
-
const wire = expressions.find((expr) => is.callExpression(expr) && is.identifier(expr.callee, { name: 'wire' }));
|
|
1097
|
-
const api = expressions.find((expr) => is.identifier(expr, { name: 'api' }));
|
|
1098
|
-
if (wire && api) {
|
|
1099
|
-
throw generateError(wire, DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'api');
|
|
1100
|
-
}
|
|
1101
|
-
const track = expressions.find((expr) => is.identifier(expr, { name: 'track' }));
|
|
1102
|
-
if (wire && track) {
|
|
1103
|
-
throw generateError(wire, DecoratorErrors.CONFLICT_WITH_ANOTHER_DECORATOR, 'track');
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
1198
|
function compileJS(src, filename, tagName, options, compilationMode) {
|
|
1107
1199
|
let ast = parseModule(src, {
|
|
1108
1200
|
module: true,
|
|
@@ -1123,8 +1215,8 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1123
1215
|
tmplExplicitImports: null,
|
|
1124
1216
|
cssExplicitImports: null,
|
|
1125
1217
|
staticStylesheetIds: null,
|
|
1126
|
-
publicProperties:
|
|
1127
|
-
privateProperties:
|
|
1218
|
+
publicProperties: new Map(),
|
|
1219
|
+
privateProperties: new Set(),
|
|
1128
1220
|
wireAdapters: [],
|
|
1129
1221
|
experimentalDynamicComponent: options.experimentalDynamicComponent,
|
|
1130
1222
|
importManager: new ImportManager(),
|
|
@@ -1150,6 +1242,9 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1150
1242
|
}),
|
|
1151
1243
|
};
|
|
1152
1244
|
}
|
|
1245
|
+
function isKeyIdentifier(node) {
|
|
1246
|
+
return is.identifier(node?.key);
|
|
1247
|
+
}
|
|
1153
1248
|
|
|
1154
1249
|
/*
|
|
1155
1250
|
* Copyright (c) 2024, Salesforce, Inc.
|
|
@@ -2454,5 +2549,5 @@ function compileTemplateForSSR(src, filename, options, mode = DEFAULT_SSR_MODE)
|
|
|
2454
2549
|
}
|
|
2455
2550
|
|
|
2456
2551
|
export { compileComponentForSSR, compileTemplateForSSR };
|
|
2457
|
-
/** version: 8.13.
|
|
2552
|
+
/** version: 8.13.2 */
|
|
2458
2553
|
//# 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/ssr-compiler",
|
|
7
|
-
"version": "8.13.
|
|
7
|
+
"version": "8.13.2",
|
|
8
8
|
"description": "Compile component for use during server-side rendering",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"compiler",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@babel/types": "7.26.
|
|
52
|
-
"@lwc/shared": "8.13.
|
|
53
|
-
"@lwc/errors": "8.13.
|
|
54
|
-
"@lwc/template-compiler": "8.13.
|
|
51
|
+
"@babel/types": "7.26.8",
|
|
52
|
+
"@lwc/shared": "8.13.2",
|
|
53
|
+
"@lwc/errors": "8.13.2",
|
|
54
|
+
"@lwc/template-compiler": "8.13.2",
|
|
55
55
|
"acorn": "8.14.0",
|
|
56
56
|
"astring": "^1.9.0",
|
|
57
57
|
"estree-toolkit": "^1.7.8",
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"meriyah": "^5.0.0"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@lwc/babel-plugin-component": "8.13.
|
|
62
|
+
"@lwc/babel-plugin-component": "8.13.2",
|
|
63
63
|
"@types/estree": "^1.0.6"
|
|
64
64
|
}
|
|
65
|
-
}
|
|
65
|
+
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { NodePath } from 'estree-toolkit';
|
|
2
|
-
import type { PropertyDefinition, MethodDefinition, BlockStatement } from 'estree';
|
|
3
|
-
import type { ComponentMetaState, WireAdapter } from './types';
|
|
4
|
-
export declare function catalogWireAdapters(path: NodePath<PropertyDefinition | MethodDefinition>, state: ComponentMetaState): void;
|
|
5
|
-
export declare function bWireAdaptersPlumbing(adapters: WireAdapter[]): BlockStatement[];
|
|
6
|
-
//# sourceMappingURL=wire.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ElseifBlock as IrElseifBlock, If as IrIf, IfBlock as IrIfBlock } from '@lwc/template-compiler';
|
|
2
|
-
import type { Transformer } from '../types';
|
|
3
|
-
export declare const If: Transformer<IrIf>;
|
|
4
|
-
export declare const IfBlock: Transformer<IrIfBlock | IrElseifBlock>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Program as EsProgram } from 'estree';
|
|
2
|
-
/**
|
|
3
|
-
* Remove any unused imports from `@lwc/ssr-runtime`.
|
|
4
|
-
* This avoids any warnings from Rollup about unused imports, and avoids us needing
|
|
5
|
-
* to manually track what's imported during AST generation.
|
|
6
|
-
* @param compiledComponentAst
|
|
7
|
-
*/
|
|
8
|
-
export declare function optimizeImports(compiledComponentAst: EsProgram): EsProgram;
|