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 ModuleDependency = require("./ModuleDependency");
|
---|
10 |
|
---|
11 | /** @typedef {import("../Dependency").ReferencedExport} ReferencedExport */
|
---|
12 | /** @typedef {import("../ModuleGraph")} ModuleGraph */
|
---|
13 | /** @typedef {import("../util/runtime").RuntimeSpec} RuntimeSpec */
|
---|
14 |
|
---|
15 | class WebAssemblyExportImportedDependency extends ModuleDependency {
|
---|
16 | constructor(exportName, request, name, valueType) {
|
---|
17 | super(request);
|
---|
18 | /** @type {string} */
|
---|
19 | this.exportName = exportName;
|
---|
20 | /** @type {string} */
|
---|
21 | this.name = name;
|
---|
22 | /** @type {string} */
|
---|
23 | this.valueType = valueType;
|
---|
24 | }
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Returns list of exports referenced by this dependency
|
---|
28 | * @param {ModuleGraph} moduleGraph module graph
|
---|
29 | * @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
---|
30 | * @returns {(string[] | ReferencedExport)[]} referenced exports
|
---|
31 | */
|
---|
32 | getReferencedExports(moduleGraph, runtime) {
|
---|
33 | return [[this.name]];
|
---|
34 | }
|
---|
35 |
|
---|
36 | get type() {
|
---|
37 | return "wasm export import";
|
---|
38 | }
|
---|
39 |
|
---|
40 | get category() {
|
---|
41 | return "wasm";
|
---|
42 | }
|
---|
43 |
|
---|
44 | serialize(context) {
|
---|
45 | const { write } = context;
|
---|
46 |
|
---|
47 | write(this.exportName);
|
---|
48 | write(this.name);
|
---|
49 | write(this.valueType);
|
---|
50 |
|
---|
51 | super.serialize(context);
|
---|
52 | }
|
---|
53 |
|
---|
54 | deserialize(context) {
|
---|
55 | const { read } = context;
|
---|
56 |
|
---|
57 | this.exportName = read();
|
---|
58 | this.name = read();
|
---|
59 | this.valueType = read();
|
---|
60 |
|
---|
61 | super.deserialize(context);
|
---|
62 | }
|
---|
63 | }
|
---|
64 |
|
---|
65 | makeSerializable(
|
---|
66 | WebAssemblyExportImportedDependency,
|
---|
67 | "webpack/lib/dependencies/WebAssemblyExportImportedDependency"
|
---|
68 | );
|
---|
69 |
|
---|
70 | module.exports = WebAssemblyExportImportedDependency;
|
---|