mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-03 10:11:15 +02:00
fix(api): correctly merge pkg exports in after-build.js script (#1609)
This commit is contained in:
@@ -13,25 +13,29 @@ const modules = readdirSync('src').map((mod) => mod.replace('.ts', ''))
|
||||
if (!pkg.exports) {
|
||||
pkg.exports = {}
|
||||
}
|
||||
const outputPkg = Object.assign(
|
||||
pkg.exports,
|
||||
...modules.map((mod) => {
|
||||
let temp = {}
|
||||
let key = `./${mod}`
|
||||
if (mod === 'index') {
|
||||
key = '.'
|
||||
}
|
||||
|
||||
temp[key] = {
|
||||
import: `./${mod}.js`,
|
||||
require: `./${mod}.cjs`
|
||||
}
|
||||
return temp
|
||||
}),
|
||||
// if for some reason in the future we manually add something in the `exports` field
|
||||
// this will ensure it doesn't get overwritten by the logic above
|
||||
{ ...pkg.exports }
|
||||
)
|
||||
const outputPkg = {
|
||||
...pkg,
|
||||
exports: Object.assign(
|
||||
{},
|
||||
...modules.map((mod) => {
|
||||
let temp = {}
|
||||
let key = `./${mod}`
|
||||
if (mod === 'index') {
|
||||
key = '.'
|
||||
}
|
||||
|
||||
temp[key] = {
|
||||
import: `./${mod}.js`,
|
||||
require: `./${mod}.cjs`
|
||||
}
|
||||
return temp
|
||||
}),
|
||||
// if for some reason in the future we manually add something in the `exports` field
|
||||
// this will ensure it doesn't get overwritten by the logic above
|
||||
{ ...pkg.exports }
|
||||
)
|
||||
}
|
||||
writeFileSync('dist/package.json', JSON.stringify(outputPkg, undefined, 2))
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user