2

enter image description hereDoes D3 version 3 support es2015/es6? Had d3 working fine using es2015 and angular but when upgrading to angular 8, d3 started giving me a runtime error. "Document is undefined"

        "d3": "3.5.17",
        "@angular/animations": "^8.0.2",
        "@angular/cdk": "^8.0.1",

{//tsconfig.json
  "compilerOptions": {
    "allowJs": true,
    "downlevelIteration": true,
    "target": "es5",
    "module": "esnext",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "es2015",
      "es2017",
      "dom",
      "esnext.asynciterable" // Enable async generators. See https://stackoverflow.com/a/43694282/62694.
    ],
Karam
  • 336
  • 5
  • 18

1 Answers1

1

D3.js is written as ES6 modules from version 4 on.

I downloaded the main repository https://github.com/d3/d3 and configured rollup to produce an es6 file for the whole d3. With that file I can use d3 in an es6-module based web project:

import * as d3 from "./d3.js"; // my own bundle

I am not aware that such bundle is offered somewhere, which surprises me in 2022.

citykid
  • 9,916
  • 10
  • 55
  • 91