Skip to content

Conversation

sis0k0
Copy link
Contributor

@sis0k0 sis0k0 commented Sep 25, 2019

Let's say that you execute the command:

ng g migrate-module about

Before this PR:

  • The migrate-module schematic uses the module schematic to generate a NgModule with name='about';
  • the module schematic filters out the files that end with about.module.ts - this is done because otherwise the we'll get a merge conflict;
  • the module schematic uses the external @schematics/angular module schematic to generate about.module.ts;
  • the migrate-module schematic renames about.module.ts to about.module.tns.ts.

Unfortunately, the filter function visits all files in node_modules and platforms and slows down the execution of the module schematic significantly.

With this PR:

  • The migrate-module schematic generates a NgModule file from a template instead of relying on the module schematic.
  • The module schematic doesn't use filter anymore, which speeds up the execution of the command.

fixes #185, #203

@sis0k0 sis0k0 force-pushed the sis0k0/refactor-generation branch from 8765b82 to 13a9004 Compare October 3, 2019 12:37
import { parseName } from '@schematics/angular/utility/parse-name';
import { dasherize } from '@angular-devkit/core/src/utils/strings';

import { Schema as CommonModuleSchema } from '../common-module/schema';
Copy link

@KristianDD KristianDD Oct 7, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we import this just to load the Schema? I am asking as it seems that the next line will override the Schema value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Schema refers to the name of the export imported from the '../common-module/schema' module, whereas CommonModuleSchema refers to the binding imported into the local module scope. In short: CommonModuleSchema and ModuleOptions (next line) will be the local names of the imported symbols.

@Fatme Fatme merged commit 38ced3d into master Oct 9, 2019
@Fatme Fatme deleted the sis0k0/refactor-generation branch October 9, 2019 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Module and component generators are slow

4 participants