简体   繁体   中英

Angular2 + Mobx + Ng2-mobx w/angular-cli

So, my project is using angular-cli version 1.0.0-beta.20-4. I have successfully integrated Ng2-mobx into the project, it works great! All components that should access the state are able to, and the UI template is updated thanks to the *mobxAutorun directive.

Now, when I run ng test , the tests fail with this error:

06 01 2017 15:46:50.740:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]: Connected on socket /#RCPcM_Qcuf-M86Z1AAAA with id 25747719
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: Unexpected token 'const'
  at webpack:///dev/ui/~/ng2-mobx/dist/ng2-mobx.js:11:0 <- src/main/js/test.ts:92028

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  SyntaxError: Unexpected token 'const'
  at webpack:///dev/ui/~/ng2-mobx/dist/ng2-mobx.js:11:0 <- src/main/js/test.ts:92028

Looking at ng2-mobx.js:11 there is a const definition that is a reference to @angular/core .

const core_1 = require("@angular/core");

This seems like something is missing, not sure what though.
Any help would be appreciated!

There's an issue opened on the PhantomJS repository:

https://github.com/webpack/webpack/issues/2407

And also another thread on SO which talks about a similar issue on a different stack:

SyntaxError: Unexpected token 'const' (with Vue, Karma, Webpack, PhantomJS)

edit:

PhantomJS 2.5.0 Beta is now available and comes with a full ES2015 support. It could solve your problem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM