source: frontend/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.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.8 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 { UsageState } = require("../ExportsInfo");
9const InitFragment = require("../InitFragment");
10const RuntimeGlobals = require("../RuntimeGlobals");
11const makeSerializable = require("../util/makeSerializable");
12const NullDependency = require("./NullDependency");
13
14/** @typedef {import("webpack-sources").ReplaceSource} ReplaceSource */
15/** @typedef {import("../Dependency")} Dependency */
16/** @typedef {import("../DependencyTemplate").DependencyTemplateContext} DependencyTemplateContext */
17/** @typedef {import("../Module").BuildMeta} BuildMeta */
18
19class HarmonyCompatibilityDependency extends NullDependency {
20 get type() {
21 return "harmony export header";
22 }
23}
24
25makeSerializable(
26 HarmonyCompatibilityDependency,
27 "webpack/lib/dependencies/HarmonyCompatibilityDependency"
28);
29
30HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate extends (
31 NullDependency.Template
32) {
33 /**
34 * Applies the plugin by registering its hooks on the compiler.
35 * @param {Dependency} dependency the dependency for which the template should be applied
36 * @param {ReplaceSource} source the current replace source which can be modified
37 * @param {DependencyTemplateContext} templateContext the context object
38 * @returns {void}
39 */
40 apply(
41 dependency,
42 source,
43 {
44 module,
45 runtimeTemplate,
46 moduleGraph,
47 initFragments,
48 runtimeRequirements,
49 runtime,
50 concatenationScope
51 }
52 ) {
53 if (concatenationScope) return;
54 const exportsInfo = moduleGraph.getExportsInfo(module);
55 if (
56 exportsInfo.getReadOnlyExportInfo("__esModule").getUsed(runtime) !==
57 UsageState.Unused
58 ) {
59 const content = runtimeTemplate.defineEsModuleFlagStatement({
60 exportsArgument: module.exportsArgument,
61 runtimeRequirements
62 });
63 initFragments.push(
64 new InitFragment(
65 content,
66 InitFragment.STAGE_HARMONY_EXPORTS,
67 0,
68 "harmony compatibility"
69 )
70 );
71 }
72 if (moduleGraph.isAsync(module)) {
73 runtimeRequirements.add(RuntimeGlobals.module);
74 runtimeRequirements.add(RuntimeGlobals.asyncModule);
75 initFragments.push(
76 new InitFragment(
77 runtimeTemplate.supportsArrowFunction()
78 ? `${RuntimeGlobals.asyncModule}(${module.moduleArgument}, async (__webpack_handle_async_dependencies__, __webpack_async_result__) => { try {\n`
79 : `${RuntimeGlobals.asyncModule}(${module.moduleArgument}, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n`,
80 InitFragment.STAGE_ASYNC_BOUNDARY,
81 0,
82 undefined,
83 `\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }${
84 /** @type {BuildMeta} */ (module.buildMeta).async ? ", 1" : ""
85 });`
86 )
87 );
88 }
89 }
90};
91
92module.exports = HarmonyCompatibilityDependency;
Note: See TracBrowser for help on using the repository browser.