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

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

Closed
ajantsch opened this issue Oct 7, 2016 · 14 comments
Closed

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

ajantsch opened this issue Oct 7, 2016 · 14 comments

Comments

@ajantsch
Copy link

ajantsch commented Oct 7, 2016

  • I'm submitting a ...
    [ ] bug report
    [ ] feature request
    [x] question about the decisions made in the repository

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?

  • webpack 1
  • angular 2.0.2
@bniehuser
Copy link

bniehuser commented Oct 11, 2016

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
Copy link

ghost commented Oct 11, 2016

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

@cyberbobjr
Copy link

same problem here

@ajantsch
Copy link
Author

Solution for me was:

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

@bniehuser
Copy link

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
Copy link

paradite commented Oct 17, 2016

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
Copy link

lailavinson commented Oct 20, 2016

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
Copy link

synapze commented Oct 21, 2016

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
Copy link

@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
Copy link

^ 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
Copy link

synapze commented Oct 24, 2016

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

  • yep, babel-loader is after typescript/angular2-template loaders in my webpack config.

  • I'm importing the following in my app.module.ts

    imports:[
    ...
    ModalModule.forRoot(),
    BootstrapModalModule,
    SharedModule.forRoot()
    ...
    ]
    
  • I'm importing the following in my shared.module.ts

 imports:[
   ...
    ModalModule,
    BootstrapModalModule
   ...
  ],
  exports:[
   ...
    ModalModule,
    BootstrapModalModule
   ...
  ]
  • I'm importing the following in any child module that wants to use it.
imports:[
   ...
    SharedModule
   ...
  ]

Hopefully that all makes sense. Thanks for the assistance.

@stephandesouza
Copy link

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

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

@synapze
Copy link

synapze commented Oct 25, 2016

@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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants