rollup-plugin-esbuild
esbuild is by far one of the fastest TS/ESNext to ES6 compilers and minifier, this plugin replaces rollup-plugin-typescript2
, @rollup/plugin-typescript
and rollup-plugin-terser
for you.
Install
yarn add esbuild rollup-plugin-esbuild --dev
Usage
In rollup.config.js
:
import esbuild from 'rollup-plugin-esbuild'
export default {
plugins: [
esbuild({
include: /\.[jt]sx?$/,
exclude: /node_modules/,
sourceMap: false,
minify: process.env.NODE_ENV === 'production',
target: 'es2017'
jsxFactory: 'React.createElement',
jsxFragment: 'React.Fragment'
define: {
__VERSION__: '"x.y.z"'
},
tsconfig: 'tsconfig.json',
loaders: {
'.json': 'json',
'.js': 'jsx'
}
}),
],
}
include
and exclude
can be String | RegExp | Array[...String|RegExp]
, when supplied it will override default values.- It uses
jsxFactory
, jsxFragmentFactory
and target
options from your tsconfig.json
as default values.
Declaration File
There are serveral ways to generate declaration file:
- Use
tsc
with emitDeclarationOnly
, the slowest way but you get type checking, it doesn't bundle the .d.ts
files. - Use
rollup-plugin-dts
which generates and bundle .d.ts
, also does type checking. - Use
api-extractor
by Microsoft, looks quite complex to me so I didn't try it, PR welcome to update this section.
Use with Vue JSX
Use this with rollup-plugin-vue-jsx:
import vueJsx from 'rollup-plugin-vue-jsx-compat'
import esbuild from 'rollup-plugin-esbuild'
export default {
plugins: [
vueJsx(),
esbuild({
jsxFactory: "vueJsxCompat",
}),
],
}
License
MIT © EGOIST (Kevin Titor)