error when bundling with webpack
vishnu4 opened this issue · 2 comments
Trying to bundle colors.js and jqColorPicker.js with some other javascript files of mine into one file using webpack, and all the other files work except jqColorPicker, which gives me the following error:
ERROR in ./bower_components/tinyColorPicker/jqColorPicker.js
Module not found: Error: Cannot resolve module 'colors' in C:\Code\StandardProject2020\DEV\Server\MVC2\CoBRAMVC4Portal\bower_components\tinyColorPicker
@ ./bower_components/tinyColorPicker/jqColorPicker.js 3:58-75
I had a few issues with commonJS style imports (browserify) - not sure if that's what webpack is using?
Solution was to require("./colors.js") rather than require("colors") in line 3 of jqColorPicker.js.
Also needed to change the factory function signature from
function(window, $, Colors, undefined)
to
function(root, $, Colors, undefined)
I was planning to make a PR with this fix but I couldn't get it to work with the single minified file version so gave up... (I minify my whole bundle, but didn't want to make a PR that potentially breaks stuff for people including multiple minified files.)
late reply, had abandoned webpack and only just now got back around to it. now i get these warnings:
WARNING in ./~/colors/lib/colors.js
Critical dependencies:
138:29-43 the request of a dependency is an expression
@ ./~/colors/lib/colors.js 138:29-43
WARNING in ./~/colors/lib/extendStringPrototype.js
Critical dependencies:
101:31-45 the request of a dependency is an expression
@ ./~/colors/lib/extendStringPrototype.js 101:31-45
which is much better than errors. Thank you!