mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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.
27 lines
718 B
JavaScript
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
|
|
}
|
|
});
|
|
}
|