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

@babel/cli: default the src/out directory #7237

Open
hzoo opened this issue Jan 18, 2018 · 16 comments · May be fixed by #7966
Open

@babel/cli: default the src/out directory #7237

hzoo opened this issue Jan 18, 2018 · 16 comments · May be fixed by #7966

Comments

@hzoo
Copy link
Member

hzoo commented Jan 18, 2018

https://babeljs.io/docs/usage/cli/#compile-directories

I think we can default babel without any arguments to be babel src --out-dir lib (default to the src/ directory and output to lib or dist?), I guess we may need to check existence and all that?

Probably a check around here?

let filenames = commander.args.reduce(function(globbed, input) {

This is just so if you want to do something in package.json like "build": "babel src -d lib", you can do "build": "babel" instead.

Can look to other tools that do this kind of thing as well.

aside: we should add some better error messages around this kind of thing, like if a config isn't found, etc.

like in https://github.com/developit/microbundle, @developit

EDIT: Comment below if you are going to work on this

@hzoo hzoo added PR: Polish 💅 A type of pull request used for our changelog categories i: enhancement and removed PR: Polish 💅 A type of pull request used for our changelog categories labels Jan 18, 2018
@Andarist
Copy link
Member

lib is a good default for me

@rajasekarm
Copy link
Member

+1 for lib

@xtuc
Copy link
Member

xtuc commented Jan 19, 2018

babel --out-dir mydist could still be possible? The src is by default if you don't specify it.

@hzoo
Copy link
Member Author

hzoo commented Jan 19, 2018

You can do whatever you want with the flags, this is just so babel does what people usually expect.

This + #6027 for cli should mean you just have to do babel

@mAAdhaTTah
Copy link
Contributor

FWIW, Webpack appears to be defaulting to dist in Webpack 4. Might be a plus to align Babel w/ Webpack on that.

@hzoo
Copy link
Member Author

hzoo commented Jan 22, 2018

Hmm I thought the convention is lib for libraries, and also what we currently do it babel, and dist for apps? not sure

@developit
Copy link
Member

Might be worth inspecting what the user has in their package.json "main" field - it should give the directory you're looking to output to, right? I believe microbundle and preact-cli use the existence of a src directory though, that part is fine just using auto-detection.

@hzoo
Copy link
Member Author

hzoo commented May 8, 2018

Ok so could look to the main field folder otherwise default to lib or dist?

@iansu
Copy link

iansu commented May 8, 2018

I’m interested in doing this if it’s still up for grabs.

@hzoo
Copy link
Member Author

hzoo commented May 8, 2018

Yeah go for it @iansu 👍

@iansu
Copy link

iansu commented May 8, 2018

As I understand it the basic algorithm will be:

  1. Try to get the output dir from main
  2. If not found check for lib or dist (in which order?)
  3. If not found default to lib or dist (which one?)

The big question is, what's the default lib or dist?

@hzoo
Copy link
Member Author

hzoo commented May 8, 2018

Yeah, I was thinking lib as default. I know dist it is for webpack but this is also for cli which is used for a library? Since it's probably npmignored I don't know if we can check the folder from init?

@iansu
Copy link

iansu commented May 8, 2018

That logic makes sense to me. I'll use lib as the default.

@nicolo-ribaudo
Copy link
Member

Since it's probably npmignored

We can check .npmignore/.gitignore

@alvaropinot
Copy link

@nicolo-ribaudo that might add some "magic" difficult to reason about by the final user, don't you think?

@iansu iansu linked a pull request May 17, 2018 that will close this issue
3 tasks
@iansu
Copy link

iansu commented May 17, 2018

I have an initial implementation of this here: #7966

It works but there are still some things to do like updating tests and documentation. Feedback welcome.

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

Successfully merging a pull request may close this issue.

10 participants