123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- "use strict";
- const DependencyReference = require("./DependencyReference");
- const ModuleDependency = require("./ModuleDependency");
- const UnsupportedWebAssemblyFeatureError = require("../wasm/UnsupportedWebAssemblyFeatureError");
- class WebAssemblyImportDependency extends ModuleDependency {
-
- constructor(request, name, description, onlyDirectImport) {
- super(request);
-
- this.name = name;
-
- this.description = description;
-
- this.onlyDirectImport = onlyDirectImport;
- }
- getReference() {
- if (!this.module) return null;
- return new DependencyReference(this.module, [this.name], false);
- }
- getErrors() {
- if (
- this.onlyDirectImport &&
- this.module &&
- !this.module.type.startsWith("webassembly")
- ) {
- return [
- new UnsupportedWebAssemblyFeatureError(
- `Import "${this.name}" from "${this.request}" with ${this.onlyDirectImport} can only be used for direct wasm to wasm dependencies`
- )
- ];
- }
- }
- get type() {
- return "wasm import";
- }
- }
- module.exports = WebAssemblyImportDependency;
|