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

ng-packagr not working with ngrx project #754

Closed
rupeshtiwari opened this issue Jan 26, 2018 · 1 comment
Closed

ng-packagr not working with ngrx project #754

rupeshtiwari opened this issue Jan 26, 2018 · 1 comment

Comments

@rupeshtiwari
Copy link
Contributor

rupeshtiwari commented Jan 26, 2018

sample app ngrx-with-ng-packgr.zip

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ x] Bug report  
[ ] Feature request
[ ] Documentation issue or request

What is the current behavior?

ng-packagr is not working


PS Z:\rupesh\rnd\angular\ngrx-with-ng-packgr\my-app> ng-packagr
Building Angular library
Generating bundle for my-app
Cleaning bundle build directory
Processing assets
Running ngc

BUILD ERROR
Error at Z:/rupesh/rnd/angular/ngrx-with-ng-packgr/my-app/.ng_pkg_build/my-app/ts/src/app/app.component.ts:34:14: Exported variable 'getProductState' has or is using name 'MemoizedSelector' from external module "Z:/rupesh/rnd/angular/ngrx-with-ng-packgr/my-app/node_modules/@ngrx/store/src/selector" but cannot be named.
Error: Error at Z:/rupesh/rnd/angular/ngrx-with-ng-packgr/my-app/.ng_pkg_build/my-app/ts/src/app/app.component.ts:34:14: Exported variable 'getProductState' has or is using name 'MemoizedSelector' from external module "Z:/rupesh/rnd/angular/ngrx-with-ng-packgr/my-app/node_modules/@ngrx/store/src/selector" but cannot
be named.
    at new UserError (C:\Users\rtiwari\AppData\Roaming\npm\node_modules\ng-packagr\node_modules\@angular\tsc-wrapped\src\tsc.js:27:28)
    at check (C:\Users\rtiwari\AppData\Roaming\npm\node_modules\ng-packagr\node_modules\@angular\tsc-wrapped\src\tsc.js:93:15)
    at Tsc.typeCheck (C:\Users\rtiwari\AppData\Roaming\npm\node_modules\ng-packagr\node_modules\@angular\tsc-wrapped\src\tsc.js:173:9)
    at C:\Users\rtiwari\AppData\Roaming\npm\node_modules\ng-packagr\node_modules\@angular\tsc-wrapped\src\main.js:122:23
    at <anonymous>

Expected behavior:

ng-packagr should create package successfully like it does for angular project without ngrx.

Minimal reproduction of the problem with instructions:

Please download the ngrx-with-ng-packgr.zip
zip project and then run

npm install
ng-packagr

Version of affected browser(s),operating system(s), npm, node and ngrx:

Browser: Chrome, OS : Windows 2010 , npm 5.6.0, node v8.9.4, ngrx 5.0.1, typescript: ~2.5.3

Other information:

As per microsoft/TypeScript#9944, I also upgraded my typescript version to typescript@next still i am getting the issue.
Please let me know where I am missing something. Also is their any other option to create a package for ngrx project which I can use as npm module. I also created one more issue in ng-packagr not sure where this bug is ng-packagr/ng-packagr#542 It seems that even though we are exporting the MemoizedSelector it is not working properly #57

@rupeshtiwari
Copy link
Contributor Author

rupeshtiwari commented Jan 26, 2018

Hi I created an issue in ng-packagr github ng-packagr/ng-packagr#542
It seems it is not ngrx issue therefore i am closing this issue. I solved this issue by the recommendation of Danny Blue . Here is the working solution, basically we have to explicitly export the types.
If you are using @ngrx/entity then please make sure you import their types and use them in order to compile using ng-packagr.

import { MemoizedSelector } from '@ngrx/store/src/selector';
import { Dictionary, EntitySelectors } from '@ngrx/entity/src/models';
const entityFns = fromProductsAdapter.getSelectors(getProductEntitiesState);
export const {
    selectIds: getProductIds,
    selectAll: getAllProducts,
    selectTotal: getTotalProducts,
  } = entityFns;
export const getProductState: MemoizedSelector<any, any> = createFeatureSelector<any('products');
export const {selectEntities: getProductEntities}: EntitySelectors<Product, any> = entityFns;

https://github.com/roopkt/angular-ngrx-using-ng-packagr

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

No branches or pull requests

1 participant