source: frontend/node_modules/webpack/lib/dependencies/ImportEagerDependency.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 2.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 makeSerializable = require("../util/makeSerializable");
9const ImportDependency = require("./ImportDependency");
10
11/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
12/** @typedef {import("../Dependency")} Dependency */
13/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
14/** @typedef {import("../Module")} Module */
15/** @typedef {import("../Module").BuildMeta} BuildMeta */
16/** @typedef {import("../javascript/JavascriptParser").ImportAttributes} ImportAttributes */
17/** @typedef {import("../javascript/JavascriptParser").Range} Range */
18/** @typedef {ImportDependency.RawReferencedExports} RawReferencedExports */
19/** @typedef {import("./ImportPhase").ImportPhaseType} ImportPhaseType */
20
21class ImportEagerDependency extends ImportDependency {
22 /**
23 * Creates an instance of ImportEagerDependency.
24 * @param {string} request the request
25 * @param {Range} range expression range
26 * @param {RawReferencedExports | null} referencedExports list of referenced exports
27 * @param {ImportPhaseType} phase import phase
28 * @param {ImportAttributes=} attributes import attributes
29 */
30 constructor(request, range, referencedExports, phase, attributes) {
31 super(request, range, referencedExports, phase, attributes);
32 }
33
34 get type() {
35 return "import() eager";
36 }
37
38 get category() {
39 return "esm";
40 }
41}
42
43makeSerializable(
44 ImportEagerDependency,
45 "webpack/lib/dependencies/ImportEagerDependency"
46);
47
48ImportEagerDependency.Template = class ImportEagerDependencyTemplate extends (
49 ImportDependency.Template
50) {
51 /**
52 * Applies the plugin by registering its hooks on the compiler.
53 * @param {Dependency} dependency the dependency for which the template should be applied
54 * @param {ReplaceSource} source the current replace source which can be modified
55 * @param {DependencyTemplateContext} templateContext the context object
56 * @returns {void}
57 */
58 apply(
59 dependency,
60 source,
61 { runtimeTemplate, module, moduleGraph, chunkGraph, runtimeRequirements }
62 ) {
63 const dep = /** @type {ImportEagerDependency} */ (dependency);
64 const content = runtimeTemplate.moduleNamespacePromise({
65 chunkGraph,
66 module: /** @type {Module} */ (moduleGraph.getModule(dep)),
67 request: dep.request,
68 strict: /** @type {BuildMeta} */ (module.buildMeta).strictHarmonyModule,
69 message: "import() eager",
70 dependency: dep,
71 runtimeRequirements
72 });
73
74 source.replace(dep.range[0], dep.range[1] - 1, content);
75 }
76};
77
78module.exports = ImportEagerDependency;
Note: See TracBrowser for help on using the repository browser.