Esbuild plugin to strip types for Flow files using flow-remove-types
npm i --dev https://github.com/dalcib/esbuild-plugin-flow
The esbuild plugin API isn't supported via CLI, so use a custom build script like so:
const esbuild = require('esbuild')
const flow = require('esbuild-plugin-flow')
esbuild
.build({
entryPoints: ['index.js'],
outfile: 'dist/bundle.js',
bundle: true,
plugins: [flow(/\.flow\.jsx?$/)],
})
.catch(() => process.exit(1))
The plugin has to parameters: regexp
and [force]
The plugin needs a RegExp to define:
;/node_modules\\package.*\.jsx?$/
;/\.flow\.jsx?$/
;/node_modules\\package1.*\.jsx?$|node_modules\\package2.*\.jsx?$|\.flow\.jsx?$/
A Boolean indicating that the plugin must act regardless of the existence of flow annotations (// @flow
or /** @flow /*
) in the file.
Due to limitations of Esbuild, the entry point is not processed.
For test, copy the folder flow-pkg
to node_modules and run node tests/test