I am in the process of trying to switch from webpack to vite. I am far from an expert in any of this js build tooling stuff, just trying to muddle through, apologies if I'm saying weird things.
Once I switched to vite, import 'devbridge-autocomplete'; no longer is succesfully installing the Autocomplete plugin into JQuery -- the plugin is not actually available.
Trying to debug, it looks like the browserify branch of the load code is being triggered:
https://github.com/devbridge/jQuery-Autocomplete/blob/8138252b4c6fa994a0d438630ea375308e7f3b11/dist/jquery.autocomplete.js#L18-L20
But doesn't actually work for some reason. Although no error appears in console. I am actually not sure why that branch is being triggered, to me it seems typeof require if undefined. But a debugger says somehow that condition is triggered, and does not work.
If the last else branch for "browser globals" is used, then everything works fine for me (because I have specifically set window.$ and window.jQuery for legacy code, I guess).
https://github.com/devbridge/jQuery-Autocomplete/blob/8138252b4c6fa994a0d438630ea375308e7f3b11/dist/jquery.autocomplete.js#L21-L23
Trying to debug further... I think the built-in initialize code is somehow loading a second copy of jQuery and installing the plugin in that, instead of in my window.jQuery where I want it. But I could be misunderstanding what's going on. And there doesn't seem to be any way to exersize any control over this anyway.
I'm not quite sure what to do to get the plugin to install in this environment. Any ideas welcome.
I am in the process of trying to switch from webpack to vite. I am far from an expert in any of this js build tooling stuff, just trying to muddle through, apologies if I'm saying weird things.
Once I switched to vite,
import 'devbridge-autocomplete';no longer is succesfully installing the Autocomplete plugin into JQuery -- the plugin is not actually available.Trying to debug, it looks like the
browserifybranch of the load code is being triggered:https://github.com/devbridge/jQuery-Autocomplete/blob/8138252b4c6fa994a0d438630ea375308e7f3b11/dist/jquery.autocomplete.js#L18-L20
But doesn't actually work for some reason. Although no error appears in console. I am actually not sure why that branch is being triggered, to me it seems
typeof requireifundefined. But a debugger says somehow that condition is triggered, and does not work.If the last else branch for "browser globals" is used, then everything works fine for me (because I have specifically set
window.$andwindow.jQueryfor legacy code, I guess).https://github.com/devbridge/jQuery-Autocomplete/blob/8138252b4c6fa994a0d438630ea375308e7f3b11/dist/jquery.autocomplete.js#L21-L23
Trying to debug further... I think the built-in initialize code is somehow loading a second copy of jQuery and installing the plugin in that, instead of in my
window.jQuerywhere I want it. But I could be misunderstanding what's going on. And there doesn't seem to be any way to exersize any control over this anyway.I'm not quite sure what to do to get the plugin to install in this environment. Any ideas welcome.