WebAssemblyExportImportedDependency.js 2.0 KB

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