bubblechart icon indicating copy to clipboard operation
bubblechart copied to clipboard

Webpack does not resolve module 'bubblechart' even if module was installed via npm

Open rafaelpivato opened this issue 10 years ago • 5 comments

In order to use this as a module through npm, you need to manually build it before hand. Which means having things like grunt installed, even if you are relying on other build system like webpack, for instance.

The usual approach to this is build and publish minified and dist source code along with rest of code at GitHub.

rafaelpivato avatar Dec 02 '15 14:12 rafaelpivato

This was premature. I can see the files present at dist now. My issue resolving the module should have other reason. In case you are curious my real problem is this error output from a Webpack build:

Module not found: Error: Cannot resolve module 'bubblechart'

rafaelpivato avatar Dec 02 '15 14:12 rafaelpivato

Thanks! Back when this was originally built I did not do a good job of making it play well with module loaders. I would definitely accept a Pull Request to improve the module loader compatibility. :+1:

jondavidjohn avatar Dec 02 '15 15:12 jondavidjohn

Adding main entry to package.json solved my issue. I think we could have that in master branch here.

...
"main": "./dist/bubblechart.js",
...

rafaelpivato avatar Dec 02 '15 15:12 rafaelpivato

Right, but I think we also need to make sure it doesn't attach globally when required, but return the BubbleChart class.

It should only attach globally when not requiring via a module system. See this for example

jondavidjohn avatar Dec 02 '15 15:12 jondavidjohn

Excellent point :+1:

rafaelpivato avatar Dec 02 '15 16:12 rafaelpivato