Sucrase Webpack loader
This is a simple Webpack loader that makes it easy to use
Sucrase in your build.
Note: Sucrase does not transform object rest/spread syntax (e.g.
{...a, b: c}
), and the syntax is not yet supported by Webpack. If you use that
syntax, you should use the
webpack-object-rest-spread-plugin
package alongside this loader, and add both to your webpack config.
Usage
First install the package and Sucrase as a dev dependency:
yarn add --dev @sucrase/webpack-loader sucrase
Then add it as a loader to your webpack config:
module: {
rules: [
{
test: /\.js$/,
use: {
loader: '@sucrase/webpack-loader',
options: {
transforms: ['jsx']
}
}
}
]
}