-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
41 lines (38 loc) · 1.35 KB
/
index.js
File metadata and controls
41 lines (38 loc) · 1.35 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
39
40
41
var map = require("./map.json");
var meteorAliases = {};
Object.keys(map).forEach(function (id) {
if (typeof map[id] === "string") {
var aliasParts = module.id.split("/");
aliasParts.pop();
aliasParts.push("node_modules", map[id]);
exports[id] = meteorAliases[id + ".js"] = meteorAliases["node:" + id] =
aliasParts.join("/");
} else {
exports[id] = map[id];
meteorAliases[id + ".js"] = meteorAliases["node:" + id] = function(){};
}
});
if (typeof meteorInstall === "function") {
meteorInstall({
// Install the aliases into a node_modules directory one level up from
// the root directory, so that they do not clutter the namespace
// available to apps and packages.
"..": {
node_modules: meteorAliases
}
});
}
// If Buffer is not defined globally, but the "buffer" built-in stub is
// installed and can be imported, use it to define global.Buffer so that
// modules like core-util-is/lib/util.js can refer to Buffer without
// crashing application startup.
if (typeof global.Buffer !== "function") {
try {
// Use (0, require)(...) to avoid registering a dependency on the
// "buffer" stub, in case it is not otherwise bundled.
global.Buffer = (0, require)("buffer").Buffer;
} catch (ok) {
// Failure to import "buffer" is fine as long as the Buffer global
// variable is not used.
}
}