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 --prodnpm i -g http-server- move root directory to
dist/angular-testFolder 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
@danielehrhardt Is that with @mgechev 's fix or?
Yes
The fix is not our yet. @danielehrhardt did you build the CLI from source?
Downgrading the devkit has problems if you run npm audit fix in your deployments. This seemed to fix it until a couple days ago and now we're getting an error
An unhandled exception occurred: Cannot find module 'webpack-dev-server
So we've switched to the solution of adding window['_rollupMoment__default'] = null; to polyfills.ts
@JosepAlacid the issue is fixed by this PR #17364. We'll release the fix on Wednesday.
Still not working. Just updated my deps to the latest ones and still same error.
I think this is because angular-cli has not been released yet, still in v9.1.0.
I tried the new version 9.1.1, that has been released today, and it solved the issue for me.
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.
The 9.1.1 CLI release seems to have fixed the same issue I got.
No more window['_rollupMoment__default'] = null;-in-polyfills.ts workaround needed.
No more window['_rollupMoment__default'] = null; but Moment imports should be updated like there : https://stackblitz.com/angular/qrmxxmanejy?file=src%2Fapp%2Fdatepicker-views-selection-example.ts
And don't forget to add
"allowSyntheticDefaultImports": true,
at compilerOptins in tsconfig.json
And don't forget to add
"allowSyntheticDefaultImports": true,at compilerOptins in tsconfig.json
@JosepAlacid indeed 😉
This fix made my "ng test" configuration use Typescript 3.6, meaning that any files using the safe navigation (Elvis) operator don't compile correctly. Is there something special I need to do (angular.json edits, etc.) so that only build optimization is impacted?
@hamfastgamgee optional chaining (safe navigation, elvis, etc.) is part of TypeScript 3.7.
@mgechev Right, and Angular 9.1.x supports 3.8. But after this fix to use 3.6 in the build optimizer, "ng test" is running as 3.6 for me, meaning that code is not working if it uses 3.7 or 3.8 features. I'm trying to figure out if it's something wrong in my config that's causing "ng test" to use the wrong TS version, or if this effectively causes TS 3.7+ to be unsupported again and should have been documented more explicitly.
Sad to see we're back to 3.6, was really liking optional chaining
@JACrazy no need to go back to 3.6. We fixed this issue and published the fix on npm.
@JACrazy no need to go back to 3.6. We fixed this issue and published the fix on npm.
Great to hear!
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.