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

NgRx Schematic doesn't add imports property when an ngmodule is empty #9

Closed
vsavkin opened this issue Sep 11, 2017 · 3 comments
Closed
Assignees
Labels
community This is a good first issue for contributing outdated type: bug

Comments

@vsavkin
Copy link
Member

vsavkin commented Sep 11, 2017

Say we have app.module.ts look something like this:

import {NgModule} from '@angular/core';

@NgModule({})
export class AppModule {}

Run something like this:

schematics @nrwl/schematics:ngrx --module=apps/client/src/app/app.module.ts 

And invalid code will be generated.

Change the module to look like and rerun the same schematic:

import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';

@NgModule({
  imports: [
    CommonModule
  ]
})
export class AppModule {}

And it will work

@ThomasBurleson
Copy link
Contributor

This issue also occurs with the follow empty imports

import {NgModule} from '@angular/core';

@NgModule({
  imports : [ ]
})
export class AppModule {
}

@ThomasBurleson ThomasBurleson self-assigned this Apr 1, 2018
@vsavkin vsavkin added the community This is a good first issue for contributing label Apr 17, 2018
@ThomasBurleson
Copy link
Contributor

Currently the command

ng g ngrx test --module=apps/myapp/src/app/app.module.ts --onlyEmptyRoot

will generate:

import {NgModule} from '@angular/core';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { environment } from '../environments/environment';
import { storeFreeze } from 'ngrx-store-freeze';

@NgModule({  imports: [StoreModule.forRoot({},{ metaReducers : !environment.production ? [storeFreeze] : [] })]
  imports: [EffectsModule.forRoot([])]
  imports: [!environment.production ? StoreDevtoolsModule.instrument() : []]
})
export class AppModule {}

This is a bug in packages/schematics/src/utils/ast-utils.ts::_addSymbolToNgModuleMetadata()

@vsavkin vsavkin closed this as completed Apr 15, 2019
FrozenPandaz referenced this issue in FrozenPandaz/nx Jan 12, 2023
@github-actions
Copy link

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
community This is a good first issue for contributing outdated type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants