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

fix(ngcc): correctly identify the package of targeted entry-points #36249

Closed

Conversation

@petebacondarwin
Copy link
Member

petebacondarwin commented Mar 25, 2020

In some scenarios, such as yarn workspaces, the node_modules
folder containing the target entry-point is not contained by
the original basePath passed to ngcc.

In this case, we were not computing the package path for secondary
entry-points correctly, instead assuming that the path was the primary
entry-point.

I optimistically suggest that is PR will fix #35747, #18637 and #36060. But I need to actually go through and check.

@ngbot ngbot bot modified the milestone: needsTriage Mar 25, 2020
@googlebot googlebot added the cla: yes label Mar 25, 2020
@pullapprove pullapprove bot requested a review from kara Mar 25, 2020
@petebacondarwin petebacondarwin requested review from gkalpak and JoostK and removed request for kara Mar 25, 2020
@petebacondarwin petebacondarwin force-pushed the petebacondarwin:ngcc-target-base-path branch 2 times, most recently from 0fc055a to c0d228c Mar 26, 2020
@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

@petebacondarwin any way I can test this PR on my project? Is there a build/preview available somewhere?

@petebacondarwin

This comment has been minimized.

@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

I've replaced just the @angular/compiler-cli dep, should be enough, right?

package.json

    "@angular/compiler-cli": "https://664025-24195339-gh.circle-artifacts.com/0/angular/compiler-cli-pr36249-c0d228c932.tgz",

I have verified by looking inside node_modules that the file modified by the PR has the proper changes.

But in the real-world project based on which I created #35747 I'm getting the same error:

Compiling @angular/material : es2015 as esm2015

Compiling @angular/material-moment-adapter : es2015 as esm2015

Compiling @ngx-loading-bar/core : es2015 as esm2015

Compiling @ngx-loading-bar/http-client : es2015 as esm2015

WARNING in Entry point 'apollo-angular-link-http-batch' contains deep imports into '/home/aandrei/projects/lets-poker-monorepo/node_modules/graphql/language/printer'. This is probably not a problem, but may cause the compilation of entry points to be out of order.

ERROR in Failed to compile entry-point @ngx-loading-bar/http-client (es2015 as esm2015) due to compilation errors:
../../node_modules/@angular/common/http/http.d.ts:2801:22 - error NG6002: Appears in the NgModule.imports of LoadingBarHttpClientModule, but could not be resolved to an NgModule class.

This likely means that the library (@angular/common/http) which declares HttpClientModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

