Skip to content

Commit e3cb0fa

Browse files
committed
require.amd gets it value from webpackOptions.amd
1 parent 0908703 commit e3cb0fa

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,10 @@ You can also save this options object in a JSON file and use it with the shell c
555555
// default: 0
556556
// only process file in seperate process if more or equal loaders applied to the file.
557557

558+
amd: { jQuery: true },
559+
// default: {}
560+
// specify the value of require.amd and define.amd
561+
558562
profile: true,
559563
// default: false
560564
// capture timings for the build.

buildin/__webpack_amd_require.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ function amdRequire(chunk, requiresFn, fn) {
1212
}
1313
for(var name in req)
1414
amdRequire[name] = req[name];
15-
amdRequire.amd = {};
15+
amdRequire.amd = require("./__webpack_options_amd.loader.js!./__webpack_options_amd.loader.js");
1616
amdRequire.config = function() {/* config is ignored, use webpack options */};
1717
module.exports = amdRequire;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function() {
2+
this.cacheable();
3+
if(!this.options.amd) return "/* empty to return {} */";
4+
return "module.exports = " + JSON.stringify(this.options.amd);
5+
}

test/browsertest/lib/index.web.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ setTimeout(function() {
215215
// cross module system support
216216
window.test(typeof require === "function", "require should be a function");
217217
window.test(typeof define === "function", "define should be a function");
218-
window.test(require.amd, "require.amd should be true");
219-
window.test(define.amd, "define.amd should be true");
218+
window.test(typeof require.amd === "object", "require.amd should be an object");
219+
window.test(typeof define.amd === "object", "define.amd should be an object");
220220
window.test(typeof module === "object", "module should be a object");
221221

222222

test/browsertest/libary2config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@ module.exports = {
1111
]
1212
}
1313
},
14-
maxChunks: 2
14+
maxChunks: 2,
15+
amd: {
16+
fromOptions: true
17+
}
1518
}

test/browsertest/node_modules/libary2/lib/main.js

Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)