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

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

F4 Finalna Verzija

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