-
-
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
issue with dll plugin #25
Comments
@zjcf |
same here |
@andrewQwer @zjcf ProvidePlugin worked for us (for most of the places LOL)
|
@Restuta unfortunately this doesn't work for me, because ProvidePlugin injects listed modules into another module where $, jQuery or window.jQuery is used. In my case third party library adds handler to html element like |
I believe I got this to work. You just need to make sure the normal bundle imports the jQuery module with expose. I did so in my webpack.config I have a module.exports.vendor = [
'expose?jQuery!jquery',
//...other vendor files
] In my dll.config.js: const DLL = require('./dll.js');
module.exports = {
entry: {
vendor: DLL.vendor(),
},
//...
} My webpack.config.entry looks like: app: [...DLL.vendor(), fromRoot('client/main.ts')] |
Yeah, finally I got this work too. I just put expose loader to both places dll and entry. |
@andrewQwer , could you please provide example of your solution? |
I just put this line into loaders section in both places: dll config and entry build config
It worked for my problem with jqGrid library. |
Hi guys, im on webpack 3.0.0 - and still can't seem to get this to work. neither "$" or "jQuery" are being exposed on the window (although my DLL is being included ok) My DLL looks like
And in my webpack.config I have:
and in module rules
Any help would be appreciated |
@ryanquinn3 @andrewQwer are you sure your normal bundle doesn't contain jQuery since the whole point of doing this is to extract jQuery it to DLL, right? Could you guys please confirm that it doesn't? |
I could only get it working using a hacky workaround. Took the dependencies that have globals out of the regular DLL/reference bundles. Seems to work, but now I have four bundles. Somewhat inconvenient, but at least the project changes are bundled separately and that is the thing that changes regularly. |
@chrisrickard did you ever get this to work with webpack 3.x? |
@bsbodden I did yes, I found out that I had to include the jquery alias in my main webpack.config (even though it was being included from my webpack.vendor.dll.js).
|
I think issue #webpack/webpack#4589 is somehow linked to this issue. @zjcf, {
"name": "vendor_dll",
"content": {
"./node_modules/expose-loader/index.js?$!./node_modules/jquery/dist/jquery.js": {
"id": 1, // exposed jquery
"meta": {}
},
"./node_modules/webpack/buildin/global.js": {
"id": 2,
"meta": {}
},
"./node_modules/jquery/dist/jquery.js": {
"id": 3, // original jquery
"meta": {}
}
}
} If I |
I have the same issue with Webpack 4. I have a
The |
Workaround, that works for me even with webpack 4
webpack.config.js
And now I can simply
|
Thanks a bunch @mifopen for sharing your configuration workaround. I will give it a try. Just want to point out for others that stumble on this difficult bug, the way I solved this is to create two independent config files:
const config: webpack.Configuration = {
module: {
rules: [
...
{
test: require.resolve('jquery'),
use: [
{
loader: 'expose-loader',
options: 'jQuery'
},
{
loader: 'expose-loader',
options: '$'
}
]
}, ... Then, const config : webpack.Configuration = {
...
externals: { //List all globally exposed packages defined in webpack.config.vendor.ts
jquery: "jQuery",
...
}, The HTML looks like: <!-- from webpack.config.vendor.ts entry -->
<script src="vendor.js"></script>
<!-- from webpack.config.ts entry -->
<script src="entry.js"></script> This way I pretty much avoid idiosyncrasies with |
@bchavez I am also experiencing this problem when switching to the dllplugin. Could you provide the full config files to get this working? I am using the latest webpack and still not working. |
Hi, I got a problem when use expose and dll plugin at the same time, when I put the jquery in dll plugin, it will not work.
If I don't use dll plugin, it can work well both use
require('expose?jQuery!jquery')
and write it in webpack config file.But since I put jquery in dll plugin, it can only work by using
require('expose?jQuery!jquery')
. If I write the jquery loader in config file, it will not work. All the code is the same, except I write a dll plugin.The text was updated successfully, but these errors were encountered: