From d9c769add3e3fe37b74d11130bb9abd44fe52a35 Mon Sep 17 00:00:00 2001 From: OpportunityLiu Date: Sat, 11 Nov 2023 19:08:06 +0800 Subject: [PATCH] feat: use esbuild, remove deps --- package.json | 17 +- pnpm-lock.yaml | 424 +---------------------------------------- scripts/tool.js | 87 ++++++++- scripts/tool.rollup.js | 7 +- 4 files changed, 94 insertions(+), 441 deletions(-) diff --git a/package.json b/package.json index d23f7f3d..c216674e 100644 --- a/package.json +++ b/package.json @@ -10,14 +10,13 @@ "start:server": "nest start --debug --watch", "build:server": "nest build", "test:server": "NODE_OPTIONS=\"${NODE_OPTIONS:-} --experimental-vm-modules\" jest --config ./test/server/jest.config.js", - "start:tool": "pnpm build:tool --watch", - "build:tool": "node scripts/tool.js", + "start:tool": "node scripts/tool.js --watch", + "build:tool": "node scripts/tool.js --minify", "test:tool": "pnpm tool --help", "tool": "node --trace-deprecation --enable-source-maps -r dotenv/config ./dist/tool", "start:browser": "ng serve", "build:browser": "ng build --configuration production", "test:browser": "echo no test", - "analyze:browser": "webpack-bundle-analyzer --mode=static --default-sizes=gzip --report=dist/browser/report.html dist/browser/stats.json", "clean": "rimraf dist", "format": "prettier --ignore-path .gitignore --write .", "lint": "eslint --ext .ts --ignore-path .gitignore --ignore-pattern '**/*.spec.ts' -- ." @@ -60,7 +59,6 @@ "reflect-metadata": "~0.1.13", "rxjs": "~7.8.1", "simple-git": "~3.20.0", - "source-map-support": "~0.5.21", "tslib": "~2.6.2" }, "devDependencies": { @@ -82,21 +80,17 @@ "@nestjs/cli": "~10.2.1", "@nestjs/schematics": "~10.0.3", "@nestjs/testing": "~10.2.8", - "@rollup/plugin-alias": "^5.0.1", - "@rollup/plugin-commonjs": "^25.0.7", - "@rollup/plugin-json": "^6.0.1", - "@rollup/plugin-node-resolve": "^15.2.3", "@types/cli-color": "~2.0.5", "@types/fs-extra": "~11.0.4", "@types/jest": "~29.5.8", "@types/js-yaml": "~4.0.9", "@types/markdown-it": "~13.0.6", "@types/node": "~20.9.0", - "@types/source-map-support": "~0.5.10", "@types/supertest": "~2.0.16", "@typescript-eslint/eslint-plugin": "~6.10.0", "@typescript-eslint/parser": "~6.10.0", "dotenv": "^16.3.1", + "esbuild": "^0.19.5", "eslint": "~8.53.0", "eslint-config-prettier": "~9.0.0", "eslint-plugin-prettier": "~5.0.1", @@ -105,16 +99,11 @@ "jest-to-match-shape-of": "~1.3.2", "material-design-icons": "^3.0.1", "prettier": "~3.0.3", - "resolve-typescript-plugin": "^2.0.1", "rimraf": "~5.0.5", - "rollup": "^4.3.1", - "rollup-plugin-esbuild": "^6.1.0", "supertest": "~6.3.3", "ts-jest": "~29.1.1", - "tsconfig-paths": "~4.2.0", "type-fest": "~4.7.1", "typescript": "~5.2.2", - "webpack-bundle-analyzer": "~4.9.1", "zone.js": "~0.14.2" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 67cbcbec..73c8ed06 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -104,9 +104,6 @@ dependencies: simple-git: specifier: ~3.20.0 version: 3.20.0 - source-map-support: - specifier: ~0.5.21 - version: 0.5.21 tslib: specifier: ~2.6.2 version: 2.6.2 @@ -163,18 +160,6 @@ devDependencies: '@nestjs/testing': specifier: ~10.2.8 version: 10.2.8(@nestjs/common@10.2.8)(@nestjs/core@10.2.8) - '@rollup/plugin-alias': - specifier: ^5.0.1 - version: 5.0.1(rollup@4.3.1) - '@rollup/plugin-commonjs': - specifier: ^25.0.7 - version: 25.0.7(rollup@4.3.1) - '@rollup/plugin-json': - specifier: ^6.0.1 - version: 6.0.1(rollup@4.3.1) - '@rollup/plugin-node-resolve': - specifier: ^15.2.3 - version: 15.2.3(rollup@4.3.1) '@types/cli-color': specifier: ~2.0.5 version: 2.0.5 @@ -193,9 +178,6 @@ devDependencies: '@types/node': specifier: ~20.9.0 version: 20.9.0 - '@types/source-map-support': - specifier: ~0.5.10 - version: 0.5.10 '@types/supertest': specifier: ~2.0.16 version: 2.0.16 @@ -208,6 +190,9 @@ devDependencies: dotenv: specifier: ^16.3.1 version: 16.3.1 + esbuild: + specifier: ^0.19.5 + version: 0.19.5 eslint: specifier: ~8.53.0 version: 8.53.0 @@ -232,36 +217,21 @@ devDependencies: prettier: specifier: ~3.0.3 version: 3.0.3 - resolve-typescript-plugin: - specifier: ^2.0.1 - version: 2.0.1(webpack@5.89.0) rimraf: specifier: ~5.0.5 version: 5.0.5 - rollup: - specifier: ^4.3.1 - version: 4.3.1 - rollup-plugin-esbuild: - specifier: ^6.1.0 - version: 6.1.0(esbuild@0.19.5)(rollup@4.3.1) supertest: specifier: ~6.3.3 version: 6.3.3 ts-jest: specifier: ~29.1.1 version: 29.1.1(@babel/core@7.23.3)(esbuild@0.19.5)(jest@29.7.0)(typescript@5.2.2) - tsconfig-paths: - specifier: ~4.2.0 - version: 4.2.0 type-fest: specifier: ~4.7.1 version: 4.7.1 typescript: specifier: ~5.2.2 version: 5.2.2 - webpack-bundle-analyzer: - specifier: ~4.9.1 - version: 4.9.1 zone.js: specifier: ~0.14.2 version: 0.14.2 @@ -4189,187 +4159,6 @@ packages: tslib: 2.6.2 dev: true - /@polka/url@1.0.0-next.23: - resolution: {integrity: sha512-C16M+IYz0rgRhWZdCmK+h58JMv8vijAA61gmz2rspCSwKwzBebpdcsiUmwrtJRdphuY30i6BSLEOP8ppbNLyLg==} - dev: true - - /@rollup/plugin-alias@5.0.1(rollup@4.3.1): - resolution: {integrity: sha512-JObvbWdOHoMy9W7SU0lvGhDtWq9PllP5mjpAy+TUslZG/WzOId9u80Hsqq1vCUn9pFJ0cxpdcnAv+QzU2zFH3Q==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - rollup: 4.3.1 - slash: 4.0.0 - dev: true - - /@rollup/plugin-commonjs@25.0.7(rollup@4.3.1): - resolution: {integrity: sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^2.68.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.3.1) - commondir: 1.0.1 - estree-walker: 2.0.2 - glob: 8.1.0 - is-reference: 1.2.1 - magic-string: 0.30.5 - rollup: 4.3.1 - dev: true - - /@rollup/plugin-json@6.0.1(rollup@4.3.1): - resolution: {integrity: sha512-RgVfl5hWMkxN1h/uZj8FVESvPuBJ/uf6ly6GTj0GONnkfoBN5KC0MSz+PN2OLDgYXMhtG0mWpTrkiOjoxAIevw==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.3.1) - rollup: 4.3.1 - dev: true - - /@rollup/plugin-node-resolve@15.2.3(rollup@4.3.1): - resolution: {integrity: sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^2.78.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.3.1) - '@types/resolve': 1.20.2 - deepmerge: 4.3.1 - is-builtin-module: 3.2.1 - is-module: 1.0.0 - resolve: 1.22.8 - rollup: 4.3.1 - dev: true - - /@rollup/pluginutils@5.0.5(rollup@4.3.1): - resolution: {integrity: sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@types/estree': 1.0.5 - estree-walker: 2.0.2 - picomatch: 2.3.1 - rollup: 4.3.1 - dev: true - - /@rollup/rollup-android-arm-eabi@4.3.1: - resolution: {integrity: sha512-D+opNc1CnFmN6EcpG2BXUo9dI/vgoqo6xijv/nUPE1t7Y0Iz9IaXkSjaqw5MJq7B1DUawXfEaIdVCod27IsAOQ==} - cpu: [arm] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-android-arm64@4.3.1: - resolution: {integrity: sha512-3UbtU+7ocBMxYoMCDymHnFYB8tALVaEOjTe5pzAB65AJwXfDFAxADYGCJnBzDXD9u/G+7ktoYnMGYhitYphFkg==} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-darwin-arm64@4.3.1: - resolution: {integrity: sha512-F19xNgrLNnLTS/LFnTdlmxYvkIjFttDSQmJ6/oXLRZpGX+LAoYZpFcz2sYk5l/umk3M34Dfgnvt1fcMfTuIjzA==} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-darwin-x64@4.3.1: - resolution: {integrity: sha512-+63fn9QVEHsDz+ZafHN1R7tAjqfVG4LaFEPeHVcM0YWSNc6vq7UOdi7IUTdQ++RZHev5rYm8GTGwJccULX1XnQ==} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-arm-gnueabihf@4.3.1: - resolution: {integrity: sha512-eG/9q+W0KPLu4xG3EwqDsG+wz9VoPMW0IDZ4bXdq2yyi2qA/CcmHb5956ZOw9PPAmL2krHvDaPyQIzFkZP0BLA==} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-arm64-gnu@4.3.1: - resolution: {integrity: sha512-zjnPmrnXz59M6SaVwJSD0bWQ3ljFxpDMDVDi94Xn60/XX/qokZco9/psvu4hSvV+3A4OKwt4XwAULygXwN8y5w==} - cpu: [arm64] - os: [linux] - libc: [glibc] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-arm64-musl@4.3.1: - resolution: {integrity: sha512-/QqGJI0Jk/Ln32EmpkJYmwpKIe+Da40zmJL8YYvJKYQWhvj7qYOJM6HntQndTWNpF5/33vpLVhngCaHqmiVhNg==} - cpu: [arm64] - os: [linux] - libc: [musl] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-x64-gnu@4.3.1: - resolution: {integrity: sha512-Q1nbux0VbjeSSYns31wa4r8pssxg/bmYD7kH9ArSfSLxN0OaJaDTaBfHuGC/Ou7dWbg83ca0YQTYHQ6rzZVvgg==} - cpu: [x64] - os: [linux] - libc: [glibc] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-linux-x64-musl@4.3.1: - resolution: {integrity: sha512-5i71ndo6vZ/EaYpWV8h0TypEc5lCmPru6hST35XiTzV9XUtvbLDfbD2T3nSU5MeQMZVgQHCHXelsH3KCGTA8WA==} - cpu: [x64] - os: [linux] - libc: [musl] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-win32-arm64-msvc@4.3.1: - resolution: {integrity: sha512-aYKKmlrLL7C0oY43B2Q4uMIlfF1BsSlSYf3R7q7SGB/SrK7Tkj2DHuxqBSYuFqSxuYuAP4PaHt230McvMpZg5A==} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-win32-ia32-msvc@4.3.1: - resolution: {integrity: sha512-/B5g1WqoXecmHyVsXsSGWfGE+QqiSIMk2I4+EOGcziXfZsUHoUbwXwaiAy5Sir/xUwdi9nEZDqj4jxwMchZPkQ==} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: true - optional: true - - /@rollup/rollup-win32-x64-msvc@4.3.1: - resolution: {integrity: sha512-2cRSO5SflYT21SKh1G+2zchLUotL2g7/jhYxbeFpJ8gfVU6CMd2YiIfN++Rs8kzTsuwaTqrE8CAK8GORqoVOeQ==} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: true - optional: true - /@schematics/angular@17.0.0: resolution: {integrity: sha512-9jKU5x/WzaBsfSkUowK1X74FqtMXa6+A60XgW4ACO8i6fwKfPeS+tIrAieeYOX80/njBh7I5CvcpHmWA2SbcXQ==} engines: {node: ^18.13.0 || >=20.9.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} @@ -4675,10 +4464,6 @@ packages: resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} dev: true - /@types/resolve@1.20.2: - resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} - dev: true - /@types/retry@0.12.0: resolution: {integrity: sha512-wWKOClTTiizcZhXnPY4wikVAwmdYHp8q6DmC+EJUzAMsycb7HB32Kh9RN4+0gExjmPmZSAQjgURXIGATPegAvA==} dev: true @@ -4714,12 +4499,6 @@ packages: '@types/node': 20.9.0 dev: true - /@types/source-map-support@0.5.10: - resolution: {integrity: sha512-tgVP2H469x9zq34Z0m/fgPewGhg/MLClalNOiPIzQlXrSS2YrKu/xCdSCKnEDwkFha51VKEKB6A9wW26/ZNwzA==} - dependencies: - source-map: 0.6.1 - dev: true - /@types/stack-utils@2.0.3: resolution: {integrity: sha512-9aEbYZ3TbYMznPdcdr3SmIrLXwC/AKZXQeCf9Pgao5CKb8CyHuEX5jzWPTkvregvhRJHcpRO6BFoGW9ycaOkYw==} dev: true @@ -5068,11 +4847,6 @@ packages: acorn: 8.11.2 dev: true - /acorn-walk@8.3.0: - resolution: {integrity: sha512-FS7hV565M5l1R08MXqo8odwMTB02C2UqzB17RVgu9EyuYFBqJZ3/ZY97sQD5FewVu1UyDFc1yztUDrAwT0EypA==} - engines: {node: '>=0.4.0'} - dev: true - /acorn@8.11.2: resolution: {integrity: sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==} engines: {node: '>=0.4.0'} @@ -5629,6 +5403,7 @@ packages: /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + dev: true /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} @@ -5644,11 +5419,6 @@ packages: ieee754: 1.2.1 dev: false - /builtin-modules@3.3.0: - resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} - engines: {node: '>=6'} - dev: true - /builtins@5.0.1: resolution: {integrity: sha512-qwVpFEHNfhYJIzNRBvd2C1kyo6jz3ZSMPyyuR47OPdiKWlbYnZNyDWuyR175qDnAJLiCo5fBBqPb3RiXgWlkOQ==} dependencies: @@ -5934,11 +5704,6 @@ packages: engines: {node: '>= 6'} dev: true - /commander@7.2.0: - resolution: {integrity: sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==} - engines: {node: '>= 10'} - dev: true - /comment-json@4.2.3: resolution: {integrity: sha512-SsxdiOf064DWoZLH799Ata6u7iV658A11PlWtZATDlXPpKGJnbJZ5Z24ybixAi+LUUqJ/GKowAejtC5GFUG7Tw==} engines: {node: '>= 6'} @@ -5954,10 +5719,6 @@ packages: resolution: {integrity: sha512-QE33hToZseCH3jS0qN96O/bSh3kaw/h+Tq7ngyY9eWDUnTlTNUyqfqvCXioLe5Na5jFsL78ra/wuBU4iuEgd4w==} dev: true - /commondir@1.0.1: - resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} - dev: true - /component-emitter@1.3.0: resolution: {integrity: sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg==} dev: true @@ -6422,10 +6183,6 @@ packages: resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} engines: {node: '>=12'} - /duplexer@0.1.2: - resolution: {integrity: sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==} - dev: true - /eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} dev: true @@ -6843,10 +6600,6 @@ packages: engines: {node: '>=4.0'} dev: true - /estree-walker@2.0.2: - resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} - dev: true - /esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} @@ -7409,12 +7162,6 @@ packages: engines: {node: '>=10'} dev: true - /get-tsconfig@4.7.2: - resolution: {integrity: sha512-wuMsz4leaj5hbGgg4IvDU0bqJagpftG5l5cXIAvo8uZrqn0NJqwtfupTN00VnkQJPcIRrxYrm1Ue24btpCha2A==} - dependencies: - resolve-pkg-maps: 1.0.0 - dev: true - /glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -7465,6 +7212,7 @@ packages: inherits: 2.0.4 minimatch: 5.1.6 once: 1.4.0 + dev: false /glob@9.3.5: resolution: {integrity: sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==} @@ -7524,13 +7272,6 @@ packages: resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==} dev: true - /gzip-size@6.0.0: - resolution: {integrity: sha512-ax7ZYomf6jqPTQ4+XCpUGyXKHk5WweS+e05MBO4/y3WJ5RkmPXNKvX+bx1behVILVwr6JSQvZAku021CHPXG3Q==} - engines: {node: '>=10'} - dependencies: - duplexer: 0.1.2 - dev: true - /handle-thing@2.0.1: resolution: {integrity: sha512-9Qn4yBxelxoh2Ow62nP+Ka/kMnOXRi8BXnRaUwezLNhqelnN49xKz4F/dPP8OYLxLxq6JDtZb2i9XznUQbNPTg==} dev: true @@ -7915,13 +7656,6 @@ packages: binary-extensions: 2.2.0 dev: true - /is-builtin-module@3.2.1: - resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} - engines: {node: '>=6'} - dependencies: - builtin-modules: 3.3.0 - dev: true - /is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} dependencies: @@ -7979,10 +7713,6 @@ packages: resolution: {integrity: sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==} dev: true - /is-module@1.0.0: - resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} - dev: true - /is-number-like@1.0.8: resolution: {integrity: sha512-6rZi3ezCyFcn5L71ywzz2bS5b2Igl1En3eTlZlvKjpz1n3IZLAYMbKYAIQgFmEu0GENg92ziU/faEOA/aixjbA==} dependencies: @@ -8014,17 +7744,12 @@ packages: /is-plain-object@5.0.0: resolution: {integrity: sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==} engines: {node: '>=0.10.0'} + dev: false /is-promise@2.2.2: resolution: {integrity: sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==} dev: false - /is-reference@1.2.1: - resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} - dependencies: - '@types/estree': 1.0.5 - dev: true - /is-stream@2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -8913,22 +8638,10 @@ packages: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} dev: true - /lodash.escape@4.0.1: - resolution: {integrity: sha512-nXEOnb/jK9g0DYMr1/Xvq6l5xMD7GDG55+GSYIYmS0G4tBk/hURD4JR9WCavs04t33WmJx9kCyp9vJ+mr4BOUw==} - dev: true - - /lodash.flatten@4.4.0: - resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==} - dev: true - /lodash.includes@4.3.0: resolution: {integrity: sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==} dev: false - /lodash.invokemap@4.6.0: - resolution: {integrity: sha512-CfkycNtMqgUlfjfdh2BhKO/ZXrP8ePOX5lEU/g0R3ItJcnuxWDwokMGKx1hWcfOikmyOVx6X9IwWnDGlgKl61w==} - dev: true - /lodash.isboolean@3.0.3: resolution: {integrity: sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==} dev: false @@ -8965,14 +8678,6 @@ packages: resolution: {integrity: sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==} dev: false - /lodash.pullall@4.2.0: - resolution: {integrity: sha512-VhqxBKH0ZxPpLhiu68YD1KnHmbhQJQctcipvmFnqIBDYzcIHzf3Zpu0tpeOKtR4x76p9yohc506eGdOjTmyIBg==} - dev: true - - /lodash.uniqby@4.7.0: - resolution: {integrity: sha512-e/zcLx6CSbmaEgFHCA7BnoQKyCtKMxnuWrJygbwPs/AIn+IMKl66L8/s+wBUn5LRw2pZx3bUHibiV1b6aTWIww==} - dev: true - /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -9211,6 +8916,7 @@ packages: engines: {node: '>=10'} dependencies: brace-expansion: 2.0.1 + dev: false /minimatch@8.0.4: resolution: {integrity: sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==} @@ -9662,11 +9368,6 @@ packages: is-wsl: 2.2.0 dev: true - /opener@1.5.2: - resolution: {integrity: sha512-ur5UIdyw5Y7yEj9wLzhqXiy6GZ3Mwx0yGI+5sMn2r0N0v3cKJvUmFH5yPP+WXh9e0xfyzyJX95D8l088DNFj7A==} - hasBin: true - dev: true - /openurl@1.1.1: resolution: {integrity: sha512-d/gTkTb1i1GKz5k3XE3XFV/PxQ1k45zDqGP2OA7YhgsaLoqm6qRvARAZOFer1fcXritWlGBRCu/UgeS4HAnXAA==} dev: true @@ -10408,20 +10109,6 @@ packages: engines: {node: '>=8'} dev: true - /resolve-pkg-maps@1.0.0: - resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} - dev: true - - /resolve-typescript-plugin@2.0.1(webpack@5.89.0): - resolution: {integrity: sha512-n0FdUHSo8vkT6omKdE+Gda7api6PzIwsoYH4RTH0tUpRq46hk8dOcWZpzBwpoJyjSz3OxHIC/hKGL8LB8B09GQ==} - engines: {node: ^14 || ^16 || >=18} - peerDependencies: - webpack: ^4.0.0 || ^5.0.0 - dependencies: - tslib: 2.5.0 - webpack: 5.89.0(esbuild@0.19.5) - dev: true - /resolve-url-loader@5.0.0: resolution: {integrity: sha512-uZtduh8/8srhBoMx//5bwqjQ+rfYOUq8zC9NrMUGtjBiGTtFJM42s58/36+hTqeqINcnYe08Nj3LkK9lW4N8Xg==} engines: {node: '>=12'} @@ -10511,23 +10198,6 @@ packages: glob: 10.3.10 dev: true - /rollup-plugin-esbuild@6.1.0(esbuild@0.19.5)(rollup@4.3.1): - resolution: {integrity: sha512-HPpXU65V8bSpW8eSYPahtUJaJHmbxJGybuf/M8B3bz/6i11YaYHlNNJIQ38gSEV0FyohQOgVxJ2YMEEZtEmwvA==} - engines: {node: '>=14.18.0'} - peerDependencies: - esbuild: '>=0.18.0' - rollup: ^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0 - dependencies: - '@rollup/pluginutils': 5.0.5(rollup@4.3.1) - debug: 4.3.4 - es-module-lexer: 1.4.0 - esbuild: 0.19.5 - get-tsconfig: 4.7.2 - rollup: 4.3.1 - transitivePeerDependencies: - - supports-color - dev: true - /rollup@3.29.4: resolution: {integrity: sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==} engines: {node: '>=14.18.0', npm: '>=8.0.0'} @@ -10536,26 +10206,6 @@ packages: fsevents: 2.3.3 dev: true - /rollup@4.3.1: - resolution: {integrity: sha512-gkvK/OnwbyacmUVjxNzuMMqSihBVQSdX9OtZkThN946cpMHA7izVzc03tHg3NVAeWXUNPzkrP7RW/rV68a42BA==} - engines: {node: '>=18.0.0', npm: '>=8.0.0'} - hasBin: true - optionalDependencies: - '@rollup/rollup-android-arm-eabi': 4.3.1 - '@rollup/rollup-android-arm64': 4.3.1 - '@rollup/rollup-darwin-arm64': 4.3.1 - '@rollup/rollup-darwin-x64': 4.3.1 - '@rollup/rollup-linux-arm-gnueabihf': 4.3.1 - '@rollup/rollup-linux-arm64-gnu': 4.3.1 - '@rollup/rollup-linux-arm64-musl': 4.3.1 - '@rollup/rollup-linux-x64-gnu': 4.3.1 - '@rollup/rollup-linux-x64-musl': 4.3.1 - '@rollup/rollup-win32-arm64-msvc': 4.3.1 - '@rollup/rollup-win32-ia32-msvc': 4.3.1 - '@rollup/rollup-win32-x64-msvc': 4.3.1 - fsevents: 2.3.3 - dev: true - /run-applescript@5.0.0: resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==} engines: {node: '>=12'} @@ -10892,15 +10542,6 @@ packages: - supports-color dev: false - /sirv@2.0.3: - resolution: {integrity: sha512-O9jm9BsID1P+0HOi81VpXPoDxYP374pkOLzACAoyUQ/3OUVndNpsz6wMnY2z+yOxzbllCKZrM+9QrWsv4THnyA==} - engines: {node: '>= 10'} - dependencies: - '@polka/url': 1.0.0-next.23 - mrmime: 1.0.1 - totalist: 3.0.1 - dev: true - /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} dev: true @@ -11032,10 +10673,12 @@ packages: dependencies: buffer-from: 1.1.2 source-map: 0.6.1 + dev: true /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + dev: true /source-map@0.7.4: resolution: {integrity: sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==} @@ -11406,11 +11049,6 @@ packages: resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} engines: {node: '>=0.6'} - /totalist@3.0.1: - resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} - engines: {node: '>=6'} - dev: true - /tr46@0.0.3: resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==} @@ -11481,10 +11119,6 @@ packages: strip-bom: 3.0.0 dev: true - /tslib@2.5.0: - resolution: {integrity: sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==} - dev: true - /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} @@ -11781,33 +11415,6 @@ packages: /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} - /webpack-bundle-analyzer@4.9.1: - resolution: {integrity: sha512-jnd6EoYrf9yMxCyYDPj8eutJvtjQNp8PHmni/e/ulydHBWhT5J3menXt3HEkScsu9YqMAcG4CfFjs3rj5pVU1w==} - engines: {node: '>= 10.13.0'} - hasBin: true - dependencies: - '@discoveryjs/json-ext': 0.5.7 - acorn: 8.11.2 - acorn-walk: 8.3.0 - commander: 7.2.0 - escape-string-regexp: 4.0.0 - gzip-size: 6.0.0 - is-plain-object: 5.0.0 - lodash.debounce: 4.0.8 - lodash.escape: 4.0.1 - lodash.flatten: 4.4.0 - lodash.invokemap: 4.6.0 - lodash.pullall: 4.2.0 - lodash.uniqby: 4.7.0 - opener: 1.5.2 - picocolors: 1.0.0 - sirv: 2.0.3 - ws: 7.5.9 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - /webpack-dev-middleware@5.3.3(webpack@5.89.0): resolution: {integrity: sha512-hj5CYrY0bZLB+eTO+x/j67Pkrquiy7kWepMHmUMoPsmcUaeEnQJqFzHJOyxgWlq746/wUuA64p9ta34Kyb01pA==} engines: {node: '>= 12.13.0'} @@ -12048,19 +11655,6 @@ packages: signal-exit: 3.0.7 dev: true - /ws@7.5.9: - resolution: {integrity: sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==} - engines: {node: '>=8.3.0'} - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ^5.0.2 - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - dev: true - /ws@8.11.0: resolution: {integrity: sha512-HPG3wQd9sNQoT9xHyNCXoDUa+Xw/VevmY9FoHyQ+g+rrMn4j6FB4np7Z0OhdTgjx6MgQLK7jwSy1YecU1+4Asg==} engines: {node: '>=10.0.0'} diff --git a/scripts/tool.js b/scripts/tool.js index 0b86bec7..d539c71c 100644 --- a/scripts/tool.js +++ b/scripts/tool.js @@ -1,10 +1,85 @@ // @ts-check -import { spawn } from 'node:child_process'; +import { createRequire } from 'node:module'; import path from 'node:path'; +import fs from 'fs-extra'; +import esbuild from 'esbuild'; -const [node, script, ...args] = process.argv; -const p = spawn(`rollup`, ['-c', path.resolve(script, '../tool.rollup.js'), ...args], { - stdio: 'inherit', - shell: true, +const watch = process.argv.includes('--watch'); +const minify = process.argv.includes('--minify'); + +const external = []; + +/** @type {import('type-fest').PackageJson} */ +const packageJson = await fs.readJSON('./package.json'); +const imports = packageJson.imports ?? {}; +packageJson.scripts = undefined; +packageJson.devDependencies = undefined; +packageJson.resolutions = undefined; +packageJson.browser = undefined; +packageJson.type = 'module'; +packageJson.imports = undefined; +for (const key in /** @type {object | undefined} */ (packageJson.exports)) { + const value = packageJson.exports[key]; + if (typeof value == 'string') { + packageJson.exports[key] = value.replace(/^.\/dist\//, './'); + } +} +if (!watch) { + packageJson.dependencies = {}; + const require = createRequire(import.meta.url); + for (const ext of external) { + /** @type {import('type-fest').PackageJson} */ + const resolved = require(ext + '/package.json'); + packageJson.dependencies[ext] = resolved.version; + } +} else { + for (const ext in packageJson.dependencies) { + external.push(ext); + } +} + +await fs.emptyDir('./dist/tool/'); +await fs.writeJSON('./dist/tool/package.json', packageJson); + +const configCommon = /** @satisfies { esbuild.BuildOptions } */ ({ + external: undefined, + outdir: './dist/tool/', + minify, + charset: 'utf8', + metafile: true, + bundle: true, + sourcemap: true, + sourcesContent: false, }); -p.on('error', (...args) => console.log(args)); +const configMain = /** @satisfies { esbuild.BuildOptions } */ ({ + ...configCommon, + entryPoints: ['./src/tool/index.ts'], + format: 'esm', + platform: 'node', + target: 'es2020', + banner: { + js: /* js */ ` + import { createRequire as __createRequire } from 'node:module'; + const require = __createRequire(import.meta.url); + ` + .split('\n') + .map((line) => line.trim()) + .join(''), + }, +}); +const configJsonp = /** @satisfies { esbuild.BuildOptions } */ ({ + ...configCommon, + entryPoints: ['./tools/flate.js'], + format: 'iife', + target: 'es6', + minify: true, +}); + +if (watch) { + const [contextMain, contextJsonp] = await Promise.all([esbuild.context(configMain), esbuild.context(configJsonp)]); + await Promise.all([contextMain.watch(), contextJsonp.watch()]); +} else { + const [resultMain, resultJsonp] = await Promise.all([esbuild.build(configMain), esbuild.build(configJsonp)]); + await fs.writeJSON('./dist/tool-index.json', resultMain.metafile); + await fs.writeJSON('./dist/tool-flate.json', resultJsonp.metafile); +} diff --git a/scripts/tool.rollup.js b/scripts/tool.rollup.js index 0cbb5b52..78dbc93c 100644 --- a/scripts/tool.rollup.js +++ b/scripts/tool.rollup.js @@ -2,12 +2,7 @@ import fs from 'fs-extra'; import path from 'node:path'; import { createRequire } from 'node:module'; -import { defineConfig } from 'rollup'; -import esbuild from 'rollup-plugin-esbuild'; -import commonjs from '@rollup/plugin-commonjs'; -import nodeResolve from '@rollup/plugin-node-resolve'; -import json from '@rollup/plugin-json'; -import alias from '@rollup/plugin-alias'; +import esbuild from 'esbuild'; const watch = process.argv.includes('--watch'); const minify = process.argv.includes('--minify');