1 | var map = require("./map.json");
|
2 | var meteorAliases = {};
|
3 |
|
4 | Object.keys(map).forEach(function (id) {
|
5 | if (typeof map[id] === "string") {
|
6 | var aliasParts = module.id.split("/");
|
7 | aliasParts.pop();
|
8 | aliasParts.push("node_modules", map[id]);
|
9 | exports[id] = meteorAliases[id + ".js"] = meteorAliases["node:" + id] =
|
10 | aliasParts.join("/");
|
11 | } else {
|
12 | exports[id] = map[id];
|
13 | meteorAliases[id + ".js"] = meteorAliases["node:" + id] = function(){};
|
14 | }
|
15 | });
|
16 |
|
17 | if (typeof meteorInstall === "function") {
|
18 | meteorInstall({
|
19 | // Install the aliases into a node_modules directory one level up from
|
20 | // the root directory, so that they do not clutter the namespace
|
21 | // available to apps and packages.
|
22 | "..": {
|
23 | node_modules: meteorAliases
|
24 | }
|
25 | });
|
26 | }
|
27 |
|
28 | // If Buffer is not defined globally, but the "buffer" built-in stub is
|
29 | // installed and can be imported, use it to define global.Buffer so that
|
30 | // modules like core-util-is/lib/util.js can refer to Buffer without
|
31 | // crashing application startup.
|
32 | if (typeof global.Buffer !== "function") {
|
33 | try {
|
34 | // Use (0, require)(...) to avoid registering a dependency on the
|
35 | // "buffer" stub, in case it is not otherwise bundled.
|
36 | global.Buffer = (0, require)("buffer").Buffer;
|
37 | } catch (ok) {
|
38 | // Failure to import "buffer" is fine as long as the Buffer global
|
39 | // variable is not used.
|
40 | }
|
41 | }
|