Skip to content

Commit ca4cea9

Browse files
committed
feat(@angular-devkit/build-angular): add experimentalImportFactories option
1 parent 8eacb50 commit ca4cea9

File tree

4 files changed

+12
-1
lines changed

4 files changed

+12
-1
lines changed

packages/angular_devkit/build_angular/src/angular-cli-files/models/build-options.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export interface BuildOptions {
5959
forkTypeChecker: boolean;
6060
profile?: boolean;
6161
es5BrowserSupport?: boolean;
62+
experimentalImportFactories?: boolean;
6263

6364
main: string;
6465
index: string;

packages/angular_devkit/build_angular/src/angular-cli-files/models/webpack-configs/typescript.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ function _createAotPlugin(
7575
contextElementDependencyConstructor: require('webpack/lib/dependencies/ContextElementDependency'),
7676
logger: wco.logger,
7777
directTemplateLoading: true,
78+
importFactories: buildOptions.experimentalImportFactories,
7879
...options,
7980
};
8081
return new AngularCompilerPlugin(pluginOptions);

packages/angular_devkit/build_angular/src/browser/schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,11 @@
315315
"type": "boolean",
316316
"default": false,
317317
"x-deprecated": true
318+
},
319+
"experimentalImportFactories": {
320+
"description": "**EXPERIMENTAL** Transform import statements for lazy routes to import factories when using View Engine. Should only be used when switching back and forth between View Engine and Ivy. See https://angular.io/guide/ivy for usage information.",
321+
"type": "boolean",
322+
"default": false
318323
}
319324
},
320325
"additionalProperties": false,

packages/ngtools/webpack/src/transformers/import_factory.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,18 @@ export function importFactory(
5353
warningCb: (warning: string) => void,
5454
): ts.TransformerFactory<ts.SourceFile> {
5555
return (context: ts.TransformationContext) => {
56+
// TODO(filipesilva): change the link to https://angular.io/guide/ivy once it is out.
5657
return (sourceFile: ts.SourceFile) => {
5758
const warning = `
5859
Found 'loadChildren' with a non-string syntax in ${sourceFile.fileName} but could not transform it.
5960
Make sure it matches the format below:
6061
6162
loadChildren: () => import('IMPORT_STRING').then(m => m.EXPORT_NAME)
6263
63-
Please note that only IMPORT_STRING and EXPORT_NAME can be replaced in this format.`;
64+
Please note that only IMPORT_STRING and EXPORT_NAME can be replaced in this format.
65+
66+
Visit https://next.angular.io/guide/ivy for more information on using Ivy.
67+
`;
6468

6569
const emitWarning = () => warningCb(warning);
6670
const visitVariableStatement: ts.Visitor = (node: ts.Node) => {

0 commit comments

Comments
 (0)