source: trip-planner-front/node_modules/webpack/lib/runtime/GetMainFilenameRuntimeModule.js@ 571e0df

Last change on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
RevLine 
[6a3a178]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("../Compilation")} Compilation */
12
13class GetMainFilenameRuntimeModule extends RuntimeModule {
14 /**
15 * @param {string} name readable name
16 * @param {string} global global object binding
17 * @param {string} filename main file name
18 */
19 constructor(name, global, filename) {
20 super(`get ${name} filename`);
21 this.global = global;
22 this.filename = filename;
23 }
24
25 /**
26 * @returns {string} runtime code
27 */
28 generate() {
29 const { global, filename, compilation, chunk } = this;
30 const { runtimeTemplate } = compilation;
31 const url = compilation.getPath(JSON.stringify(filename), {
32 hash: `" + ${RuntimeGlobals.getFullHash}() + "`,
33 hashWithLength: length =>
34 `" + ${RuntimeGlobals.getFullHash}().slice(0, ${length}) + "`,
35 chunk,
36 runtime: chunk.runtime
37 });
38 return Template.asString([
39 `${global} = ${runtimeTemplate.returningFunction(url)};`
40 ]);
41 }
42}
43
44module.exports = GetMainFilenameRuntimeModule;
Note: See TracBrowser for help on using the repository browser.