xieziyu / ngx-echarts

An angular (ver >= 2.x) directive for ECharts (ver >= 3.x)
https://xieziyu.github.io/ngx-echarts/
MIT License
1.11k stars 197 forks source link

Can not build production version after update to v4.0.0 #148

Open hijamoya opened 6 years ago

hijamoya commented 6 years ago

Can not build production version after update to v4.0.0:

ERROR in ./node_modules/zrender/lib/core/BoundingRect.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read property 'kind' of undefined
    at isObjectOrObjectArrayTypeReference (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20709:34)
    at parseNestedTypeLiteral (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20748:43)
    at parseParameterOrPropertyTag (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20733:85)
    at parseTag (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20572:40)
    at /Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20447:44
    at Object.scanRange (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:8611:26)
    at parseJSDocCommentWorker (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20419:25)
    at Object.parseJSDocComment (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20373:31)
    at addJSDocComment (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15579:68)
    at createNodeWithJSDoc (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15906:17)
    at parseObjectLiteralElement (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18930:24)
    at parseListElement (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16289:20)
    at parseDelimitedList (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16574:31)
    at parseObjectLiteralExpression (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18979:31)
    at parsePrimaryExpression (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18872:28)
    at parseMemberExpressionOrHigher (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18445:30)
ERROR in ./node_modules/echarts/lib/coord/geo/Region.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read property 'kind' of undefined
    at isObjectOrObjectArrayTypeReference (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20709:34)
    at parseNestedTypeLiteral (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20748:43)
    at parseParameterOrPropertyTag (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20733:85)
    at parseTag (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20572:40)
    at /Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20447:44
    at Object.scanRange (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:8611:26)
    at parseJSDocCommentWorker (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20419:25)
    at Object.parseJSDocComment (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20373:31)
    at addJSDocComment (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15579:68)
    at createNodeWithJSDoc (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15906:17)
    at parseObjectLiteralElement (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18930:24)
    at parseListElement (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16289:20)
    at parseDelimitedList (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16574:31)
    at parseObjectLiteralExpression (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18979:31)
    at parsePrimaryExpression (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18872:28)
    at parseMemberExpressionOrHigher (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:18445:30)
ERROR in ./node_modules/echarts/lib/data/Tree.js
Module build failed (from ./node_modules/@angular-devkit/build-optimizer/src/build-optimizer/webpack-loader.js):
TypeError: Cannot read property 'kind' of undefined
    at isObjectOrObjectArrayTypeReference (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20709:34)
    at parseNestedTypeLiteral (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20748:43)
    at parseParameterOrPropertyTag (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20733:85)
    at parseTag (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20572:40)
    at /Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20447:44
    at Object.scanRange (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:8611:26)
    at parseJSDocCommentWorker (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20419:25)
    at Object.parseJSDocComment (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:20373:31)
    at addJSDocComment (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15579:68)
    at createNodeWithJSDoc (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15906:17)
    at parseStatement (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:19455:53)
    at parseListElement (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16289:20)
    at parseList (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:16273:35)
    at parseSourceFileWorker (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15558:37)
    at Object.parseSourceFile (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15429:26)
    at Object.createSourceFile (/Users/jam_hsu/Projects/Lativ-mini-program/erp/frontend/node_modules/@angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:15260:29)
samuelliu805 commented 4 years ago

I am having the same issue, however it works for me when I was using ng serve --aot. Note that I used import {init} from echarts; and NgxEchartsModule.forRoot({echarts: init}) in my module (because otherwise it will throw "Cannot read property 'init' of null" error)

lundmikkel commented 4 years ago

Note that I used import {init} from echarts; and NgxEchartsModule.forRoot({echarts: init})

This solved my problem! I did, however, write it like this instead, since I'm using version 5.0.0:

import * as echarts from "echarts";

NgxEchartsModule.forRoot({
    echarts: { init: echarts.init }
})

Edit: my solution turned out not to work properly with typing :(

werts commented 4 years ago

Have the same issue

vandernath commented 4 years ago

Same issue

vandernath commented 4 years ago

Alright, here's how I fixed it:

npm uninstall ngx-echarts
npm uninstall echarts

npm install ngx-echarts@4.2.2
npm install echarts@4.2.1

In the module where I use ngx-echarts, I removed the forRoot part, and simply imported the module like any other:

@NgModule({
    imports: [
        NgxEchartsModule,
    ],

At this point another error occured, but I remember the fix was rather simple:

npm install @angular-devkit/build-angular@0.803.20

Hope this helps someone.

lundmikkel commented 4 years ago

Yeah, downgrading seems to be the only solution for now. I do, however, use the latest version of echarts, i.e. 4.8.0. Works fine so far.