-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
NamedModulePlugins breaks global lookups, such as jquery #4613
Comments
duplicate of shakacode/bootstrap-loader#288 |
@sokra |
Surely this is a webpack issue, not an issue of bootstrap-loader. If I add this plugin, it breaks jquery and velocity. I do not use bootstrap-loader. @sokra |
I'm seeing the same issue. Why is this closed? I have these two modules rules (note the dependence the first has on the exported [upper-case Q for jQuery] jQuery: |
Could you file a new issue? |
I've filed this under the expose-loader project, as I believe that is the culprit. |
I tracked this down and I believe it's a bug in I can try coming up with a PR, although I'm fairly new to webpack, especially the internals. But it seems like it should be an easy fix. @sokra do you want a new issue filed, or do you think it makes sense to re-open this issue. |
This problem is preventing us to use
on the issue linked above. So I am surprised he closed this one. |
I have zero experience with Webpack's source code (except for reading it to figure things out when docs fall short). So I probably don't know what I am talking about. Take it with a grain of salt: So a patch like what @alangpierce described would make /*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
class NamedModulesPlugin {
constructor(options) {
this.options = options || {};
}
apply(compiler) {
compiler.plugin("compilation", (compilation) => {
compilation.plugin("before-module-ids", (modules) => {
let usedIds = [];
modules.forEach((module) => {
let proposedId = null;
if (module.id === null && module.libIdent) {
proposedId = module.libIdent({
context: this.options.context || compiler.options.context
});
if (!usedIds.includes(proposedId)) {
module.id = proposedId;
usedIds.push(proposedId);
}
}
});
});
});
}
}
module.exports = NamedModulesPlugin; This is, in fact, easy and fixes the Let's wait for @sokra to weigh in. |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Adding NamedModulesPlugin to a project that uses certain global lookups results in what are effectively reference errors.
If the current behavior is a bug, please provide the steps to reproduce.
Add NamedModulePlugins to https://github.com/shakacode/bootstrap-loader/blob/master/examples/basic/webpack.dev.config.js (which uses jquery & bootstrap. Resulting Error).
https://github.com/eggheadio/egghead-ui/blob/master/src/components/Icon/index.js#L65 also breaks with
keys
being declared not a function.What is the expected behavior?
That global lookups work.
If this is a feature request, what is motivation or use case for changing the behavior?
Compatibility with other libraries.
Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.
webpack: 2.2.1
The text was updated successfully, but these errors were encountered: