1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const makeSerializable = require("../util/makeSerializable");
|
---|
9 | const ContextDependency = require("./ContextDependency");
|
---|
10 | const ContextDependencyTemplateAsId = require("./ContextDependencyTemplateAsId");
|
---|
11 |
|
---|
12 | /** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
---|
13 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
---|
14 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
---|
15 | /** @typedef {import("./ContextDependency").ContextDependencyOptions} ContextDependencyOptions */
|
---|
16 |
|
---|
17 | class RequireResolveContextDependency extends ContextDependency {
|
---|
18 | /**
|
---|
19 | * @param {ContextDependencyOptions} options options
|
---|
20 | * @param {Range} range range
|
---|
21 | * @param {Range} valueRange value range
|
---|
22 | * @param {TODO} context context
|
---|
23 | */
|
---|
24 | constructor(options, range, valueRange, context) {
|
---|
25 | super(options, context);
|
---|
26 |
|
---|
27 | this.range = range;
|
---|
28 | this.valueRange = valueRange;
|
---|
29 | }
|
---|
30 |
|
---|
31 | get type() {
|
---|
32 | return "amd require context";
|
---|
33 | }
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * @param {ObjectSerializerContext} context context
|
---|
37 | */
|
---|
38 | serialize(context) {
|
---|
39 | const { write } = context;
|
---|
40 |
|
---|
41 | write(this.range);
|
---|
42 | write(this.valueRange);
|
---|
43 |
|
---|
44 | super.serialize(context);
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * @param {ObjectDeserializerContext} context context
|
---|
49 | */
|
---|
50 | deserialize(context) {
|
---|
51 | const { read } = context;
|
---|
52 |
|
---|
53 | this.range = read();
|
---|
54 | this.valueRange = read();
|
---|
55 |
|
---|
56 | super.deserialize(context);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | makeSerializable(
|
---|
61 | RequireResolveContextDependency,
|
---|
62 | "webpack/lib/dependencies/RequireResolveContextDependency"
|
---|
63 | );
|
---|
64 |
|
---|
65 | RequireResolveContextDependency.Template = ContextDependencyTemplateAsId;
|
---|
66 |
|
---|
67 | module.exports = RequireResolveContextDependency;
|
---|