Skip to content

Commit

Permalink
set package.json#browserify#transform as fallback option for deps tha…
Browse files Browse the repository at this point in the history
…t don't specify a given --transform-key
  • Loading branch information
serapath committed May 11, 2017
1 parent 91ed9c8 commit 50aac24
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions bin/advanced.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ Advanced Options:
Instead of the default package.json#browserify#transform field to list
all transforms to apply when running browserify, a custom field, like, e.g.
package.json#browserify#production or package.json#browserify#staging
can be used, by for example running:
can be used by running:
* `browserify index.js --transform-key=production > bundle.js`
* `browserify index.js --transform-key=staging > bundle.js`

if dependency doesn't specify the custom field, it falls back to
package.json#browserify#transform for that dependency

--node

Alias for --bare and --no-browser-field.
Expand Down Expand Up @@ -110,4 +113,3 @@ Passing arguments to transforms and plugins:
will call the `foo` transform for each applicable file by calling:

foo(file, { x: 3, beep: true })

3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,8 @@ Browserify.prototype._createDeps = function (opts) {
self._extensions = mopts.extensions;

mopts.transform = [];
mopts.transformKey = defined(opts.transformKey, [ 'browserify', 'transform' ]);
mopts.defaultTransformKey = [ 'browserify', 'transform' ];
mopts.transformKey = defined(opts.transformKey, mopts.defaultTransformKey);
mopts.postFilter = function (id, file, pkg) {
if (opts.postFilter && !opts.postFilter(id, file, pkg)) return false;
if (self._external.indexOf(file) >= 0) return false;
Expand Down
5 changes: 4 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,13 @@ Advanced Options:
Instead of the default package.json#browserify#transform field to list
all transforms to apply when running browserify, a custom field, like, e.g.
package.json#browserify#production or package.json#browserify#staging
can be used, by for example running:
can be used by running:
* `browserify index.js --transform-key=production > bundle.js`
* `browserify index.js --transform-key=staging > bundle.js`
if dependency doesn't specify the custom field, it falls back to
package.json#browserify#transform for that dependency
--node
Alias for --bare and --no-browser-field.
Expand Down

0 comments on commit 50aac24

Please sign in to comment.