alexpods / angular2-universal-starter

Enjoy Server Side rendering and Web Workers in your Angular2 Application
224 stars 50 forks source link

ng2-highcharts issue #53

Closed vaseker closed 8 years ago

vaseker commented 8 years ago

Hello! Im trying to use highcharts via ng2-highcharts directives, but I stuck with error (npm run dev, NO_WW, NO_SS)

ERROR in ./~/ng2-highcharts/ng2-highcharts.ts
Module parse failed: ./node_modules/ng2-highcharts/ng2-highcharts.ts Line 1: Unexpected token
You may need an appropriate loader to handle this file type.
| import {Ng2Highcharts} from './src/directives/ng2-highcharts';
| export * from './src/directives/ng2-highcharts';
|

It works well in official ng2-highcharts sample.

So Im trying to use it like this:

import HighCharts from 'ng2-highcharts/ng2-highcharts';

@Component({
    directives: [HighCharts.directives],
    template: `<div [ng2-highstocks]="chartStock" class="graph"></div>`
})

What is wrong?

Thank you.

alexpods commented 8 years ago

I think the reason of the error are this and this lines of code. Briefly: typescript loader are not applied to node modules and .ts extension has a priority over .js.

Possible solution: set resolve.extensions to ['', '.js', '.ts'] (now .js extension has a priority over .ts) (you need to change it here, here, here and here)

@vaseker Please, try this solution and tell me the results.

vaseker commented 8 years ago

set resolve.extensions to ['', '.js', '.ts']

Yes, this is it!

Thank you!