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

addModuleImportToRootModule does not work with module initialization #7

Open
lexon0011 opened this issue Jul 25, 2019 · 4 comments
Open
Labels
bug Something isn't working

Comments

@lexon0011
Copy link

I use the the function addModuleImportToRootModule in the following way:

addModuleImportToRootModule(
   host,
   `MyModule.forRoot(
     {
       option1: '<value of option1>',
       option2: '<value of option2>',
     })`,
   '@mycompany/my-module',
   project
);

As result, I get an invalid import statement in my app.module.ts. The module will be added correctly to the NgModule, but create an invalid import statement:

import { MyModule.forRoot(
   {
       option1: '<value of option1>',
       option2: '<value of option2>',
   }) } from '@mycompany/my-module';

Is there a way to to solve this problem?

Thanks!

@nitayneeman nitayneeman added the bug Something isn't working label Aug 2, 2019
@nitayneeman
Copy link
Owner

HI,

The original code has been changed, as you can see here:
https://github.com/angular/components/blob/e02fa3a2ab2fc5616c633437dd74691bd8a0cf85/src/cdk/schematics/utils/ast.ts#L31

It's possible this change solves your issue, so if you could verify that, it would be awesome!
Anyway - I'm planning to update the code, but it may take a while.

Until then, feel free to suggest a solution 🙂

@nitayneeman
Copy link
Owner

It has been done - the code was refactored to use the original source!

Would you like to check if now, with v2.0.0, the issue still happens?

@dipaktelangre
Copy link

I am also getting the same issue and has been not able to proceed further.

@dipaktelangre
Copy link

I have imported same function from @schematics/angular instead of schematics-utilities and now its working.

import {
  addProviderToModule,
  addImportToModule,
} from "@schematics/angular/utility/ast-utils";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants