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