Closed vvo closed 9 years ago
What config are you using?
@bendrucker I was more asking on a feature side if that was feasible.
Well it should work
So what would be the configuration to use to inject window.jQuery
as require('jquery')
in a file tree containing a package.json and a file2.js being required in index.js with require('./file2.js')
that look like:
(function($) {
// use $
})(window.jQuery)
?
If I'm understanding right, this should be in the pkg:
{
"browserify-shim": {
"./file2.js": {
"depends": "jquery:jQuery"
}
}
}
Thanks, what would be the configuration if ./file.2
is moduleName
?
Like
app.js
var module = require('moduleName');
moduleName
(function($) {
// use $
})(window.jQuery)
Basically I am trying to force to use my node_modules jQuery to typeahead (0.10.5): https://github.com/twitter/typeahead.js/blob/v0.10.5/dist/typeahead.bundle.js
thx @bendrucker
So that story gets a bit more complicated. Browserify transforms don't run on code in node_modules
unless you make it a global transform.
browserify -e app.js -g browserify-shim
{
"module-name": {
"depends": "jquery:jQuery"
}
}
Assuming this is resolved, please update if it isn't
Thanks for the answer, did not know about global transforms. Sorry for late reply
Hi, I was wondering if given this file:
file.js
I was able to inject
window.jQuery = require('jquery');
by using browserify-shim?I cannot make it work, the only thing I want is to
require('./vendor/file.js')
with window.jQuery being a commonJS reference to jQuery (since we can nowrequire('jquery')
Thanks!