pika-plugin-build-web-babel
Advanced tools
Comparing version 0.8.2 to 0.8.3
{ | ||
"name": "pika-plugin-build-web-babel", | ||
"description": "A @pika/pack plugin: Adds an babel compiled ESM distribution to your package", | ||
"version": "0.8.2", | ||
"version": "0.8.3", | ||
"files": [ | ||
@@ -6,0 +6,0 @@ "src/" |
@@ -21,6 +21,10 @@ var path = (require('path')); | ||
} | ||
function manifest(manifest, { options }) { | ||
function manifest(manifest, { options, cwd }) { | ||
const srcDir = path.join(cwd, 'src'); | ||
const format = options.format || defaultFormat; | ||
const dist = `${dirMap[format]}/index.js`; | ||
const field = format === 'esm' ? 'module' : 'main'; | ||
if (fs.existsSync(path.join(srcDir, 'index.d.ts'))) { | ||
manifest.types = 'index.d.ts'; | ||
} | ||
manifest[field] = manifest[field] || dist; | ||
@@ -44,2 +48,7 @@ } | ||
let input = path.join(src, 'index'); | ||
if (fs.existsSync(path.join(src, 'index.d.ts'))) { | ||
fs.createReadStream(path.join(src, 'index.d.ts')).pipe(fs.createWriteStream(path.join(out, 'index.d.ts'))); | ||
} | ||
const isTs = (fs.existsSync(input + '.ts') || fs.existsSync(input + '.tsx')); | ||
@@ -46,0 +55,0 @@ const plugins = [ |
4470
117