1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | Author Tobias Koppers @sokra, Zackary Jackson @ScriptedAlchemy, Marais Rossouw @maraisr
|
---|
4 | */
|
---|
5 |
|
---|
6 | "use strict";
|
---|
7 |
|
---|
8 | const ModuleDependency = require("../dependencies/ModuleDependency");
|
---|
9 | const makeSerializable = require("../util/makeSerializable");
|
---|
10 |
|
---|
11 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
---|
12 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
---|
13 |
|
---|
14 | class ContainerExposedDependency extends ModuleDependency {
|
---|
15 | /**
|
---|
16 | * @param {string} exposedName public name
|
---|
17 | * @param {string} request request to module
|
---|
18 | */
|
---|
19 | constructor(exposedName, request) {
|
---|
20 | super(request);
|
---|
21 | this.exposedName = exposedName;
|
---|
22 | }
|
---|
23 |
|
---|
24 | get type() {
|
---|
25 | return "container exposed";
|
---|
26 | }
|
---|
27 |
|
---|
28 | get category() {
|
---|
29 | return "esm";
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * @returns {string | null} an identifier to merge equal requests
|
---|
34 | */
|
---|
35 | getResourceIdentifier() {
|
---|
36 | return `exposed dependency ${this.exposedName}=${this.request}`;
|
---|
37 | }
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * @param {ObjectSerializerContext} context context
|
---|
41 | */
|
---|
42 | serialize(context) {
|
---|
43 | context.write(this.exposedName);
|
---|
44 | super.serialize(context);
|
---|
45 | }
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * @param {ObjectDeserializerContext} context context
|
---|
49 | */
|
---|
50 | deserialize(context) {
|
---|
51 | this.exposedName = context.read();
|
---|
52 | super.deserialize(context);
|
---|
53 | }
|
---|
54 | }
|
---|
55 |
|
---|
56 | makeSerializable(
|
---|
57 | ContainerExposedDependency,
|
---|
58 | "webpack/lib/container/ContainerExposedDependency"
|
---|
59 | );
|
---|
60 |
|
---|
61 | module.exports = ContainerExposedDependency;
|
---|