source: trip-planner-front/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js@ 188ee53

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

initial commit

  • 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 { 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")} Module */
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 * @param {Dependency} dependency the dependency for which the template should be applied
35 * @param {ReplaceSource} source the current replace source which can be modified
36 * @param {DependencyTemplateContext} templateContext the context object
37 * @returns {void}
38 */
39 apply(
40 dependency,
41 source,
42 {
43 module,
44 runtimeTemplate,
45 moduleGraph,
46 initFragments,
47 runtimeRequirements,
48 runtime,
49 concatenationScope
50 }
51 ) {
52 if (concatenationScope) return;
53 const exportsInfo = moduleGraph.getExportsInfo(module);
54 if (
55 exportsInfo.getReadOnlyExportInfo("__esModule").getUsed(runtime) !==
56 UsageState.Unused
57 ) {
58 const content = runtimeTemplate.defineEsModuleFlagStatement({
59 exportsArgument: module.exportsArgument,
60 runtimeRequirements
61 });
62 initFragments.push(
63 new InitFragment(
64 content,
65 InitFragment.STAGE_HARMONY_EXPORTS,
66 0,
67 "harmony compatibility"
68 )
69 );
70 }
71 if (moduleGraph.isAsync(module)) {
72 runtimeRequirements.add(RuntimeGlobals.module);
73 runtimeRequirements.add(RuntimeGlobals.asyncModule);
74 initFragments.push(
75 new InitFragment(
76 runtimeTemplate.supportsArrowFunction()
77 ? `${RuntimeGlobals.asyncModule}(${module.moduleArgument}, async (__webpack_handle_async_dependencies__) => {\n`
78 : `${RuntimeGlobals.asyncModule}(${module.moduleArgument}, async function (__webpack_handle_async_dependencies__) {\n`,
79 InitFragment.STAGE_ASYNC_BOUNDARY,
80 0,
81 undefined,
82 module.buildMeta.async
83 ? `\n__webpack_handle_async_dependencies__();\n}, 1);`
84 : "\n});"
85 )
86 );
87 }
88 }
89};
90
91module.exports = HarmonyCompatibilityDependency;
Note: See TracBrowser for help on using the repository browser.