Closed ajantsch closed 7 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
I have the same issue, anyone got a solution yet?
same problem here
Solution for me was:
1) set es6 as target in my tsconfig 2) use babel as additional loader in my webpack config
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. :)
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
.
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!
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
@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",
^ 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
@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:
I'm importing the following in my app.module.ts
imports:[
...
ModalModule.forRoot(),
BootstrapModalModule,
SharedModule.forRoot()
...
]
imports:[
...
ModalModule,
BootstrapModalModule
...
],
exports:[
...
ModalModule,
BootstrapModalModule
...
]
imports:[
...
SharedModule
...
]
Hopefully that all makes sense. Thanks for the assistance.
@synapze Are you using "babel-preset-es2015"?
"babel-preset-es2015": "^6.18.0",
@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.
Consolidated in #244, please come help and replay there.
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?