angular-cli: bug(moment-adapter): "_rollupMoment__default is not defined"
(related with https://github.com/angular/angular/issues/36248)
Reproduction
https://github.com/kaito3desuyo/angular-test
Steps to reproduce:
- clone this repository
ng build --prod
npm i -g http-server
- move root directory to
dist/angular-test
Folder http-server
- open
http://localhost:8080
This issue only occurs with production builds.
Expected Behavior
Screen is displayed correctly
Actual Behavior
Screen goes blank with console error
Environment
- Angular: 9.1.0
- CDK/Material: 9.2.0
- Browser(s): Chrome 80.0.3987.149
- Operating System (e.g. Windows, macOS, Ubuntu): Windows 10 x64 1909 18363.720
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 80
- Comments: 58 (7 by maintainers)
Commits related to this issue
- fix(@angular-devkit/build-optimizer): use TypeScript 3.6 Fixes: #17320 — committed to clydin/angular-cli by clydin 4 years ago
- fix(@angular-devkit/build-optimizer): use TypeScript 3.6 Fixes: #17320 — committed to clydin/angular-cli by clydin 4 years ago
- Update 3rd party libraries Need to pin @angular-devkit/build-angular to 0.900.7 due to https://github.com/angular/angular-cli/issues/17320 Request: MO Change-Id: I2fe563fb83fc35621a1f1511377497f1c3f... — committed to bdeployteam/bdeploy by mduft 4 years ago
- fix(@angular-devkit/build-optimizer): use TypeScript 3.6 Fixes: #17320 — committed to angular/angular-cli by clydin 4 years ago
- fix(@angular-devkit/build-optimizer): use TypeScript 3.6 Fixes: #17320 — committed to angular/angular-cli by clydin 4 years ago
The new
@angular-devkit/build-angular
has a problem compiling@angular/material-moment-adapter
:Possible workaround is just to add this to
polyfills.ts
:window['_rollupMoment__default'] = null;
Edit: Noted wrong package š
Can recreate with
"@angular-devkit/build-angular": "~0.901.0"
āResolvedā with
"@angular-devkit/build-angular": "~0.900.7"
Issue is not resolved, this is a workaround. We shouldānt have to downgrade or change moment import.
I spent some time investigating it and itās most-likely an issue with
build-angular
like mentioned above. Iāve narrowed it down to somewhere between0.900.3
and0.901.0-next.4
. The issue comes from the following lines:Compared to the ones from a working version:
Iām transferring the issue over to the correct repo.
Same problem
This is probably the better workaround instead of downgrading the angular-devkit.
I have btw. the same issue with āgetAngularJSGlobalā and ā_rollupMoment__defaultā in our AngularJS/Angular 9.1 Hybrid App.
@JosepAlacid the issue is fixed by this PR https://github.com/angular/angular-cli/pull/17364. Weāll release the fix on Wednesday.
Please note that this is not only problem with Moment - Iām getting the same error with ng2-dragula lib
Lost one day looking for this š¢
I tried the new version 9.1.1, that has been released today, and it solved the issue for me.
Same problem here in production build only with ā@angular-devkit/build-angularā: ā~0.901.0ā. Downgraded for now.
Yep, also seeing this issue with moment after upgrading
Have the same problem but with
main-es2015.8a5dc9b260c775d8aa4b.js:1 Uncaught ReferenceError: dragulaExpt__default is not defined
(ā@angular-devkit/build-angularā: ā~0.901.0ā)@wasiddiqui, ~0.907.0 worked for me. My project is using another lib, that was also built with ~0.901.0. once Iāve rebuilt that lib and my project, the issue has gone. So you might need to check your dependencies.
Same Here:
@JACrazy no need to go back to 3.6. We fixed this issue and published the fix on npm.
Please note that this issue breaks the prod build even for those who donāt use
Moment.js
and_rollupMoment
. Some regression has been introduced going from0.900.7
to0.901.0
.The fix is not our yet. @danielehrhardt did you build the CLI from source?
Thank you @4typen, I was just trying to fix that and your workaround is much better!
As @OckePocke mentioned, we released CLI 9.1.1 today. If the problem still persist for you, feel free to open a new issue linking this one.
I think this is because angular-cli has not been released yet, still in v9.1.0.
I just donāt understand how to apply @mgechev fix or I donāt understand why this issue is closed.
Same here with ng2-dragula after updating from 9.0.0 to 9.1.0ā¦
Same problem with the production build.