diff --git a/package-lock.json b/package-lock.json index 9fba5fa..52a5bf2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,10 +27,6 @@ "is-ci": "^3.0.1", "lint-staged": "^12.4.1", "prettier": "^2.6.2", - "rimraf": "^3.0.2", - "rollup": "^2.74.1", - "rollup-plugin-dts": "^4.2.1", - "rollup-plugin-tsconfig-paths": "^1.3.0", "semantic-release": "^19.0.2", "tsup": "^6.2.3", "typescript": "^4.8.4", @@ -5271,18 +5267,6 @@ "node": ">=10" } }, - "node_modules/magic-string": { - "version": "0.26.6", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.6.tgz", - "integrity": "sha512-6d+3bFybzyQFJYSoRsl9ZC0wheze8M1LrQC7tNMRqXR4izUTDOLMd9BtSuExK9iAukFh+s5K0WAhc/dlQ+HKYA==", - "dev": true, - "dependencies": { - "sourcemap-codec": "^1.4.8" - }, - "engines": { - "node": ">=12" - } - }, "node_modules/make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -9175,40 +9159,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/rollup-plugin-dts": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-4.2.2.tgz", - "integrity": "sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==", - "dev": true, - "dependencies": { - "magic-string": "^0.26.1" - }, - "engines": { - "node": ">=v12.22.11" - }, - "funding": { - "url": "https://github.com/sponsors/Swatinem" - }, - "optionalDependencies": { - "@babel/code-frame": "^7.16.7" - }, - "peerDependencies": { - "rollup": "^2.55", - "typescript": "^4.1" - } - }, - "node_modules/rollup-plugin-tsconfig-paths": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-tsconfig-paths/-/rollup-plugin-tsconfig-paths-1.3.0.tgz", - "integrity": "sha512-H+tK/vGJ64wLc/TWc3v6QYypH9vvS6XwzrXkRol3N3fFRSw488Q8csFUVLDkMMv/6R46xLkP3m+0wxUU41VyOg==", - "dev": true, - "dependencies": { - "typescript-paths": "^1.4.0" - }, - "peerDependencies": { - "rollup": "^2" - } - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -9612,12 +9562,6 @@ "source-map": "^0.6.0" } }, - "node_modules/sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, "node_modules/spawn-error-forwarder": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz", @@ -10367,15 +10311,6 @@ "node": ">=4.2.0" } }, - "node_modules/typescript-paths": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/typescript-paths/-/typescript-paths-1.4.0.tgz", - "integrity": "sha512-olt3yKj5d4ON5MpQgxvqpiN24ApsrdlRnIQFwqlbzuTjRZFQNoTOzzTJ13vyDRt7VW0cuO+g8HA+eoYfBLWWMA==", - "dev": true, - "peerDependencies": { - "typescript": "^4.7.2" - } - }, "node_modules/uglify-js": { "version": "3.17.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.3.tgz", @@ -14666,15 +14601,6 @@ "yallist": "^4.0.0" } }, - "magic-string": { - "version": "0.26.6", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.26.6.tgz", - "integrity": "sha512-6d+3bFybzyQFJYSoRsl9ZC0wheze8M1LrQC7tNMRqXR4izUTDOLMd9BtSuExK9iAukFh+s5K0WAhc/dlQ+HKYA==", - "dev": true, - "requires": { - "sourcemap-codec": "^1.4.8" - } - }, "make-dir": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", @@ -17388,25 +17314,6 @@ "fsevents": "~2.3.2" } }, - "rollup-plugin-dts": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-dts/-/rollup-plugin-dts-4.2.2.tgz", - "integrity": "sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.16.7", - "magic-string": "^0.26.1" - } - }, - "rollup-plugin-tsconfig-paths": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/rollup-plugin-tsconfig-paths/-/rollup-plugin-tsconfig-paths-1.3.0.tgz", - "integrity": "sha512-H+tK/vGJ64wLc/TWc3v6QYypH9vvS6XwzrXkRol3N3fFRSw488Q8csFUVLDkMMv/6R46xLkP3m+0wxUU41VyOg==", - "dev": true, - "requires": { - "typescript-paths": "^1.4.0" - } - }, "run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", @@ -17717,12 +17624,6 @@ "source-map": "^0.6.0" } }, - "sourcemap-codec": { - "version": "1.4.8", - "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", - "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", - "dev": true - }, "spawn-error-forwarder": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/spawn-error-forwarder/-/spawn-error-forwarder-1.0.0.tgz", @@ -18285,13 +18186,6 @@ "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", "dev": true }, - "typescript-paths": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/typescript-paths/-/typescript-paths-1.4.0.tgz", - "integrity": "sha512-olt3yKj5d4ON5MpQgxvqpiN24ApsrdlRnIQFwqlbzuTjRZFQNoTOzzTJ13vyDRt7VW0cuO+g8HA+eoYfBLWWMA==", - "dev": true, - "requires": {} - }, "uglify-js": { "version": "3.17.3", "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.17.3.tgz", diff --git a/package.json b/package.json index e4b7404..4a19151 100644 --- a/package.json +++ b/package.json @@ -33,10 +33,9 @@ "node": ">=14.17.0" }, "scripts": { - "build": "tsup && npm run build:rollup", - "build:rollup": "node --loader @esbuild-kit/esm-loader scripts/compile.ts", - "fmt:prettier": "prettier --write \"**/*.{js,ts,tsx,json}\"", + "build": "tsup", "fmt:lint": "eslint --fix --ext .js,.ts,.tsx .", + "fmt:prettier": "prettier --write \"**/*.{js,ts,tsx,json}\"", "postversion": "node --loader @esbuild-kit/esm-loader scripts/release.ts restore", "prepare": "is-ci || husky install", "prerelease": "node --loader @esbuild-kit/esm-loader scripts/release.ts prepare", @@ -88,10 +87,6 @@ "is-ci": "^3.0.1", "lint-staged": "^12.4.1", "prettier": "^2.6.2", - "rimraf": "^3.0.2", - "rollup": "^2.74.1", - "rollup-plugin-dts": "^4.2.1", - "rollup-plugin-tsconfig-paths": "^1.3.0", "semantic-release": "^19.0.2", "tsup": "^6.2.3", "typescript": "^4.8.4", diff --git a/scripts/compile.ts b/scripts/compile.ts deleted file mode 100644 index 7d24649..0000000 --- a/scripts/compile.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { readdir, unlink } from 'fs/promises' - -import { rollup, InputOptions, OutputOptions } from 'rollup' -import dts from 'rollup-plugin-dts' - -interface BundleOptions { - input: InputOptions - output: Array -} - -function createTypesBundleOptions(entry: string): BundleOptions { - return { - input: { - input: `${entry}.d.ts`, - plugins: [dts()] - }, - output: [ - { - file: `${entry}.d.ts`, - format: 'esm' - } - ] - } -} - -async function compile() { - try { - const entries = [ - createTypesBundleOptions('dist/index'), - createTypesBundleOptions('dist/parsers'), - createTypesBundleOptions('dist/combinators') - ] - await Promise.all( - entries.map(async ({ input, output }) => { - const bundle = await rollup(input) - - for (const out of output) { - await bundle.generate(out) - await bundle.write(out) - } - - await bundle.close() - }) - ) - const distFiles = await readdir('dist') - await Promise.all( - distFiles - .filter( - (file) => - file.endsWith('.d.ts') && - !file.startsWith('index') && - !file.startsWith('combinators') && - !file.startsWith('parsers') - ) - .map(async (file) => unlink('dist/' + file)) - ) - } catch (error) { - console.error(error) - process.exit(1) - } -} - -compile() diff --git a/tsconfig.types.json b/tsconfig.types.json deleted file mode 100644 index a86e256..0000000 --- a/tsconfig.types.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "dist/types", - "emitDeclarationOnly": true, - "skipLibCheck": true - }, - "include": ["src"], - "exclude": ["src/__tests__"] -} diff --git a/tsup.config.ts b/tsup.config.ts index 3a1f29c..13c92b7 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,15 +1,31 @@ -import { defineConfig } from 'tsup' +import { defineConfig, type Options } from 'tsup' const entry = ['src/index.ts', 'src/parsers.ts', 'src/combinators.ts'] -export default defineConfig({ - entry, +const sharedConfig = defineConfig({ splitting: false, sourcemap: true, clean: true, format: ['esm', 'cjs'], treeshake: true, - dts: true, minify: false, bundle: true }) + +const mainConfig = defineConfig({ + ...sharedConfig, + entry, + dts: false +}) as Options + +const createDTSConfig = (e: string): Options => + defineConfig({ + ...sharedConfig, + entry, + dts: { + entry: e, + only: true + } + }) as Options + +export default defineConfig([mainConfig, ...entry.map(createDTSConfig)])