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

package.json browserify.transform dedendencies responsibility #1850

Closed
cancerberoSgx opened this issue Jun 29, 2018 · 3 comments
Closed

package.json browserify.transform dedendencies responsibility #1850

cancerberoSgx opened this issue Jun 29, 2018 · 3 comments

Comments

@cancerberoSgx
Copy link

cancerberoSgx commented Jun 29, 2018

This is more a question, but I'm seeing the following problem in some packages using package.json browserify.transform property as described here and want to be sure before start reporting issues. Suppose I'm developing package "a" that depends on package "b" and "b" declares the following in its package.json:

  "browserify": {
    "transform": [
      ["babelify" ]
    ]
  },

Fact: when I execute browserify on package "a" "babelify" is executed on package "b".
Question: is that the expected behavior? If so,

Question: who is responsible of providing dependencies so that transformation works? My guess is "b". And if so,

Question: , that implies that "b" must install those dependencies as "dependencies" (not "devDependencies" since they need to be present when "b" is used as a dependency, right ? (and also configuration files required by the transform to work (such as .babelrc.js) should be included in the npm package ?)

Thanks in advanced.

@goto-bus-stop
Copy link
Member

"b" should depend directly on all the transforms it uses in the transform key.

The transform key is intended for things that have to be done to a package at bundle time. However Babel should be run before publish 99% of the time. Chances are that a package that specifies babelify in the transform key means to configure babel in their own build process, to generate a UMD bundle or something, not in the build process of the consumer. So, ideally package "b" would not have that transform key at all and instead use the browserify command line flags or the Node API to generate its UMD bundle, and ship compiled ES5 code in the npm package.

Hope that makes sense!

@cancerberoSgx
Copy link
Author

Yes that's what I though, just wanted to be sure because this package.json thingy is new to me although I'm working with browserify for a long time. The example in the docs using brfs makes sense, but babelify as you say doesn't and is probably as you say - just removing he property will solve the problem.

Would a PR adding a paragraph here regarding this be accepted ?

Thank you very much

@cancerberoSgx
Copy link
Author

Look here there seems to be another example, and this is serious because is the recommendation of the buildtool. If anybody builds library (something that can be required by others) then it won't work their users use browserify: https://github.com/choojs/bankai#configuration

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

No branches or pull requests

2 participants