Skip to content
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

fixes #8081 #8083

Merged
merged 1 commit into from Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
})
]
};