-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
including in webpack build #8
Comments
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? |
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:
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. |
Ok, thanks for the info and glad you could manage it, @acthp. The above line you have added to the 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 |
Is there a recommended way to include this lib from webpack? Doing a simple require() results in dependencies (d3-tip) not being available at run-time.
The text was updated successfully, but these errors were encountered: