Skip to content

addModuleImportToRootModule doesn't affect the appModule #23

@TheNemus

Description

@TheNemus

KO in 2.0.0 and 2.0.1
OK in 1.1.3

Here is my rule factory function

import {
  Rule, Tree/*, SchematicContext*/
} from '@angular-devkit/schematics';
import { addModuleImportToRootModule, getProjectFromWorkspace } from 'schematics-utilities';
import { getWorkspace } from '@schematics/angular/utility/config';

export function ngAdd(options: any): Rule {
  return (host: Tree/*, context: SchematicContext*/) => {
      // get the workspace config of the consuming project
      // i.e. angular.json file
      const workspace = getWorkspace(host);

      // identify the project config which is using our library
      // or default to the default project in consumer workspace
      const project = getProjectFromWorkspace(
        workspace,
        options.project || workspace.defaultProject
      );
      // inject our module into the current main module of the selected project
      addModuleImportToRootModule(
        // tree to modify
        host,
        // Module name to insert
        'AngularCoreModule',
        // project name for import statement
        '@corp/angular-core',
        // project to be modified
        project
      );

      // return updated tree
      return host;
  };
}

Here is what I got in console

Installing packages for tooling via npm.
Installed packages for tooling via npm.
UPDATE src/app/app.module.ts (1333 bytes)

But my app.module.ts is absolutely the same as before.

I could downgrade to 1.1.3 but I need to set configuration for my modules, but then I got this issue:

#7

What am I supposed to do?

P.S. Where I can find a comprehensive list of the API your package expoes? Thank you?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions