Skip to content

[app-shell] ng build -prod Unexpected token export #8848

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

Closed
whyvrafvr opened this issue Dec 12, 2017 · 13 comments
Closed

[app-shell] ng build -prod Unexpected token export #8848

whyvrafvr opened this issue Dec 12, 2017 · 13 comments
Labels
Milestone

Comments

@whyvrafvr
Copy link

ng build -prod produces the following error :

ng build -prod
Date: 2017-12-12T14:49:37.929Z
Hash: 4d60263954c3747c95b5
Time: 107922ms
chunk {0} 0.099b11ca3eb0d7801c76.chunk.js (common) 95 kB [rendered]
chunk {1} 1.5e38cc6f9b8fc746d27f.chunk.js () 3.85 kB [rendered]
chunk {2} 2.02a1a1877b3701e42d92.chunk.js () 92.5 kB [rendered]
chunk {3} 3.206ef7db82003266beed.chunk.js () 31.8 kB [rendered]
chunk {4} 4.e4f93b0588db95625db7.chunk.js () 3.56 kB [rendered]
chunk {5} 5.f2a2a15e9becbf222fb7.chunk.js () 3.59 kB [rendered]
chunk {6} 6.2697f6d4ddacf8b1ad3f.chunk.js () 3.57 kB [rendered]
chunk {7} 7.9b8422429e3ca93f2129.chunk.js () 87.5 kB [rendered]
chunk {8} 8.fee4bb159e55adb3b228.chunk.js () 3.63 kB [rendered]
chunk {9} 9.d0fe86cfa48e90d50792.chunk.js () 3.57 kB [rendered]
chunk {10} 10.51afbe17591fb56cc5cc.chunk.js () 1.48 kB [rendered]
chunk {11} 11.ba3968b01c53404c212f.chunk.js () 9.69 kB [rendered]
chunk {12} main.720cf8da75e50077b111.bundle.js (main) 1.21 MB [initial] [rendered]
chunk {13} polyfills.8ec93566c689cefbeab1.bundle.js (polyfills) 61 kB [initial] [rendered]
chunk {14} styles.ab4e27ce710a9e61640c.bundle.css (styles) 45 kB [initial] [rendered]
chunk {15} inline.7b3f406ccd40bedad9e5.bundle.js (inline) 1.75 kB [entry] [rendered]
Date: 2017-12-12T14:50:17.701Z
Hash: 731c78bb935196096ae1
Time: 39523ms
chunk {0} main.034865b9801ae4e3c5d0.bundle.js (main) 731 kB [entry] [rendered]
chunk {1} polyfills.49f00aadbe49adb42f32.bundle.js (polyfills) 788 bytes [entry] [rendered]
chunk {2} styles.ab4e27ce710a9e61640c.bundle.css (styles) 45 kB [entry] [rendered]
Unexpected token export
/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/node_modules/@angular/common/locales/fr.js:10
export default [
^^^^^^
SyntaxError: Unexpected token export
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.fYTv (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:408157)
at l (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:211)
at Object.aR8+ (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:263541)
at l (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:211)
at Object.JwoV (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:152280)
at l (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:211)
at Object.Zq8w (/Users/jsie/Projects/comptandye/dev/comptandye_frontend/webapp/dist-server/main.034865b9801ae4e3c5d0.bundle.js:1:252141)

Versions


    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/

Angular CLI: 1.6.0
Node: 6.10.3
OS: darwin x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

@angular/cdk: 5.0.1
@angular/cli: 1.6.0
@angular/material-moment-adapter: 5.0.1
@angular/material: 5.0.1
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.4.2
webpack: 3.10.0

Desired behavior

Should generate dist and dist-server without errors :-)

Mention any other details that might be useful (optional)

In AppModule :

(...)
// uses locale FR
import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
import { MAT_DATE_LOCALE } from '@angular/material';
registerLocaleData(localeFr);

@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
CoreModule,
SharedModule,
LoginModule,
AppRoutingModule
],
providers: [{ provide: MAT_DATE_LOCALE, useValue: 'fr-FR' }],
bootstrap: [AppComponent]
})
export class AppModule { }

@whyvrafvr
Copy link
Author

Removing locale definition in AppModule and using --locale instead on cli seems to solve this issue but should be fine to understand why the content of localeFr blocks the parsing any way. Cheers.

@Brocco
Copy link
Contributor

Brocco commented Dec 14, 2017

Are you able to build the server app independently?

ng build --prod --app=1 (assuming "1" is the index of your server app)

@Brocco Brocco self-assigned this Dec 14, 2017
@Brocco Brocco added command: build P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken labels Dec 14, 2017
@whyvrafvr
Copy link
Author

Hi @Brocco, yes, I am.

ng build --prod --app=1 Date: 2017-12-14T20:11:54.993Z Hash: 3c924409f6beda7c3066 Time: 51664ms chunk {0} main.eebe723c52ca65334ddd.bundle.js (main) 731 kB [entry] [rendered] chunk {1} polyfills.49f00aadbe49adb42f32.bundle.js (polyfills) 788 bytes [entry] [rendered] chunk {2} styles.ab4e27ce710a9e61640c.bundle.css (styles) 45 kB [entry] [rendered]

@brunonm
Copy link

brunonm commented Jan 24, 2018

Hi,
I'm suffering the same problem. Any news?

@whyvrafvr
Copy link
Author

No. I've just removed the provider and use ng serve --locale fr-FR instead. Works fine.

@brunonm
Copy link

brunonm commented Jan 24, 2018

@Skonx In my case, the error is not the locale. I guess there is a correlation with "useValue" in providers.

Date: 2018-01-24T16:24:40.495Z
Hash: 083edbe37c854a6e000e
Time: 85777ms
chunk {scripts} scripts.8532177f8890e20ee510.bundle.js (scripts) 733 kB [initial] [rendered]
chunk {0} polyfills.068a3368e475b96b6e80.bundle.js (polyfills) 216 kB [initial] [rendered]
chunk {1} main.2222256f8f9b7c4d2bf7.bundle.js (main) 1.38 MB [initial] [rendered]
chunk {2} styles.179a7e049b24e409945c.bundle.css (styles) 130 kB [initial] [rendered]
chunk {3} inline.41c96c0b77fb652b051d.bundle.js (inline) 1.45 kB [entry] [rendered]
Date: 2018-01-24T16:25:18.186Z
Hash: dbb260d4019b6b4e3204
Time: 37615ms
chunk {scripts} scripts.8532177f8890e20ee510.bundle.js (scripts) 733 kB [initial] [rendered]
chunk {0} main.49911d009355e70be4ac.bundle.js (main) 304 kB [entry] [rendered]
chunk {1} styles.179a7e049b24e409945c.bundle.css (styles) 130 kB [entry] [rendered]
Unexpected token import
/var/www/test-appshell/node_modules/@company/angular-components/index.js:1
(function (exports, require, module, __filename, __dirname) { import { ChangeDetectorRef, Component, ContentChildren, Directive, ElementRef, EventEmitter, HostListener, Inject, Injectable, Input, NgModule, Output, TemplateRef, ViewChild, ViewContainerRef } from '@angular/core';
^^^^^^

SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:599:28)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.wqiu (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:303132)
at n (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:220)
at Object.K181 (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:103839)
at n (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:220)
at Object.5Qte (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:21345)
at n (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:220)
at Object.JwoV (/var/www/test-appshell/dist-server/main.49911d009355e70be4ac.bundle.js:1:91521)

@filipesilva
Copy link
Contributor

This seems like a bug but we'll need to look at a reproduction to find and fix the problem. Can you setup a minimal repro please?

You can read here why this is needed. A good way to make a minimal repro is to create a new app via ng new repro-app and adding the minimum possible code to show the problem. Then you can push this repository to github and link it here.

@filipesilva filipesilva added needs: repro steps We cannot reproduce the issue with the information given and removed P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken labels Feb 1, 2018
@hansl hansl unassigned Brocco Feb 1, 2018
@whyvrafvr
Copy link
Author

whyvrafvr commented Feb 23, 2018

Hi there.
Sorry for the very late reply.
I've just opened a git rep : https://github.com/skonx/app-shell-issue8848.git

Basically, it should display a mat-date-picker with french format.
It works running ng serve but I get the same error "Unexpected token export" running ng build --prod.

@whyvrafvr
Copy link
Author

Date: 2018-02-23T18:29:33.682Z
Hash: aad3b5ba92425188a06d
Time: 47497ms
chunk {0} polyfills.bf95165a1d5098766b92.bundle.js (polyfills) 59.4 kB [initial] [rendered]
chunk {1} main.5879847340cbb631be69.bundle.js (main) 529 kB [initial] [rendered]
chunk {2} styles.60f2c673d6a13f4d5d86.bundle.css (styles) 46.8 kB [initial] [rendered]
chunk {3} inline.318b50c57b4eba3d437b.bundle.js (inline) 796 bytes [entry] [rendered]
Date: 2018-02-23T18:29:47.591Z
Hash: a26709f920406d996f64
Time: 13756ms
chunk {0} main.054670c8631af4ffa4cb.bundle.js (main) 83.5 kB [entry] [rendered]
chunk {1} styles.60f2c673d6a13f4d5d86.bundle.css (styles) 46.8 kB [entry] [rendered]
Unexpected token export
/Users/jsie/git/app-shell-issue8848/node_modules/@angular/common/locales/fr.js:16
export default [
^^^^^^
SyntaxError: Unexpected token export
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.fYTv (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:74158)
at l (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:220)
at Object.Iksp (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:43971)
at l (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:220)
at Object.Ub9p (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:50408)
at l (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:220)
at Object.or6l (/Users/jsie/git/app-shell-issue8848/dist-server/main.054670c8631af4ffa4cb.bundle.js:1:76581)
jsie-macbook:app-shell-issue8848 jsie$

@whyvrafvr
Copy link
Author

ng version

_                      _                 ____ _     ___

/ \ _ __ __ _ _ | | __ _ _ __ / | | | |
/ △ \ | '
\ / _ | | | | |/ _ | '
| | | | | | |
/ ___ | | | | (
| | || | | (| | | | || | | |
// __| ||_, |_,||_,|| _|||
|___/

Angular CLI: 1.7.1
Node: 6.10.3
OS: darwin x64
Angular: 5.2.6
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router

@angular/cdk: 5.2.2
@angular/cli: 1.7.1
@angular/material: 5.2.2
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.1
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0

@vytautas-pranskunas-
Copy link

I am not sure if it is same issue lik emine but i am able to build project with SSR but when trying to build app-shell i got error

Unexpected token import
C:\git\wearlenses-3-client\web\node_modules\ng-state\src\store\store.js:11
import { Clear } from './clear';
^^^^^^

i know this is because import in one of libraries but cannot get why because same imports used evevn in ng forms + project builds fine (browser and server) normally.

@alan-agius4 alan-agius4 removed the needs: repro steps We cannot reproduce the issue with the information given label Sep 21, 2018
@ngbot ngbot bot added this to the needsTriage milestone Sep 21, 2018
@filipesilva filipesilva added type: bug/fix freq1: low Only reported by a handful of users who observe it rarely severity5: regression labels Sep 24, 2018
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Sep 24, 2018
@hansl
Copy link
Contributor

hansl commented Sep 27, 2018

We moved to webpack 4 a while back which should support import and export keywords. I'm closing this as fixed.

If you think this is still happening, please file a new issue.

@hansl hansl closed this as completed Sep 27, 2018
@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 Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

7 participants