-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrebundled_external_package.js
More file actions
38 lines (35 loc) · 1.64 KB
/
rebundled_external_package.js
File metadata and controls
38 lines (35 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import AbstractExternalPackage from "../abstract_external_package";
import CommonInfo from "../common_info";
import NamedSourceFile from "../source_file/named_source_file";
/**
* Represents an external package that rebundles other packages into one file.
*/
export default class RebundledExternalPackage extends AbstractExternalPackage {
/**
* Creates a representation of rebundled external package.
* @param {CommonInfo} commonInfo Common information from common info builder.
* @param {string} globalName The global identifier that will represent the rebundled package.
* @param {Object} subglobals Pairs of external name (key) and global variable (value) of every
* external package that will be rebundled.
* @param {string} file The path to the source file which imports the external packages to be
* rebundled.
* @param {any[]} plugins Plugins that will be used to bundle the source file.
* @param {AbstractExternalPackage[]} [externals=[]] Array of external packages that will not be
* included in the bundle.
*/
constructor(commonInfo, globalName, subglobals, file, plugins, externals = []) {
super("", globalName);
this._subglobals = subglobals;
this._sourceFile = new NamedSourceFile(commonInfo, globalName, file, plugins, externals);
}
toConfigurationArray() {
return this._sourceFile.toConfigurationArray();
}
getGlobals() {
const globals = {};
for (const [ packageName, globalIdentifier ] of Object.entries(this._subglobals)) {
globals[packageName] = `${this._globalName}.${globalIdentifier}`;
}
return globals;
}
}