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

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

LanderBeeuwsaert avatar Mar 26 '20 08:03 LanderBeeuwsaert

Edit: Noted wrong package :/

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

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

jnfaerch avatar Mar 26 '20 08:03 jnfaerch

Same here, @jnfaerch suggestion worked.

keserwan avatar Mar 26 '20 12:03 keserwan

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

mgameover avatar Mar 26 '20 16:03 mgameover

Same Here: image

newargus avatar Mar 26 '20 16:03 newargus

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

wasiddiqui avatar Mar 26 '20 16:03 wasiddiqui

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

mgameover avatar Mar 26 '20 16:03 mgameover

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

wasiddiqui avatar Mar 26 '20 17:03 wasiddiqui

ISSUE RESOLVED

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

blackholegalaxy avatar Mar 26 '20 17:03 blackholegalaxy

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.

crisbeto avatar Mar 26 '20 20:03 crisbeto

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

marsc avatar Mar 27 '20 09:03 marsc

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

LemonyPie avatar Mar 27 '20 12:03 LemonyPie

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

TheParad0X avatar Mar 27 '20 18:03 TheParad0X

Yep, also seeing this issue with moment after upgrading

mikejunt avatar Mar 28 '20 00:03 mikejunt

Same

atsjo avatar Mar 28 '20 00:03 atsjo

any news?

fpmk avatar Mar 29 '20 12:03 fpmk

Same problem

pabloxn avatar Mar 30 '20 08:03 pabloxn

Same problem with the production build.

deepakgonda avatar Mar 30 '20 10:03 deepakgonda

Any good news?

acherniak avatar Mar 30 '20 13:03 acherniak

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"

jasoninrapid avatar Mar 30 '20 15:03 jasoninrapid