@mikojs/babel-plugin-transform-flow

1.17.0 • Public • Published

@mikojs/babel-plugin-transform-flow · npm npm-size

Use to build the flow files with babel.

Example

In

├── index.js
├── index.js.flow
└── lib.js

Out

├── index.js
├── index.js.flow // if flow file exist in the source folder, just copy file to the target folder.
├── lib.js
└── lib.js.flow // if flow file does not exist in the source folder, transform the file with plugins to the target folder.

Install

yarn add @mikojs/babel-plugin-transform-flow --dev

Add @mikojs/babel-plugin-transform-flow to babel config.

...
  plugins: [
    ...
    '@mikojs/transform-flow',
    ...
  ]
...

With the custom options

...
  plugins: [
    ...
    [
      '@mikojs/transform-flow',
      {
        dir: './cutom-output-dir-path',
        relativeRoot: './relativeRoot-path-from-root',
        presets: ['other-babel-presets'],
        plugins: ['other-babel-plugins'],
        verbose: false,
        ignore: /ignore-pattern/,
      },
    ],
    ...
  ]
...

This plugin use babel.transformsync to build the flow files. This will read the parserOpts from your babel config automatically. However, we need to transform the code somtime.

For example, pipeline is not supported by flow. As a result, we need to add @babel/proposal-pipeline-operator in the plugins option to make @mikojs/babel-plugin-transform-flow transform the pipeline before build the file.

/@mikojs/babel-plugin-transform-flow/

    Package Sidebar

    Install

    npm i @mikojs/babel-plugin-transform-flow

    Weekly Downloads

    1

    Version

    1.17.0

    License

    MIT

    Unpacked Size

    8.79 kB

    Total Files

    5

    Last publish

    Collaborators

    • hsuting