From 960cf471cb0616abd0bbc89168ad217c0a721333 Mon Sep 17 00:00:00 2001 From: YunYouJun Date: Wed, 5 Feb 2025 10:50:35 +0800 Subject: [PATCH] fix: postbuild script error replace --- package.json | 1 - scripts/postbuild.ts | 23 ----------------------- tsup.config.ts | 1 - 3 files changed, 25 deletions(-) delete mode 100644 scripts/postbuild.ts diff --git a/package.json b/package.json index 00ef1ec..1099096 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,6 @@ "scripts": { "build": "tsup", "dev": "tsup --watch src", - "build:fix": "esno scripts/postbuild.ts", "lint": "eslint .", "play": "npm -C playground run dev", "prepublishOnly": "npm run build", diff --git a/scripts/postbuild.ts b/scripts/postbuild.ts deleted file mode 100644 index 2346f30..0000000 --- a/scripts/postbuild.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { basename, dirname, resolve } from 'node:path' -import { promises as fs } from 'node:fs' -import { fileURLToPath } from 'node:url' -import fg from 'fast-glob' -import chalk from 'chalk' - -async function run(): Promise { - // fix cjs exports - const files = await fg('*.cjs', { - ignore: ['chunk-*'], - absolute: true, - cwd: resolve(dirname(fileURLToPath(import.meta.url)), '../dist'), - }) - for (const file of files) { - console.log(chalk.cyan.inverse(' POST '), `Fix ${basename(file)}`) - let code = await fs.readFile(file, 'utf8') - code = code.replace('exports.default =', 'module.exports =') - code += 'exports.default = module.exports;' - await fs.writeFile(file, code) - } -} - -run() diff --git a/tsup.config.ts b/tsup.config.ts index 3ce6ce2..8d57897 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -9,5 +9,4 @@ export default { dts: true, cjsInterop: true, splitting: true, - onSuccess: 'npm run build:fix', }