Skip to content

Commit

Permalink
Merge pull request #8083 from webpack/bugfix/amd-hash
Browse files Browse the repository at this point in the history
fixes #8081
  • Loading branch information
sokra committed Sep 25, 2018
2 parents c4d8a3c + d836bcb commit 8dd7caf
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/AmdMainTemplatePlugin.js
Expand Up @@ -79,7 +79,9 @@ class AmdMainTemplatePlugin {

mainTemplate.hooks.hash.tap("AmdMainTemplatePlugin", hash => {
hash.update("exports amd");
hash.update(this.name);
if (this.name) {
hash.update(this.name);
}
});
}
}
Expand Down
10 changes: 10 additions & 0 deletions test/configCases/target/amd-named/index.js
@@ -0,0 +1,10 @@
it("should run", function() {

});

it("should name define", function() {
var fs = require("fs");
var source = fs.readFileSync(__filename, "utf-8");

expect(source).toMatch("define(\"NamedLibrary\",");
});
17 changes: 17 additions & 0 deletions test/configCases/target/amd-named/webpack.config.js
@@ -0,0 +1,17 @@
const webpack = require("../../../../");
module.exports = {
output: {
library: "NamedLibrary",
libraryTarget: "amd"
},
node: {
__dirname: false,
__filename: false
},
plugins: [
new webpack.BannerPlugin({
raw: true,
banner: "function define(name, deps, fn) { fn(); }\n"
})
]
};
10 changes: 10 additions & 0 deletions test/configCases/target/amd-unnamed/index.js
@@ -0,0 +1,10 @@
it("should run", function() {

});

it("should name define", function() {
var fs = require("fs");
var source = fs.readFileSync(__filename, "utf-8");

expect(source).toMatch("define(function(");
});
16 changes: 16 additions & 0 deletions test/configCases/target/amd-unnamed/webpack.config.js
@@ -0,0 +1,16 @@
const webpack = require("../../../../");
module.exports = {
output: {
libraryTarget: "amd"
},
node: {
__dirname: false,
__filename: false
},
plugins: [
new webpack.BannerPlugin({
raw: true,
banner: "function define(deps, fn) { fn(); }\n"
})
]
};

0 comments on commit 8dd7caf

Please sign in to comment.