| 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").ReferencedExports} ReferencedExports */
|
|---|
| 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 | * Creates an instance of WebAssemblyExportImportedDependency.
|
|---|
| 22 | * @param {string} exportName export name
|
|---|
| 23 | * @param {string} request request
|
|---|
| 24 | * @param {string} name name
|
|---|
| 25 | * @param {string} valueType value type
|
|---|
| 26 | */
|
|---|
| 27 | constructor(exportName, request, name, valueType) {
|
|---|
| 28 | super(request);
|
|---|
| 29 | /** @type {string} */
|
|---|
| 30 | this.exportName = exportName;
|
|---|
| 31 | /** @type {string} */
|
|---|
| 32 | this.name = name;
|
|---|
| 33 | /** @type {string} */
|
|---|
| 34 | this.valueType = valueType;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | /**
|
|---|
| 38 | * Could affect referencing module.
|
|---|
| 39 | * @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
|
|---|
| 40 | */
|
|---|
| 41 | couldAffectReferencingModule() {
|
|---|
| 42 | return Dependency.TRANSITIVE;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | * Returns list of exports referenced by this dependency
|
|---|
| 47 | * @param {ModuleGraph} moduleGraph module graph
|
|---|
| 48 | * @param {RuntimeSpec} runtime the runtime for which the module is analysed
|
|---|
| 49 | * @returns {ReferencedExports} referenced exports
|
|---|
| 50 | */
|
|---|
| 51 | getReferencedExports(moduleGraph, runtime) {
|
|---|
| 52 | return [[this.name]];
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | get type() {
|
|---|
| 56 | return "wasm export import";
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | get category() {
|
|---|
| 60 | return "wasm";
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | /**
|
|---|
| 64 | * Serializes this instance into the provided serializer context.
|
|---|
| 65 | * @param {ObjectSerializerContext} context context
|
|---|
| 66 | */
|
|---|
| 67 | serialize(context) {
|
|---|
| 68 | const { write } = context;
|
|---|
| 69 |
|
|---|
| 70 | write(this.exportName);
|
|---|
| 71 | write(this.name);
|
|---|
| 72 | write(this.valueType);
|
|---|
| 73 |
|
|---|
| 74 | super.serialize(context);
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | /**
|
|---|
| 78 | * Restores this instance from the provided deserializer context.
|
|---|
| 79 | * @param {ObjectDeserializerContext} context context
|
|---|
| 80 | */
|
|---|
| 81 | deserialize(context) {
|
|---|
| 82 | const { read } = context;
|
|---|
| 83 |
|
|---|
| 84 | this.exportName = read();
|
|---|
| 85 | this.name = read();
|
|---|
| 86 | this.valueType = read();
|
|---|
| 87 |
|
|---|
| 88 | super.deserialize(context);
|
|---|
| 89 | }
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | makeSerializable(
|
|---|
| 93 | WebAssemblyExportImportedDependency,
|
|---|
| 94 | "webpack/lib/dependencies/WebAssemblyExportImportedDependency"
|
|---|
| 95 | );
|
|---|
| 96 |
|
|---|
| 97 | module.exports = WebAssemblyExportImportedDependency;
|
|---|