shlomiassaf / ngx-modialog

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

packaged framework/utils.js contains es6 => functions #216

Open leon opened 8 years ago

leon commented 8 years ago

When I try to build my angular-cli beta.16 app I get

SyntaxError: Unexpected token: operator (>)

I've traced it to your utils.js file in /esm/framework/utils.js

https://github.com/shlomiassaf/angular2-modal/blob/master/src/components/angular2-modal/framework/utils.ts#L32

https://github.com/shlomiassaf/angular2-modal/blob/master/src/components/angular2-modal/framework/utils.ts#L65

That file contains es6 functions which cause UglifyJs sprit out an error.

Could it be that the 2.0.0 package is broken, or that you aren't compiling utils.ts to es5?

shlomiassaf commented 8 years ago

esm is ES6 module package.

The es5 version is packages into 1 UMD file in the bundle directory.

The package.json main property points to the bundle version (es5) But if you use a bundler it will look the at module property which points to the ESM version.

This is no different then how angular is built...

leon commented 8 years ago

We have to differentiate between the module system and what the target runtime is.

We need to output typescript to the es6 module system so that webpack2 or rollup can do it's tree shaking thing, but compile all the code into es5 so that it runs in all browsers.

I've checked in the angular code base and cannot find a single => function in their compiled esm code.

Therefor I think we should change into:

"compilerOptions": {
    "module": "es6",
    "target": "es5"
}

What do you think @shlomiassaf, am I wrong?

animator013 commented 8 years ago

I have the same problem when importing from webpack. I can't make a production version because of const (problem with iOS, because of the strict mode) and => arrow functions.

isaacplmann commented 8 years ago

@leon I updated that line, and now things are compiling fine. I'll submit a PR.

shlomiassaf commented 8 years ago

Published 2.0.1, please close if fixed :)

animator013 commented 8 years ago

This is fixed. Please close it 👍