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

The library is repacking d3 modules #20

Closed
ghost opened this issue Apr 12, 2017 · 6 comments
Closed

The library is repacking d3 modules #20

ghost opened this issue Apr 12, 2017 · 6 comments

Comments

@ghost
Copy link

ghost commented Apr 12, 2017

When including this library file directly, it comes with it's own version of d3 modules, duplicating the code when d3 lib is already on the page

@susielu
Copy link
Owner

susielu commented Apr 13, 2017

Ah yes, what is your build setup?

I've had quite a few problems with rollup not packing up the module properly regarding dependencies. I am thinking of moving over to webpack.

@ghost
Copy link
Author

ghost commented Apr 27, 2017

I was not using any build setup, I was adding the file directly to the html page.

There's more than way to bundle the package for publishing, but I think the way d3 approaches the problem is quite reasonable.
If you pick as an example the d3-scale module, when you import it directly on the html page:

<script src="https://d3js.org/d3-scale.v1.min.js"></script>
or
<script src="https://unpkg.com/d3-scale@1"></script>

you need to also import each one of its dependencies.

If you use the d3-scale through npm and a package bundler you import it using import or require and it's own dependencies are solved through npm dependency resolution.

For both cases, the dependencies of d3-scale are not bundled together with the package code.
The opposite is happening with d3-annotation, the package bundled up the code of its dependencies, so when using it directly in a html or a node project together with another d3 import you get double the code of some of some of d3-modules.

If this makes sense to you, I can try to take a look into doing a PR for matching how d3-modules solve their dependencies.

@susielu
Copy link
Owner

susielu commented Apr 27, 2017

Thanks for the full explanation, I am using a similar setup with rollup for some of the other packages for npm. I can try using it for the web version as well and see if I can get it working. I had some issues with it in the past. If I run into issues, will definitely take you up on your offer for a PR.

@susielu
Copy link
Owner

susielu commented May 7, 2017

@LuisCarli would you mind taking a look at this branch https://github.com/susielu/d3-annotation/tree/new-build ? The d3-annotation files shouldn't be packaging the dependencies anymore but curious to hear if the new files work properly with your use cases. Was able to get all my examples to work.

@susielu
Copy link
Owner

susielu commented May 9, 2017

Merged to master, closing this unless you find any issues @LuisCarli

@susielu susielu closed this as completed May 9, 2017
@ghost
Copy link
Author

ghost commented May 17, 2017

Looks great, thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant