How do I pile ES6 JS code with all required dependencies using babel-cli
module? For example.
I have the next project structure:
/lib
/packageA
/node_modules
- package.json
- index.js
/packageB
/node_modules
- package.json
- index.js
/app
- index.js
- package.json
I import packages packageA
and packageB
in /app/index.js
, all the ponents are written using ES6 syntax, except from the packages installed with npm
in node_modules
.
I would like to pile /app/index.js
with all the dependencies, but cannot figure out a simple way without to explicitly provide paths of packageA
and packageB
.
I have found this module , but is there other tools / approaches / native babel soultions?
How do I pile ES6 JS code with all required dependencies using babel-cli
module? For example.
I have the next project structure:
/lib
/packageA
/node_modules
- package.json
- index.js
/packageB
/node_modules
- package.json
- index.js
/app
- index.js
- package.json
I import packages packageA
and packageB
in /app/index.js
, all the ponents are written using ES6 syntax, except from the packages installed with npm
in node_modules
.
I would like to pile /app/index.js
with all the dependencies, but cannot figure out a simple way without to explicitly provide paths of packageA
and packageB
.
I have found this module https://github./mairatma/babel-deps, but is there other tools / approaches / native babel soultions?
If you pile several files with babel
it will concat the files. If what you want is to get a piled file in app/index.js
that includes the dependencies I would remend using something like rollup.
If you decide to go with rollup, a rollup.config.js
like this will do what I think you want:
import nodeResolve from 'rollup-plugin-node-resolve';
import babel from 'rollup-plugin-babel';
import monjs from 'rollup-plugin-monjs';
export default {
entry: 'index.js',
dest: 'app/app.js',
plugins: [
babel(),
nodeResolve(),
monjs()]
};
And then just run rollup -c