-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This became too difficult to manage on the command-line. What we're trying to do here is ship a version of the `Buffer` shim which plays well with IE9/IE10. Browserify ships with a version which does NOT play well, meaning we have to force it to use the version we choose (`[email protected]`). The fix is in two parts: 1. `insertGlobalVars` option replaces usages of global `Buffer` with `require('/path/to/mocha/node_modules/buffer').Buffer` 2. Any *other* module which explicitly requires `buffer` or, yes, `buffer/`, must *also* use `/path/to/mocha/node_modules/buffer` If *both* of these are not in place, Browserify will use its *own* version of the `buffer` shim.
- Loading branch information
Showing
5 changed files
with
123 additions
and
25 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,46 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
|
||
/** | ||
* Mocha's build script which is sadly too complex to manage from the command | ||
* line | ||
* @type {Browserify} | ||
*/ | ||
|
||
const browserify = require('browserify'); | ||
const path = require('path'); | ||
const dedefine = require('./dedefine'); | ||
const aliasify = require('aliasify'); | ||
|
||
const options = { | ||
basedir: path.join(__dirname, '..'), | ||
entries: ['./browser-entry.js'], | ||
insertGlobalVars: { | ||
Buffer (file, basedir) { | ||
const filepath = path.join(path.relative(path.dirname(file), basedir), | ||
'node_modules', | ||
'buffer'); | ||
return `require('${filepath}').Buffer`; | ||
} | ||
} | ||
}; | ||
|
||
const build = (b) => b.ignore('fs') | ||
.ignore('glob') | ||
.ignore('path') | ||
.ignore('supports-color') | ||
.transform(aliasify, { | ||
replacements: { | ||
'^buffer/?': () => require.resolve('buffer/index.js') | ||
}, | ||
global: true | ||
}) | ||
.plugin(dedefine); | ||
|
||
exports.build = build; | ||
exports.options = options; | ||
|
||
if (require.main === module) { | ||
build(browserify(options)).bundle() | ||
.pipe(process.stdout); | ||
} |