Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: set package.json#browserify#transform as fallback option when using --transform-key #1721

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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