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 Dependency = require("../Dependency");
|
---|
9 | const makeSerializable = require("../util/makeSerializable");
|
---|
10 | const ModuleDependency = require("./ModuleDependency");
|
---|
11 |
|
---|
12 | /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
---|
13 | /** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
|
---|
14 | /** @typedef {import("../ModuleGraph")} ModuleGraph */
|
---|
15 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
|
---|
16 | /** @typedef {import("../serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
|
---|
17 | /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
---|
18 |
|
---|
19 | class WebAssemblyExportImportedDependency extends ModuleDependency {
|
---|
20 | /**
|
---|
21 | * @param {string} exportName export name
|
---|
22 | * @param {string} request request
|
---|
23 | * @param {string} name name
|
---|
24 | * @param {TODO} valueType value type
|
---|
25 | */
|
---|
26 | constructor(exportName, request, name, valueType) {
|
---|
27 | super(request);
|
---|
28 | /** @type {string} */
|
---|
29 | this.exportName = exportName;
|
---|
30 | /** @type {string} */
|
---|
31 | this.name = name;
|
---|
32 | /** @type {string} */
|
---|
33 | this.valueType = valueType;
|
---|
34 | }
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * @returns {boolean | TRANSITIVE} true, when changes to the referenced module could affect the referencing module; TRANSITIVE, when changes to the referenced module could affect referencing modules of the referencing module
|
---|
38 | */
|
---|
39 | couldAffectReferencingModule() {
|
---|
40 | return Dependency.TRANSITIVE;
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Returns list of exports referenced by this dependency
|
---|
45 | * @param {ModuleGraph} moduleGraph module graph
|
---|
46 | * @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
---|
47 | * @returns {(string[] | ReferencedExport)[]} referenced exports
|
---|
48 | */
|
---|
49 | getReferencedExports(moduleGraph, runtime) {
|
---|
50 | return [[this.name]];
|
---|
51 | }
|
---|
52 |
|
---|
53 | get type() {
|
---|
54 | return "wasm export import";
|
---|
55 | }
|
---|
56 |
|
---|
57 | get category() {
|
---|
58 | return "wasm";
|
---|
59 | }
|
---|
60 |
|
---|
61 | /**
|
---|
62 | * @param {ObjectSerializerContext} context context
|
---|
63 | */
|
---|
64 | serialize(context) {
|
---|
65 | const { write } = context;
|
---|
66 |
|
---|
67 | write(this.exportName);
|
---|
68 | write(this.name);
|
---|
69 | write(this.valueType);
|
---|
70 |
|
---|
71 | super.serialize(context);
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * @param {ObjectDeserializerContext} context context
|
---|
76 | */
|
---|
77 | deserialize(context) {
|
---|
78 | const { read } = context;
|
---|
79 |
|
---|
80 | this.exportName = read();
|
---|
81 | this.name = read();
|
---|
82 | this.valueType = read();
|
---|
83 |
|
---|
84 | super.deserialize(context);
|
---|
85 | }
|
---|
86 | }
|
---|
87 |
|
---|
88 | makeSerializable(
|
---|
89 | WebAssemblyExportImportedDependency,
|
---|
90 | "webpack/lib/dependencies/WebAssemblyExportImportedDependency"
|
---|
91 | );
|
---|
92 |
|
---|
93 | module.exports = WebAssemblyExportImportedDependency;
|
---|