|
| 1 | +/* |
| 2 | + MIT License http://www.opensource.org/licenses/mit-license.php |
| 3 | + Author Tobias Koppers @sokra |
| 4 | +*/ |
| 5 | +var Module = require("./Module"); |
| 6 | +var RawSource = require("webpack-core/lib/RawSource"); |
| 7 | + |
| 8 | +function MultiModule(context, dependencies, name) { |
| 9 | + Module.call(this); |
| 10 | + this.context = context; |
| 11 | + this.dependencies = dependencies; |
| 12 | + this.name = name; |
| 13 | + this.built = false; |
| 14 | + this.cacheable = true; |
| 15 | +} |
| 16 | +module.exports = MultiModule; |
| 17 | + |
| 18 | +MultiModule.prototype = Object.create(Module.prototype); |
| 19 | + |
| 20 | +MultiModule.prototype.identifier = function() { |
| 21 | + return "multi " + this.name; |
| 22 | +}; |
| 23 | + |
| 24 | +MultiModule.prototype.readableIdentifier = function(requestShortener) { |
| 25 | + return "multi " + this.name; |
| 26 | +}; |
| 27 | + |
| 28 | +MultiModule.prototype.disconnect = function disconnect() { |
| 29 | + this.built = false; |
| 30 | + Module.prototype.disconnect.call(this); |
| 31 | +}; |
| 32 | + |
| 33 | +MultiModule.prototype.build = function build(options, compilation, resolver, fs, callback) { |
| 34 | + this.built = true; |
| 35 | + return callback(); |
| 36 | +}; |
| 37 | + |
| 38 | +MultiModule.prototype.source = function(dependencyTemplates, outputOptions, requestShortener) { |
| 39 | + var str = ["module.exports = "]; |
| 40 | + this.dependencies.forEach(function(dep, idx) { |
| 41 | + if(dep.module) { |
| 42 | + str.push("require("); |
| 43 | + if(outputOptions.pathinfo) |
| 44 | + str.push("/*! "+dep.request+" */"); |
| 45 | + str.push(""+dep.module.id); |
| 46 | + str.push(")"); |
| 47 | + } else { |
| 48 | + str.push("(function webpackMissingModule() { throw new Error("); |
| 49 | + str.push(JSON.stringify("Cannot find module \"" + dep.request + "\"")); |
| 50 | + str.push("); }())"); |
| 51 | + } |
| 52 | + str.push(";\n"); |
| 53 | + }); |
| 54 | + return new RawSource(str.join("")); |
| 55 | +}; |
| 56 | + |
| 57 | +MultiModule.prototype.needRebuild = function needRebuild(fileTimestamps, contextTimestamps) { |
| 58 | + return false; |
| 59 | +}; |
| 60 | + |
| 61 | +MultiModule.prototype.size = function() { |
| 62 | + return 16 + this.dependencies.length * 12; |
| 63 | +}; |
| 64 | + |
| 65 | +MultiModule.prototype.updateHash = function(hash) { |
| 66 | + hash.update("multi module"); |
| 67 | + hash.update(this.name || ""); |
| 68 | + Module.prototype.updateHash.call(this, hash); |
| 69 | +}; |
0 commit comments