1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 | const RuntimeGlobals = require("../RuntimeGlobals");
|
8 | const RuntimeModule = require("../RuntimeModule");
|
9 |
|
10 | class RuntimeIdRuntimeModule extends RuntimeModule {
|
11 | constructor() {
|
12 | super("runtimeId");
|
13 | }
|
14 |
|
15 | |
16 |
|
17 |
|
18 | generate() {
|
19 | const { chunkGraph, chunk } = this;
|
20 | const runtime = chunk.runtime;
|
21 | if (typeof runtime !== "string")
|
22 | throw new Error("RuntimeIdRuntimeModule must be in a single runtime");
|
23 | const id = chunkGraph.getRuntimeId(runtime);
|
24 | return `${RuntimeGlobals.runtimeId} = ${JSON.stringify(id)};`;
|
25 | }
|
26 | }
|
27 |
|
28 | module.exports = RuntimeIdRuntimeModule;
|