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/store v11 throws a compilation error #2919

Closed
matheo opened this issue Feb 10, 2021 · 15 comments · Fixed by #2922
Closed

@ngrx/store v11 throws a compilation error #2919

matheo opened this issue Feb 10, 2021 · 15 comments · Fixed by #2922

Comments

@matheo
Copy link

matheo commented Feb 10, 2021

Today I've updated @ngrx v11 and I got a broken library-build with this error message
(reverting to `v10 goes back to normal):

@my/package: ✖ Compiling TypeScript sources through NGC
@my/package: ERROR: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: Error: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package: @ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
@my/package:   Expression form not supported.
@my/package:     at Object.compileSourceFiles (/my/project/node_modules/ng-packagr/src/lib/ngc/compile-source-files.ts:96:11)

Versions of NgRx, Angular, Node, affected browser(s):

Angular CLI: 11.1.4
Node: 10.22.0
OS: linux x64

Angular: 11.1.2
... animations, common, compiler, compiler-cli, core, elements
... forms, language-service, platform-browser
... platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1101.4
@angular-devkit/build-angular   0.1101.4
@angular-devkit/core            11.1.4
@angular-devkit/schematics      11.1.4
@angular/cdk                    11.2.0
@angular/cli                    11.1.4
@schematics/angular             11.1.4
@schematics/update              0.1101.4
rxjs                            6.6.3
typescript                      4.1.3

I would be willing to submit a PR to fix this issue

[ ] Yes (Assistance is provided if you need help submitting a pull request)
[x] No

@timdeschryver
Copy link
Member

Do you have a reproduction of this @matheo ?
There's also this stack overflow question that has the same problem.
I tried to reproduce this problem at the angular-ngrx-material-starter repo, and everything seems to work after the upgrade.

@matheo
Copy link
Author

matheo commented Feb 10, 2021

@timdeschryver Unfortunately nope, and my lerna setup is hard to reproduce.
But if someone else is having the issue then it might be reproducable on a NX with Angular libraries tho,
the one triggering the issue is ng-packagr, that's why I kept the origin of my log.

@rishi-tandon
Copy link

We faces the same issue while updating Angular and NgRx to 11.

✖ Compiling TypeScript sources through NGC
ERROR: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
  Expression form not supported.

@bbortt
Copy link

bbortt commented Feb 10, 2021

it was me who opened the stackoverflow thread. because I didn't want to spam your repo with an issue I am pretty much sure is my fault :)
I can track down the beta-release versions of @ngrx/store@^11.0.0 tomorrow. we can take a look at the diffs if we know between which exact versions the error occurs.

@bbortt
Copy link

bbortt commented Feb 11, 2021

so, I've done some investigation. as already mentioned on Stackoverflow I've tracked the issue down to the StoreModule#forFeature:

AModule:

import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { ReactiveFormsModule } from '@angular/forms';
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { reducers } from './reducers';

export const COMPONENTS = [
  /* a, b */
];

@NgModule({
  imports: [/* ... , */ CommonModule, ReactiveFormsModule],
  declarations: COMPONENTS,
  exports: COMPONENTS
})
export class AModule {
  static forRoot(): ModuleWithProviders<RootAModule> {
    return {
      ngModule: RootAModule,
      providers: [
        /* ... */
      ]
    };
  }
}

@NgModule({
  imports: [
    AModule,
    StoreModule.forFeature('a', reducers),
    EffectsModule.forFeature([
      /* ... */
    ])
  ]
})
export class RootAModule {}

reducers:

export interface AStateData {
  a: fromA.aType;
  b: fromB.bType;
}

export const reducers = {
  a: fromA.a,
  b: fromB.b
};

// fromA
export function a(state = initialState, action: a.Actions): aType { ... }

// fromB
export function b(state = initialState, action: b.Actions): bType { ... }

versions and build results, "@angular/core": "11.1.2" in use:

  • 10.1.2 build passes.
  • 11.0.0-beta.0 (diff) build failes, slightly different error:
An unhandled exception occurred: Error during template compile of 'RootAModule'
  Function calls are not supported in decorators but 'StoreModule' was called.
Unexpected value 'undefined' imported by the module 'RootAModule in ...'
Error during template compile of 'AModule'
  Function calls are not supported in decorators but 'StoreModule' was called.
  • 11.0.0-beta.1 (diff) build passes again.
  • 11.0.0-beta.2 (diff) build failes:
An unhandled exception occurred: @ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(224,21): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(231,15): Error during template compile of 'StoreModule'
  Expression form not supported.
@ngrx/store/ngrx-store.ts(257,13): Error during template compile of 'StoreModule'
  Expression form not supported.
  • 11.0.0-rc-0 build failes, same error.
  • 11.0.0 build failes, same error.

I will take a look at the diffs now. maybe I can find something.

Edit 1: Maybe I will try creating a reproducible example based on our source. let's see what I can do.

@bbortt
Copy link

bbortt commented Feb 11, 2021

@timdeschryver there you go: https://github.com/bbortt/ngrx-store-module-reproducible
yarn && yarn build:lib should do "the trick" (aka result in the error). thanks for any help!

@qirex
Copy link

qirex commented Feb 11, 2021

I can reproduce this with another project and can confirm that this error was not appearing in 11.0.0-beta.1 . After upgrading to 11.0.0 the build is failing.

@timdeschryver
Copy link
Member

Thanks for the reproduction @bbortt

@brandonroberts
Copy link
Member

I'm going to bet it's probably this one, as it's the only changes made to StoreModule.forFeature

#2885

@timdeschryver
Copy link
Member

@brandonroberts I got a fix, I'm just validating it works against the reproduction @bbortt provided

@brandonroberts
Copy link
Member

👍🏿

@bbortt
Copy link

bbortt commented Feb 12, 2021

@brandonroberts I got a fix, I'm just validating it works against the reproduction @bbortt provided

@timdeschryver I can approve it. many thanks.

@matheo
Copy link
Author

matheo commented Feb 15, 2021

@timdeschryver the fix is still unreleased :-?

@bbortt
Copy link

bbortt commented Feb 15, 2021

@timdeschryver the fix is still unreleased :-?

saw that too this morning. any chance to get 11.0.1? 😄

@timdeschryver
Copy link
Member

@matheo the fix will be in v 11.0.1

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 a pull request may close this issue.

6 participants