mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
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.
This commit is contained in:
12
index.js
12
index.js
@@ -3,13 +3,11 @@ var meteorAliases = {};
|
||||
|
||||
Object.keys(map).forEach(function (id) {
|
||||
if (typeof map[id] === "string") {
|
||||
try {
|
||||
exports[id] = meteorAliases[id + ".js"] =
|
||||
require.resolve(map[id]);
|
||||
} catch (e) {
|
||||
// Resolution can fail at runtime if the stub was not included in the
|
||||
// bundle because nothing depended on it.
|
||||
}
|
||||
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(){};
|
||||
|
||||
Reference in New Issue
Block a user