Skip to content

Commit 4960ac9

Browse files
committed
fix(@angular-devkit/schematics): fix __dasherize__ name
Sometimes, some actions are not properly optimized. I havent had time to fully investigate, and we will rework the ActionList entirely (making it more solid and in line with the rest of the pipeline), so this error will move away properly. In the meantime, when creating a source, optimizing the tree early helps tremendously, and since it is not merged (and built from an empty tree), there is no side effect to optimizing.
1 parent afc33b2 commit 4960ac9

File tree

2 files changed

+17
-2
lines changed
  • packages
    • angular_devkit/schematics/src/rules
    • schematics/angular/ng-new

2 files changed

+17
-2
lines changed

packages/angular_devkit/schematics/src/rules/base.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
branch,
1515
empty as staticEmpty,
1616
merge as staticMerge,
17+
optimize as staticOptimize,
1718
partition as staticPartition,
1819
} from '../tree/static';
1920
import { VirtualTree } from '../tree/virtual';
@@ -53,7 +54,22 @@ export function chain(rules: Rule[]): Rule {
5354
*/
5455
export function apply(source: Source, rules: Rule[]): Source {
5556
return (context: SchematicContext) => {
56-
return callRule(chain(rules), callSource(source, context), context);
57+
return callRule(chain([
58+
...rules,
59+
// Optimize the tree. Since this is a source tree, there's not much harm here and this might
60+
// avoid further issues.
61+
tree => {
62+
if (tree instanceof VirtualTree) {
63+
tree.optimize();
64+
65+
return tree;
66+
} else if (tree.actions.length != 0) {
67+
return staticOptimize(tree);
68+
} else {
69+
return tree;
70+
}
71+
},
72+
]), callSource(source, context), context);
5773
};
5874
}
5975

packages/schematics/angular/ng-new/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ export default function (options: NgNewOptions): Rule {
6060
schematic('workspace', workspaceOptions),
6161
schematic('application', applicationOptions),
6262
move(options.directory || options.name),
63-
tree => Tree.optimize(tree),
6463
]),
6564
),
6665
(host: Tree, context: SchematicContext) => {

0 commit comments

Comments
 (0)