Files
meteor/packages/modules/install-packages.js
Ben Newman b3a83bd118 Install reliable stubs for all Package[name] objects.
If a Meteor package had a file called index.js, the runtime module system
would resolve "meteor/<name>" to "/node_modules/meteor/<name>/index.js",
instead of falling back to Package[<name>] as expected.

Installing a stub for Package[<name>] at /node_modules/meteor/<name>.js
means the runtime module system no longer needs the fallback, and will no
longer be confused by index.js files.

Fixes #6590.
2016-04-07 13:05:52 -04:00

23 lines
725 B
JavaScript

function install(name) {
var meteorDir = {};
// Given a package name <name>, install a stub module in the
// /node_modules/meteor directory called <name>.js, so that
// require.resolve("meteor/<name>") will always return
// /node_modules/meteor/<name>.js instead of something like
// /node_modules/meteor/<name>/index.js, in the rare but possible event
// that the package contains a file called index.js (#6590).
meteorDir[name + ".js"] = function (r, e, module) {
module.exports = Package[name];
};
meteorInstall({
node_modules: {
meteor: meteorDir
}
});
}
// This file will be modified during computeJsOutputFilesMap to include
// install(<name>) calls for every Meteor package.