diff --git a/package.json b/package.json index a5affdb..c8a3e86 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "scripts": { "lint": "eslint --cache .", "lint:fix": "pnpm run lint --fix", - "build": "tsup && tsx scripts/postbuild.mts", + "build": "tsup", "dev": "pnpm run -C playground dev", "test": "vitest", "release": "bumpp && pnpm publish", @@ -123,7 +123,7 @@ "eslint-define-config": "^1.22.0", "fast-glob": "^3.3.1", "prettier": "^3.0.0", - "tsup": "^7.1.0", + "tsup": "^7.2.0", "tsx": "^3.12.7", "typescript": "^5.1.6", "vite": "^4.4.8", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 104403b..318af5d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -70,8 +70,8 @@ importers: specifier: ^3.0.0 version: 3.0.0 tsup: - specifier: ^7.1.0 - version: 7.1.0(typescript@5.1.6) + specifier: ^7.2.0 + version: 7.2.0(typescript@5.1.6) tsx: specifier: ^3.12.7 version: 3.12.7 @@ -4127,8 +4127,8 @@ packages: resolution: {integrity: sha512-t0hLfiEKfMUoqhG+U1oid7Pva4bbDPHYfJNiB7BiIjRkj1pyC++4N3huJfqY6aRH6VTB0rvtzQwjM4K6qpfOig==} dev: true - /tsup@7.1.0(typescript@5.1.6): - resolution: {integrity: sha512-mazl/GRAk70j8S43/AbSYXGgvRP54oQeX8Un4iZxzATHt0roW0t6HYDVZIXMw0ZQIpvr1nFMniIVnN5186lW7w==} + /tsup@7.2.0(typescript@5.1.6): + resolution: {integrity: sha512-vDHlczXbgUvY3rWvqFEbSqmC1L7woozbzngMqTtL2PGBODTtWlRwGDDawhvWzr5c1QjKe4OAKqJGfE1xeXUvtQ==} engines: {node: '>=16.14'} hasBin: true peerDependencies: diff --git a/scripts/postbuild.mts b/scripts/postbuild.mts deleted file mode 100644 index aaac6cf..0000000 --- a/scripts/postbuild.mts +++ /dev/null @@ -1,19 +0,0 @@ -import { basename, dirname, resolve } from 'node:path' -import { readFile, writeFile } from 'node:fs/promises' -import { fileURLToPath } from 'node:url' -import fg from 'fast-glob' - -// fix cjs exports -const files = await fg('*.js', { - ignore: ['index.js', 'chunk-*'], - absolute: true, - cwd: resolve(dirname(fileURLToPath(import.meta.url)), '../dist'), -}) -for (const file of files) { - // eslint-disable-next-line no-console - console.log('[postbuild]', basename(file)) - let code = await readFile(file, 'utf8') - code = code.replace('exports.default =', 'module.exports =') - code += 'exports.default = module.exports;' - await writeFile(file, code) -} diff --git a/src/index.ts b/src/index.ts index 1bc17a1..f047d90 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,7 +8,7 @@ declare global { const jsxRaw: (variable: any) => any } -export default createUnplugin((options = {}) => { +export default createUnplugin((options = {}) => { const opt = resolveOption(options) const filter = createFilter(opt.include, opt.exclude) diff --git a/tsup.config.ts b/tsup.config.ts index 0197060..df33511 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,9 +1,11 @@ import { defineConfig } from 'tsup' export default defineConfig({ - entry: ['./src'], + entry: ['./src/*.ts'], format: ['cjs', 'esm'], target: 'node16.14', + splitting: true, + cjsInterop: true, clean: true, dts: true, })