Last change
on this file since 59329aa was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.2 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 |
|
---|
8 | const Generator = require("../Generator");
|
---|
9 |
|
---|
10 | /** @typedef {import("webpack-sources").Source} Source */
|
---|
11 | /** @typedef {import("../Generator").GenerateContext} GenerateContext */
|
---|
12 | /** @typedef {import("../NormalModule")} NormalModule */
|
---|
13 |
|
---|
14 | const TYPES = new Set(["webassembly"]);
|
---|
15 |
|
---|
16 | class AsyncWebAssemblyGenerator extends Generator {
|
---|
17 | constructor(options) {
|
---|
18 | super();
|
---|
19 | this.options = options;
|
---|
20 | }
|
---|
21 |
|
---|
22 | /**
|
---|
23 | * @param {NormalModule} module fresh module
|
---|
24 | * @returns {Set<string>} available types (do not mutate)
|
---|
25 | */
|
---|
26 | getTypes(module) {
|
---|
27 | return TYPES;
|
---|
28 | }
|
---|
29 |
|
---|
30 | /**
|
---|
31 | * @param {NormalModule} module the module
|
---|
32 | * @param {string=} type source type
|
---|
33 | * @returns {number} estimate size of the module
|
---|
34 | */
|
---|
35 | getSize(module, type) {
|
---|
36 | const originalSource = module.originalSource();
|
---|
37 | if (!originalSource) {
|
---|
38 | return 0;
|
---|
39 | }
|
---|
40 | return originalSource.size();
|
---|
41 | }
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * @param {NormalModule} module module for which the code should be generated
|
---|
45 | * @param {GenerateContext} generateContext context for generate
|
---|
46 | * @returns {Source} generated code
|
---|
47 | */
|
---|
48 | generate(module, generateContext) {
|
---|
49 | return module.originalSource();
|
---|
50 | }
|
---|
51 | }
|
---|
52 |
|
---|
53 | module.exports = AsyncWebAssemblyGenerator;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.