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