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): remove inlineDynamicImports from custom elements targets #3897

6 changes: 6 additions & 0 deletions BREAKING_CHANGES.md
Expand Up @@ -24,6 +24,7 @@ This is a comprehensive list of the breaking changes introduced in the major ver
* [`dist-custom-elements` Output Target](#dist-custom-elements-output-target)
* [Add `customElementsExportBehavior` to Control Export Behavior](#add-customelementsexportbehavior-to-control-export-behavior)
* [Move `autoDefineCustomElements` Configuration](#move-autodefinecustomelements-configuration)
* [Remove `inlineDynamicImports` Configuration](#remove-inlinedynamicimports-configuration)
* [`dist-custom-elements-bundle` Output Target](#dist-custom-elements-bundle-output-target)
* [Legacy Angular Output Target](#legacy-angular-output-target)
* [Stencil APIs](#stencil-apis)
Expand Down Expand Up @@ -208,6 +209,11 @@ export const config: Config = {
};
```

#### Remove `inlineDynamicImports` Configuration

The `inlineDynamicImports` configuration option on `dist-custom-elements` has been removed. Previously, this option would throw an error at build
time during the Rollup bundling process if the build contained multiple "inputs" (components).

#### `dist-custom-elements-bundle` Output Target
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).
Users of this output target should migrate to the `dist-custom-elements` output target.
Expand Down
8 changes: 8 additions & 0 deletions src/compiler/bundle/bundle-interface.ts
Expand Up @@ -35,6 +35,14 @@ export interface BundleOptions {
* @see {@link loader-plugin:loaderPlugin}
*/
loader?: { [id: string]: string };
/**
* Duplicate of Rollup's `inlineDynamicImports` output option.
*
* Creates dynamic imports (i.e. `import()` calls) as a part of the same
* chunk being bundled. Rather than being created as separate chunks.
*
* @see {@link https://rollupjs.org/guide/en/#outputinlinedynamicimports}
*/
inlineDynamicImports?: boolean;
inlineWorkers?: boolean;
/**
Expand Down
4 changes: 3 additions & 1 deletion src/compiler/bundle/bundle-output.ts
Expand Up @@ -96,6 +96,9 @@ export const getRollupOptions = (
const afterPlugins = config.rollupPlugins.after || [];
const rollupOptions: RollupOptions = {
input: bundleOpts.inputs,
output: {
inlineDynamicImports: bundleOpts.inlineDynamicImports ?? false,
},

plugins: [
coreResolvePlugin(config, compilerCtx, bundleOpts.platform, bundleOpts.externalRuntime),
Expand Down Expand Up @@ -129,7 +132,6 @@ export const getRollupOptions = (
],

treeshake: getTreeshakeOption(config, bundleOpts),
inlineDynamicImports: bundleOpts.inlineDynamicImports,
preserveEntrySignatures: bundleOpts.preserveEntrySignatures ?? 'strict',

onwarn: createOnWarnFn(buildCtx.diagnostics),
Expand Down
Expand Up @@ -64,7 +64,6 @@ const bundleCustomElements = async (
loader: {
'\0core': generateEntryPoint(outputTarget, buildCtx),
},
inlineDynamicImports: outputTarget.inlineDynamicImports,
preserveEntrySignatures: 'allow-extension',
};

Expand Down
Expand Up @@ -88,7 +88,6 @@ export const getBundleOptions = (
index: '\0core',
},
loader: {},
inlineDynamicImports: outputTarget.inlineDynamicImports,
preserveEntrySignatures: 'allow-extension',
});

Expand Down
Expand Up @@ -119,15 +119,6 @@ export * from '${USER_INDEX_ENTRY_ID}';
expect(options.externalRuntime).toBe(false);
}
});

it.each([true, false, undefined])('should pass through inlineDynamicImports=%p', (inlineDynamicImports) => {
const { config, buildCtx, compilerCtx } = setup();
const options = getBundleOptions(config, buildCtx, compilerCtx, {
type: DIST_CUSTOM_ELEMENTS,
inlineDynamicImports,
});
expect(options.inlineDynamicImports).toBe(inlineDynamicImports);
});
});

describe('bundleCustomElements', () => {
Expand Down
2 changes: 0 additions & 2 deletions src/declarations/stencil-public-compiler.ts
Expand Up @@ -2063,7 +2063,6 @@ export interface OutputTargetDistCustomElements extends OutputTargetBaseNext {
*/
externalRuntime?: boolean;
copy?: CopyTask[];
inlineDynamicImports?: boolean;
includeGlobalScripts?: boolean;
minify?: boolean;
/**
Expand All @@ -2083,7 +2082,6 @@ export interface OutputTargetDistCustomElementsBundle extends OutputTargetBaseNe
empty?: boolean;
externalRuntime?: boolean;
copy?: CopyTask[];
inlineDynamicImports?: boolean;
includeGlobalScripts?: boolean;
minify?: boolean;
}
Expand Down