shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 242 forks source link

'unexpected token export' after updating from beta.13 to 2.0.1 #220

Closed ajantsch closed 7 years ago

ajantsch commented 8 years ago

After updating from beta.13 to 2.0.1 I get 'unexpected token export'. What do I have to change in order to make this work again?

bniehuser commented 8 years ago

same here -- webpack 1.13.2, angular 2.0.2 -- problem appears to be in the non-bundle files, seems like they are exported as es6 and webpack doesn't like the incompatible syntax. worked fine with systemjs, but stuck unable to proceed with webpack

update: attempted to get webpack to use babel-loader for angular2-modal files specifically, but either i'm doing it wrong or it's not working -- if someone has a working config for using babel-loader with the es6 files and webpack, pls post

ghost commented 8 years ago

I have the same issue, anyone got a solution yet?

cyberbobjr commented 8 years ago

same problem here

ajantsch commented 8 years ago

Solution for me was:

1) set es6 as target in my tsconfig 2) use babel as additional loader in my webpack config

bniehuser commented 8 years ago

i ended up using 6to5-loader on just the angular2-modal files and that worked. i would still request that the owner of the repo include es5 .js files for those using webpack or other build systems for maximum compatibility and reduction of overall headaches -- also would let me remove a couple otherwise useless packages from my project. :)

paradite commented 8 years ago

for anyone still having the issue and not familiar with webpack, here is the complete config that I use:

      {
        test: /\.ts$/,
        loaders: ['awesome-typescript-loader', 'angular2-template-loader']
      },
      {
        test: /\.js$/,
        include: /(angular2-modal)/,
        loader: 'babel-loader',
        query: {
          presets: ['es2015']
        }
      },
     // others

This alone is sufficient, there is no need to change target to es6 in tsconfig.json.

lailavinson commented 8 years ago

I have this issue too. Solution above works for some browsers but not in IE

EDIT - Nevermind, @paradite 's solution does work in IE (and other browsers). Thanks!

synapze commented 7 years ago

What could I be doing wrong with @peradite's fix?

I'm getting the following error in the console

angular2_modal_1 is not defined

angular : 2.1.0 angular2-modal: 2.0.1

paradite commented 7 years ago

@synapze maybe it is due to the new angular version. I am using:

    "@angular/common": "2.0.0",
    "@angular/compiler": "2.0.0",
    "@angular/core": "2.0.0",
    "@angular/forms": "2.0.0",
    "@angular/http": "2.0.0",
    "@angular/material": "^2.0.0-alpha.9-3",
    "@angular/platform-browser": "2.0.0",
    "@angular/platform-browser-dynamic": "2.0.0",
    "@angular/router": "3.0.0",
    "angular2-modal": "^2.0.1",
lailavinson commented 7 years ago

^ The babel loader still works for me using angular 2.1.0, angular2-modal 2.0.1.

@synapze how are importing angular2-modal into your angular app? Also, make sure to put the babel-loader after your typescript/angular2-template loaders in the webpack config

synapze commented 7 years ago

@lailavinson sounds like I might need to create a plunkr to work this out. Hopefully it's just the way im importing the angular2-modal.

See below in regards to your questions:

 imports:[
   ...
    ModalModule,
    BootstrapModalModule
   ...
  ],
  exports:[
   ...
    ModalModule,
    BootstrapModalModule
   ...
  ]
imports:[
   ...
    SharedModule
   ...
  ]

Hopefully that all makes sense. Thanks for the assistance.

stephandesouza commented 7 years ago

@synapze Are you using "babel-preset-es2015"?

"babel-preset-es2015": "^6.18.0",

synapze commented 7 years ago

@stephandesouza nope, i was using

"babel-preset-es2015": "^6.16.0",

I installed

"babel-preset-es2015": "^6.18.0",

however I still get the same problem. If its working for some of you it must be the way i've wired it up in my existing ng2 app. Going to create plunkr and work it out.

shlomiassaf commented 7 years ago

Consolidated in #244, please come help and replay there.