Skip to content
This repository was archived by the owner on Aug 26, 2021. It is now read-only.

themaven-net/rollup-plugin-esbuild

 
 

Repository files navigation

- 6/21/21 - DEPRECATED REPO, NO LONGER USED.

rollup-plugin-esbuild

esbuild is by far one of the fastest TS/ESNext to ES6 compilers, so it makes sense to use it over Babel/TSC with Rollup to take advantage of both worlds (Speed and the Rollup plugin ecosytem).

Install

yarn add rollup-plugin-esbuild --dev

Usage

In rollup.config.js:

import esbuild from 'rollup-plugin-esbuild'

export default {
  plugins: [
    esbuild({
      // All options are optional
      include: /\.[jt]sx?$/, // default
      exclude: /node_modules/, // default
      watch: process.argv.includes('--watch'),
      minify: process.env.NODE_ENV === 'production',
      target: 'es2017' // default, or 'es20XX', 'esnext'
      jsxFactory: 'React.createElement',
      jsxFragment: 'React.Fragment'
      // Like @rollup/plugin-replace
      define: {
        __VERSION__: '"x.y.z"'
      }
    }),
  ],
}
  • include and exclude can be String | RegExp | Array[...String|RegExp], when supplied it will override 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, no type checking so it's very fast.
  • Use api-extractor by Microsoft, looks quite complex to me so I didn't try it, PR welcome to update this section.

Type Checking

How do I get type checking then? VS Code only shows type errors for opened files!

You can enable type checking in testing, for example use jest with ts-jest to run tests, here's an example jest config file.

License

MIT © EGOIST (Kevin Titor)

About

Use ESBuild with Rollup to transform ESNext and TypeScript code.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • TypeScript 91.0%
  • JavaScript 9.0%