| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,15 +4,15 @@ Advanced Options: | |||
| 4 | 4 | ||
| 5 | 5 | Skip detection and always insert definitions for process, global, | |
| 6 | 6 | __filename, and __dirname. | |
| 7 | - | ||
| 7 | + | ||
| 8 | 8 | benefit: faster builds | |
| 9 | 9 | cost: extra bytes | |
| 10 | - | ||
| 10 | + | ||
| 11 | 11 | --insert-global-vars, --igv | |
| 12 | 12 | ||
| 13 | 13 | Comma-separated list of global variables to detect and define. | |
| 14 | 14 | Default: __filename,__dirname,process,Buffer,global | |
| 15 | - | ||
| 15 | + | ||
| 16 | 16 | --detect-globals, --dg [default: true] | |
| 17 | 17 | ||
| 18 | 18 | Detect the presence of process, global, __filename, and __dirname and define | |
@@ -36,16 +36,16 @@ Advanced Options: | |||
| 36 | 36 | provides the core builtins. | |
| 37 | 37 | ||
| 38 | 38 | --no-commondir | |
| 39 | - | ||
| 39 | + | ||
| 40 | 40 | Turn off setting a commondir. This is useful if you want to preserve the | |
| 41 | - original paths that a bundle was generated with. | ||
| 42 | - | ||
| 41 | + original paths that a bundle was generated with. | ||
| 42 | + | ||
| 43 | 43 | --no-bundle-external | |
| 44 | 44 | ||
| 45 | 45 | Turn off bundling of all external modules. This is useful if you only want | |
| 46 | 46 | to bundle your local files. | |
| 47 | 47 | ||
| 48 | - --bare | ||
| 48 | + --bare | ||
| 49 | 49 | ||
| 50 | 50 | Alias for both --no-builtins, --no-commondir, and sets --insert-global-vars | |
| 51 | 51 | to just "__filename,__dirname". This is handy if you want to run bundles in | |
@@ -56,6 +56,15 @@ Advanced Options: | |||
| 56 | 56 | Turn off package.json browser field resolution. This is also handy if you | |
| 57 | 57 | need to run a bundle in node. | |
| 58 | 58 | ||
| 59 | + --transform-key | ||
| 60 | + | ||
| 61 | + Instead of the default package.json#browserify#transform field to list | ||
| 62 | + all transforms to apply when running browserify, a custom field, like, e.g. | ||
| 63 | + package.json#browserify#production or package.json#browserify#staging | ||
| 64 | + can be used, by for example running: | ||
| 65 | + * `browserify index.js --transform-key=production > bundle.js` | ||
| 66 | + * `browserify index.js --transform-key=staging > bundle.js` | ||
| 67 | + | ||
| 59 | 68 | --node | |
| 60 | 69 | ||
| 61 | 70 | Alias for --bare and --no-browser-field. | |
@@ -66,7 +75,7 @@ Advanced Options: | |||
| 66 | 75 | preserving the original paths that a bundle was generated with. | |
| 67 | 76 | ||
| 68 | 77 | --deps | |
| 69 | - | ||
| 78 | + | ||
| 70 | 79 | Instead of standard bundle output, print the dependency array generated by | |
| 71 | 80 | module-deps. | |
| 72 | 81 | ||
@@ -75,7 +84,7 @@ Advanced Options: | |||
| 75 | 84 | Turn off deduping. | |
| 76 | 85 | ||
| 77 | 86 | --list | |
| 78 | - | ||
| 87 | + | ||
| 79 | 88 | Print each file in the dependency graph. Useful for makefiles. | |
| 80 | 89 | ||
| 81 | 90 | --extension=EXTENSION | |
@@ -101,4 +110,3 @@ Passing arguments to transforms and plugins: | |||
| 101 | 110 | will call the `foo` transform for each applicable file by calling: | |
| 102 | 111 | ||
| 103 | 112 | foo(file, { x: 3, beep: true }) | |
| 104 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -51,7 +51,7 @@ module.exports = function (args, opts) { | |||
| 51 | 51 | node: false | |
| 52 | 52 | } | |
| 53 | 53 | }); | |
| 54 | - | ||
| 54 | + | ||
| 55 | 55 | var entries = argv._.concat(argv.entry) | |
| 56 | 56 | .filter(Boolean).map(function (entry) { | |
| 57 | 57 | if (entry === '-') { | |
@@ -64,7 +64,7 @@ module.exports = function (args, opts) { | |||
| 64 | 64 | } | |
| 65 | 65 | return entry; | |
| 66 | 66 | }); | |
| 67 | - | ||
| 67 | + | ||
| 68 | 68 | if (argv.node) { | |
| 69 | 69 | argv.bare = true; | |
| 70 | 70 | argv.browserField = false; | |
@@ -76,7 +76,7 @@ module.exports = function (args, opts) { | |||
| 76 | 76 | argv.igv = '__filename,__dirname'; | |
| 77 | 77 | } | |
| 78 | 78 | } | |
| 79 | - | ||
| 79 | + | ||
| 80 | 80 | if (argv.igv) { | |
| 81 | 81 | var insertGlobalVars = {}; | |
| 82 | 82 | var wantedGlobalVars = argv.igv.split(','); | |
@@ -86,12 +86,12 @@ module.exports = function (args, opts) { | |||
| 86 | 86 | } | |
| 87 | 87 | }); | |
| 88 | 88 | } | |
| 89 | - | ||
| 89 | + | ||
| 90 | 90 | var ignoreTransform = argv['ignore-transform'] || argv.it; | |
| 91 | 91 | var b = browserify(xtend({ | |
| 92 | 92 | noParse: Array.isArray(argv.noParse) ? argv.noParse : [argv.noParse], | |
| 93 | 93 | extensions: [].concat(argv.extension).filter(Boolean).map(function (extension) { | |
| 94 | - if (extension.charAt(0) != '.') { | ||
| 94 | + if (extension.charAt(0) != '.') { | ||
| 95 | 95 | return '.' + extension; | |
| 96 | 96 | } else { | |
| 97 | 97 | return extension | |
@@ -105,6 +105,7 @@ module.exports = function (args, opts) { | |||
| 105 | 105 | bundleExternal: argv['bundle-external'], | |
| 106 | 106 | basedir: argv.basedir, | |
| 107 | 107 | browserField: argv.browserField, | |
| 108 | + transformKey: argv['transform-key'] ? ['browserify', argv['transform-key']] : undefined, | ||
| 108 | 109 | dedupe: argv['dedupe'], | |
| 109 | 110 | ||
| 110 | 111 | detectGlobals: argv.detectGlobals, | |
@@ -128,7 +129,7 @@ module.exports = function (args, opts) { | |||
| 128 | 129 | b.plugin(pf, pOpts); | |
| 129 | 130 | }) | |
| 130 | 131 | ; | |
| 131 | - | ||
| 132 | + | ||
| 132 | 133 | [].concat(argv.ignore).filter(Boolean) | |
| 133 | 134 | .forEach(function (i) { | |
| 134 | 135 | b._pending ++; | |
@@ -144,11 +145,11 @@ module.exports = function (args, opts) { | |||
| 144 | 145 | }); | |
| 145 | 146 | }) | |
| 146 | 147 | ; | |
| 147 | - | ||
| 148 | + | ||
| 148 | 149 | [].concat(argv.exclude).filter(Boolean) | |
| 149 | 150 | .forEach(function (u) { | |
| 150 | 151 | b.exclude(u); | |
| 151 | - | ||
| 152 | + | ||
| 152 | 153 | b._pending ++; | |
| 153 | 154 | glob(u, function (err, files) { | |
| 154 | 155 | if (err) return b.emit('error', err); | |
@@ -164,7 +165,7 @@ module.exports = function (args, opts) { | |||
| 164 | 165 | b.require(xs[0], { expose: xs.length === 1 ? xs[0] : xs[1] }) | |
| 165 | 166 | }) | |
| 166 | 167 | ; | |
| 167 | - | ||
| 168 | + | ||
| 168 | 169 | // resolve any external files and add them to the bundle as externals | |
| 169 | 170 | [].concat(argv.external).filter(Boolean) | |
| 170 | 171 | .forEach(function (x) { | |
@@ -181,26 +182,26 @@ module.exports = function (args, opts) { | |||
| 181 | 182 | }); | |
| 182 | 183 | } | |
| 183 | 184 | else add(x, {}); | |
| 184 | - | ||
| 185 | + | ||
| 185 | 186 | function add (x, opts) { | |
| 186 | 187 | if (/^[\/.]/.test(x)) b.external(path.resolve(x), opts) | |
| 187 | 188 | else b.external(x, opts) | |
| 188 | 189 | } | |
| 189 | 190 | }) | |
| 190 | 191 | ; | |
| 191 | - | ||
| 192 | + | ||
| 192 | 193 | [].concat(argv.transform) | |
| 193 | 194 | .filter(Boolean) | |
| 194 | 195 | .forEach(function (t) { addTransform(t) }) | |
| 195 | 196 | ; | |
| 196 | - | ||
| 197 | + | ||
| 197 | 198 | [].concat(argv.g).concat(argv['global-transform']) | |
| 198 | 199 | .filter(Boolean) | |
| 199 | 200 | .forEach(function (t) { | |
| 200 | 201 | addTransform(t, { global: true }); | |
| 201 | 202 | }) | |
| 202 | 203 | ; | |
| 203 | - | ||
| 204 | + | ||
| 204 | 205 | function addTransform (t, opts) { | |
| 205 | 206 | if (typeof t === 'string' || typeof t === 'function') { | |
| 206 | 207 | b.transform(opts, t); | |
@@ -218,7 +219,7 @@ module.exports = function (args, opts) { | |||
| 218 | 219 | } | |
| 219 | 220 | else error('unexpected transform of type ' + typeof t); | |
| 220 | 221 | } | |
| 221 | - | ||
| 222 | + | ||
| 222 | 223 | [].concat(argv.command).filter(Boolean) | |
| 223 | 224 | .forEach(function (c) { | |
| 224 | 225 | var cmd = parseShell(c); | |
@@ -231,7 +232,7 @@ module.exports = function (args, opts) { | |||
| 231 | 232 | var ps = spawn(cmd[0], cmd.slice(1), { env: env }); | |
| 232 | 233 | var error = ''; | |
| 233 | 234 | ps.stderr.on('data', function (buf) { error += buf }); | |
| 234 | - | ||
| 235 | + | ||
| 235 | 236 | ps.on('exit', function (code) { | |
| 236 | 237 | if (code === 0) return; | |
| 237 | 238 | console.error([ | |
@@ -245,12 +246,12 @@ module.exports = function (args, opts) { | |||
| 245 | 246 | }); | |
| 246 | 247 | }) | |
| 247 | 248 | ; | |
| 248 | - | ||
| 249 | + | ||
| 249 | 250 | if (argv.standalone === '') { | |
| 250 | 251 | error('--standalone requires an export name argument'); | |
| 251 | 252 | return b; | |
| 252 | 253 | } | |
| 253 | - | ||
| 254 | + | ||
| 254 | 255 | return b; | |
| 255 | 256 | }; | |
| 256 | 257 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -164,6 +164,15 @@ Advanced Options: | |||
| 164 | 164 | Turn off package.json browser field resolution. This is also handy if you | |
| 165 | 165 | need to run a bundle in node. | |
| 166 | 166 | ||
| 167 | + --transform-key | ||
| 168 | + | ||
| 169 | + Instead of the default package.json#browserify#transform field to list | ||
| 170 | + all transforms to apply when running browserify, a custom field, like, e.g. | ||
| 171 | + package.json#browserify#production or package.json#browserify#staging | ||
| 172 | + can be used, by for example running: | ||
| 173 | + * `browserify index.js --transform-key=production > bundle.js` | ||
| 174 | + * `browserify index.js --transform-key=staging > bundle.js` | ||
| 175 | + | ||
| 167 | 176 | --node | |
| 168 | 177 | ||
| 169 | 178 | Alias for --bare and --no-browser-field. | |
| Back | FazBrowse Home | New Git URL |
0 commit comments