Wrap Module.prototype.require instead of using options.wrapRequire.

a630b5c2ac
7a9abeca88
This commit is contained in:
Ben Newman
2018-06-25 16:34:42 -04:00
parent 9f06a6f6c5
commit 24865b28a0
6 changed files with 31 additions and 31 deletions

View File

@@ -2,9 +2,9 @@
"lockfileVersion": 1,
"dependencies": {
"install": {
"version": "0.11.1",
"resolved": "https://registry.npmjs.org/install/-/install-0.11.1.tgz",
"integrity": "sha512-T562YLqjg/ixCFIcqxjFy2dWkulV5o6gDkKTUbUZU4O/JlrzpDMWqR8sR1BPVeb+SAXoQ6scv09MxY2XOzknQQ=="
"version": "0.12.0",
"resolved": "https://registry.npmjs.org/install/-/install-0.12.0.tgz",
"integrity": "sha512-KOKFSWPANzP4XIbBnaRqIiMaCZmPxJEE0HbRrZ8MEt5Z9g4TdXA3LRAHBhb6UH7d8Ig9aSWwrD0Dy2Y3rPKs9w=="
}
}
}

View File

@@ -1,17 +1,17 @@
// On the client, make package resolution prefer the "browser" field of
// package.json files to the "main" field.
makeInstallerOptions.browser = true;
meteorInstall = makeInstaller({
// On the client, make package resolution prefer the "browser" field of
// package.json files to the "main" field.
browser: true,
makeInstallerOptions.fallback = function (id, parentId, error) {
if (id && id.startsWith('meteor/')) {
var packageName = id.split('/', 2)[1];
throw new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
fallback: function(id, parentId, error) {
if (id && id.startsWith('meteor/')) {
var packageName = id.split('/', 2)[1];
throw new Error(
'Cannot find package "' + packageName + '". ' +
'Try "meteor add ' + packageName + '".'
);
}
throw error;
}
throw error;
};
meteorInstall = makeInstaller(makeInstallerOptions);
});

View File

@@ -1,10 +0,0 @@
makeInstallerOptions = {};
if (typeof Profile === "function" &&
process.env.METEOR_PROFILE) {
makeInstallerOptions.wrapRequire = function (require) {
return Profile(function (id) {
return "require(" + JSON.stringify(id) + ")";
}, require);
};
}

View File

@@ -1,13 +1,13 @@
Package.describe({
name: "modules-runtime",
version: "0.10.1",
version: "0.10.2",
summary: "CommonJS module system",
git: "https://github.com/benjamn/install",
documentation: "README.md"
});
Npm.depends({
install: "0.11.1"
install: "0.12.0"
});
Package.onUse(function(api) {
@@ -18,9 +18,9 @@ Package.onUse(function(api) {
bare: true
});
api.addFiles("options.js");
api.addFiles("client.js", "client");
api.addFiles("server.js", "server");
api.addFiles("profile.js");
api.export("meteorInstall");
});

View File

@@ -0,0 +1,7 @@
if (typeof Profile === "function" &&
process.env.METEOR_PROFILE) {
var Mp = meteorInstall.Module.prototype;
Mp.require = Profile(function (id) {
return "require(" + JSON.stringify(id) + ")";
}, Mp.require);
}

View File

@@ -1,3 +1,6 @@
// Options that will be populated below and then passed to makeInstaller.
var makeInstallerOptions = {};
// RegExp matching strings that don't start with a `.` or a `/`.
var topLevelIdPattern = /^[^./]/;