UNPKG

2.07 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const Dependency = require("../Dependency");
9const makeSerializable = require("../util/makeSerializable");
10const ModuleDependency = require("./ModuleDependency");
11
12/** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
13/** @typedef {import("../Dependency").TRANSITIVE} TRANSITIVE */
14/** @typedef {import("../ModuleGraph")} ModuleGraph */
15/** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
16
17class WebAssemblyExportImportedDependency extends ModuleDependency {
18 constructor(exportName, request, name, valueType) {
19 super(request);
20 /** @type {string} */
21 this.exportName = exportName;
22 /** @type {string} */
23 this.name = name;
24 /** @type {string} */
25 this.valueType = valueType;
26 }
27
28 /**
29 * @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
30 */
31 couldAffectReferencingModule() {
32 return Dependency.TRANSITIVE;
33 }
34
35 /**
36 * Returns list of exports referenced by this dependency
37 * @param {ModuleGraph} moduleGraph module graph
38 * @param {RuntimeSpec} runtime the runtime for which the module is analysed
39 * @returns {(string[] | ReferencedExport)[]} referenced exports
40 */
41 getReferencedExports(moduleGraph, runtime) {
42 return [[this.name]];
43 }
44
45 get type() {
46 return "wasm export import";
47 }
48
49 get category() {
50 return "wasm";
51 }
52
53 serialize(context) {
54 const { write } = context;
55
56 write(this.exportName);
57 write(this.name);
58 write(this.valueType);
59
60 super.serialize(context);
61 }
62
63 deserialize(context) {
64 const { read } = context;
65
66 this.exportName = read();
67 this.name = read();
68 this.valueType = read();
69
70 super.deserialize(context);
71 }
72}
73
74makeSerializable(
75 WebAssemblyExportImportedDependency,
76 "webpack/lib/dependencies/WebAssemblyExportImportedDependency"
77);
78
79module.exports = WebAssemblyExportImportedDependency;