-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix exposed requires being persisted across bundles
- Loading branch information
1 parent
ad4b65b
commit bf4ea7a
Showing
4 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var browserify = require('../'); | ||
var test = require('tap').test; | ||
var vm = require('vm'); | ||
|
||
test('exposed modules do not leak across bundles', function (t) { | ||
var bundle1, bundle2; | ||
|
||
bundle1 = browserify(); | ||
bundle1.add(__dirname + '/require_expose/main.js'); | ||
bundle1.require(__dirname + '/require_expose/some_dep.js', { expose: 'foo' }); | ||
|
||
bundle1.bundle(function (err, src) { | ||
if (err) t.fail(err); | ||
|
||
var c = {}; | ||
vm.runInNewContext(src, c); | ||
t.equal(c.foo, 'some_dep'); | ||
|
||
bundle2 = browserify(); | ||
bundle2.add(__dirname + '/require_expose/main.js'); | ||
|
||
bundle2.bundle(function (err) { | ||
t.ok(err && err.message.match(/Cannot find module 'foo'/), 'should fail with missing module'); | ||
t.end(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo = require('foo'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = 'some_dep'; |