-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
perf: fine tune schematics #1925
Conversation
Exclude node_modules Only commit file updates when there are changes
@@ -162,3 +166,13 @@ export function createChangeRecorder( | |||
} | |||
return recorder; | |||
} | |||
|
|||
export function commitChanges(tree: Tree, path: string, changes: Change[]) { | |||
if (changes.length === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only commit the file when there are changes, I forgot this in some of the v8 migrations making them slow (plus there was a information message on every file changes, even node_modules, which might confuse people).
|
||
if (sourceFile.isDeclarationFile) { | ||
return; | ||
function* visit(directory: DirEntry): IterableIterator<ts.SourceFile> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use tree.visit
for more flexibility (like ignore node_modules
).
Inspiration from https://github.com/angular/angular-cli/blob/576119f2cab6a53f0bc67026b723fffbe8407258/packages/schematics/angular/migrations/update-8/update-lazy-module-paths.ts. I like this solution the most as we break out the node_modules
folder as fast as possible.
Another option is to use the ignore
package, like the nx workspace does - https://github.com/nrwl/nx/blob/3af31f1cd996db2f225773eb1888bd109efb9f76/packages/schematics/migrations/update-8-0-0/update-8-0-0.ts#L176
Or to simple check if node_modules
is in the path.
@@ -7,6 +7,7 @@ | |||
"emitDecoratorMetadata": true, | |||
"experimentalDecorators": true, | |||
"strictPropertyInitialization": false, | |||
"downlevelIteration": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needed for yield* visit(directory.dir(path));
Preview docs changes for 889d9de at https://previews.ngrx.io/pr1925-889d9de/ |
Exclude node_modules
Only commit file updates when there are changes
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Closes #
What is the new behavior?
Does this PR introduce a breaking change?
This PR modifies the v8 migrations.
While running the
ng update
schematics, I noticed these were taking a long time.Initially I thought this was because we did not exclude
node_modules
, but the main reason was that we committed changes on every ts file.That's why I extracted the common logic into schematics-core, so we don't have this problem in the future.