Files
meteor/index.js
Ben Newman e22136d56d Avoid calling require.resolve at runtime.
In an environment that supports dynamic asynchronous module fetching,
require.resolve will fail during application startup but might succeed
later, so it's safer to use a known identifier string alias.
2017-01-26 17:54:02 -05:00

27 lines
718 B
JavaScript

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"] =
aliasParts.join("/");
} else {
exports[id] = map[id];
meteorAliases[id + ".js"] = 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
}
});
}