source: imaps-frontend/node_modules/webpack/lib/dependencies/HarmonyCompatibilityDependency.js@ 79a0317

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

F4 Finalna Verzija

  • 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")} Module */
18/** @typedef {import("../Module").BuildMeta} BuildMeta */
19
20class HarmonyCompatibilityDependency extends NullDependency {
21 get type() {
22 return "harmony export header";
23 }
24}
25
26makeSerializable(
27 HarmonyCompatibilityDependency,
28 "webpack/lib/dependencies/HarmonyCompatibilityDependency"
29);
30
31HarmonyCompatibilityDependency.Template = class HarmonyExportDependencyTemplate extends (
32 NullDependency.Template
33) {
34 /**
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.