-
-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exposing jQuery not working #20
Comments
For what I was trying to do, I abandoned the above approach and simply pulled out jQuery into its own bundle using CommonChunks:
|
Be sure you have stable version of node installed. I had latest and it wasn't erroring or anything. Just wasn't working. Installed stable, good to go. |
@JohnnyFun are you running v4.5.0? |
Yep: |
What is your version of jQuery? Still have the same error as @tysonnero. |
i have this problem toooooo |
Have the same issue |
fwiw, a kind of hacky way I've worked around it in the past was to make a module that explicitly sets jquery on the window: import Jquery from 'jquery'; Then just import/require that in your entry file and should be good. But of course favor the way webpack says to do it. This should only be used if you just want to move on with your life and get jquery plugins to shut up and work. |
I finally got 2 solutions that resolved my issue: //entry js file
import 'expose-loader?$!jquery';
import 'expose-loader?jQuery!jquery';
//... second (as @JohnnyFun mentioned ): //entry js file
import $ from 'jquery';
global.$ = global.jQuery = $;
//... |
@Wapweb this approach is also working for me but I've faced with that standard way is not working (or maybe I do something wrong)
but this one is working fine
anyway standard is looking much better from my side, any suggestions how to make standard work ? |
@gingray Did you manage to find a solution to your problem, as I have the exact same issue where the |
@ErikSchierboom yes sorry for late response but hope it will be still helpful. Webpack is pretty tricky tool (I think for most of backend developers). class @Spinner
... to use import 'expose-loader?Spinner!../clasess/spinner.coffee'; but need to do changes in coffee class itself class Spinner
...
module.exports = Spinner as you can see you haven't And one more thing sometimes you need just load current js it might be a plugin or pure js code which not support modules and all the ideas behind new js wave. For this purposes use plugin |
Experiencing the described problem with Webpack 4. |
same here :\ |
this is also OKrequire("expose-loader?$!jquery");
require("expose-loader?jQuery!jquery");
|
None of these solutions are working for me. I have created a project with create-react-app, installed expose-loader via npm, and all of these |
@elsheepo you might consider using webpack's provide plugin like:
Many npm packages are smart enough to try to import/require in their dependencies and thus won't actually need them set on the window. But if you do indeed need it set on the window, did you try my hack above, where you make a module that imports jquery and sets it on the window? |
@JohnnyFun indeed, provide plugin worked like a charm 👍 thanks! |
Just spent way too much time figuring this one out, but I finally was able to get jquery exposed properly. This was always working for me:
But I wanted to move that into my config like so:
This didn't work though because I was also creating an alias to jquery to point to a minified version:
The alias wasn't allowing expose-loader to find 'jquery', so I removed the alias and now Although this leads me to a new issue (which I can live without for now)... anybody know how to get an alias working with expose-loader? |
Fixed, now you can use |
In my webpack config I have the following line to expose jQuery on the global scope
I have a file that uses the $. For example:
However, during my webpack build, get the following error:
Also, if I put the following directly in my file:
I get this error:
According to this page, the above should all work: https://webpack.github.io/docs/shimming-modules.html. I must be missing something. Any advice?
The text was updated successfully, but these errors were encountered: