angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

bug(moment-adapter): "_rollupMoment__default is not defined"

Open kaito3desuyo opened this issue 6 years ago • 58 comments

(related with https://github.com/angular/angular/issues/36248)

Reproduction

https://github.com/kaito3desuyo/angular-test

Steps to reproduce:

  1. clone this repository
  2. ng build --prod
  3. npm i -g http-server
  4. move root directory to dist/angular-test Folder
  5. http-server
  6. 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

kaito3desuyo avatar Mar 26 '20 02:03 kaito3desuyo

@danielehrhardt Is that with @mgechev 's fix or?

Yes

danielehrhardt avatar Apr 06 '20 22:04 danielehrhardt

The fix is not our yet. @danielehrhardt did you build the CLI from source?

mgechev avatar Apr 06 '20 22:04 mgechev

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

mtpultz avatar Apr 07 '20 21:04 mtpultz

@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.

gultyayev avatar Apr 08 '20 11:04 gultyayev

I think this is because angular-cli has not been released yet, still in v9.1.0.

cedricduffournet avatar Apr 08 '20 11:04 cedricduffournet

I tried the new version 9.1.1, that has been released today, and it solved the issue for me.

OckePocke avatar Apr 08 '20 18:04 OckePocke

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.

mgechev avatar Apr 08 '20 20:04 mgechev

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.

Rajarml avatar Apr 09 '20 08:04 Rajarml

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

whyvrafvr avatar Apr 09 '20 10:04 whyvrafvr

And don't forget to add "allowSyntheticDefaultImports": true, at compilerOptins in tsconfig.json

JosepAlacid avatar Apr 09 '20 11:04 JosepAlacid

And don't forget to add "allowSyntheticDefaultImports": true, at compilerOptins in tsconfig.json

@JosepAlacid indeed 😉

whyvrafvr avatar Apr 09 '20 13:04 whyvrafvr

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 avatar Apr 09 '20 23:04 hamfastgamgee

@hamfastgamgee optional chaining (safe navigation, elvis, etc.) is part of TypeScript 3.7.

mgechev avatar Apr 10 '20 05:04 mgechev

@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.

hamfastgamgee avatar Apr 10 '20 11:04 hamfastgamgee

Sad to see we're back to 3.6, was really liking optional chaining

JACrazy avatar Apr 17 '20 23:04 JACrazy

@JACrazy no need to go back to 3.6. We fixed this issue and published the fix on npm.

mgechev avatar Apr 18 '20 03:04 mgechev

@JACrazy no need to go back to 3.6. We fixed this issue and published the fix on npm.

Great to hear!

JACrazy avatar Apr 18 '20 06:04 JACrazy

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.