source: imaps-frontend/node_modules/webpack/lib/wasm-async/AsyncWebAssemblyGenerator.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const Generator = require("../Generator");
9const { WEBASSEMBLY_TYPES } = require("../ModuleSourceTypesConstants");
10
11/** @typedef {import("webpack-sources").Source} Source */
12/** @typedef {import("../Generator").GenerateContext} GenerateContext */
13/** @typedef {import("../Module").SourceTypes} SourceTypes */
14/** @typedef {import("../NormalModule")} NormalModule */
15
16/**
17 * @typedef {object} AsyncWebAssemblyGeneratorOptions
18 * @property {boolean} [mangleImports] mangle imports
19 */
20
21class AsyncWebAssemblyGenerator extends Generator {
22 /**
23 * @param {AsyncWebAssemblyGeneratorOptions} options options
24 */
25 constructor(options) {
26 super();
27 this.options = options;
28 }
29
30 /**
31 * @param {NormalModule} module fresh module
32 * @returns {SourceTypes} available types (do not mutate)
33 */
34 getTypes(module) {
35 return WEBASSEMBLY_TYPES;
36 }
37
38 /**
39 * @param {NormalModule} module the module
40 * @param {string=} type source type
41 * @returns {number} estimate size of the module
42 */
43 getSize(module, type) {
44 const originalSource = module.originalSource();
45 if (!originalSource) {
46 return 0;
47 }
48 return originalSource.size();
49 }
50
51 /**
52 * @param {NormalModule} module module for which the code should be generated
53 * @param {GenerateContext} generateContext context for generate
54 * @returns {Source | null} generated code
55 */
56 generate(module, generateContext) {
57 return /** @type {Source} */ (module.originalSource());
58 }
59}
60
61module.exports = AsyncWebAssemblyGenerator;
Note: See TracBrowser for help on using the repository browser.