source: imaps-frontend/node_modules/webpack/lib/runtime/GetMainFilenameRuntimeModule.js@ 79a0317

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3*/
4
5"use strict";
6
7const RuntimeGlobals = require("../RuntimeGlobals");
8const RuntimeModule = require("../RuntimeModule");
9const Template = require("../Template");
10
11/** @typedef {import("../Chunk")} Chunk */
12/** @typedef {import("../Compilation")} Compilation */
13
14class GetMainFilenameRuntimeModule extends RuntimeModule {
15 /**
16 * @param {string} name readable name
17 * @param {string} global global object binding
18 * @param {string} filename main file name
19 */
20 constructor(name, global, filename) {
21 super(`get ${name} filename`);
22 this.global = global;
23 this.filename = filename;
24 }
25
26 /**
27 * @returns {string | null} runtime code
28 */
29 generate() {
30 const { global, filename } = this;
31 const compilation = /** @type {Compilation} */ (this.compilation);
32 const chunk = /** @type {Chunk} */ (this.chunk);
33 const { runtimeTemplate } = compilation;
34 const url = compilation.getPath(JSON.stringify(filename), {
35 hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
36 hashWithLength: length =>
37 `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
38 chunk,
39 runtime: chunk.runtime
40 });
41 return Template.asString([
42 `${global} = ${runtimeTemplate.returningFunction(url)};`
43 ]);
44 }
45}
46
47module.exports = GetMainFilenameRuntimeModule;
Note: See TracBrowser for help on using the repository browser.