Skip to content

Commit

Permalink
expose property doesn't work with fullPaths enabled (fixes browserify…
Browse files Browse the repository at this point in the history
  • Loading branch information
mwiencek committed Nov 13, 2014
1 parent 691efa3 commit f947308
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Expand Up @@ -597,6 +597,11 @@ Browserify.prototype._label = function (opts) {
if (row.indexDeps) row.deps = row.indexDeps || {};

Object.keys(row.deps).forEach(function (key) {
if (self._expose[key]) {
row.deps[key] = key;
return;
}

var afile = path.resolve(path.dirname(row.file), key);
var rfile = '/' + path.relative(basedir, afile);
if (self._external.indexOf(rfile) >= 0) {
Expand Down
1 change: 1 addition & 0 deletions test/entry/needs_three.js
@@ -0,0 +1 @@
require("three");
5 changes: 5 additions & 0 deletions test/entry/package.json
@@ -0,0 +1,5 @@
{
"browser": {
"three": "./three.js"
}
}
1 change: 1 addition & 0 deletions test/entry/three.js
@@ -0,0 +1 @@
module.exports = 3;
18 changes: 18 additions & 0 deletions test/full_paths.js
@@ -1,6 +1,7 @@
var unpack = require('browser-unpack');
var browserify = require('../');
var test = require('tap').test;
var vm = require('vm');

var deps = [
__dirname + '/entry/main.js',
Expand Down Expand Up @@ -37,3 +38,20 @@ test('fullPaths disabled', function (t) {
});
});
});

test('fullPaths enabled, with custom exposed dependency name', function (t) {
t.plan(1);

var b = browserify({
entries: [__dirname + '/entry/needs_three.js'],
fullPaths: true
});

b.require(__dirname + '/entry/three.js', { expose: 'three' });

b.bundle(function (err, src) {
t.doesNotThrow(function () {
vm.runInNewContext(src, { console: console, t: t });
});
});
});

0 comments on commit f947308

Please sign in to comment.