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

Need to run "ng build | serve | test" twice to finish command without errors #19395

Closed
3 of 15 tasks
madoar opened this issue Nov 15, 2020 · 2 comments · Fixed by #19399
Closed
3 of 15 tasks

Need to run "ng build | serve | test" twice to finish command without errors #19395

madoar opened this issue Nov 15, 2020 · 2 comments · Fixed by #19399
Labels
area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Milestone

Comments

@madoar
Copy link

madoar commented Nov 15, 2020

🐞 Bug report

Command (mark with an x)

  • new
  • build
  • serve
  • test
  • e2e
  • generate
  • add
  • update
  • lint
  • extract-i18n
  • run
  • config
  • help
  • version
  • doc

Is this a regression?

Yes, if I remember correctly with Angular 8 this error was not present or at least I didn't stumble across it. (I'm not entirely sure but it is also possible that it worked as well with Angular 9)

Description

I'm the author of the angular library angular-archwizard which I build with angular-cliandng-packagr. In addition to the main repository that contains the sourcecode for the library I have a second repository called angular-archwizard-demothat contains an angular project with a number of buildable examples usingangular-archwizard`.

I also use the angular-archwizard-demo project for manual testing to ensure that any changes that I make on the sourcecode of the library continues to function correctly visually. For this purpose I'm added a custom "preinstall" script to my travis setup that first clones the angular-archwizard repository, builds it locally and then includes it into the angular-archwizard-demo project using npm install --save ../angular-archwizard/dist.

For a while now I discovered that I need to run certain ng commands twice to get a "successful" result. These commands are ng build, ng serve and ng test. The first time I execute ng build or ng serve I receive an erroneous build, that leads to the following error message in the console of Chromium:

Uncaught Error: Type ArchwizardModule does not have 'ɵmod' property.
    at getNgModuleDef (core.js:1839)
    at recurse (core.js:24878)
    at recurse (core.js:24889)
    at recurse (core.js:24889)
    at registerNgModuleType (core.js:24874)
    at new NgModuleFactory$1 (core.js:24988)
    at compileNgModuleFactory__POST_R3__ (core.js:28544)
    at PlatformRef.bootstrapModule (core.js:28782)
    at Module.zUnb (main.ts:11)
    at __webpack_require__ (bootstrap:79)

The second time I get a functional build, that works as expected.

When running ng test for the first time it fails with the errors as shown in the following Travis CI job. When executing the tests for the second time they finish successfully.

In my opinion it is also important to note that I build the library itself (angular-archwizard) with Ivy disabled and the demo project (angular-archwizard-demo) with Ivy enabled. If I change this to either building both projects with Ivy enabled or disabled the commands work as expected on the first try. Therefore my guess is that the interoperability of Ivy projects with non-Ivy projects is somehow erroneous (or my config is)

🔬 Minimal Reproduction

Tasks to build the library

  1. clone angular-archwizard (https://github.com/madoar/angular-archwizard)
  2. install all dependencies (npm install)
  3. build the library (npm run build)

Tasks to build the demo and run its tests

  1. clone angular-archwizard-demo (https://github.com/madoar/angular-archwizard-demo)
  2. switch to the Angular (11) update branch (git checkout enhancement-update-dependencies)
  3. optional step: delete package-lock.json file
  4. install your local "development" version of angular-archwizard (npm install --save ../angular-archwizard/dist)
  5. install all remaining dependencies (npm install)
  6. run tests (npm test)

🔥 Exception or Error

🌍 Your Environment



     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 11.0.1
Node: 12.12.0
OS: linux x64

Angular: 11.0.0
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: Yes

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1100.1
@angular-devkit/build-angular   0.1100.1
@angular-devkit/core            11.0.1
@angular-devkit/schematics      11.0.1
@angular/cli                    11.0.1
@schematics/angular             11.0.1
@schematics/update              0.1100.1
rxjs                            6.6.3
typescript                      4.0.5

Anything else relevant?
Off-topic: If you execute the above commands with node 15 you get an error message because of an incompatible karma version (5.2.x is larger than 5.1.x)

@alan-agius4 alan-agius4 added area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix labels Nov 16, 2020
@ngbot ngbot bot modified the milestone: Backlog Nov 16, 2020
@alan-agius4
Copy link
Collaborator

Hi @madoar,

Thanks for the excellent reproduction. I managed to track down the issue and I'll be doing a PR shortly.

Off-topic: If you execute the above commands with node 15 you get an error message because of an incompatible karma version (5.2.x is larger than 5.1.x)

This error is shown on all versions of Node.JS. @angular-devkit/build-angular version 0.1100.1 only supported karma 5.1.x

clydin pushed a commit that referenced this issue Nov 16, 2020
…CC processing

Use `enhanced-resolve` instead of `require.resolve` to ensure that we can use symlink path instead of real-path when resolving a linked module.

Closes #19395
clydin pushed a commit that referenced this issue Nov 16, 2020
…CC processing

Use `enhanced-resolve` instead of `require.resolve` to ensure that we can use symlink path instead of real-path when resolving a linked module.

Closes #19395

(cherry picked from commit eb313f7)
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 17, 2020
ikjelle pushed a commit to ikjelle/angular-cli that referenced this issue Mar 26, 2024
…CC processing

Use `enhanced-resolve` instead of `require.resolve` to ensure that we can use symlink path instead of real-path when resolving a linked module.

Closes angular#19395
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: @ngtools/webpack freq1: low Only reported by a handful of users who observe it rarely severity3: broken type: bug/fix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants