Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(compiler): moves autoDefineCustomElements to an export behavior #3615

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/cli/telemetry/test/telemetry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe('anonymizeConfigForTelemetry', () => {
outputTargets: [
{ type: WWW, baseUrl: 'https://example.com' },
{ type: DIST_HYDRATE_SCRIPT, external: ['beep', 'boop'], dir: 'shoud/go/away' },
{ type: DIST_CUSTOM_ELEMENTS, autoDefineCustomElements: false },
{ type: DIST_CUSTOM_ELEMENTS },
{ type: DIST_CUSTOM_ELEMENTS, generateTypeDeclarations: true },
{ type: DIST, typesDir: 'my-types' },
],
Expand All @@ -270,7 +270,7 @@ describe('anonymizeConfigForTelemetry', () => {
expect(anonymizedConfig.outputTargets).toEqual([
{ type: WWW, baseUrl: 'omitted' },
{ type: DIST_HYDRATE_SCRIPT, external: ['beep', 'boop'], dir: 'omitted' },
{ type: DIST_CUSTOM_ELEMENTS, autoDefineCustomElements: false },
{ type: DIST_CUSTOM_ELEMENTS },
{ type: DIST_CUSTOM_ELEMENTS, generateTypeDeclarations: true },
{ type: DIST, typesDir: 'omitted' },
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const addDefineCustomElementFunctions = (
setupComponentDependencies(moduleFile, components, newStatements, caseStatements, tagNames);
addDefineCustomElementFunction(tagNames, newStatements, caseStatements);

if (outputTarget.autoDefineCustomElements) {
if (outputTarget.customElementsExportBehavior === 'auto-define-custom-elements') {
const conditionalDefineCustomElementCall = createAutoDefinitionExpression(
principalComponent.componentClassName
);
Expand Down
15 changes: 8 additions & 7 deletions src/declarations/stencil-public-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2027,9 +2027,16 @@ export interface OutputTargetBaseNext {
* output target configuration for `customElementsExportBehavior`.
*
* - `default`: No additional export or definition behavior will happen.
* - `auto-define-custom-elements`: Enables the auto-definition of a component and its children (recursively) in the custom elements registry. This
* functionality allows consumers to bypass the explicit call to define a component, its children, its children's
* children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
* - `single-export-module`: All components will be re-exported from the specified directory's root `index.js` file.
*/
export const CustomElementsExportBehaviorOptions = ['default', 'single-export-module'] as const;
export const CustomElementsExportBehaviorOptions = [
'default',
'auto-define-custom-elements',
'single-export-module',
] as const;

/**
* This type is auto-generated based on the values in `CustomElementsExportBehaviorOptions` array.
Expand All @@ -2045,12 +2052,6 @@ export interface OutputTargetDistCustomElements extends OutputTargetBaseNext {
inlineDynamicImports?: boolean;
includeGlobalScripts?: boolean;
minify?: boolean;
/**
* Enables the auto-definition of a component and its children (recursively) in the custom elements registry. This
* functionality allows consumers to bypass the explicit call to define a component, its children, its children's
* children, etc. Users of this flag should be aware that enabling this functionality may increase bundle size.
*/
autoDefineCustomElements?: boolean;
/**
* Enables the generation of type definition files for the output target.
*/
Expand Down