| | |
| | | "use strict"; |
| | | |
| | | const Generator = require("../Generator"); |
| | | const { |
| | | JAVASCRIPT_TYPE, |
| | | WEBASSEMBLY_TYPE |
| | | } = require("../ModuleSourceTypeConstants"); |
| | | const { WEBASSEMBLY_MODULE_TYPE_SYNC } = require("../ModuleTypeConstants"); |
| | | const WebAssemblyExportImportedDependency = require("../dependencies/WebAssemblyExportImportedDependency"); |
| | | const WebAssemblyImportDependency = require("../dependencies/WebAssemblyImportDependency"); |
| | | const { compareModulesByIdOrIdentifier } = require("../util/comparators"); |
| | | const { compareModulesByFullName } = require("../util/comparators"); |
| | | const memoize = require("../util/memoize"); |
| | | const WebAssemblyInInitialChunkError = require("./WebAssemblyInInitialChunkError"); |
| | | |
| | |
| | | const PLUGIN_NAME = "WebAssemblyModulesPlugin"; |
| | | |
| | | /** |
| | | * Options that influence how synchronous WebAssembly modules are transformed |
| | | * and emitted. |
| | | * @typedef {object} WebAssemblyModulesPluginOptions |
| | | * @property {boolean=} mangleImports mangle imports |
| | | */ |
| | | |
| | | /** |
| | | * Adds parser, generator, manifest, and validation support for synchronous |
| | | * WebAssembly modules in the compilation pipeline. |
| | | */ |
| | | class WebAssemblyModulesPlugin { |
| | | /** |
| | | * Stores options that affect generated synchronous WebAssembly output. |
| | | * @param {WebAssemblyModulesPluginOptions} options options |
| | | */ |
| | | constructor(options) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * Apply the plugin |
| | | * Registers compilation hooks that parse and generate sync WebAssembly |
| | | * modules, emit their binary assets, and report invalid placement in initial |
| | | * chunks. |
| | | * @param {Compiler} compiler the compiler instance |
| | | * @returns {void} |
| | | */ |
| | |
| | | const WebAssemblyGenerator = getWebAssemblyGenerator(); |
| | | |
| | | return Generator.byType({ |
| | | javascript: new WebAssemblyJavascriptGenerator(), |
| | | webassembly: new WebAssemblyGenerator(this.options) |
| | | [JAVASCRIPT_TYPE]: new WebAssemblyJavascriptGenerator(), |
| | | [WEBASSEMBLY_TYPE]: new WebAssemblyGenerator(this.options) |
| | | }); |
| | | }); |
| | | |
| | |
| | | |
| | | for (const module of chunkGraph.getOrderedChunkModulesIterable( |
| | | chunk, |
| | | compareModulesByIdOrIdentifier(chunkGraph) |
| | | compareModulesByFullName(compiler) |
| | | )) { |
| | | if (module.type === WEBASSEMBLY_MODULE_TYPE_SYNC) { |
| | | const filenameTemplate = outputOptions.webassemblyModuleFilename; |