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

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

Closed
kaito3desuyo opened this issue Mar 26, 2020 · 58 comments · Fixed by #17364
Closed

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

kaito3desuyo opened this issue Mar 26, 2020 · 58 comments · Fixed by #17364

Comments

@kaito3desuyo
Copy link

(related with angular/angular#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
@LanderBeeuwsaert
Copy link

I'm also using the moment-adapter so most probably the cause is the same.

@jnfaerch
Copy link

jnfaerch commented Mar 26, 2020

Edit: Noted wrong package :/

Can recreate with "@angular-devkit/build-angular": "~0.901.0"

"Resolved" with "@angular-devkit/build-angular": "~0.900.7"

@keserwan
Copy link

Same here, @jnfaerch suggestion worked.

@mgameover
Copy link

mgameover commented Mar 26, 2020

Same issue: main.95606efb9a87c022e413.js:1 Uncaught ReferenceError: _rollupMoment__default is not defined
@jnfaerch suggestion worked

@newargus
Copy link

Same Here:
image

@wasiddiqui
Copy link

wasiddiqui commented Mar 26, 2020

facing the same issue
tried to build with @angular-devkit/build-angular": "~0.900.7" but not working

@mgameover
Copy link

mgameover commented Mar 26, 2020

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

@wasiddiqui
Copy link

wasiddiqui commented Mar 26, 2020

MY ISSUE RESOLVED by workaround
Steps

  1. Allow "allowSyntheticDefaultImport":true in tsconfig.json under compilerOptions.
  2. Change "@angular-devkit/build-angular": "~0.901.0" to @angular-devkit/build-angular": "~0.900.7"
  3. Import moment like this

import * as _moment from 'moment';
import { default as _rollupMoment } from 'moment';
const moment = _rollupMoment || _moment;

  1. npm install
  2. ng build

@blackholegalaxy
Copy link

ISSUE RESOLVED

Issue is not resolved, this is a workaround. We should'nt have to downgrade or change moment import.

@crisbeto crisbeto self-assigned this Mar 26, 2020
@crisbeto
Copy link
Member

crisbeto commented Mar 26, 2020

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 between 0.900.3 and 0.901.0-next.4. The issue comes from the following lines:

var Jg = n("wd/R");
const Zg = _rollupMoment__default || Jg

Compared to the ones from a working version:

Ng = n("wd/R"),
Vg = n.n(Ng).a || Ng

I'm transferring the issue over to the correct repo.

@marsc
Copy link

marsc commented Mar 27, 2020

Same problem here in production build only with "@angular-devkit/build-angular": "~0.901.0". Downgraded for now.

@LemonyPie
Copy link

LemonyPie commented Mar 27, 2020

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")

@TheParad0X
Copy link

Same problem here after an update from Angular 9.0.5 to the latest

@mikejunt
Copy link

Yep, also seeing this issue with moment after upgrading

@atsjo
Copy link

atsjo commented Mar 28, 2020

Same

@fpmk
Copy link

fpmk commented Mar 29, 2020

any news?

@pabloxn
Copy link

pabloxn commented Mar 30, 2020

Same problem

@deepakgonda
Copy link

Same problem with the production build.

@acherniak
Copy link

Any good news?

@jasoninrapid
Copy link

We're seeing the same problem on an Angular 8 to Angular 9 upgrade we did on March 26. Details:

  • ng2-dragular module got transpiled with the same bad "dragulaExpt__default" referenced above.
  • Downgrading angular devkit fix it for us. Our (fixed) entry in the dev dependencies in package.json looks like: "@angular-devkit/build-angular": "0.900.7"

@JosepAlacid
Copy link

I just don't understand how to apply @mgechev fix or I don't understand why this issue is closed.

@mgechev
Copy link
Member

mgechev commented Apr 6, 2020

@JosepAlacid the issue is fixed by this PR #17364. We'll release the fix on Wednesday.

@JosepAlacid
Copy link

I will go on until then with the "window['_rollupMoment__default'] = null;" workaround.
Thanks for your kind response.

@danielehrhardt
Copy link

image

@spock123
Copy link

spock123 commented Apr 6, 2020

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

@danielehrhardt
Copy link

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

Yes

@mgechev
Copy link
Member

mgechev commented Apr 6, 2020

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

@mtpultz
Copy link

mtpultz commented Apr 7, 2020

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

@gultyayev
Copy link
Contributor

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

@cedricduffournet
Copy link

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

@OckePocke
Copy link

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

@mgechev
Copy link
Member

mgechev commented Apr 8, 2020

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.

@Rajarml
Copy link

Rajarml commented Apr 9, 2020

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.

@whyvrafvr
Copy link

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

@JosepAlacid
Copy link

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

@whyvrafvr
Copy link

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

@JosepAlacid indeed 😉

@hamfastgamgee
Copy link

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?

@mgechev
Copy link
Member

mgechev commented Apr 10, 2020

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

@hamfastgamgee
Copy link

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

@JACrazy
Copy link

JACrazy commented Apr 17, 2020

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

@mgechev
Copy link
Member

mgechev commented Apr 18, 2020

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

@JACrazy
Copy link

JACrazy commented Apr 18, 2020

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

Great to hear!

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators May 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.