A Rollup-based bundler for D3 modules.
To install:
npm install --save-dev d3-bundler
To use, define an ES6 module that imports the D3 code you need and defines the
corresponding d3
object. For example:
import {
event,
select,
selectAll
} from "d3-selection";
export default {
get event() { return event; },
select: select,
selectAll: selectAll
};
Make sure you have these D3 modules installed:
npm install --save d3-selection
Build your bundle:
node_modules/.bin/d3-bundler -- bundle.js > d3.js
Have a nice day!
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="d3.js"></script>
<script>
d3.select("body").append("h1").text("Hello, world!");
</script>
d3-bundler [options] -- [file]
The input file should be an ES6 module that defines a default export object. See the examples.
Options:
- --polyfill-map [default: false]
Include a simple polyfill for platforms that do not implement ES6 Map natively.
- --format [default: "umd"]
Specify the output format of the generated JavaScript. See Rollup for supported values.
- --name [default: "d3"]
Specify the name of the output module. This determines the name of the exported global in certain output formats.