Skip to content

Commit af598d7

Browse files
committed
depend on d3 directly
1 parent 7675cea commit af598d7

30 files changed

Lines changed: 70 additions & 62 deletions

package.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
},
3232
"devDependencies": {
3333
"clean-css": "^5.1.1",
34-
"d3": "^6.5.0",
3534
"eslint": "^7.12.1",
3635
"esm": "^3.2.25",
3736
"js-beautify": "^1.13.0",
@@ -46,14 +45,7 @@
4645
"tape-await": "^0.1.2"
4746
},
4847
"dependencies": {
49-
"d3-array": "^2.10.0",
50-
"d3-axis": "^2.0.0",
51-
"d3-color": "^2.0.0",
52-
"d3-interpolate": "^2.0.1",
53-
"d3-scale": "^3.2.3",
54-
"d3-scale-chromatic": "^2.0.0",
55-
"d3-selection": "^2.0.0",
56-
"d3-shape": "^2.0.0"
48+
"d3": "^6.6.0"
5749
},
5850
"publishConfig": {
5951
"registry": "https://npm.pkg.github.com"

rollup.config.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import CleanCSS from "clean-css";
66
import * as meta from "./package.json";
77

88
const filename = meta.name.split("/").pop();
9-
const external = Object.keys(meta.dependencies || {}).filter(key => /^d3-/.test(key));
9+
10+
// Resolve D3 dependency.
11+
const d3 = require("d3/package.json");
12+
if (typeof d3.jsdelivr === "undefined") throw new Error("unable to resolve d3");
13+
const d3Path = `d3@${d3.version}/${d3.jsdelivr}`;
1014

1115
// A lil’ Rollup plugin to allow importing of style.css.
1216
const cssPath = path.resolve("./src/style.css");
@@ -30,7 +34,7 @@ const css = {
3034

3135
const config = {
3236
input: "src/index.js",
33-
external,
37+
external: ["d3"],
3438
output: {
3539
indent: false,
3640
banner: `// ${meta.name} v${meta.version} Copyright ${(new Date).getFullYear()} ${meta.author.name}`
@@ -57,8 +61,8 @@ export default [
5761
format: "umd",
5862
extend: true,
5963
file: `dist/${filename}.umd.js`,
60-
globals: Object.fromEntries(external.map(key => [key, "d3"])),
61-
paths: Object.fromEntries(external.map(key => [key, "d3@6"]))
64+
globals: {"d3": "d3"},
65+
paths: {"d3": d3Path}
6266
}
6367
},
6468
{
@@ -69,8 +73,8 @@ export default [
6973
format: "umd",
7074
extend: true,
7175
file: `dist/${filename}.umd.min.js`,
72-
globals: Object.fromEntries(external.map(key => [key, "d3"])),
73-
paths: Object.fromEntries(external.map(key => [key, "d3@6"]))
76+
globals: {"d3": "d3"},
77+
paths: {"d3": d3Path}
7478
},
7579
plugins: [
7680
...config.plugins,

src/axis.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {axisTop, axisBottom, axisRight, axisLeft} from "d3-axis";
2-
import {interpolateRound} from "d3-interpolate";
3-
import {create} from "d3-selection";
1+
import {axisTop, axisBottom, axisRight, axisLeft} from "d3";
2+
import {interpolateRound} from "d3";
3+
import {create} from "d3";
44

55
export class AxisX {
66
constructor({

src/curve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import {
1919
curveStep,
2020
curveStepAfter,
2121
curveStepBefore
22-
} from "d3-shape";
22+
} from "d3";
2323

2424
const curves = new Map([
2525
["basis", curveBasis],

src/defined.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {ascending, descending} from "d3-array";
1+
import {ascending, descending} from "d3";
22

33
export function defined(x) {
44
return x != null && !Number.isNaN(x);

src/facet.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {cross, groups, InternMap} from "d3-array";
2-
import {create} from "d3-selection";
1+
import {cross, groups, InternMap} from "d3";
2+
import {create} from "d3";
33
import {Mark, first, second} from "./mark.js";
44

55
export function facets(data, {x, y, ...options}, marks) {

src/mark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {color} from "d3-color";
1+
import {color} from "d3";
22
import {ascendingDefined, nonempty} from "./defined.js";
33

44
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray

src/marks/area.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {group} from "d3-array";
2-
import {create} from "d3-selection";
3-
import {area as shapeArea} from "d3-shape";
1+
import {group} from "d3";
2+
import {create} from "d3";
3+
import {area as shapeArea} from "d3";
44
import {Curve} from "../curve.js";
55
import {defined} from "../defined.js";
66
import {Mark, indexOf, maybeColor, maybeZero, titleGroup} from "../mark.js";

src/marks/bar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {ascending} from "d3-array";
2-
import {create} from "d3-selection";
1+
import {ascending} from "d3";
2+
import {create} from "d3";
33
import {filter} from "../defined.js";
44
import {Mark, number, maybeColor, maybeZero, title} from "../mark.js";
55
import {Style, applyDirectStyles, applyIndirectStyles, applyTransform} from "../style.js";

src/marks/dot.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {ascending} from "d3-array";
2-
import {create} from "d3-selection";
1+
import {ascending} from "d3";
2+
import {create} from "d3";
33
import {filter, positive} from "../defined.js";
44
import {Mark, identity, first, second, maybeColor, maybeNumber, title} from "../mark.js";
55
import {Style, applyDirectStyles, applyIndirectStyles, applyTransform} from "../style.js";

0 commit comments

Comments
 (0)