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("../util/Hash")} Hash */
|
---|
17 |
|
---|
18 | class StaticExportsDependency extends NullDependency {
|
---|
19 | /**
|
---|
20 | * @param {string[] | true} exports export names
|
---|
21 | * @param {boolean} canMangle true, if mangling exports names is allowed
|
---|
22 | */
|
---|
23 | constructor(exports, canMangle) {
|
---|
24 | super();
|
---|
25 | this.exports = exports;
|
---|
26 | this.canMangle = canMangle;
|
---|
27 | }
|
---|
28 |
|
---|
29 | get type() {
|
---|
30 | return "static exports";
|
---|
31 | }
|
---|
32 |
|
---|
33 | /**
|
---|
34 | * Returns the exported names
|
---|
35 | * @param {ModuleGraph} moduleGraph module graph
|
---|
36 | * @returns {ExportsSpec | undefined} export names
|
---|
37 | */
|
---|
38 | getExports(moduleGraph) {
|
---|
39 | return {
|
---|
40 | exports: this.exports,
|
---|
41 | canMangle: this.canMangle,
|
---|
42 | dependencies: undefined
|
---|
43 | };
|
---|
44 | }
|
---|
45 |
|
---|
46 | serialize(context) {
|
---|
47 | const { write } = context;
|
---|
48 | write(this.exports);
|
---|
49 | write(this.canMangle);
|
---|
50 | super.serialize(context);
|
---|
51 | }
|
---|
52 |
|
---|
53 | deserialize(context) {
|
---|
54 | const { read } = context;
|
---|
55 | this.exports = read();
|
---|
56 | this.canMangle = read();
|
---|
57 | super.deserialize(context);
|
---|
58 | }
|
---|
59 | }
|
---|
60 |
|
---|
61 | makeSerializable(
|
---|
62 | StaticExportsDependency,
|
---|
63 | "webpack/lib/dependencies/StaticExportsDependency"
|
---|
64 | );
|
---|
65 |
|
---|
66 | module.exports = StaticExportsDependency;
|
---|