2801 export declare class HttpClientModule {
                          ~~~~~~~~~~~~~~~~
../../node_modules/@angular/common/http/http.d.ts:2801:22 - error NG6003: Appears in the NgModule.exports of LoadingBarHttpClientModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.

This likely means that the library (@angular/common/http) which declares HttpClientModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

2801 export declare class HttpClientModule {
@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

Not sure whether this matters, but the packages get installed by yarn into this layout:

image

So ngcc is under a subdirectory in packages, and the rest of the packages are outside in the root node_modules.

@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

Some additional information that might be helpful. I've added these debugging logs:

image

This is the output right up to the error:

(click to expand)
0% compiling[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser-dynamic',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/compiler',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/core',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/router',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser/animations',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/forms',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-cache-inmemory',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-cache-inmemory',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-link-context',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-link-context',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-link',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-link',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-link-ws',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-link-ws',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-utilities',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-utilities',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/subscriptions-transport-ws',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/subscriptions-transport-ws',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/packages/proj-shared',
  '/home/aandrei/projects/proj-monorepo/packages'
]
[ 'second', '/home', '/' ]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-translate/core',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-translate'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-translate',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/graphql',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/graphql',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http-batch',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http-batch',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/material',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/material-moment-adapter',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/core',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/http-client',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/http-client',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/tslib',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/tslib',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/core',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/core',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/tslib',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/tslib',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/core',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/@angular',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'first',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]
[
  'second',
  '/home/aandrei/projects/proj-monorepo/node_modules/rxjs',
  '/home/aandrei/projects/proj-monorepo/node_modules'
]

Compiling @ngx-loading-bar/http-client : es2015 as esm2015

Edit: Interestingly, the actual packagePath that was computed prior to this PR looks correct:

'/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http'

That's the actual disk location.

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

So notably it does not appear to be building @angular/common/http, right? Did you clean out your entire node_modules at all levels before running this again?

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

'/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http' is the entry-point path but '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common' would be the package path. Can you change your logging to be:

    if (this.fs.exists(join(packagePath, 'package.json'))) {
      console.log(entryPointPath, packagePath);
      return packagePath;
    }
@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

@petebacondarwin it is building @angular/common/http, here's the relevant log:

/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs

Compiling @angular/common/http : es2015 as esm2015

I did clear node_modules, but just did it again and added the log you mentioned.

The full log is here: https://gist.github.com/andreialecu/1dc278a2433438cf647076c75d26c1f3

@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

'/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http' is the entry-point path but '/home/aandrei/projects/proj-monorepo/node_modules/@angular/common' would be the package path

Also, from what I can see there is both an @angular/common and an @angular/common/http both with their own package.jsons.

image

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

I think there is a bug in my PR for namespaced packages (e.g. @angular/....). Working on a fix.

@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

@petebacondarwin I also added this log, for the fallback case:

            // If we get here then none of the `basePaths` matched the `entryPointPath`, which
            // is somewhat unexpected and means that this entry-point lives completely outside
            // any of the `basePaths`.
            // All we can do is assume that his entry-point is a primary entry-point to a package.
            console.log(entryPointPath, this.fs.exists(file_system_1.join(entryPointPath, 'package.json')));
            return entryPointPath;

And this is logged:

yarn run v1.22.0
$ yarn workspace proj-admin build-release
$ cross-env NODE_ENV=production yarn workspace proj-shared build
$ tsc -b tsconfig.build.json
$ ng build --aot --prod
0% compiling/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser-dynamic true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/compiler true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/core true
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/@angular/router true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/common true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/platform-browser/animations true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/forms true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http true
/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular /home/aandrei/projects/proj-monorepo/node_modules/apollo-angular
/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http /home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http
/home/aandrei/projects/proj-monorepo/node_modules/apollo-cache-inmemory /home/aandrei/projects/proj-monorepo/node_modules/apollo-cache-inmemory
/home/aandrei/projects/proj-monorepo/node_modules/apollo-link-context /home/aandrei/projects/proj-monorepo/node_modules/apollo-link-context
/home/aandrei/projects/proj-monorepo/node_modules/apollo-link /home/aandrei/projects/proj-monorepo/node_modules/apollo-link
/home/aandrei/projects/proj-monorepo/node_modules/apollo-link-ws /home/aandrei/projects/proj-monorepo/node_modules/apollo-link-ws
/home/aandrei/projects/proj-monorepo/node_modules/apollo-utilities /home/aandrei/projects/proj-monorepo/node_modules/apollo-utilities
/home/aandrei/projects/proj-monorepo/node_modules/subscriptions-transport-ws /home/aandrei/projects/proj-monorepo/node_modules/subscriptions-transport-ws
/home/aandrei/projects/proj-monorepo/packages/proj-shared true
/home/aandrei/projects/proj-monorepo/node_modules/@ngx-translate/core true
/home/aandrei/projects/proj-monorepo/node_modules/graphql /home/aandrei/projects/proj-monorepo/node_modules/graphql
/home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http-batch /home/aandrei/projects/proj-monorepo/node_modules/apollo-angular-link-http-batch
/home/aandrei/projects/proj-monorepo/node_modules/@angular/material true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/material-moment-adapter true
/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/core true
/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/http-client true
/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/http-client true
/home/aandrei/projects/proj-monorepo/node_modules/tslib /home/aandrei/projects/proj-monorepo/node_modules/tslib
/home/aandrei/projects/proj-monorepo/node_modules/@ngx-loading-bar/core true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/core true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/common/http true
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/tslib /home/aandrei/projects/proj-monorepo/node_modules/tslib
/home/aandrei/projects/proj-monorepo/node_modules/@angular/core true
/home/aandrei/projects/proj-monorepo/node_modules/@angular/common true
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/@angular/common true
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs/operators /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs
/home/aandrei/projects/proj-monorepo/node_modules/rxjs /home/aandrei/projects/proj-monorepo/node_modules/rxjs

Compiling @ngx-loading-bar/http-client : es2015 as esm2015

ERROR in Failed to compile entry-point @ngx-loading-bar/http-client (es2015 as esm2015) due to compilation errors:
../../node_modules/@angular/common/http/http.d.ts:2801:22 - error NG6002: Appears in the NgModule.imports of LoadingBarHttpClientModule, but could not be resolved to an NgModule class.

This likely means that the library (@angular/common/http) which declares HttpClientModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

2801 export declare class HttpClientModule {
                          ~~~~~~~~~~~~~~~~
../../node_modules/@angular/common/http/http.d.ts:2801:22 - error NG6003: Appears in the NgModule.exports of LoadingBarHttpClientModule, but could not be resolved to an NgModule, Component, Directive, or Pipe class.

This likely means that the library (@angular/common/http) which declares HttpClientModule has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

2801 export declare class HttpClientModule {
                          ~~~~~~~~~~~~~~~~

I can see that it is indeed looking for both @angular/common and @angular/common/http in the proper places and the package.json exists in both. This might indicate that the bug isn't in this particular section of ngcc?

@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

One thing I noticed is that there is no __ivy_ngcc__ directory in node_modules/@angular/common/http. I'm not familiar with the internals so maybe that is to be expected:

image

node_modules/@angular/common has it, but upon inspection of the files there I don't see anything http related.

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

Yeah the __ivy_ngcc__ folders only exist in the package directory not under what we think of as entry-point directories. This is because entry-points can actually have source files spread across the whole package directory and not necessarily only under the entry-point path.

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

Pushed a new commit...

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

I can confirm that this latest set of commits fixes the problem with the repo at https://github.com/andreialecu/ang9-ng6002, when I tested it locally.

@petebacondarwin petebacondarwin requested a review from JoostK Mar 26, 2020
@andreialecu

This comment has been minimized.

Copy link
Contributor

andreialecu commented Mar 26, 2020

Success! 🚀 🚀

The latest commit indeed fixed it and it seems that the Ivy build finally completed on the actual production project.

Great job @petebacondarwin. Thanks for this!

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

Thanks to @JoostK for the original insight into what was happening here - #36060 (comment)

@petebacondarwin

This comment has been minimized.

Copy link
Member Author

petebacondarwin commented Mar 26, 2020

And thanks for your patience and help @andreialecu

@JoostK
JoostK approved these changes Mar 26, 2020
Copy link
Member

JoostK left a comment

I think this got us covered for the situations we discussed! 💯

@petebacondarwin petebacondarwin removed the request for review from gkalpak Mar 26, 2020
Previously we only searched for package paths below the set of `basePaths`
that were computed from the `basePath` provided to ngcc and the set of
`pathMappings`.

In some scenarios, such as hoisted packages, the entry-point is not within
any of the `basePaths` identified above. For example:

```
project
  packages
    app
      node_modules
        app-lib (depends on lib1)
  node_modules
    lib1 (depends on lib2)
      node_modules
        lib2 (depends on lib3/entry-point)
    lib3
      entry-point
```

When CLI is compiling `app-lib` ngcc will be given
`project/packages/app/node_modules` as the `basePath.

If ngcc is asked to target `lib2`, the `targetPath` will be
`project/node_modules/lib1/node_modules/lib2`.

Since `lib2` depends upon `lib3/entry-point`, ngcc will need to compute
the package path for `project/node_modules/lib3/entry-point`.

Since `project/node_modules/lib3/entry-point` is not contained in the `basePath`
`project/packages/app/node_modules`, ngcc failed to compute the `packagePath`
correctly, instead assuming that it was the same as the entry-point path.

Now we also consider the nearest `node_modules` folder to the entry-point
path as an additional `basePath`. If one is found then we use the first
directory directly below that `node_modules` directory as the package path.

In the case of our example this extra `basePath` would be `project/node_modules`
which allows us to compute the `packagePath` of `project/node_modules/lib3`.

Fixes #35747
@petebacondarwin petebacondarwin force-pushed the petebacondarwin:ngcc-target-base-path branch from 479841a to 49fdbbd Mar 26, 2020
alxhub added a commit that referenced this pull request Mar 27, 2020
…nts (#36249)

Previously we only searched for package paths below the set of `basePaths`
that were computed from the `basePath` provided to ngcc and the set of
`pathMappings`.

In some scenarios, such as hoisted packages, the entry-point is not within
any of the `basePaths` identified above. For example:

```
project
  packages
    app
      node_modules
        app-lib (depends on lib1)
  node_modules
    lib1 (depends on lib2)
      node_modules
        lib2 (depends on lib3/entry-point)
    lib3
      entry-point
```

When CLI is compiling `app-lib` ngcc will be given
`project/packages/app/node_modules` as the `basePath.

If ngcc is asked to target `lib2`, the `targetPath` will be
`project/node_modules/lib1/node_modules/lib2`.

Since `lib2` depends upon `lib3/entry-point`, ngcc will need to compute
the package path for `project/node_modules/lib3/entry-point`.

Since `project/node_modules/lib3/entry-point` is not contained in the `basePath`
`project/packages/app/node_modules`, ngcc failed to compute the `packagePath`
correctly, instead assuming that it was the same as the entry-point path.

Now we also consider the nearest `node_modules` folder to the entry-point
path as an additional `basePath`. If one is found then we use the first
directory directly below that `node_modules` directory as the package path.

In the case of our example this extra `basePath` would be `project/node_modules`
which allows us to compute the `packagePath` of `project/node_modules/lib3`.

Fixes #35747

PR Close #36249
@alxhub alxhub closed this in 995cd15 Mar 27, 2020
@petebacondarwin petebacondarwin deleted the petebacondarwin:ngcc-target-base-path branch Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants
You can’t perform that action at this time.