Repository navigation
Closed
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimeeffort2: daysfreq1: lowfreq3: hightype: bug/fix
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/common/http
Last line of ./node_modules/@angular/common/fesm5/http.js looks like:
export { ..., HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, ... };
After running ngcc, a new line appears just below:
export {HttpClientXsrfModule};
Which then makes ng build --aot fail (if HttpClientModule is imported), with or without ivy enabled with:
ERROR in ./node_modules/@angular/common/fesm5/http.js 2024:9
Module parse failed: Duplicate export 'HttpClientXsrfModule' (2024:9)
You may need an appropriate loader to handle this file type.
| */
| export { NoopInterceptor as ɵangular_packages_common_http_http_a, JsonpCallbackContext as ɵangular_packages_common_http_http_b, jsonpCallbackContext as ɵangular_packages_common_http_http_c, BrowserXhr as ɵangular_packages_common_http_http_d, HttpXsrfCookieExtractor as ɵangular_packages_common_http_http_g, HttpXsrfInterceptor as ɵangular_packages_common_http_http_h, XSRF_COOKIE_NAME as ɵangular_packages_common_http_http_e, XSRF_HEADER_NAME as ɵangular_packages_common_http_http_f, HttpBackend, HttpHandler, HttpClient, HttpHeaders, HTTP_INTERCEPTORS, JsonpClientBackend, JsonpInterceptor, HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpInterceptingHandler as ɵHttpInterceptingHandler, HttpParams, HttpUrlEncodingCodec, HttpRequest, HttpErrorResponse, HttpEventType, HttpHeaderResponse, HttpResponse, HttpResponseBase, HttpXhrBackend, XhrFactory, HttpXsrfTokenExtractor };
> export { HttpClientXsrfModule };
Is this a regression?
The bug has been present since 7.0 releases (talked on Slack with @petebacondarwin ).
Description
ngcc exports HttpClientXsrfModule twice.
🔬 Minimal Reproduction
ng new ivy-http --defaults
cd ivy-http
$(npm bin)/ivy-ngcc
# check ./node_modules/@angular/common/fesm5/http.js
# add HttpClientModule to AppModule
ng build --aot
🔥 Exception or Error
ERROR in ./node_modules/@angular/common/fesm5/http.js 2024:9
Module parse failed: Duplicate export 'HttpClientXsrfModule' (2024:9)
You may need an appropriate loader to handle this file type.
| */
| export { NoopInterceptor as ɵangular_packages_common_http_http_a, JsonpCallbackContext as ɵangular_packages_common_http_http_b, jsonpCallbackContext as ɵangular_packages_common_http_http_c, BrowserXhr as ɵangular_packages_common_http_http_d, HttpXsrfCookieExtractor as ɵangular_packages_common_http_http_g, HttpXsrfInterceptor as ɵangular_packages_common_http_http_h, XSRF_COOKIE_NAME as ɵangular_packages_common_http_http_e, XSRF_HEADER_NAME as ɵangular_packages_common_http_http_f, HttpBackend, HttpHandler, HttpClient, HttpHeaders, HTTP_INTERCEPTORS, JsonpClientBackend, JsonpInterceptor, HttpClientJsonpModule, HttpClientModule, HttpClientXsrfModule, HttpInterceptingHandler as ɵHttpInterceptingHandler, HttpParams, HttpUrlEncodingCodec, HttpRequest, HttpErrorResponse, HttpEventType, HttpHeaderResponse, HttpResponse, HttpResponseBase, HttpXhrBackend, XhrFactory, HttpXsrfTokenExtractor };
> export { HttpClientXsrfModule };
🌍 Your Environment
Angular Version:
Angular CLI: 7.2.0
Node: 10.14.1
OS: darwin x64
Angular: 7.2.0
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.12.0
@angular-devkit/build-angular 0.12.0
@angular-devkit/build-optimizer 0.12.0
@angular-devkit/build-webpack 0.12.0
@angular-devkit/core 7.2.0
@angular-devkit/schematics 7.2.0
@ngtools/webpack 7.2.0
@schematics/angular 7.2.0
@schematics/update 0.12.0
rxjs 6.3.3
typescript 3.2.2
webpack 4.23.1
Metadata
Metadata
Assignees
Labels
area: coreIssues related to the framework runtimeIssues related to the framework runtimeeffort2: daysfreq1: lowfreq3: hightype: bug/fix
Activity
petebacondarwin commentedon Jan 11, 2019
We are not checking in ngcc to see whether an export that we need is already exported in the code...
JoostK commentedon Jan 24, 2019
I can no longer reproduce. AFAIK, only ngcc's
PrivateDeclarationsAnalyzercontributes to the exports that are written into the output, which does take into account a module's exports. I'm not sure which of the recent changes has apparently resolved this issue though.petebacondarwin commentedon Jan 25, 2019
I don't see it in the latest ngcc of
@angular/commoneither.@cexbrayat - can you double check this before I close it?
gkalpak commentedon Jan 25, 2019
This is the error I was fixing with 78da65f23 (part of #26947). The problem was that (for some reason I don't recall 😇), ngcc would be requested to find the declaration of both the outer
HttpClientXsrfModulevariable identifier and the inner (from inside the IIFE)HttpClientXsrfModulefunction identifier. (Error on CI).Since it could not detect that both identifier refer to the same thing (and return the same declaration), it would create an extra import for essentially the same thing.
Not sure why it works now without my fix 😁
gkalpak commentedon Jan 25, 2019
(To be clear: I tried building aio with ivy without my fix and I no longer get the
Duplicate exporterror I was getting before.)JoostK commentedon Jan 25, 2019
I suspected #27848 to have something to do with it, but I tried reverting that change and this issue did still not occur. I don't know what happened 🤷♂️
cexbrayat commentedon Jan 25, 2019
I tried again, and the problem is indeed fixed with
8.0.0-beta.1👍CarreraPHP commentedon Mar 6, 2019
Below is my Angular Client Version Details & My application is created with experimental-ivy config.
I am still facing the issue, can i know in version of 7.x.x the fix will be available?
petebacondarwin commentedon Mar 6, 2019
This will not be fixed in Angular 7.x, since ngcc is a tool in the new ivy feature set which is not part of v7.
CarreraPHP commentedon Mar 10, 2019
@petebacondarwin, thanks for the reply. I am now having 2 applications with same code base. One normal & other ivy. Let me try with the 8.x Version and report if any issue faced.
angular-automatic-lock-bot commentedon Sep 14, 2019
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.