You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by GitBox <gi...@apache.org> on 2021/02/25 14:00:17 UTC

[GitHub] [echarts] lz1998 opened a new pull request #14352: fix: import theme error

lz1998 opened a new pull request #14352:
URL: https://github.com/apache/echarts/pull/14352


   <!-- Please fill in the following information to help us review your PR more efficiently. -->
   
   ## Brief Information
   
   This pull request is in the type of:
   
   - [x] bug fixing
   - [ ] new feature
   - [ ] others
   
   
   
   ### What does this PR do?
   fix https://github.com/apache/echarts/issues/14351#issuecomment-785905520
   
   <!-- USE ONCE SENTENCE TO DESCRIBE WHAT THIS PR DOES. -->
   
   
   
   ### Fixed issues
   
   <!--
   - #xxxx: ...
   -->
   
   
   ## Details
   
   ### Before: What was the problem?
   
   <!-- DESCRIBE THE BUG OR REQUIREMENT HERE. -->
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ### After: How is it fixed in this PR?
   
   <!-- THE RESULT AFTER FIXING AND A SIMPLE EXPLANATION ABOUT HOW IT IS FIXED. -->
   
   <!-- ADD SCREENSHOT HERE IF APPLICABLE. -->
   
   
   
   ## Usage
   
   ### Are there any API changes?
   
   - [ ] The API has been changed.
   
   <!-- LIST THE API CHANGES HERE -->
   
   
   
   ### Related test cases or examples to use the new APIs
   
   NA.
   
   
   
   ## Others
   
   ### Merging options
   
   - [ ] Please squash the commits into a single one when merge.
   
   ### Other information
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] echarts-bot[bot] commented on pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
echarts-bot[bot] commented on pull request #14352:
URL: https://github.com/apache/echarts/pull/14352#issuecomment-785915524


   Thanks for your contribution!
   The community will review it ASAP. In the meanwhile, please checkout [the coding standard](https://echarts.apache.org/en/coding-standard.html) and Wiki about [How to make a pull request](https://github.com/apache/incubator-echarts/wiki/How-to-make-a-pull-request).


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang closed pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
pissang closed pull request #14352:
URL: https://github.com/apache/echarts/pull/14352


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] lz1998 commented on pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
lz1998 commented on pull request #14352:
URL: https://github.com/apache/echarts/pull/14352#issuecomment-786371835


   This is my code. Line `require("echarts/theme/vintage")` report this error
   
   ```javascript
   import {createCanvas} from 'canvas'
   import * as echarts from 'echarts'
   import Express from 'express'
   import {Request, Response} from 'express'
   
   // 导入主题
   require("echarts/theme/vintage")
   
   
   // 生成图片
   function generateImage(options: any, width: number, height: number, theme: string) {
     console.log("GENERATE IMAGE")
     console.log(`WIDTH: ${width}`)
     console.log(`HEIGHT: ${height}`)
     console.log(`THEME: ${theme}`)
     console.log(`OPTIONS: ${JSON.stringify(options)}`)
     const canvas = createCanvas(width, height) as any
     const ctx = canvas.getContext('2d')
     ctx.font = '12px'
     echarts.setCanvasCreator(() => canvas)
     const chart = echarts.init(canvas, theme)
     options.animation = false
     chart.setOption(options)
     return (chart.getDom() as any).toBuffer()
   }
   
   const express = require('express')
   const app = Express()
   app.use(express.json())
   const imgController = (req: Request, res: Response) => {
     console.log("RECV REQ")
     let options = req.query.options || req.body
     if (typeof options === 'string') {
       options = JSON.parse(options)
     }
     let width = parseInt(req.query.width || options.width || 1024)
     let height = parseInt(req.query.height || options.height || 768)
     let theme = req.query.theme || options.theme || 'dark'
     res.header("Content-Type", "image/png")
     res.send(generateImage(options, width, height, theme))
   }
   app.post('/', imgController)
   app.get('/', imgController)
   
   const PORT = process.env.PORT || 3000
   app.listen(PORT)
   console.log("echarts started port:" + PORT)
   
   ```
   
   Error
   ```bash
   /Users/lz1998/WebstormProjects/ssr-echarts/node_modules/echarts/lib/echarts.js:44
   export * from './export/core';
   ^^^^^^
   
   SyntaxError: Unexpected token 'export'
       at wrapSafe (internal/modules/cjs/loader.js:1054:16)
       at Module._compile (internal/modules/cjs/loader.js:1102:27)
       at Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
       at Object.require.extensions.<computed> [as .js] (/Users/lz1998/WebstormProjects/ssr-echarts/node_modules/ts-node/src/index.ts:1045:43)
       at Module.load (internal/modules/cjs/loader.js:986:32)
       at Function.Module._load (internal/modules/cjs/loader.js:879:14)
       at Module.require (internal/modules/cjs/loader.js:1026:19)
       at require (internal/modules/cjs/helpers.js:72:18)
       at /Users/lz1998/WebstormProjects/ssr-echarts/node_modules/echarts/theme/vintage.js:29:26
       at Object.<anonymous> (/Users/lz1998/WebstormProjects/ssr-echarts/node_modules/echarts/theme/vintage.js:34:3)
   
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang edited a comment on pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
pissang edited a comment on pull request #14352:
URL: https://github.com/apache/echarts/pull/14352#issuecomment-786360454


   Hi, thanks for the contribution. In 5.0, we changed require(`echarts`) to  require(`echarts/lib/echarts`) to avoid bundling the whole package accidentally when importing themes. I guess we need to find a better solution


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] plainheart commented on pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
plainheart commented on pull request #14352:
URL: https://github.com/apache/echarts/pull/14352#issuecomment-786374134


   A transpilation from ES6 module to `commonjs` module may be required for `export * from xxx`.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] lz1998 commented on pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
lz1998 commented on pull request #14352:
URL: https://github.com/apache/echarts/pull/14352#issuecomment-787247661


   > A transpilation from ES6 module to `commonjs` module may be required for `export * from xxx`.
   
   When will it be fixed?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org


[GitHub] [echarts] pissang commented on pull request #14352: fix: import theme error

Posted by GitBox <gi...@apache.org>.
pissang commented on pull request #14352:
URL: https://github.com/apache/echarts/pull/14352#issuecomment-786360454


   In 5.0, we changed require(`echarts`) to  require(`echarts/lib/echarts`) to avoid bundling the whole package accidentally when importing themes. I guess we need to find a better solution


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org