From b0fa2637a7df259c9a31061752b0b7539ea200d7 Mon Sep 17 00:00:00 2001 From: hemengke1997 <23536175@qq.com> Date: Thu, 26 Oct 2023 17:21:54 +0800 Subject: [PATCH] perf: build --- package.json | 6 ++++-- pnpm-lock.yaml | 17 +++++++++-------- tsup.config.ts | 25 +++++++++++++++++-------- 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index ef7f30d..9316514 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,10 @@ "peerDependencies": { "postcss": ">=8.0.0" }, + "dependencies": { + "decode-uri-component": "^0.4.1", + "split-on-first": "^3.0.0" + }, "devDependencies": { "@commitlint/cli": "^18.0.0", "@minko-fe/commitlint-config": "^2.0.4", @@ -61,13 +65,11 @@ "bumpp": "^9.2.0", "conventional-changelog-cli": "^2.2.2", "cross-env": "^7.0.3", - "decode-uri-component": "^0.4.1", "eslint": "^8.50.0", "npm-run-all": "^4.1.5", "postcss": "^8.4.30", "postcss-nested": "^6.0.1", "simple-git-hooks": "^2.9.0", - "split-on-first": "^3.0.0", "tsup": "^7.2.0", "typescript": "^5.2.2", "vite": "^4.4.9", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a20285d..f353cf8 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -7,6 +7,13 @@ settings: importers: .: + dependencies: + decode-uri-component: + specifier: ^0.4.1 + version: 0.4.1 + split-on-first: + specifier: ^3.0.0 + version: 3.0.0 devDependencies: '@commitlint/cli': specifier: ^18.0.0 @@ -32,9 +39,6 @@ importers: cross-env: specifier: ^7.0.3 version: 7.0.3 - decode-uri-component: - specifier: ^0.4.1 - version: 0.4.1 eslint: specifier: ^8.50.0 version: 8.50.0 @@ -50,9 +54,6 @@ importers: simple-git-hooks: specifier: ^2.9.0 version: 2.9.0 - split-on-first: - specifier: ^3.0.0 - version: 3.0.0 tsup: specifier: ^7.2.0 version: 7.2.0(postcss@8.4.30)(ts-node@10.9.1)(typescript@5.2.2) @@ -2340,7 +2341,7 @@ packages: /decode-uri-component@0.4.1: resolution: {integrity: sha512-+8VxcR21HhTy8nOt6jf20w0c9CADrw1O8d+VZ/YzzCt4bJ3uBjw+D1q2osAB8RnpwwaeYBxy0HyKQxD5JBMuuQ==} engines: {node: '>=14.16'} - dev: true + dev: false /deep-eql@4.1.3: resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} @@ -5688,7 +5689,7 @@ packages: /split-on-first@3.0.0: resolution: {integrity: sha512-qxQJTx2ryR0Dw0ITYyekNQWpz6f8dGd7vffGNflQQ3Iqj9NJ6qiZ7ELpZsJ/QBhIVAiDfXdag3+Gp8RvWa62AA==} engines: {node: '>=12'} - dev: true + dev: false /split2@3.2.2: resolution: {integrity: sha512-9NThjpgZnifTkJpzTZ7Eue85S49QwpNhZTq6GRJwObb6jnLFNGB7Qm73V5HewTROPyxD0C29xqmaI68bQtV+hg==} diff --git a/tsup.config.ts b/tsup.config.ts index 7bf5a44..c417672 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,19 +1,28 @@ -import { defineConfig } from 'tsup' +import { type Options, defineConfig } from 'tsup' -export const tsup = defineConfig((option) => ({ +const commonConfig = (option: Options): Options => ({ entry: ['src/index.ts'], target: 'node16', dts: !option.watch, clean: true, - format: ['cjs', 'esm'], minify: false, sourcemap: !!option.watch, - esbuildOptions: (options) => { - // postcss plugin export default plugin config - if (options.format === 'cjs') { +}) + +export const tsup = defineConfig((option) => [ + { + format: ['esm'], + ...commonConfig(option), + }, + { + noExternal: ['decode-uri-component', 'split-on-first'], + format: ['cjs'], + esbuildOptions: (options) => { + // postcss plugin export default plugin config options.footer = { js: 'module.exports = module.exports.default;', } - } + }, + ...commonConfig(option), }, -})) +])