Skip to content

Commit

Permalink
fix(app): lazy routing with async - await
Browse files Browse the repository at this point in the history
fix #1042
  • Loading branch information
vogloblinsky committed Jul 15, 2021
1 parent ffe8abb commit 150d97a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/utils/router-parser.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export class RouterParserUtil {
private modulesWithRoutes = [];
private transformAngular8ImportSyntax =
/(['"]loadChildren['"]:)\(\)(:[^)]+?)?=>"import\((\\'|'|")([^'"]+?)(\\'|'|")\)\.then\(\(?\w+?\)?=>\S+?\.([^)]+?)\)(\\'|'|")/g;
private transformAngular8ImportSyntaxAsyncAwait =
/(['"]loadChildren['"]:)\(\)(:[^)]+?)?=>\("import\((\\'|'|")([^'"]+?)(\\'|'|")\)"\)\.['"]([^)]+?)['"]/g;

private static instance: RouterParserUtil;
private constructor() {}
Expand Down Expand Up @@ -73,6 +75,11 @@ export class RouterParserUtil {
'$1"$4#$6"'
);

routesWithoutSpaces = routesWithoutSpaces.replace(
this.transformAngular8ImportSyntaxAsyncAwait,
'$1"$4#$6"'
);

return JSON5.parse(routesWithoutSpaces);
}

Expand All @@ -88,6 +95,11 @@ export class RouterParserUtil {
'$1"$4#$6"'
);

routesWithoutSpaces = routesWithoutSpaces.replace(
this.transformAngular8ImportSyntaxAsyncAwait,
'$1"$4#$6"'
);

return routesWithoutSpaces;
}

Expand Down
1 change: 1 addition & 0 deletions test/src/cli/cli-routes-graph.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ describe('CLI Routes graph', () => {
const isFileExists = exists(`${distFolder}/js/routes/routes_index.js`);
expect(isFileExists).to.be.true;
let file = read(`${distFolder}/js/routes/routes_index.js`);
expect(file).to.contain('AboutComponent');
});
});

Expand Down

0 comments on commit 150d97a

Please sign in to comment.