Permalink
Browse files

Fix missing baseDir bug.

- In Node.js >= 0.10, this would cause errors of the form "TypeError: Arguments to path.resolve must be strings".
- Also, the baseDir was not being passed through to the alias processing.
  • Loading branch information...
1 parent caa948a commit 9265ab9b9556c09573a4921a4fe3e79a04ff6f34 Domenic Denicola committed May 20, 2013
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/browserify-deoptimizer.js
@@ -69,7 +69,7 @@ function addPrelude(bundle, result) {
bundle.reload();
}
-function addAliases(bundle, result) {
+function addAliases(bundle, result, baseDir) {
if (Object.keys(bundle.aliases).length === 0) {
return;
}
@@ -79,7 +79,7 @@ function addAliases(bundle, result) {
// Add files and entries for this temp bundle: this gets the un-aliased files to be included. I.e. if we alias
// jquery-browserify to jquery, this puts jquery-browserify in the result.
- addFilesAndEntries(tempBundle, result);
+ addFilesAndEntries(tempBundle, result, baseDir);
// Now we're going to generate the browserify-aliases.js file. To do this, remove all actual files and the prelude:
// we just want the `require.alias` calls.
@@ -104,13 +104,17 @@ function addEntryRequirer(bundle, result, baseDir) {
}
module.exports = function (bundle, baseDir) {
+ if (baseDir === undefined) {
+ baseDir = process.cwd();
+ }
+
var result = Object.create(null);
// The multi-file nature necessitates forcing all exports, otherwise subsequent files don't know what `require` is.
bundle.exports = true;
addPrelude(bundle, result);
- addAliases(bundle, result);
+ addAliases(bundle, result, baseDir);
addFilesAndEntries(bundle, result, baseDir);
addEntryRequirer(bundle, result, baseDir);

0 comments on commit 9265ab9

Please sign in to comment.