Open mbostock opened 5 years ago
I agree that it'd be nice to have a bundling feature for files in the same package, but I'm not sure the best way to go about it. There are 2 ways I can think of:
?bundle
) that uses Rollup to concat all the files. I guess in this case any externals would also use ?bundle
, similar to how ?module
propagates through to all dependencies now?package.json
like "unpkg": { "bundle": true }
that would tell unpkg to always try to bundle resources from this package. This could possibly also provide some level of configuration for package authors who want to customize how the bundling happens, while also providing cleaner URLs.But ya, I've thought about this a lot too. 👍
@mjackson is there any plan to support bundle ES Modules? Or is there another way? 😂
Any news on this subject?
Having a bundled option to get a single file greatly improve performance, and in my use case it takes around 3.5s to get 60 .js files for a 90kb size :/
Related to autominification #57, I’d love it if
?module
requests were automatically bundled (say using Rollup) as well as minified. This import currently triggers ~576 non-minified requests, which makes it somewhat unreasonable to recommend:I could ship bundled and minified ES modules for all the D3 modules using the
module
entry point, but that’s not ideal outside of unpkg because now source users (say people bundling D3 into their app) are also seeing pre-minified code. If unpkg supported multiple entry points #93, then I could specify a bundled and minified ES module for the unpkg-specific module entry point, but it’d be even more convenient if unpkg did this automatically.My recommendation is that unpkg only bundle relative imports, and leave imports of bare module specifiers as (rewritten) imports, as
?module
currently does. It should be possible to tell Rollup to externalize all such dependencies.