@snowpack/plugin-babel
Advanced tools
Comparing version 2.0.3 to 2.1.0
{ | ||
"name": "@snowpack/plugin-babel", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"main": "plugin.js", | ||
@@ -10,5 +10,6 @@ "license": "MIT", | ||
"dependencies": { | ||
"@babel/core": "^7.10.5" | ||
"@babel/core": "^7.10.5", | ||
"workerpool": "^6.0.0" | ||
}, | ||
"gitHead": "654bd755e28046312aafd74dc8aed5f5ec6f8bdc" | ||
"gitHead": "d1b2ec113353d267fc68b88ce4bf8ac12f32f562" | ||
} |
@@ -1,2 +0,3 @@ | ||
const babel = require('@babel/core'); | ||
const workerpool = require('workerpool'); | ||
let worker, pool; | ||
@@ -22,6 +23,8 @@ module.exports = function plugin(snowpackConfig, options = {}) { | ||
async load({filePath}) { | ||
if (!filePath) return; | ||
const {transformOptions = {}} = options; | ||
let {code, map} = await babel.transformFileAsync(filePath, { | ||
if (!filePath) { | ||
return; | ||
} | ||
pool = pool || workerpool.pool(require.resolve('./worker.js')); | ||
worker = worker || (await pool.proxy()); | ||
let encodedResult = await worker.transformFileAsync(filePath, { | ||
cwd: process.cwd(), | ||
@@ -31,4 +34,5 @@ ast: false, | ||
sourceMaps: snowpackConfig.buildOptions.sourceMaps, | ||
...transformOptions, | ||
...(options.transformOptions || {}), | ||
}); | ||
let {code, map} = JSON.parse(encodedResult); | ||
@@ -49,3 +53,6 @@ if (code) { | ||
}, | ||
cleanup() { | ||
pool && pool.terminate(); | ||
}, | ||
}; | ||
}; |
4716
5
62
2
+ Addedworkerpool@^6.0.0
+ Addedworkerpool@6.5.1(transitive)