esbuild-plugin-babel
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "esbuild-plugin-babel", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Babel plugin for esbuild.", | ||
@@ -5,0 +5,0 @@ "repository": "nativew/esbuild-plugin-babel", |
@@ -7,7 +7,7 @@ import babel from '@babel/core'; | ||
name: 'babel', | ||
setup(build, { transform } = {}) { | ||
async setup(build, { transform } = {}) { | ||
const { filter = /.*/, namespace = '', config = {} } = options; | ||
const transformContents = ({ args, contents }) => { | ||
const babelOptions = babel.loadOptions(config); | ||
const babelOptions = babel.loadOptions({ filename: args.path, ...config }); | ||
@@ -20,12 +20,10 @@ if (babelOptions.sourceMaps) { | ||
babel.transform(contents, babelOptions, (error, result) => { | ||
if (error) throw error; | ||
contents = result.code; | ||
return new Promise((resolve, reject) => { | ||
babel.transform(contents, babelOptions, (error, result) => { | ||
error ? reject(error) : resolve({ contents: result.code }); | ||
}); | ||
}); | ||
return { contents }; | ||
}; | ||
if (transform) return transformContents(transform); | ||
if (transform) return await transformContents(transform); | ||
@@ -35,3 +33,3 @@ build.onLoad({ filter, namespace }, async args => { | ||
return transformContents({ args, contents }); | ||
return await transformContents({ args, contents }); | ||
}); | ||
@@ -38,0 +36,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3807