We’re excited to announce Bit’s new home at bit.dev!Learn more

babel-base-compiler

v0.0.3arrow_drop_down
v0.0.3
v0.0.2
v0.0.1
STATUS
Passing
DOWNLOADS
114
LICENSE
MIT
VISIBILITY
Public
PUBLISHED
A year ago
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
Set Bit as a scoped registryLearn more
npm config set '@bit:registry' https://node.bit.dev
Component Example
Add dependency... help_outline
Just
import
any of the 1 million components
and packages in Bit or NPM to the example.
import Button from '@bit/grommet.grommet.button';
import Lodash from 'lodash';
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;