1
|
/*
|
2
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
3
|
Author Tobias Koppers @sokra
|
4
|
*/
|
5
|
"use strict";
|
6
|
|
7
|
const Module = require("./Module");
|
8
|
const { OriginalSource, RawSource } = require("webpack-sources");
|
9
|
|
10
|
module.exports = class RawModule extends Module {
|
11
|
constructor(source, identifier, readableIdentifier) {
|
12
|
super("javascript/dynamic", null);
|
13
|
this.sourceStr = source;
|
14
|
this.identifierStr = identifier || this.sourceStr;
|
15
|
this.readableIdentifierStr = readableIdentifier || this.identifierStr;
|
16
|
this.built = false;
|
17
|
}
|
18
|
|
19
|
identifier() {
|
20
|
return this.identifierStr;
|
21
|
}
|
22
|
|
23
|
size() {
|
24
|
return this.sourceStr.length;
|
25
|
}
|
26
|
|
27
|
readableIdentifier(requestShortener) {
|
28
|
return requestShortener.shorten(this.readableIdentifierStr);
|
29
|
}
|
30
|
|
31
|
needRebuild() {
|
32
|
return false;
|
33
|
}
|
34
|
|
35
|
build(options, compilations, resolver, fs, callback) {
|
36
|
this.built = true;
|
37
|
this.buildMeta = {};
|
38
|
this.buildInfo = {
|
39
|
cacheable: true
|
40
|
};
|
41
|
callback();
|
42
|
}
|
43
|
|
44
|
source() {
|
45
|
if (this.useSourceMap) {
|
46
|
return new OriginalSource(this.sourceStr, this.identifier());
|
47
|
} else {
|
48
|
return new RawSource(this.sourceStr);
|
49
|
}
|
50
|
}
|
51
|
|
52
|
updateHash(hash) {
|
53
|
hash.update(this.sourceStr);
|
54
|
super.updateHash(hash);
|
55
|
}
|
56
|
};
|