Giter Site home page Giter Site logo

including in webpack build about muts-needle-plot HOT 3 OPEN

bbglab avatar bbglab commented on August 29, 2024
including in webpack build

from muts-needle-plot.

Comments (3)

mpschr avatar mpschr commented on August 29, 2024

Hi @acthp

I have never used webpack and don't know what may be causing the problem. Does webpack also use the package.json file to install dependencies?

from muts-needle-plot.

acthp avatar acthp commented on August 29, 2024

Yes, webpack uses npm and require(). The problem is that muts-needle-plot uses a combination of require() , and global variables, with d3, underscore, and d3-svg-legend being loaded as globals, but others being loaded with require(). I eventually worked out a solution using webpack's shims for legacy modules. Like this:

// The next three are required for muts-needle-plot.
{ test: /d3-svg-legend/, loader: "imports?d3=d3" },
{ test: /muts-needle-plot/, loader: "imports?_=underscore" },
// The d3-tip AMD loader does not populate d3.tip, which is expected
// by muts-needle-plot. So, we disable it here. The CommonJS loader
// will populate d3.tip.
{ test: /d3-tip/, loader: "imports?define=>false" },

and also doing an explicit require() for d3-svg-legend. The 'imports' loader injects a binding into a module that is expecting a global variable.

If you don't want to directly require() some dependencies, e.g. so the user can override them, you can parameterize the lib with the dependencies. Like change the globals to parameters on the constructor, or on an 'initialize' routine.

from muts-needle-plot.

mpschr avatar mpschr commented on August 29, 2024

Ok, thanks for the info and glad you could manage it, @acthp.

The above line you have added to the package.json? Please feel free to make a fork and add you changes.

Also if you know very well which changes to make to muts-needle-plot I would appreciate a patch since in this moment I don't see time to tackle this issue and it wuold help you clean up the code in your project.

Best

from muts-needle-plot.

Related Issues (11)

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.