From 51ddeec9d90b9312963534c1ac102471a616001c Mon Sep 17 00:00:00 2001 From: JinmingYang <2214962083@qq.com> Date: Tue, 4 Jul 2023 00:40:56 +0800 Subject: [PATCH] feat: optimize package size for web --- packages/gpt-runner-cli/src/cli-start.ts | 2 +- packages/gpt-runner-web/build.config.ts | 3 +++ packages/gpt-runner-web/package.json | 13 ++++--------- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/packages/gpt-runner-cli/src/cli-start.ts b/packages/gpt-runner-cli/src/cli-start.ts index aca7432e..93635b09 100644 --- a/packages/gpt-runner-cli/src/cli-start.ts +++ b/packages/gpt-runner-cli/src/cli-start.ts @@ -10,7 +10,7 @@ import { version } from '../package.json' import type { CliOptions } from './types' const dirname = PathUtils.getCurrentDirName(import.meta.url, () => __dirname) -const startServerJsPath = PathUtils.resolve(dirname, '../node_modules/@nicepkg/gpt-runner-web/dist/start-server.mjs') +const startServerJsPath = PathUtils.resolve(dirname, '../node_modules/@nicepkg/gpt-runner-web/dist/start-server.cjs') export async function startCli(cwd = PathUtils.resolve(process.cwd()), argv = process.argv, options: CliOptions = {}) { const cli = cac('gptr') diff --git a/packages/gpt-runner-web/build.config.ts b/packages/gpt-runner-web/build.config.ts index d3675155..67270b6b 100644 --- a/packages/gpt-runner-web/build.config.ts +++ b/packages/gpt-runner-web/build.config.ts @@ -63,6 +63,9 @@ ${output.banner || ''} ` } }) + + // remove esm + rollupOptions.output = rollupOptions.output.filter(output => output.format !== 'esm') }, }, }) diff --git a/packages/gpt-runner-web/package.json b/packages/gpt-runner-web/package.json index 122a8455..d482d3b3 100644 --- a/packages/gpt-runner-web/package.json +++ b/packages/gpt-runner-web/package.json @@ -25,28 +25,23 @@ "exports": { ".": { "types": "./dist/common/index.d.ts", - "require": "./dist/common.cjs", - "import": "./dist/common.mjs" + "require": "./dist/common.cjs" }, "./*": "./*", "./server": { "types": "./dist/server/index.d.ts", - "require": "./dist/server.cjs", - "import": "./dist/server.mjs" + "require": "./dist/server.cjs" }, "./start-server": { "types": "./dist/server/start-server.d.ts", - "require": "./dist/start-server.cjs", - "import": "./dist/start-server.mjs" + "require": "./dist/start-server.cjs" }, "./common": { "types": "./dist/common/index.d.ts", - "require": "./dist/common.cjs", - "import": "./dist/common.mjs" + "require": "./dist/common.cjs" } }, "main": "dist/common.cjs", - "module": "dist/common.mjs", "types": "./dist/common/index.d.ts", "files": [ "dist/",