Skip to content

Commit 9d365e1

Browse files
authored
Merge branch 'main' into chore/jest-migrate-bundler-and-ci
2 parents 16f034b + e790c24 commit 9d365e1

File tree

9 files changed

+16
-13
lines changed

9 files changed

+16
-13
lines changed

src/client/client-host-ref.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { BUILD } from '@app-data';
2+
import { CMP_FLAGS } from '@utils/constants';
23
import { reWireGetterSetter } from '@utils/es2022-rewire-class-members';
34

45
import type * as d from '../declarations';
@@ -29,7 +30,7 @@ export const registerInstance = (lazyInstance: any, hostRef: d.HostRef) => {
2930
lazyInstance.__stencil__getHostRef = () => hostRef;
3031
hostRef.$lazyInstance$ = lazyInstance;
3132

32-
if (BUILD.modernPropertyDecls && (BUILD.state || BUILD.prop)) {
33+
if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) {
3334
reWireGetterSetter(lazyInstance, hostRef);
3435
}
3536
};
@@ -69,7 +70,7 @@ export const registerHost = (hostElement: d.HostElement, cmpMeta: d.ComponentRun
6970
const ref = hostRef;
7071
hostElement.__stencil__getHostRef = () => ref;
7172

72-
if (!BUILD.lazyLoad && BUILD.modernPropertyDecls && (BUILD.state || BUILD.prop)) {
73+
if (!BUILD.lazyLoad && cmpMeta.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) {
7374
reWireGetterSetter(hostElement, hostRef);
7475
}
7576

src/compiler/app-core/app-data.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export const getBuildFeatures = (cmps: ComponentCompilerMeta[]): BuildFeatures =
4040
member: cmps.some((c) => c.hasMember),
4141
method: cmps.some((c) => c.hasMethod),
4242
mode: cmps.some((c) => c.hasMode),
43-
modernPropertyDecls: cmps.some((c) => c.hasModernPropertyDecls),
4443
observeAttribute: cmps.some((c) => c.hasAttribute || c.hasWatchCallback || c.hasDeserializer),
4544
prop: cmps.some((c) => c.hasProp),
4645
propBoolean: cmps.some((c) => c.hasPropBoolean),

src/compiler/output-targets/dist-lazy/lazy-build-conditionals.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const getLazyBuildConditionals = (
1818

1919
const hasHydrateOutputTargets = config.outputTargets.some(isOutputTargetHydrate);
2020
build.hydrateClientSide = hasHydrateOutputTargets;
21-
build.modernPropertyDecls = cmps.some((c) => c.hasModernPropertyDecls);
2221

2322
updateBuildConditionals(config, build);
2423

src/compiler/transformers/static-to-meta/component.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,7 @@ export const parseStaticComponentMeta = (
183183
visitComponentChildNode(cmpNode, buildCtx);
184184
parseClassMethods(classMethods, cmp);
185185

186-
if (!moduleFile.isCollectionDependency) {
187-
// collection dependencies can cause 'modern class prop declaration' false positives;
188-
// the end result will be compiled by rollup and the modern class props will be stripped
189-
cmp.hasModernPropertyDecls = detectModernPropDeclarations(cmpNode);
190-
}
191-
186+
cmp.hasModernPropertyDecls = detectModernPropDeclarations(cmpNode) || doesExtend;
192187
cmp.htmlAttrNames = unique(cmp.htmlAttrNames);
193188
cmp.htmlTagNames = unique(cmp.htmlTagNames);
194189
cmp.potentialCmpRefs = unique(cmp.potentialCmpRefs);

src/compiler/transformers/test/native-component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ describe('nativeComponentTransform', () => {
7171
});
7272

7373
expect(await formatCode(transpiledModule.outputText)).toContain(
74-
await c`__stencil_defineCustomElement(CmpA, [0, 'cmp-a', { baz: [2], bar: [2], foo: [2] }])`,
74+
await c`__stencil_defineCustomElement(CmpA, [512, 'cmp-a', { baz: [2], bar: [2], foo: [2] }])`,
7575
);
7676

7777
expect(await formatCode(transpiledModule.outputText)).toContain(

src/declarations/stencil-private.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export interface BuildFeatures {
153153
reflect: boolean;
154154

155155
taskQueue: boolean;
156-
modernPropertyDecls: boolean;
157156
}
158157

159158
export interface BuildConditionals extends Partial<BuildFeatures> {

src/hydrate/platform/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { BUILD } from '@app-data';
22
import { reWireGetterSetter } from '@utils/es2022-rewire-class-members';
33

44
import type * as d from '../../declarations';
5+
import { CMP_FLAGS } from '@utils/constants';
56

67
let customError: d.ErrorHandler;
78

@@ -139,7 +140,7 @@ export const registerInstance = (lazyInstance: any, hostRef: d.HostRef) => {
139140
lazyInstance.__stencil__getHostRef = () => hostRef;
140141
hostRef.$lazyInstance$ = lazyInstance;
141142

142-
if (BUILD.modernPropertyDecls && (BUILD.state || BUILD.prop)) {
143+
if (hostRef.$cmpMeta$.$flags$ & CMP_FLAGS.hasModernPropertyDecls && (BUILD.state || BUILD.prop)) {
143144
reWireGetterSetter(lazyInstance, hostRef);
144145
}
145146
return hostRef;

src/utils/constants.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ export const enum CMP_FLAGS {
124124
* Determines if a component has a render function.
125125
*/
126126
hasRenderFn = 1 << 8,
127+
128+
/**
129+
* Determines if a component uses modern class property declarations.
130+
*/
131+
hasModernPropertyDecls = 1 << 9,
127132
}
128133

129134
/**

src/utils/format-component-runtime-meta.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,16 @@ export const formatComponentRuntimeMeta = (
4141
if (compilerMeta.hasMode) {
4242
flags |= CMP_FLAGS.hasMode;
4343
}
44+
if (compilerMeta.hasModernPropertyDecls) {
45+
flags |= CMP_FLAGS.hasModernPropertyDecls;
46+
}
4447

4548
const members = formatComponentRuntimeMembers(compilerMeta, includeMethods);
4649
const hostListeners = formatHostListeners(compilerMeta);
4750
const watchers = formatComponentRuntimeReactiveHandlers(compilerMeta, 'watchers');
4851
const serializers = formatComponentRuntimeReactiveHandlers(compilerMeta, 'serializers');
4952
const deserializers = formatComponentRuntimeReactiveHandlers(compilerMeta, 'deserializers');
53+
5054
return trimFalsy([
5155
flags,
5256
compilerMeta.tagName,

0 commit comments

Comments
 (0)