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 ContextDependencyTemplateAsRequireCall = require("./ContextDependencyTemplateAsRequireCall");
|
---|
11 |
|
---|
12 | /** @typedef {import("../javascript/JavascriptParser").Range} Range */
|
---|
13 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
---|
14 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
---|
15 |
|
---|
16 | class ImportContextDependency extends ContextDependency {
|
---|
17 | /**
|
---|
18 | * @param {TODO} options options
|
---|
19 | * @param {Range} range range
|
---|
20 | * @param {Range} valueRange value range
|
---|
21 | */
|
---|
22 | constructor(options, range, valueRange) {
|
---|
23 | super(options);
|
---|
24 |
|
---|
25 | this.range = range;
|
---|
26 | this.valueRange = valueRange;
|
---|
27 | }
|
---|
28 |
|
---|
29 | get type() {
|
---|
30 | return `import() context ${this.options.mode}`;
|
---|
31 | }
|
---|
32 |
|
---|
33 | get category() {
|
---|
34 | return "esm";
|
---|
35 | }
|
---|
36 |
|
---|
37 | /**
|
---|
38 | * @param {ObjectSerializerContext} context context
|
---|
39 | */
|
---|
40 | serialize(context) {
|
---|
41 | const { write } = context;
|
---|
42 |
|
---|
43 | write(this.valueRange);
|
---|
44 |
|
---|
45 | super.serialize(context);
|
---|
46 | }
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * @param {ObjectDeserializerContext} context context
|
---|
50 | */
|
---|
51 | deserialize(context) {
|
---|
52 | const { read } = context;
|
---|
53 |
|
---|
54 | this.valueRange = read();
|
---|
55 |
|
---|
56 | super.deserialize(context);
|
---|
57 | }
|
---|
58 | }
|
---|
59 |
|
---|
60 | makeSerializable(
|
---|
61 | ImportContextDependency,
|
---|
62 | "webpack/lib/dependencies/ImportContextDependency"
|
---|
63 | );
|
---|
64 |
|
---|
65 | ImportContextDependency.Template = ContextDependencyTemplateAsRequireCall;
|
---|
66 |
|
---|
67 | module.exports = ImportContextDependency;
|
---|