babel-base-compiler

v0.0.3arrow_drop_down
v0.0.3
v0.0.2
v0.0.1
STATUS
Passing
DOWNLOADS
40
LICENSE
MIT
VISIBILITY
Public
subject
Base babel compiler that supplies the basic algorithm for transpiling components using babel.
1 contributor
Like
Use babel-base-compiler in your project ?
Copied
npm i @bit/bit.envs.utils.babel-base-compiler

Configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Don't show this again
Component Example
chevron_left
chevron_right

Base babel compiler

All compilers using babel follow the same algorithm:

  1. get babel options from the .babelrc file in the compiler directory.
  2. compile (babel.transform) only certain file types.
  3. Return all component files as dist files - both those that were compiled and those that weren’t.

Therefore, the base compiler expects the following arguments:

  1. files - files array sent by bit to compiler.
  2. distPath - dist path sent by bit compiler.
  3. compilerPath - path of the concrete compiler.
  4. compiledFileTypes - an array of file types to compile.

Example

Here’s an example for a compiler that uses the babel-base-compiler:

import baseCompile from '@bit/bit.envs.utils.babel-base-compiler';

const compiledFileTypes = ['js', 'jsx', 'ts'];

const compile = (files, distPath) => {
  return baseCompile(files, distPath, __dirname, compiledFileTypes);
}

export default compile;