Skip to content

Commit

Permalink
Refactor browserify system
Browse files Browse the repository at this point in the history
Instead of opting to replace when compiling to the distribution
files, this refactoring uses the `package.json`s `browser`
field. This ensures other tools adhering to that `browser`
field work.

Related to GH-1.
  • Loading branch information
wooorm committed Oct 23, 2015
1 parent 5b0a281 commit c95686d
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 4 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"vfile": "^1.0.0",
"ware": "^1.3.0"
},
"browser": {
"node-extend": "extend"
},
"repository": {
"type": "git",
"url": "https://github.com/wooorm/unified.git"
Expand Down Expand Up @@ -56,7 +59,7 @@
"lint": "npm run lint-api && npm run lint-style",
"make": "npm run lint && npm run test-coverage",
"build-md": "mdast . --quiet",
"build-bundle": "browserify index.js -s AttachWare -u node-extend > unified.js",
"build-bundle": "browserify index.js -s AttachWare > unified.js",
"postbuild-bundle": "esmangle unified.js > unified.min.js",
"build": "npm run build-md && npm run build-bundle"
}
Expand Down
53 changes: 51 additions & 2 deletions unified.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ function unified(options) {

module.exports = unified;

},{"attach-ware":2,"bail":3,"extend":8,"node-extend":undefined,"unherit":12,"vfile":13,"ware":14}],2:[function(require,module,exports){
},{"attach-ware":2,"bail":3,"extend":8,"node-extend":8,"unherit":12,"vfile":13,"ware":14}],2:[function(require,module,exports){
/**
* @author Titus Wormer
* @copyright 2015 Titus Wormer
Expand Down Expand Up @@ -2983,6 +2983,55 @@ try {
SEPARATOR = require('pa' + 'th').sep;
} catch (e) { /* empty */ }

/**
* Construct a new file message.
*
* Note: We cannot invoke `Error` on the created context,
* as that adds readonly `line` and `column` attributes on
* Safari 9, thus throwing and failing the data.
*
* @example
* var message = new VFileMessage('Whoops!');
*
* message instanceof Error // true
*
* @constructor
* @class {VFileMessage}
* @param {string} reason - Reason for messaging.
* @property {boolean} [fatal=null] - Whether the message
* is fatal.
* @property {string} [name=''] - File-name and positional
* information.
* @property {string} [file=''] - File-path.
* @property {string} [reason=''] - Reason for messaging.
* @property {number} [line=null] - Start of message.
* @property {number} [column=null] - Start of message.
* @property {Position|Location} [location=null] - Place of
* message.
* @property {string} [stack] - Stack-trace of warning.
*/
function VFileMessage(reason) {
this.message = reason;
}

/**
* Inherit from `Error#`.
*/
function VFileMessagePrototype() {}

VFileMessagePrototype.prototype = Error.prototype;

var proto = new VFileMessagePrototype();

VFileMessage.prototype = proto;

/*
* Expose defaults.
*/

proto.file = proto.name = proto.reason = proto.message = proto.stack = '';
proto.fatal = proto.column = proto.line = null;

/**
* File-related message with location information.
*
Expand Down Expand Up @@ -3310,7 +3359,7 @@ function message(reason, position) {
}
}

err = new Error(reason.message || reason);
err = new VFileMessage(reason.message || reason);

err.name = (filePath ? filePath + ':' : '') + range;
err.file = filePath;
Expand Down

0 comments on commit c95686d

Please sign in to comment.