2014-03-02 03:07:42 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
|
|
|
Author Tobias Koppers @sokra
|
|
|
|
*/
|
|
|
|
var Module = require("./Module");
|
2015-12-30 00:44:55 +08:00
|
|
|
var OriginalSource = require("webpack-sources").OriginalSource;
|
|
|
|
var RawSource = require("webpack-sources").RawSource;
|
2014-03-02 03:07:42 +08:00
|
|
|
|
|
|
|
function RawModule(source, identifier, readableIdentifier) {
|
|
|
|
Module.call(this);
|
|
|
|
this.sourceStr = source;
|
|
|
|
this.identifierStr = identifier || this.sourceStr;
|
|
|
|
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
|
|
|
this.cacheable = true;
|
|
|
|
this.built = false;
|
|
|
|
}
|
|
|
|
module.exports = RawModule;
|
|
|
|
|
|
|
|
RawModule.prototype = Object.create(Module.prototype);
|
2016-05-20 13:39:36 +08:00
|
|
|
RawModule.prototype.constructor = RawModule;
|
2014-03-02 03:07:42 +08:00
|
|
|
|
|
|
|
RawModule.prototype.identifier = function() {
|
|
|
|
return this.identifierStr;
|
|
|
|
};
|
|
|
|
|
|
|
|
RawModule.prototype.readableIdentifier = function(requestShortener) {
|
|
|
|
return requestShortener.shorten(this.readableIdentifierStr);
|
|
|
|
};
|
|
|
|
|
2015-04-24 05:55:50 +08:00
|
|
|
RawModule.prototype.needRebuild = function() {
|
2014-03-02 03:07:42 +08:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
|
|
|
|
RawModule.prototype.build = function(options, compilation, resolver, fs, callback) {
|
|
|
|
this.builtTime = new Date().getTime();
|
|
|
|
callback();
|
|
|
|
};
|
|
|
|
|
2015-04-24 05:55:50 +08:00
|
|
|
RawModule.prototype.source = function() {
|
2015-07-16 06:19:23 +08:00
|
|
|
if(this.useSourceMap)
|
2014-03-02 03:07:42 +08:00
|
|
|
return new OriginalSource(this.sourceStr, this.identifier());
|
|
|
|
else
|
|
|
|
return new RawSource(this.sourceStr);
|
|
|
|
};
|
|
|
|
|
|
|
|
RawModule.prototype.size = function() {
|
|
|
|
return this.sourceStr.length;
|
|
|
|
};
|