Files
ionic-framework/core/stencil.config.ts
Ryan Waskiewicz 5cf84eea59 refactor(config): enable stencil's experimental slot fixes (#28995)
Issue number: N/A

---------

<!-- Please do not submit updates to dependencies unless it fixes an
issue. -->

<!-- Please try to limit your pull request to one type (bugfix, feature,
etc). Submit multiple pull requests if needed. -->

## What is the current behavior?
<!-- Please describe the current behavior that you are modifying. -->

the stencil team has been working on fixing multiple issues with slots
elements in the stencil code base. to make these changes backwards
compatible and communicate that they were volatile, we added two
configuration flags for these fixes that were prefixed with the word
"experimental".

now that the effort to provide these fixes has largely solidified, the
features behind these flags are slightly less volatile. while the
"experimental" aspect still technically holds true, we've requested
the Framework team to enable these flags in a v8 beta. the stencil
team expects these flags to be set to `true` by default in stencil
v5, which ought to help prepare for future migrations the ionic
framework has to undergo.

Previously, Stencil would allow content to project through to a
component even when a slot was not present. However, with the changes in
`extras.experimentalScopedSlotChanges`, this behavior was changed to
hide elements without a destination slot - matching the behavior of a
shadow encapsulated component.

As such, elements projected through the `ion-label` or `ion-buttons`
components would no longer be visible in rendered output.

## What is the new behavior?
<!-- Please describe the behavior or changes that are being added by
this PR. -->

This commit adds an explicit `slot` tag to components in core leveraging
"scoped" encapsulation with no rendered content (i.e. elements with only
a `Host` tag and styles).

`subtree` was added to a mutation observer.
This fixes an issue with the `ion-input` component not re-rendering in
some cases when using the label slot functionality.

HTML element patches in Stencil that are enabled by the
`experimentalSlotFixes` flag result in DOM manipulations that won't
trigger the current mutation observer configuration and callback.

## Does this introduce a breaking change?

- [] Yes
- [x] No

<!--
  If this introduces a breaking change:
1. Describe the impact and migration path for existing applications
below.
  2. Update the BREAKING.md file with the breaking change.
3. Add "BREAKING CHANGE: [...]" to the commit description when merging.
See
https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#footer
for more information.
-->


## Other information

Would you like us to update the commit message to include the `BREAKING
CHANGE:` comment? Unsure of the actual impact on end users here.

Similarly, would you like us to update the commit message here from
`chore()` to something else?
<!-- Any other information that is important to this PR such as
screenshots of how the component looks before and after the change. -->

---------

Co-authored-by: Tanner Reits <47483144+tanner-reits@users.noreply.github.com>
Co-authored-by: Liam DeBeasi <liamdebeasi@users.noreply.github.com>
Co-authored-by: Tanner Reits <tanner@ionic.io>
Co-authored-by: Maria Hutt <thetaPC@users.noreply.github.com>
2024-03-12 16:08:14 -04:00

275 lines
8.4 KiB
TypeScript

