Install Meteor packages into virtual node_modules/meteor/ directory.

Previously Meteor packages were installed at /node_modules/<package-name>.
This commit wraps them in an additional directory called "meteor", which
prevents their names from colliding with other installed npm package
names, and also means Meteor package identifiers must now include the
"meteor/" prefix:

  import Blaze from "meteor/blaze"

This change will eventually enable Meteor packages to import npm packages
installed in top-level node_modules directories of apps. That won't work
just yet, though, because the app bundler doesn't yet know anything about
external dependencies imported by packages.
This commit is contained in:
Ben Newman
2015-12-18 20:22:01 -05:00
parent fb89e46c8c
commit 0a6324013a
2 changed files with 7 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
import {AccountsTest} from "accounts-base";
import {AccountsTest} from "meteor/accounts-base";
Tinytest.add("accounts - parse urls for accounts-password",
function (test) {

View File

@@ -203,10 +203,7 @@ export default class ImportScanner {
if (this.name) {
// If we're bundling a package, prefix path with
// node_modules/<package name>/.
path = pathJoin("node_modules", this.name, path);
} else {
// If we're bundling an app, prefix path with app/.
path = pathJoin("app", path);
path = pathJoin("node_modules", "meteor", this.name, path);
}
return path;
@@ -372,9 +369,10 @@ export default class ImportScanner {
}
_getMeteorPackageNameFromId(id) {
const possiblePackageName = id.split("/", 1)[0];
if (has(this.usedPackageNames, possiblePackageName)) {
return possiblePackageName;
const [meteor, packageName] = id.split("/", 2);
if (meteor === "meteor" &&
has(this.usedPackageNames, packageName)) {
return packageName;
}
}
@@ -436,7 +434,7 @@ export default class ImportScanner {
// directories, npm never takes advantage of this possibility, which
// conveniently allows Meteor to install files there without conflict.
_addMeteorPackageStubToOutput(packageName) {
const relPkgPath = pathJoin("node_modules", packageName + ".js");
const relPkgPath = pathJoin("node_modules", "meteor", packageName + ".js");
const absPkgPath = pathJoin(this.sourceRoot, relPkgPath);
// Note that this absPkgPath need not actually exist on disk!