Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Importing specific modules from CDN #16054

Closed
LeaVerou opened this issue Nov 11, 2021 · 5 comments
Closed

Importing specific modules from CDN #16054

LeaVerou opened this issue Nov 11, 2021 · 5 comments
Labels
en This issue is in English new-feature resolved

Comments

@LeaVerou
Copy link

LeaVerou commented Nov 11, 2021

What problem does this feature solve?

I'm not sure if this due to lack of docs around this, but it does not seem possible to only import specific modules as described here and let the browser do the tree-shaking when using the CDN (jsdelivr), only one large monolithic bundle is available.

What does the proposed API look like?

It would be good to have built versions on jsdelivr of all modules one can import via the npm syntax, so that people can do things like this while using a CDN as well.

@echarts-bot
Copy link

echarts-bot bot commented Nov 11, 2021

Hi! We've received your issue and please be patient to get responded. 🎉
The average response time is expected to be within one day for weekdays.

In the meanwhile, please make sure that it contains a minimum reproducible demo and necessary images to illustrate. Otherwise, our committers will ask you to do so.

A minimum reproducible demo should contain as little data and components as possible but can still illustrate your problem. This is the best way for us to reproduce it and solve the problem faster.

You may also check out the API and chart option to get the answer.

If you don't get helped for a long time (over a week) or have an urgent question to ask, you may also send an email to [email protected]. Please attach the issue link if it's a technical question.

If you are interested in the project, you may also subscribe to our mailing list.

Have a nice day! 🍵

@echarts-bot echarts-bot bot added en This issue is in English new-feature pending We are not sure about whether this is a bug/new feature. waiting-for: community labels Nov 11, 2021
@LeaVerou LeaVerou changed the title Using SVGRenderer from CDN Importing specific modules from CDN Nov 11, 2021
@plainheart
Copy link
Member

plainheart commented Nov 11, 2021

I remember we ever built ES modules into the esm directory in several previous versions since v5.0.0. But it seems only a minimized version remained since v5.0.2. It would be great if we provide such a feature like the uuid package, which provides ESM support for both browser and Node.

ping @pissang

@pissang
Copy link
Contributor

pissang commented Nov 11, 2021

Hi, I'm afraid we can only import the whole bundle in the browser now.

Importing ES module in the browser needs to have .js extension explictly. But we don't use .js extension in our source code. If we importing modules from 'echarts/core', it will try to load other modules without giving .js extension and failed.

import-map seems to be a potential solution, but it don't have wildcard to match all the paths.

I'm not sure if importing specific modules with hundreds of dependency files is better than importing a single large bundled file. If the scenario exits, I think we can plan to add '.js' extension in our import statements to fix this issue. But after this change, we may still need import-map to resolve the zrender dependency from npm

@plainheart We put our esm modules in the lib folder now

@plainheart plainheart removed the pending We are not sure about whether this is a bug/new feature. label Nov 11, 2021
@plainheart
Copy link
Member

Instead of changing the source code, how about handling the .js extension name in a build script?

@LeaVerou
Copy link
Author

LeaVerou commented Nov 11, 2021

Instead of changing the source code, how about handling the .js extension name in a build script?

Yup, what @plainheart is saying is exactly what I was suggesting. Keep your source code as-is, just mirror the structure of the lib directory in dist, with output files that can be used in a browser.

@pissang pissang added this to the 5.3 milestone Nov 11, 2021
@pissang pissang removed this from the 5.3 milestone Jan 4, 2022
@echarts-bot echarts-bot bot closed this as completed Jan 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
en This issue is in English new-feature resolved
Projects
None yet
Development

No branches or pull requests

3 participants