Skip to content
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

Merged
merged 1 commit into from
Jun 6, 2019
Merged

Conversation

timdeschryver
Copy link
Member

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?

[ ] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[x] Other... Please describe: Performance

What is the current behavior?

Closes #

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

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.

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) {
Copy link
Member Author

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> {
Copy link
Member Author

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,
Copy link
Member Author

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));

@ngrxbot
Copy link
Collaborator

ngrxbot commented Jun 6, 2019

Preview docs changes for 889d9de at https://previews.ngrx.io/pr1925-889d9de/

@brandonroberts brandonroberts merged commit 5fcdd3b into master Jun 6, 2019
@brandonroberts brandonroberts deleted the pr/fine-tune-schematics branch June 6, 2019 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants