fix(release): strip source conditions from publish manifests
This commit is contained in:
parent
b88362dc10
commit
0dd60e2a39
|
|
@ -62,8 +62,21 @@ async function copyRecursive(from: string, to: string): Promise<void> {
|
|||
await copyFile(from, to)
|
||||
}
|
||||
|
||||
function removeUnpublishedConditions(value: unknown): void {
|
||||
if (!value || typeof value !== 'object') return
|
||||
if (Array.isArray(value)) {
|
||||
for (const item of value) removeUnpublishedConditions(item)
|
||||
return
|
||||
}
|
||||
const record = value as Record<string, unknown>
|
||||
delete record.bun
|
||||
for (const child of Object.values(record)) removeUnpublishedConditions(child)
|
||||
}
|
||||
|
||||
export function publishPackageJSON(source: PackageJSON, coreVersion: string): PackageJSON {
|
||||
const json = structuredClone(source)
|
||||
removeUnpublishedConditions(json.exports)
|
||||
removeUnpublishedConditions(json.imports)
|
||||
|
||||
for (const field of PACKAGE_FIELDS) {
|
||||
const dependencies = json[field]
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ async function fixtureRoot() {
|
|||
version: '1.0.0',
|
||||
scripts: { build: 'tsdown' },
|
||||
dependencies: { '@open-pencil/core': 'workspace:*', zod: '^4.0.0' },
|
||||
exports: { '.': { bun: './src/index.ts', import: './dist/index.js' } },
|
||||
devDependencies: { typescript: '^5.0.0' },
|
||||
publishConfig: { access: 'public', main: './dist/index.js', types: './dist/index.d.ts' }
|
||||
},
|
||||
|
|
@ -38,6 +39,7 @@ describe('publishPackageJSON', () => {
|
|||
name: '@open-pencil/example',
|
||||
scripts: { build: 'tsdown' },
|
||||
dependencies: { '@open-pencil/core': 'workspace:*', zod: '^4.0.0' },
|
||||
exports: { '.': { bun: './src/index.ts', import: './dist/index.js' } },
|
||||
devDependencies: { typescript: '^5.0.0' },
|
||||
publishConfig: { access: 'public', main: './dist/index.js' }
|
||||
},
|
||||
|
|
@ -47,6 +49,7 @@ describe('publishPackageJSON', () => {
|
|||
expect(json).toEqual({
|
||||
name: '@open-pencil/example',
|
||||
dependencies: { '@open-pencil/core': '^0.13.2', zod: '^4.0.0' },
|
||||
exports: { '.': { import: './dist/index.js' } },
|
||||
main: './dist/index.js'
|
||||
})
|
||||
})
|
||||
|
|
@ -86,6 +89,7 @@ describe('preparePublishDirectories', () => {
|
|||
name: '@open-pencil/example',
|
||||
version: '1.0.0',
|
||||
dependencies: { '@open-pencil/core': '^0.13.2', zod: '^4.0.0' },
|
||||
exports: { '.': { import: './dist/index.js' } },
|
||||
main: './dist/index.js',
|
||||
types: './dist/index.d.ts'
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue