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

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.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 RuntimeGlobals = require("../RuntimeGlobals");
9
10/** @typedef {import("../Module")} Module */
11/** @typedef {import("../Module").RuntimeRequirements} RuntimeRequirements */
12/** @typedef {"exports" | "module.exports" | "this" | "Object.defineProperty(exports)" | "Object.defineProperty(module.exports)" | "Object.defineProperty(this)"} CommonJSDependencyBaseKeywords */
13
14/**
15 * @param {CommonJSDependencyBaseKeywords} depBase commonjs dependency base
16 * @param {Module} module module
17 * @param {RuntimeRequirements} runtimeRequirements runtime requirements
18 * @returns {[string, string]} type and base
19 */
20module.exports.handleDependencyBase = (
21 depBase,
22 module,
23 runtimeRequirements
24) => {
25 let base;
26 let type;
27 switch (depBase) {
28 case "exports":
29 runtimeRequirements.add(RuntimeGlobals.exports);
30 base = module.exportsArgument;
31 type = "expression";
32 break;
33 case "module.exports":
34 runtimeRequirements.add(RuntimeGlobals.module);
35 base = `${module.moduleArgument}.exports`;
36 type = "expression";
37 break;
38 case "this":
39 runtimeRequirements.add(RuntimeGlobals.thisAsExports);
40 base = "this";
41 type = "expression";
42 break;
43 case "Object.defineProperty(exports)":
44 runtimeRequirements.add(RuntimeGlobals.exports);
45 base = module.exportsArgument;
46 type = "Object.defineProperty";
47 break;
48 case "Object.defineProperty(module.exports)":
49 runtimeRequirements.add(RuntimeGlobals.module);
50 base = `${module.moduleArgument}.exports`;
51 type = "Object.defineProperty";
52 break;
53 case "Object.defineProperty(this)":
54 runtimeRequirements.add(RuntimeGlobals.thisAsExports);
55 base = "this";
56 type = "Object.defineProperty";
57 break;
58 default:
59 throw new Error(`Unsupported base ${depBase}`);
60 }
61
62 return [type, base];
63};
Note: See TracBrowser for help on using the repository browser.