Skip to content

Commit 90aa4f5

Browse files
authored
feat(compiler): remove inlineDynamicImports from custom elements targets (#3897)
* feat(compiler): move inlineDynamicImports option to Rollup output section This commit updates the Rollup config we generate to have `inlineDynamicImports` defined as a part of the `output` section of the config rather than at the root level. The root-level option has been deprecated in Rollup v3 and will be removed in the future * feat(compiler): remove inlineDynamicImports from custom-element targets * docs(): update breaking changes & option JSdoc * fix(compiler): add fallback for inlineDynamicImports generating bundle opts * chore(breaking-changes): revert formatting * fix(): revert removal of field
1 parent 5fb32af commit 90aa4f5

File tree

7 files changed

+17
-14
lines changed

7 files changed

+17
-14
lines changed

BREAKING_CHANGES.md

+6
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver
2626
* [`dist-custom-elements` Output Target](#dist-custom-elements-output-target)
2727
* [Add `customElementsExportBehavior` to Control Export Behavior](#add-customelementsexportbehavior-to-control-export-behavior)
2828
* [Move `autoDefineCustomElements` Configuration](#move-autodefinecustomelements-configuration)
29+
* [Remove `inlineDynamicImports` Configuration](#remove-inlinedynamicimports-configuration)
2930
* [`dist-custom-elements-bundle` Output Target](#dist-custom-elements-bundle-output-target)
3031
* [Legacy Angular Output Target](#legacy-angular-output-target)
3132
* [Stencil APIs](#stencil-apis)
@@ -236,6 +237,11 @@ export const config: Config = {
236237
};
237238
```
238239

240+
#### Remove `inlineDynamicImports` Configuration
241+
242+
The `inlineDynamicImports` configuration option on `dist-custom-elements` has been removed. Previously, this option would throw an error at build
243+
time during the Rollup bundling process if the build contained multiple "inputs" (components).
244+
239245
#### `dist-custom-elements-bundle` Output Target
240246
The `dist-custom-elements-bundle` has been removed starting with Stencil v3.0.0, following the [RFC process](https://github.com/ionic-team/stencil/issues/3136).
241247
Users of this output target should migrate to the `dist-custom-elements` output target.

src/compiler/bundle/bundle-interface.ts

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ export interface BundleOptions {
3535
* @see {@link loader-plugin:loaderPlugin}
3636
*/
3737
loader?: { [id: string]: string };
38+
/**
39+
* Duplicate of Rollup's `inlineDynamicImports` output option.
40+
*
41+
* Creates dynamic imports (i.e. `import()` calls) as a part of the same
42+
* chunk being bundled. Rather than being created as separate chunks.
43+
*
44+
* @see {@link https://rollupjs.org/guide/en/#outputinlinedynamicimports}
45+
*/
3846
inlineDynamicImports?: boolean;
3947
inlineWorkers?: boolean;
4048
/**

src/compiler/bundle/bundle-output.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ export const getRollupOptions = (
9696
const afterPlugins = config.rollupPlugins.after || [];
9797
const rollupOptions: RollupOptions = {
9898
input: bundleOpts.inputs,
99+
output: {
100+
inlineDynamicImports: bundleOpts.inlineDynamicImports ?? false,
101+
},
99102

100103
plugins: [
101104
coreResolvePlugin(config, compilerCtx, bundleOpts.platform, bundleOpts.externalRuntime),
@@ -129,7 +132,6 @@ export const getRollupOptions = (
129132
],
130133

131134
treeshake: getTreeshakeOption(config, bundleOpts),
132-
inlineDynamicImports: bundleOpts.inlineDynamicImports,
133135
preserveEntrySignatures: bundleOpts.preserveEntrySignatures ?? 'strict',
134136

135137
onwarn: createOnWarnFn(buildCtx.diagnostics),

src/compiler/output-targets/dist-custom-elements-bundle/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const bundleCustomElements = async (
6464
loader: {
6565
'\0core': generateEntryPoint(outputTarget, buildCtx),
6666
},
67-
inlineDynamicImports: outputTarget.inlineDynamicImports,
6867
preserveEntrySignatures: 'allow-extension',
6968
};
7069

src/compiler/output-targets/dist-custom-elements/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ export const getBundleOptions = (
8888
index: '\0core',
8989
},
9090
loader: {},
91-
inlineDynamicImports: outputTarget.inlineDynamicImports,
9291
preserveEntrySignatures: 'allow-extension',
9392
});
9493

src/compiler/output-targets/test/output-targets-dist-custom-elements.spec.ts

-9
Original file line numberDiff line numberDiff line change
@@ -119,15 +119,6 @@ export * from '${USER_INDEX_ENTRY_ID}';
119119
expect(options.externalRuntime).toBe(false);
120120
}
121121
});
122-
123-
it.each([true, false, undefined])('should pass through inlineDynamicImports=%p', (inlineDynamicImports) => {
124-
const { config, buildCtx, compilerCtx } = setup();
125-
const options = getBundleOptions(config, buildCtx, compilerCtx, {
126-
type: DIST_CUSTOM_ELEMENTS,
127-
inlineDynamicImports,
128-
});
129-
expect(options.inlineDynamicImports).toBe(inlineDynamicImports);
130-
});
131122
});
132123

133124
describe('bundleCustomElements', () => {

src/declarations/stencil-public-compiler.ts

-2
Original file line numberDiff line numberDiff line change
@@ -2066,7 +2066,6 @@ export interface OutputTargetDistCustomElements extends OutputTargetBaseNext {
20662066
*/
20672067
externalRuntime?: boolean;
20682068
copy?: CopyTask[];
2069-
inlineDynamicImports?: boolean;
20702069
includeGlobalScripts?: boolean;
20712070
minify?: boolean;
20722071
/**
@@ -2086,7 +2085,6 @@ export interface OutputTargetDistCustomElementsBundle extends OutputTargetBaseNe
20862085
empty?: boolean;
20872086
externalRuntime?: boolean;
20882087
copy?: CopyTask[];
2089-
inlineDynamicImports?: boolean;
20902088
includeGlobalScripts?: boolean;
20912089
minify?: boolean;
20922090
}

0 commit comments

Comments
 (0)