import { angularOutputTarget } from '@stencil/angular-output-target';
import type { Config } from '@stencil/core';
import { reactOutputTarget } from '@stencil/react-output-target';
import { sass } from '@stencil/sass';
import { vueOutputTarget } from '@stencil/vue-output-target';
// @ts-ignore
import { apiSpecGenerator } from './scripts/api-spec-generator';
const componentCorePackage = '@ionic/core';
const getAngularOutputTargets = () => {
const excludeComponents = [
// overlays that accept user components
'ion-modal',
'ion-popover',
// navigation
'ion-router',
'ion-route',
'ion-route-redirect',
'ion-router-link',
'ion-router-outlet',
'ion-nav',
'ion-back-button',
// tabs
'ion-tabs',
'ion-tab',
// auxiliar
'ion-picker-legacy-column',
]
return [
angularOutputTarget({
componentCorePackage,
directivesProxyFile: '../packages/angular/src/directives/proxies.ts',
directivesArrayFile: '../packages/angular/src/directives/proxies-list.ts',
excludeComponents,
outputType: 'component',
}),
angularOutputTarget({
componentCorePackage,
directivesProxyFile: '../packages/angular/standalone/src/directives/proxies.ts',
excludeComponents: [
...excludeComponents,
/**
* IonIcon is a special case because it does not come
* from the `@ionic/core` package, so generating proxies that
* are reliant on the CE build will reference the wrong
* import location.
*/
'ion-icon',
/**
* Value Accessors are manually implemented in the `@ionic/angular/standalone` package.
*/
'ion-input',
'ion-textarea',
'ion-searchbar',
'ion-datetime',
'ion-segment',
'ion-checkbox',
'ion-toggle',
'ion-range',
'ion-radio-group',
'ion-select'
],
outputType: 'standalone',
})
];
}
export const config: Config = {
autoprefixCss: true,
sourceMap: false,
namespace: 'Ionic',
bundles: [
{ components: ['ion-action-sheet'] },
{ components: ['ion-alert'] },
{ components: ['ion-back-button'] },
{ components: ['ion-app', 'ion-router-outlet', 'ion-buttons', 'ion-content', 'ion-footer', 'ion-header', 'ion-title', 'ion-toolbar'] },
{ components: ['ion-avatar', 'ion-badge', 'ion-thumbnail'] },
{ components: ['ion-backdrop'] },
{ components: ['ion-button', 'ion-icon'] },
{ components: ['ion-card', 'ion-card-content', 'ion-card-header', 'ion-card-title', 'ion-card-subtitle'] },
{ components: ['ion-checkbox'] },
{ components: ['ion-chip'] },
{ components: ['ion-datetime', 'ion-picker-legacy', 'ion-picker-legacy-column'] },
{ components: ['ion-fab', 'ion-fab-button', 'ion-fab-list'] },
{ components: ['ion-grid', 'ion-row', 'ion-col'] },
{ components: ['ion-infinite-scroll', 'ion-infinite-scroll-content'] },
{ components: ['ion-input'] },
{ components: ['ion-textarea'] },
{ components: ['ion-item', 'ion-item-divider', 'ion-item-group', 'ion-label', 'ion-list', 'ion-list-header', 'ion-skeleton-text', 'ion-note'] },
{ components: ['ion-item-sliding', 'ion-item-options', 'ion-item-option'] },
{ components: ['ion-loading'] },
{ components: ['ion-menu', 'ion-menu-toggle', 'ion-menu-button'] },
{ components: ['ion-modal'] },
{ components: ['ion-nav', 'ion-nav-link'] },
{ components: ['ion-img'] },
{ components: ['ion-popover'] },
{ components: ['ion-progress-bar'] },
{ components: ['ion-radio', 'ion-radio-group'] },
{ components: ['ion-range'] },
{ components: ['ion-refresher', 'ion-refresher-content'] },
{ components: ['ion-reorder', 'ion-reorder-group'] },
{ components: ['ion-ripple-effect'] },
{ components: ['ion-router', 'ion-route', 'ion-route-redirect', 'ion-router-link'] },
{ components: ['ion-searchbar'] },
{ components: ['ion-segment', 'ion-segment-button'] },
{ components: ['ion-select', 'ion-select-option', 'ion-select-popover'] },
{ components: ['ion-spinner'] },
{ components: ['ion-split-pane'] },
{ components: ['ion-tabs', 'ion-tab'] },
{ components: ['ion-tab-bar', 'ion-tab-button'] },
{ components: ['ion-text'] },
{ components: ['ion-toast'] },
{ components: ['ion-toggle'] },
{ components: ['ion-accordion-group', 'ion-accordion'] },
{ components: ['ion-breadcrumb', 'ion-breadcrumbs'] },
],
plugins: [
sass(),
],
outputTargets: [
reactOutputTarget({
componentCorePackage,
includeImportCustomElements: true,
includePolyfills: false,
includeDefineCustomElements: false,
proxiesFile: '../packages/react/src/components/proxies.ts',
excludeComponents: [
// Routing
'ion-router',
'ion-route',
'ion-route-redirect',
'ion-router-link',
'ion-router-outlet',
'ion-back-button',
'ion-breadcrumb',
'ion-tab-button',
'ion-tabs',
'ion-tab-bar',
'ion-button',
'ion-card',
'ion-fab-button',
'ion-item',
'ion-item-option',
// Overlays
'ion-action-sheet',
'ion-alert',
'ion-loading',
'ion-modal',
'ion-picker-legacy',
'ion-popover',
'ion-toast',
'ion-app',
'ion-icon'
]
}),
vueOutputTarget({
componentCorePackage,
includeImportCustomElements: true,
includePolyfills: false,
includeDefineCustomElements: false,
proxiesFile: '../packages/vue/src/proxies.ts',
excludeComponents: [
// Routing
'ion-router',
'ion-route',
'ion-route-redirect',
'ion-router-link',
'ion-router-outlet',
'ion-back-button',
'ion-tab-button',
'ion-tabs',
'ion-tab',
'ion-tab-bar',
// Overlays
'ion-action-sheet',
'ion-alert',
'ion-loading',
'ion-modal',
'ion-picker-legacy',
'ion-popover',
'ion-toast',
'ion-app',
'ion-icon'
],
componentModels: [
{
elements: ['ion-checkbox', 'ion-toggle'],
targetAttr: 'checked',
event: 'ion-change'
},
{
elements: ['ion-datetime', 'ion-radio-group', 'ion-radio', 'ion-segment', 'ion-segment-button', 'ion-select', 'ion-accordion-group'],
targetAttr: 'value',
event: 'ion-change',
},
{
elements: ['ion-input', 'ion-searchbar', 'ion-textarea', 'ion-range'],
targetAttr: 'value',
event: 'ion-input',
}
],
}),
{
type: 'docs-vscode',
file: 'dist/html.html-data.json',
sourceCodeBaseUrl: 'https://github.com/ionic-team/ionic/tree/main/core/',
},
{
type: 'dist',
esmLoaderPath: '../loader'
},
{
type: 'dist-custom-elements',
dir: 'components',
copy: [{
src: '../scripts/custom-elements',
dest: 'components',
warn: true
}],
includeGlobalScripts: false
},
{
type: 'docs-json',
file: '../docs/core.json'
},
{
type: 'dist-hydrate-script'
},
apiSpecGenerator({
file: 'api.txt'
}) as any,
// {
// type: 'stats',
// file: 'stats.json'
// },
...getAngularOutputTargets(),
],
buildEs5: 'prod',
testing: {
moduleNameMapper: {
"@utils/test": ["<rootDir>/src/utils/test/utils"],
"@utils/logging": ["<rootDir>/src/utils/logging"],
},
setupFilesAfterEnv: ['./setupJest.js']
},
preamble: '(C) Ionic http://ionicframework.com - MIT License',
globalScript: 'src/global/ionic-global.ts',
enableCache: true,
transformAliasedImportPaths: true,
extras: {
/**
* `experimentalSlotFixes` is necessary in Stencil v4 until the fixes described in
* {@link https://stenciljs.com/docs/config-extras#experimentalslotfixes the Stencil docs for the flag} are the
* default behavior (slated for a future Stencil major version).
*/
experimentalSlotFixes: true,
/**
* `experimentalScopedSlotChanges` is necessary in Stencil v4 until the fixes described in
* {@link https://stenciljs.com/docs/config-extras#experimentalscopedslotchanges the Stencil docs for the flag} are
* the default behavior (slated for a future Stencil major version).
*/
experimentalScopedSlotChanges: true,
}
};