mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
resolves #30279 resolves #30359 ## What is the current behavior? While Ionic's `stencil.config.ts` sets `experimentalSlotFixes: true`, the fixes never get applied at runtime. Ionic is using an external runtime, so Ionic components import `defineCustomElement` from `@stencil/core/internal/client` at runtime and this code has no awareness of the project's stencil configuration. This leads to a `NotFoundError` (Failed to execute 'removeChild' on 'Node') when filtering or dynamically removing radios in an `ion-radio-group`. The error occurs because `ion-radio-group` wraps its slotted content in an internal `<div>`. ## What is the new behavior? By setting `externalRuntime: false`, Stencil generates a project-specific file with `defineCustomElement` that components import. This file has the project's build settings baked in, correctly applying slot fixes. Additionally, the internal wrapper `<div>` around the slotted content in `ion-radio-group` is removed. With slot fixes correctly applied and the wrapper removed, radios can be filtered or dynamically removed without triggering `NotFoundError` or `DOMExceptions`. ## Does this introduce a breaking change? - [ ] Yes - [X] No ## Other information External Runtime is enabled by default and designed for projects that import Stencil components from multiple sources. This is flawed because those components will not be running with the runtime settings for which they were made.
274 lines
8.4 KiB
TypeScript
274 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',
|
|
|
|
// 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-input-otp',
|
|
'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-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-input-otp', '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-framework/tree/main/core/',
|
|
},
|
|
{
|
|
type: 'dist',
|
|
esmLoaderPath: '../loader',
|
|
},
|
|
{
|
|
type: 'dist-custom-elements',
|
|
dir: 'components',
|
|
copy: [{
|
|
src: '../scripts/custom-elements',
|
|
dest: 'components',
|
|
warn: true
|
|
}],
|
|
includeGlobalScripts: false,
|
|
externalRuntime: false,
|
|
},
|
|
{
|
|
type: 'docs-json',
|
|
file: '../packages/docs/core.json'
|
|
},
|
|
{
|
|
type: 'dist-hydrate-script'
|
|
},
|
|
apiSpecGenerator({
|
|
file: 'api.txt'
|
|
}) as any,
|
|
// {
|
|
// type: 'stats',
|
|
// file: 'stats.json'
|
|
// },
|
|
...getAngularOutputTargets(),
|
|
],
|
|
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,
|
|
}
|
|
};
|