Skip to content

Commit 2f23a8a

Browse files
authored
feat(config): add enableImportInjection flag (#4156)
this commit introduces a new flag to `config#extras`, `enableImportInjection`. `enableImportInjection` is meant to be a drop-in replacement for `experimentalImportInjection`. both flags control the same functionality for enabling import statements to be generated when using a bundler such as vite. `enableImportInjection` is introduced in this commit to begin to phase out the "experimental" wording of `experimentalImportInjection`. `experimentalImportInjection` will continue to function as it has until stencil v4.0. at which time, it is intended to remove the flag. however, `enableImportInjection` is intended to be a drop-in replacement, that can be migrated to at any given time.
1 parent 56389a4 commit 2f23a8a

File tree

5 files changed

+14
-4
lines changed

5 files changed

+14
-4
lines changed

src/compiler/config/test/fixtures/stencil.config2.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ export const config: Config = {
66
dev: true,
77
},
88
extras: {
9-
experimentalImportInjection: true,
9+
enableImportInjection: true,
1010
},
1111
};

src/compiler/config/test/load-config.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('load config', () => {
4242
// these fields are defined in the config file on disk, and should be present
4343
expect<ConfigFlags>(actualConfig.flags).toEqual({ dev: true });
4444
expect(actualConfig.extras).toBeDefined();
45-
expect(actualConfig.extras!.experimentalImportInjection).toBe(true);
45+
expect(actualConfig.extras!.enableImportInjection).toBe(true);
4646
});
4747

4848
it('uses the provided config path when no initial config provided', async () => {

src/compiler/output-targets/dist-lazy/generate-lazy-module.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const generateLazyModules = async (
4848
})
4949
);
5050

51-
if (!!config.extras?.experimentalImportInjection && !isBrowserBuild) {
51+
if ((!!config.extras?.experimentalImportInjection || !!config.extras?.enableImportInjection) && !isBrowserBuild) {
5252
addStaticImports(rollupResults, bundleModules);
5353
}
5454

src/declarations/stencil-public-compiler.ts

+10
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,19 @@ export interface ConfigExtras {
302302
* loading components when using a bundler such as Vite or Parcel. Setting this flag to `true` will change how Stencil
303303
* lazily loads components in a way that works with additional bundlers. Setting this flag to `true` will increase
304304
* the size of the compiled output. Defaults to `false`.
305+
* @deprecated This flag has been deprecated in favor of `enableImportInjection`, which provides the same
306+
* functionality. `experimentalImportInjection` will be removed in a future major version of Stencil.
305307
*/
306308
experimentalImportInjection?: boolean;
307309

310+
/**
311+
* Projects that use a Stencil library built using the `dist` output target may have trouble lazily
312+
* loading components when using a bundler such as Vite or Parcel. Setting this flag to `true` will change how Stencil
313+
* lazily loads components in a way that works with additional bundlers. Setting this flag to `true` will increase
314+
* the size of the compiled output. Defaults to `false`.
315+
*/
316+
enableImportInjection?: boolean;
317+
308318
/**
309319
* Dispatches component lifecycle events. Mainly used for testing. Defaults to `false`.
310320
*/

test/bundler/component-library/stencil.config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export const config: Config = {
1616
},
1717
],
1818
extras: {
19-
experimentalImportInjection: true,
19+
enableImportInjection: true,
2020
},
2121
};

0 commit comments

Comments
 (0)