2014-06-03 14:45:26 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
2015-12-30 00:44:55 +08:00
|
|
|
var ConcatSource = require("webpack-sources").ConcatSource;
|
2014-06-03 14:45:26 +08:00
|
|
|
|
2015-07-13 06:20:09 +08:00
|
|
|
function FunctionModuleTemplatePlugin() {}
|
2014-06-03 14:45:26 +08:00
|
|
|
module.exports = FunctionModuleTemplatePlugin;
|
|
|
|
|
|
|
|
FunctionModuleTemplatePlugin.prototype.apply = function(moduleTemplate) {
|
2015-04-24 05:55:50 +08:00
|
|
|
moduleTemplate.plugin("render", function(moduleSource, module) {
|
2014-06-03 14:45:26 +08:00
|
|
|
var source = new ConcatSource();
|
2017-01-11 17:51:58 +08:00
|
|
|
var defaultArguments = [module.moduleArgument || "module", module.exportsArgument || "exports"];
|
2017-01-10 00:11:34 +08:00
|
|
|
if((module.arguments && module.arguments.length !== 0) || module.hasDependencies(d => d.requireWebpackRequire !== false)) {
|
2015-05-28 02:09:45 +08:00
|
|
|
defaultArguments.push("__webpack_require__");
|
|
|
|
}
|
2017-01-01 00:08:40 +08:00
|
|
|
source.add("/***/ (function(" + defaultArguments.concat(module.arguments || []).join(", ") + ") {\n\n");
|
2016-06-10 05:09:54 +08:00
|
|
|
if(module.strict) source.add("\"use strict\";\n");
|
|
|
|
source.add(moduleSource);
|
2017-01-01 00:08:40 +08:00
|
|
|
source.add("\n\n/***/ })");
|
2014-06-03 14:45:26 +08:00
|
|
|
return source;
|
|
|
|
});
|
2015-04-24 05:55:50 +08:00
|
|
|
moduleTemplate.plugin("package", function(moduleSource, module) {
|
2015-07-16 06:19:23 +08:00
|
|
|
if(this.outputOptions.pathinfo) {
|
2014-06-03 14:45:26 +08:00
|
|
|
var source = new ConcatSource();
|
|
|
|
var req = module.readableIdentifier(this.requestShortener);
|
2016-09-06 05:41:03 +08:00
|
|
|
if(Array.isArray(module.providedExports))
|
|
|
|
source.add("/* exports provided: " + module.providedExports.join(", ") + " */\n");
|
|
|
|
else if(module.providedExports)
|
|
|
|
source.add("/* unknown exports provided */\n");
|
2016-09-07 15:46:13 +08:00
|
|
|
if(Array.isArray(module.usedExports))
|
|
|
|
source.add("/* exports used: " + module.usedExports.join(", ") + " */\n");
|
|
|
|
else if(module.usedExports)
|
|
|
|
source.add("/* all exports used */\n");
|
2014-06-03 14:45:26 +08:00
|
|
|
source.add("/*!****" + req.replace(/./g, "*") + "****!*\\\n");
|
|
|
|
source.add(" !*** " + req.replace(/\*\//g, "*_/") + " ***!\n");
|
|
|
|
source.add(" \\****" + req.replace(/./g, "*") + "****/\n");
|
|
|
|
source.add(moduleSource);
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
return moduleSource;
|
|
|
|
});
|
|
|
|
moduleTemplate.plugin("hash", function(hash) {
|
|
|
|
hash.update("FunctionModuleTemplatePlugin");
|
|
|
|
hash.update("2");
|
|
|
|
});
|
|
|
|
};
|