Closed arcthur closed 8 years ago
Perhaps there’s a language issue here, but I’m not sure what you are asking.
The overhead of producing a UMD bundle versus a dedicated CommonJS bundle is negligible (a few extra bytes for UMD).
The UMD bundle is universal (the U in UMD), meaning that it works in CommonJS (Node.js) as well as vanilla and AMD (RequireJS). So it is already compatible.
And, if you’re using ES6, then you can use the jsnext:main entry point, which points to the ES6 index module. So it’s already compatible with ES6 as well.
It’s true that you can’t require
the individual files inside this repository, because I’ve decided to adopt the ES6 module standard rather than CommonJS. But I would not consider switching from ES6 modules back to CommonJS.
Hi,
I think the
main
config ofpackage.json
has a problem. The main used to CommonJS export, and this main is contain the umd package. Than, It is hard to load d3 modules on required which could make the application package smaller.That is react-router config. It is distinguishing the umd/ lib/ and es6/, and it could be provided three kinds export methods.
So
"main": "build/d3-shape.js", "jsnext:main": "index",
to"main": "lib/index", "jsnext:main": "es6/index",
It could be compatibled with normal CommonJS export and es6/es2015 export, and umd file could be exported to npmcdn or other cdn.