esbuild-plugin-babel
Advanced tools
Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "esbuild-plugin-babel", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "Babel plugin for esbuild.", | ||
@@ -5,0 +5,0 @@ "repository": "nativew/esbuild-plugin-babel", |
@@ -7,2 +7,7 @@ # esbuild-plugin-babel | ||
First, check if [esbuild supports](https://esbuild.github.io/content-types/) the transform you need _(it's faster)_. | ||
If not, you can add the Babel plugin you need with this plugin. | ||
<br> | ||
### Install | ||
@@ -53,6 +58,6 @@ | ||
babel({ | ||
filter = /.*/, | ||
namespace = '', | ||
config = {} // babel config here or in babel.config.json | ||
}) | ||
filter: /.*/, | ||
namespace: '', | ||
config: {} // babel config here or in babel.config.json | ||
}); | ||
``` | ||
@@ -64,14 +69,15 @@ | ||
{ | ||
"presets": [["@babel/preset-env", { "modules": false }]], | ||
"plugins": ["@babel/plugin"], | ||
"sourceMaps": "inline" | ||
"presets": [...], | ||
"plugins": [...] | ||
} | ||
``` | ||
[`.browserslistrc`](https://github.com/browserslist/browserslist) | ||
<br> | ||
```yaml | ||
defaults | ||
``` | ||
### Check | ||
[esbuild-plugin-pipe](https://github.com/nativew/esbuild-plugin-pipe) → Pipe esbuild plugins output. | ||
[esbuild-plugin-postcss-literal](https://github.com/nativew/esbuild-plugin-postcss-literal) → PostCSS tagged template literals plugin for esbuild. | ||
<br> |
@@ -11,11 +11,11 @@ import babel from '@babel/core'; | ||
const transformContents = ({ args, contents }) => { | ||
options = babel.loadOptions(config); | ||
const babelOptions = babel.loadOptions(config); | ||
if (options.sourceMaps) { | ||
if (babelOptions.sourceMaps) { | ||
const filename = path.relative(process.cwd(), args.path); | ||
options.sourceFileName = filename; | ||
babelOptions.sourceFileName = filename; | ||
} | ||
babel.transform(contents, options, (error, result) => { | ||
babel.transform(contents, babelOptions, (error, result) => { | ||
if (error) throw error; | ||
@@ -22,0 +22,0 @@ |
3670
81