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

🐞[BUG]: Compatiblity between versions #2021

Closed
chihab opened this issue May 17, 2023 · 3 comments
Closed

🐞[BUG]: Compatiblity between versions #2021

chihab opened this issue May 17, 2023 · 3 comments

Comments

@chihab
Copy link

chihab commented May 17, 2023

If a library depends on @ngxs/store, should the app using it be on the exact same @ngxs/store version? If yes then my bad, we can close the issue but maybe have it documented somewhere.

If not then here is a repo reproducing compatibility issues:
https://github.com/chihab/ngxs-store-compat

git clone https://github.com/chihab/ngxs-store-compat.git
cd ngxs-store-compat

Angular 13, App using v3.7, Lib using 3.8

git reset --hard v13-app3.7-lib3.8
cd ng-lib && npm i && npm run build && cd ../ng-app && npm i && npm run build
> ng-lib@0.0.0 build
> ng build

Building Angular Package

------------------------------------------------------------------------------
Building entry point 'ngxs-lib'
------------------------------------------------------------------------------
✔ Compiling with Angular sources in Ivy partial compilation mode.
✔ Generating FESM2020
✔ Generating FESM2015
✔ Copying assets
✔ Writing package manifest
✔ Built ngxs-lib

------------------------------------------------------------------------------
Built Angular Package
 - from: /tmp/ngx-store-bug/ng-lib/projects/ngxs-lib
 - to:   /tmp/ngx-store-bug/ng-lib/dist/ngxs-lib
------------------------------------------------------------------------------

Build at: 2023-05-17T19:20:10.611Z - Time: 3598ms


added 122 packages, removed 105 packages, changed 116 packages, and audited 963 packages in 9s

122 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> ng-app@0.0.0 build
> ng build

⠙ Generating browser application bundles (phase: setup)...
- @ngxs/store/internals [es2015/esm2015] (git+https://github.com/ngxs/store.git)

- @ngxs/store [es2015/esm2015] (git+https://github.com/ngxs/store.git)
✔ Browser application bundle generation complete.

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i2.ɵNgxsRootModule to symbol
    at /tmp/ngx-store-bug/ng-app/node_modules/@ngtools/webpack/src/ivy/loader.js:81:18
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i2.ɵNgxsRootModule to symbol
    at /tmp/ngx-store-bug/ng-app/node_modules/@ngtools/webpack/src/ivy/loader.js:81:18
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Error: node_modules/ngxs-lib/lib/ngxs-lib.module.d.ts:6:98 - error TS2339: Property 'ɵNgxsRootModule' does not exist on type 'typeof import("/tmp/ngx-store-bug/ng-app/node_modules/@ngxs/store/ngxs-store")'.

6     static ɵmod: i0.ɵɵNgModuleDeclaration<ShellModule, never, [typeof i1.CommonModule, typeof i2.ɵNgxsRootModule], never>;

Angular 15, App using v3.8, Lib using 3.7

git reset --hard v15-app3.8-lib3.7
cd ng-lib && npm i && npm run build && cd ../ng-app && npm i && npm run build
Building Angular Package

------------------------------------------------------------------------------
Building entry point 'ngxs-lib'
------------------------------------------------------------------------------
⠋ Compiling with Angular sources in Ivy partial compilation mode.- @ngxs/store/internals [es2015/esm2015] (git+https://github.com/ngxs/store.git)
- @ngxs/store [es2015/esm2015] (git+https://github.com/ngxs/store.git)
✔ Compiling with Angular sources in Ivy partial compilation mode.
✔ Generating FESM2020
✔ Generating FESM2015
✔ Copying assets
✔ Writing package manifest
✔ Built ngxs-lib

------------------------------------------------------------------------------
Built Angular Package
 - from: /tmp/ngx-store-bug/ng-lib/projects/ngxs-lib
 - to:   /tmp/ngx-store-bug/ng-lib/dist/ngxs-lib
------------------------------------------------------------------------------

Build at: 2023-05-17T19:24:29.811Z - Time: 4028ms


added 105 packages, removed 123 packages, changed 116 packages, and audited 946 packages in 8s

104 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

> ng-app@0.0.0 build
> ng build

✔ Browser application bundle generation complete.

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i2.ɵj to symbol

./src/polyfills.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Cannot resolve type entity i2.ɵj to symbol

Error: node_modules/ngxs-lib/lib/ngxs-lib.module.d.ts:6:98 - error TS2339: Property 'ɵj' does not exist on type 'typeof import("@ngxs/store")'.

6     static ɵmod: i0.ɵɵNgModuleDeclaration<ShellModule, never, [typeof i1.CommonModule, typeof i2.ɵj], never>;
@markwhitfeld
Copy link
Member

The issue here is that you are using Angular 15 which does not run ngcc for compatibility with libraries compiled for view engine.
Ngxs v3.7 is not compatible with Angular 15. You should have got a warning about incompatible peer dependencies during your npm install.

With semantic versioning, if a library (or your code) depends on a version of another lib, then it will be compatible with all minor versions and patches above that.
Minor versions add features and patches fix bugs. It is always additive.

@chihab
Copy link
Author

chihab commented May 18, 2023

if ngxs v3.7 is not compatible with Angular 15, the peerDependencies should be fixed here no?

"peerDependencies": { "@angular/core": ">=6.1.0 <16.0.0", "rxjs": ">=6.5.5" },

@s-lee
Copy link

s-lee commented May 18, 2023

Hi @markwhitfeld , for the first case, the error is thrown when both app and lib are based on Angular 13, but using the different NGXS versions, 3.7.x and 3.8.0. are they supposed to be using the same version?

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

3 participants