yagajs / leaflet-ng2

Angular.io integration of Leaflet
https://leaflet-ng2.yagajs.org
ISC License
66 stars 26 forks source link

Unexpected token: name (MarkerDirective) #213

Closed kaynz closed 7 years ago

kaynz commented 7 years ago

Hi,

with RC5 it's not possible to run ng buid --prod:

ERROR in vendor.4be936037a7b9291ee70.bundle.js from UglifyJs Unexpected token: name (MarkerDirective) [vendor.4be936037a7b9291ee70.bundle.js:983,6]

However building without the --prod flag is working.

atd-schubert commented 7 years ago

The reason is that uglyfyjs does not support "ES6".

Because of troubles with the es6-shims for this module we decide to remove the shims as dependency and transpile the module in ES6 (look at #191 and #202 second comment).

If you want to transpile our library in ES5, I would recommend to run the following code within your project folder:

cd node_modules/@yaga/leaflet-ng2
tsc --target es5 # you have to have typescript as global npm module...

# and then again...
cd ../../..
ng build --prod

Note: The transpiler will have some errors, but you do not have to take care about them...

I think we should give a hint for this issue in the README.md file...

kaynz commented 7 years ago

I don't think that this is a good way to use this library. Usually u never touch node_modules.

atd-schubert commented 7 years ago

Yes, that is true. But, when we change it back to es5 we have similar problems with other frameworks, because of the es6-shim.

Maybe I find another solution...

kaynz commented 7 years ago

Any news on this? Maybe you should create a second repo for this? :)

atd-schubert commented 7 years ago

We don't need a second repo, maybe another release something like:

{
  "dependencies": {
    "@yaga/leaflet-ng2": "1.0.0-es5"
  }
}

But this is not a so nice way to change this library, because it is a lack of uglify that it is not supported. This is not an issue on this project and I have more work to do on every release.

The best approach is to fix the support of es6 in uglify. I have done some research (but have not tested it yet) there is a new uglify for es6, that maybe should be merged in the standard uglify. It is under this issue for harmony support.

So maybe uglify-es is the right approach for you.

atd-schubert commented 7 years ago

see #224

atd-schubert commented 7 years ago

See PR #227