I'm trying to build a module which uses d3, but I don't want to bundle d3 with that module and, crucially, I don't want to have to bind d3 to the window. The module is to be installed on another project with npm as a git dependency. On the module I have a set up something like this:
output: {
path: path.resolve(__dirname, '../dist'),
filename: '[name].min.js',
libraryTarget: 'umd',
umdNamedDefine: true
},
externals: [
{
"d3": {
root: "d3"
}
}
]
and in the project it's installed onto I want something like this:
import d3 from 'd3'
import example from 'example'
However, that only works if I also do this:
import d3 from 'd3'
window.d3=d3
import example from 'example'
Is it possible to use both modules without touching the global scope?