LocalModule.js
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
"use strict";
const makeSerializable = require("../util/makeSerializable");
/** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
class LocalModule {
/**
* @param {string} name name
* @param {number} idx index
*/
constructor(name, idx) {
this.name = name;
this.idx = idx;
this.used = false;
}
flagUsed() {
this.used = true;
}
/**
* @returns {string} variable name
*/
variableName() {
return "__WEBPACK_LOCAL_MODULE_" + this.idx + "__";
}
/**
* @param {ObjectSerializerContext} context context
*/
serialize(context) {
const { write } = context;
write(this.name);
write(this.idx);
write(this.used);
}
/**
* @param {ObjectDeserializerContext} context context
*/
deserialize(context) {
const { read } = context;
this.name = read();
this.idx = read();
this.used = read();
}
}
makeSerializable(LocalModule, "webpack/lib/dependencies/LocalModule");
module.exports = LocalModule;