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

specifying browserify options (plugins, extensions) #359

Open
goto-bus-stop opened this issue Dec 27, 2017 · 6 comments
Open

specifying browserify options (plugins, extensions) #359

goto-bus-stop opened this issue Dec 27, 2017 · 6 comments

Comments

@goto-bus-stop
Copy link
Member

goto-bus-stop commented Dec 27, 2017

ref #285, #262

currently you can only specify browserify transforms using the browserify.transform key in package.json. altlangs like typescript and coffeescript use custom (non-.js) extensions though which cannot be configured in package.json.

@yoshuawuyts & i chatted about this recently--adding some custom logic to bankai that reads additional configuration from the application's package.json only (not from package.json in dependencies) could be a nice option:

// for typescript
{
  "browserify": {
    "plugin": [ "tsify" ]
  }
}
// for coffeescript
{
  "browserify": {
    "extensions": [ ".coffee" ],
    "transform": [ "coffeeify" ]
  }
}

this still leaves out plugins that need things like functions in their options, but you could work around that by wrapping it in a small plugin like so:

// package.json
{
  "browserify": {
    "plugin": [ "./browserifyConfig" ]
  }
}
// browserifyConfig.js
module.exports = function (b) {
  b.plugin('some-plugin', { option: function () {} })
}

anyone have more thoughts on this?

@s3ththompson
Copy link
Member

Just ran into this issue as well! Custom logic seems a bit hacky--is there any chance @substack would accept an upstream PR to add something like this to browserify core?

Alternately, perhaps we could carve out a typescript-specific solution? I feel like now that Choo has typescript support it would be great if Bankai supported it out-of-the-box too!

@s3ththompson
Copy link
Member

From irc:

<s3ththompson>: goto-bus-stop: just ran into bankai #359 (supporting typescript plugin in browserify) and saw you opened an issue! is there any chance upstream browserify would accept a PR to start reading a plugin config key in package.json?
<substack>: s3ththompson: package.json is for transforms only, because you might have a dependency with a package.json transform configured
plugins aren't so clean as that

@goto-bus-stop
Copy link
Member Author

goto-bus-stop commented Dec 31, 2017 via email

@yoshuawuyts
Copy link
Member

Alternately, perhaps we could carve out a typescript-specific solution? I feel like now that Choo has typescript support it would be great if Bankai supported it out-of-the-box too!

I wonder what this would look like; perhaps a separate issue might be cool for this? I'm open to the idea, especially because so far it seems to be the only direct use case we have for a plugin!

@goto-bus-stop
Copy link
Member Author

goto-bus-stop commented Jan 4, 2018

adding support for a module-scoped browserify.extensions key inside browserify upstream, like described in browserify/browserify#809, would address the coffeescript case. if we do that + support typescript out of the box we would've addressed probably 99% of use cases for this issue

@yoshuawuyts
Copy link
Member

@goto-bus-stop yeah, that seems reasonable!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants