zertosh / errorify Goto Github PK
View Code? Open in Web Editor NEWBrowserify plugin to write failed build error messages to the output file
Browserify plugin to write failed build error messages to the output file
errorify
works with [email protected]. Using watchify 3.5-3.7, when there is an error, nothing happens at all. No bundle file is created, or if the file already exists, nothing is written to it.
I like the idea of this and would be interested in bringing it into my workflow, but I find Beefy's DOM-based error reporting (using <pre>
) to be a bit cleaner and less jarring/disruptive than a modal alert()
.
There's also more potential for colors, err.stack
, etc rather than just a string message.
Are you open to this? Or would you rather it be in another module?
A simple template ends up looking like this: (mostly from Beefy)
function(error) {
console.error(error)
var doc = typeof document === 'undefined' ? null : document
if (!doc)
return
if(!doc.body) {
return doc.addEventListener('DOMContentLoaded', function() {
output()
})
} else
output()
function output() {
var pre = doc.createElement('pre')
pre.textContent = error
if (doc.body.children.length)
doc.body.insertBefore(pre, doc.body.children[0])
else
doc.body.appendChild(pre)
}
}
Is it possible to emit/catch an error event or something so I can attach a custom callback function to execute in addition to the default console.error
(for example trigger a system beep)?
This is my code:
let b = browserify(file, {
debug: true,
cache: {},
packageCache: {}
});
let bundle = () => b.bundle().pipe(fs.createWriteStream(outFile));
b.transform('babelify', {sourceMapsAbsolute: true})
.transform('brfs')
.plugin('minifyify', {
map: `${path.basename(outFile)}.map`,
output: `${outFile}.map`
});
bundle();
b.plugin(errorify)
.plugin(watchify, {poll: true})
.on('update', bundle)
.on('log', (msg) => console.log('Bundle %s created. %s', file, msg));
I've tried attaching to .on('error')
but it does not get triggered.
The error is no longer so pretty with babelify@6
I can submit a PR that looks something like this:
var message;
if (err.codeFrame) { //[email protected]
message = [err.message, err.codeFrame].join('\n\n');
} else { //[email protected] and browserify
message = err.annotated || err.message;
}
//normalize error properties
err = {
message: message,
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.