From 838d6849ef81c206e31bd42549c18ef743a1e544 Mon Sep 17 00:00:00 2001 From: graphemecluster Date: Mon, 7 Oct 2024 20:28:36 +0800 Subject: [PATCH] Output more bundle format --- .gitignore | 5 +---- package.json | 20 +++++++++++++------- rollup.config.js | 30 ++++++++++++++++++++++-------- 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 67c06f0..54267da 100644 --- a/.gitignore +++ b/.gitignore @@ -8,10 +8,7 @@ *.log yarn.lock -/index.js -/index.js.map -/index.d.ts - +/dist /docs /prepare/data.csv diff --git a/package.json b/package.json index 0d3218f..1513d0c 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,18 @@ "version": "0.15.1", "description": "A JavaScript library for the Qieyun phonological system", "type": "module", - "main": "index.js", - "types": "index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "browser": "./dist/index.js", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "require": "./dist/index.cjs", + "import": "./dist/index.mjs", + "browser": "./dist/index.js" + } + }, "scripts": { "build": "run-p build:*", "build:rollup": "rollup -c", @@ -79,11 +89,7 @@ "typescript-eslint": "^8.3.0" }, "files": [ - "index.js", - "index.js.map", - "index.d.ts", - "LICENSE", - "README.md" + "dist" ], "ava": { "failFast": true, diff --git a/rollup.config.js b/rollup.config.js index b4b5901..48e8a92 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -5,14 +5,28 @@ import typescript from '@rollup/plugin-typescript'; /** @type { import("rollup").RollupOptions[] } */ export default [ { - input: 'src/index.ts', - output: { - file: 'index.js', - format: 'umd', - sourcemap: true, - name: 'TshetUinh', - exports: 'named', - }, + input: './src/index.ts', + output: [ + { + file: './dist/index.js', + format: 'umd', + name: 'TshetUinh', + exports: 'named', + sourcemap: true, + }, + { + file: './dist/index.cjs', + format: 'cjs', + exports: 'named', + sourcemap: true, + }, + { + file: './dist/index.mjs', + format: 'es', + exports: 'named', + sourcemap: true, + }, + ], plugins: [ typescript({ // NOTE Apparently needed with `"incremental": true` in tsconfig