-
-
Save Volune/5236967 to your computer and use it in GitHub Desktop.
Try to reproduce browserify/browserify#338, sometime fails because the bug is dependent of results order of asynchronous calls
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
var common = require('./common'); | |
common.log('A'); |
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
module.exports.log = require('./logger').log; |
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
module.exports.log = function() { | |
if (typeof console != 'undefined') { | |
console.log.apply(console, arguments); | |
} | |
if (typeof document != 'undefined') { | |
var index; | |
for (index = 0; index < arguments.length; ++index) { | |
document.write(arguments[index] + ''); | |
} | |
} | |
}; |
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
{ | |
"name": "test_br2_bug", | |
"version": "0.1.0", | |
"dependencies": { | |
"express": "3.0.x", | |
"browserify": "2.7.1" | |
} | |
} |
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
var path = require('path'); | |
var browserify = require('browserify'); | |
var express = require('express'); | |
var brA = browserify(path.resolve(__dirname, 'a.js')); | |
brA.require(path.resolve(__dirname, 'common.js'), {expose: true}); | |
var app = express(); | |
app.all('/a.js', function (req, res) { | |
brA.bundle({}, function sendBundleResult(err, src) { | |
if (err) | |
res.send(500, err); | |
else { | |
res.statusCode = 200; | |
res.setHeader('Content-Type', 'application/javascript'); | |
res.end(src); | |
} | |
}); | |
}); | |
app.use(express.static(__dirname)); | |
var port = 8088; | |
app.listen(port, function () { | |
console.info("Serving http://localhost:%d/test.html", port); | |
}); |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="application/javascript" src="a.js"></script> | |
</head> | |
<body></body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment