Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.3 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 |
|
---|
8 | const RuntimeGlobals = require("../RuntimeGlobals");
|
---|
9 |
|
---|
10 | exports.handleDependencyBase = (depBase, module, runtimeRequirements) => {
|
---|
11 | let base = undefined;
|
---|
12 | let type;
|
---|
13 | switch (depBase) {
|
---|
14 | case "exports":
|
---|
15 | runtimeRequirements.add(RuntimeGlobals.exports);
|
---|
16 | base = module.exportsArgument;
|
---|
17 | type = "expression";
|
---|
18 | break;
|
---|
19 | case "module.exports":
|
---|
20 | runtimeRequirements.add(RuntimeGlobals.module);
|
---|
21 | base = `${module.moduleArgument}.exports`;
|
---|
22 | type = "expression";
|
---|
23 | break;
|
---|
24 | case "this":
|
---|
25 | runtimeRequirements.add(RuntimeGlobals.thisAsExports);
|
---|
26 | base = "this";
|
---|
27 | type = "expression";
|
---|
28 | break;
|
---|
29 | case "Object.defineProperty(exports)":
|
---|
30 | runtimeRequirements.add(RuntimeGlobals.exports);
|
---|
31 | base = module.exportsArgument;
|
---|
32 | type = "Object.defineProperty";
|
---|
33 | break;
|
---|
34 | case "Object.defineProperty(module.exports)":
|
---|
35 | runtimeRequirements.add(RuntimeGlobals.module);
|
---|
36 | base = `${module.moduleArgument}.exports`;
|
---|
37 | type = "Object.defineProperty";
|
---|
38 | break;
|
---|
39 | case "Object.defineProperty(this)":
|
---|
40 | runtimeRequirements.add(RuntimeGlobals.thisAsExports);
|
---|
41 | base = "this";
|
---|
42 | type = "Object.defineProperty";
|
---|
43 | break;
|
---|
44 | default:
|
---|
45 | throw new Error(`Unsupported base ${depBase}`);
|
---|
46 | }
|
---|
47 |
|
---|
48 | return [type, base];
|
---|
49 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.