Giter Site home page Giter Site logo

Comments (7)

mbostock avatar mbostock commented on August 29, 2024

Sorry, but I’m not familiar with SystemJS, so I can’t advise on how to configure it. If you’re loading the ES5 bundles generated by Rollup, there should be no reference to “d3-selection” or “d3-transition” as the code from those modules is inlined directly into the bundle. That said, if your goal is to use D3 in an ES2015+ environment, you probably want to load the ES2015 source which would mean the module entry defined in the package.json (rather than the main entry which points to the generated bundle). But it looks like you’re not using the package.json at all and just pointing directly to the generated bundles.

from d3-selection-multi.

zzx88991 avatar zzx88991 commented on August 29, 2024

Thanks for answering my question. Actually I am using Typescript and transecompile the code back to ES5 with bundle script below.
<script src="https://d3js.org/d3-selection-multi.v1.min.js"></script>
Correct me if i am wrong. Since i am running my app in chrome, the minified script thinks it is running in a ES2015 environment, so it starts to look for the module references for d3-selection and d3-transition? That is why the error is produced?

from d3-selection-multi.

mbostock avatar mbostock commented on August 29, 2024

The minified script knows nothing about ES2015. It’s just using the standard UMD boilerplate generated by Rollup. Look at the source here:

https://d3js.org/d3-selection-multi.v1.js

In an AMD environment (e.g., when using RequireJS), the minified script declares that it depends on d3-selection and d3-transition. In a CommonJS environment, d3-selection and d3-transition are require’d. Otherwise, it assumes that the d3 global already contains the necessary d3-selection and d3-transition modules. My guess is that you are in an AMD environment.

from d3-selection-multi.

zzx88991 avatar zzx88991 commented on August 29, 2024

That answers my question. Yeah, it is running in AMD. Thanks!

from d3-selection-multi.

zzx88991 avatar zzx88991 commented on August 29, 2024

Sorry, but there is one thing I still couldn't figure out. Since i am loading both d3.v4.min.js and d3-selection-multi.v1.min.js in AMD environment, why is d3-selection-multi.v1.min.js still missing the d3-selection and d3-transition modules? Aren't they exported by d3.v4.min.js?

from d3-selection-multi.

mbostock avatar mbostock commented on August 29, 2024

The expectation when you are using AMD is that you load d3-selection and d3-transition separately, rather than using the d3 default bundle. All the D3 bundles are defined anonymously (the recommended best practice for UMD), so either you’d need to write a shim or whatever to configure your AMD environment to draw d3-selection and d3-transition from the loaded d3 bundle, or you should require the modules separately and it’ll work the normal way.

from d3-selection-multi.

zzx88991 avatar zzx88991 commented on August 29, 2024

Now i understand. I appreciate your answer!

from d3-selection-multi.

Related Issues (16)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.