| 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 NullDependency = require("./NullDependency");
|
|---|
| 10 |
|
|---|
| 11 | /** @typedef {import("../Dependency").ExportsSpec} ExportsSpec */
|
|---|
| 12 | /** @typedef {import("../ModuleGraph")} ModuleGraph */
|
|---|
| 13 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
|---|
| 14 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
|---|
| 15 |
|
|---|
| 16 | /** @typedef {string[] | true} Exports */
|
|---|
| 17 |
|
|---|
| 18 | class StaticExportsDependency extends NullDependency {
|
|---|
| 19 | /**
|
|---|
| 20 | * Creates an instance of StaticExportsDependency.
|
|---|
| 21 | * @param {Exports} exports export names
|
|---|
| 22 | * @param {boolean} canMangle true, if mangling exports names is allowed
|
|---|
| 23 | */
|
|---|
| 24 | constructor(exports, canMangle) {
|
|---|
| 25 | super();
|
|---|
| 26 | this.exports = exports;
|
|---|
| 27 | this.canMangle = canMangle;
|
|---|
| 28 | }
|
|---|
| 29 |
|
|---|
| 30 | get type() {
|
|---|
| 31 | return "static exports";
|
|---|
| 32 | }
|
|---|
| 33 |
|
|---|
| 34 | /**
|
|---|
| 35 | * Returns the exported names
|
|---|
| 36 | * @param {ModuleGraph} moduleGraph module graph
|
|---|
| 37 | * @returns {ExportsSpec | undefined} export names
|
|---|
| 38 | */
|
|---|
| 39 | getExports(moduleGraph) {
|
|---|
| 40 | return {
|
|---|
| 41 | exports: this.exports,
|
|---|
| 42 | canMangle: this.canMangle,
|
|---|
| 43 | dependencies: undefined
|
|---|
| 44 | };
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | /**
|
|---|
| 48 | * Serializes this instance into the provided serializer context.
|
|---|
| 49 | * @param {ObjectSerializerContext} context context
|
|---|
| 50 | */
|
|---|
| 51 | serialize(context) {
|
|---|
| 52 | const { write } = context;
|
|---|
| 53 | write(this.exports);
|
|---|
| 54 | write(this.canMangle);
|
|---|
| 55 | super.serialize(context);
|
|---|
| 56 | }
|
|---|
| 57 |
|
|---|
| 58 | /**
|
|---|
| 59 | * Restores this instance from the provided deserializer context.
|
|---|
| 60 | * @param {ObjectDeserializerContext} context context
|
|---|
| 61 | */
|
|---|
| 62 | deserialize(context) {
|
|---|
| 63 | const { read } = context;
|
|---|
| 64 | this.exports = read();
|
|---|
| 65 | this.canMangle = read();
|
|---|
| 66 | super.deserialize(context);
|
|---|
| 67 | }
|
|---|
| 68 | }
|
|---|
| 69 |
|
|---|
| 70 | makeSerializable(
|
|---|
| 71 | StaticExportsDependency,
|
|---|
| 72 | "webpack/lib/dependencies/StaticExportsDependency"
|
|---|
| 73 | );
|
|---|
| 74 |
|
|---|
| 75 | module.exports = StaticExportsDependency;
|
|---|