Babel multiple directores into single output directory - babeljs

I've scouered the documentation for Babel and cannot seem to find an answer, so I turn to the glorious community.
With a directory structure like this:
src/
folder1/
file1.js
file2.js
folder2/
file3.js
folder3/
file4.js
file5.js
I want Babel to transpile all files into a flattened directory:
lib/
file1.js
file2.js
file3.js
file4.js
file5.js
No matter what I try, Babel always inherits the src/ directory structure. Any ideas?

If you are using babel-cli, you can do this:
babel folder1 folder2 folder3 folder4 -d lib
which works fine if you have a limited number of folders. It'll output them all flattened.

To expand on samanime's answer, if you're using babel-cli, you can simply use a wildcard on your parent folder...
babel src/** -d lib

Related

BabelJS: Doesn't find all .js files in directory

Babel doesn't find all of my .js/.es6 files in my directory.
I have this directory structure:
src/
assets/
sample/
models.es6
scripts/
playground.es6
If I run babel src --out-dir dist --source-maps --copy-files --presets env, it only transpiles /src/assets/sample/models.es6 and doesnt go through src/scripts/playground.es6.
What am I doing wrong?
Looking forward to your response!
You can do like below :
babel src/** --out-dir lib
more at official doc
Compile Directories
Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
if you still stuck, you can use gulp or grunt or webpack to load/transpile mupltiple directives from different locations.
Hope it helps
I found the problem. It has barely to do with Babel.
Inside the src/assets/** is my Realm database sample.realm (https://realm.io). The file itself doesnt cause the problem. But if you open the sample.realm file with Realm Studio on MacOSX, a file called sample.realm.note gets created. This file causes babel to not exit the transpile task.

Babel file structure is duplicating

Using latest babel preset. My .babelrc contains
{
"presets": ["env"]
}
In my package.json, I run it as follows:
"build:babel": "babel app.js app/** venue/** -d build",
My original code structure is:
But after running babel my build folder looks like the following:
The problem I'm seeing is that it's building the file in the sub-directories correctly but it also putting it into the root build folder. Example: "containers" is in the build folder under app/plugins/containers which is correct. But its also in the root build folder. Also, the files "border, button, card, checkbox, click, color_picker, ..." belong in other sub-directories (which it is), but is also in the root build folder.
I'm wondering if I'm running it incorrectly?

agignore not respecting nested forlder

my directory structure is like this:
roo
|
node_modules
|
packages
|
project1
|
lib
node_modules
project2
|
build
node_modules
I want to exclude lib, build or node_modules no matter where they are in the directory structure.
Here is my .gitignore
# dependencies
node_modules
/node_modules/
# testing
/coverage
# production
/build
/lib
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
.tern-port
packages/*/lib/*
packages/*/dist/*
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log
packages/*/node_modules
packages/*/lib
packages/*/build
Two options:
Use an .ignore file, and add the following to skip lib and node_moduels (for example):
*node_modules/
*lib/
Use the command line option to ignore a directory, the "--ignore-dir." For example, if you want to ignore node_modules and lib, you'd use this:
ag --ignore-dir lib --ignore-dir node_modules value
Note: I tested this with your exact directory structure.

Can I have multiple configure.ac files and what to do with AC_OUTPUT then?

I have this directory structure:
foo
foo/libfoo - libfoo project
foo/libfoo/src - sources
foo/foo - foo project
foo/foo/src - sources
There are two separate things that have to be build here, a libtool library (libfoo) and an executable (foo) using that library.
I could just place a configure.ac file into each foo/libfoo and foo/foo and everything would be fine.
However I would like to be able to build both projects at once, so I thought about placing an additional configure.ac into the top level foo directory.
Is this a good idea?
If yes, how would the AC_OUTPUT makro be used in such a case?
Does the top level configure.ac file generate all the Makefiles in the whole tree or are there separate AC_OUTPUT makros in the sub directories that each output there Makefiles?
Since both projects have different dependencies I would think the subdir ac files do the output of their makefiles?
Can the two projects in the sub dirs still be build separately in this case?
There is a AC_CONFIG_SUBDIRS macro that does what I want, it recurses into subdirs and executes the configure.ac files there.
The sub dir projects can still be build independently.
My Makefile.am only contains SUBDIRS = libfoo foo now.
The configure.ac file contains AC_CONFIG_SUBDIRS=([libfoo foo]).

Implementing a directory structure in Grunt

I am working on a project using coffeescript and want to have a directory structure like:
project/
Gruntfile
common/
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
server/
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
client/
*.html
*.css
*.coffee
*.spec.coffee
*.scaffold.coffee
bin/
test/
Where coffee files get compiled to bin, spec.coffee and scaffold.coffee get compiled to test. There are directories containing static files that are not shown.
Is there an easy/standard way to do this?
this is a general question so the general answer is: yes, most grunt plugins have easy ways to configure each task, identify source files and where the output gets generated.
take a look at the documentation for grunt-contrib-coffee, shows lots of examples of how to config directories to process coffee files including options to flatten sub-directories, etc.
https://github.com/gruntjs/grunt-contrib-coffee