From f1f21c50ddc02d71d33cabde364dfe98abd71aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Wed, 17 Jul 2024 04:10:38 +0800 Subject: [PATCH] refactor: upgrade TS & enable `verbatimModuleSyntax` --- package.json | 4 +- pnpm-lock.yaml | 321 ++++-------------------------- src/api-extractor.ts | 2 +- src/cli-main.ts | 2 +- src/esbuild/external.ts | 2 +- src/esbuild/index.ts | 10 +- src/esbuild/native-node-module.ts | 2 +- src/esbuild/node-protocol.ts | 2 +- src/esbuild/postcss.ts | 2 +- src/esbuild/svelte.ts | 2 +- src/esbuild/swc.ts | 6 +- src/index.ts | 6 +- src/lib/report-size.ts | 2 +- src/options.ts | 2 +- src/plugin.ts | 20 +- src/plugins/cjs-interop.ts | 2 +- src/plugins/cjs-splitting.ts | 2 +- src/plugins/shebang.ts | 2 +- src/plugins/size-reporter.ts | 2 +- src/plugins/swc-target.ts | 2 +- src/plugins/terser.ts | 8 +- src/plugins/tree-shaking.ts | 4 +- src/rollup.ts | 6 +- src/rollup/ts-resolve.ts | 2 +- src/tsc.ts | 4 +- src/utils.ts | 2 +- test/example.test.ts | 6 +- tsconfig.json | 4 +- 28 files changed, 95 insertions(+), 336 deletions(-) diff --git a/package.json b/package.json index 214855f77..f919429e1 100644 --- a/package.json +++ b/package.json @@ -69,8 +69,8 @@ "terser": "^5.16.0", "ts-essentials": "9.1.2", "tsconfig-paths": "3.12.0", - "tsup": "7.1.0", - "typescript": "5.0.2", + "tsup": "8.1.0", + "typescript": "5.5.3", "vitest": "2.0.3", "wait-for-expect": "3.0.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86c51f267..2e8a7ee59 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -101,7 +101,7 @@ importers: version: 1.20.0 rollup-plugin-dts: specifier: 6.1.0 - version: 6.1.0(rollup@4.0.2)(typescript@5.0.2) + version: 6.1.0(rollup@4.0.2)(typescript@5.5.3) sass: specifier: 1.62.1 version: 1.62.1 @@ -113,22 +113,22 @@ importers: version: 3.46.4 svelte-preprocess: specifier: 5.0.3 - version: 5.0.3(postcss-load-config@4.0.1(postcss@8.4.12))(postcss@8.4.12)(sass@1.62.1)(svelte@3.46.4)(typescript@5.0.2) + version: 5.0.3(postcss-load-config@4.0.1(postcss@8.4.12))(postcss@8.4.12)(sass@1.62.1)(svelte@3.46.4)(typescript@5.5.3) terser: specifier: ^5.16.0 version: 5.16.0 ts-essentials: specifier: 9.1.2 - version: 9.1.2(typescript@5.0.2) + version: 9.1.2(typescript@5.5.3) tsconfig-paths: specifier: 3.12.0 version: 3.12.0 tsup: - specifier: 7.1.0 - version: 7.1.0(@swc/core@1.2.218)(postcss@8.4.12)(typescript@5.0.2) + specifier: 8.1.0 + version: 8.1.0(@microsoft/api-extractor@7.38.3(@types/node@14.18.12))(@swc/core@1.2.218)(postcss@8.4.12)(typescript@5.5.3) typescript: - specifier: 5.0.2 - version: 5.0.2 + specifier: 5.5.3 + version: 5.5.3 vitest: specifier: 2.0.3 version: 2.0.3(@types/node@14.18.12)(sass@1.62.1)(terser@5.16.0) @@ -160,264 +160,132 @@ packages: cpu: [ppc64] os: [aix] - '@esbuild/android-arm64@0.18.2': - resolution: {integrity: sha512-1Y2pb0hLdmji8I0zBwNsYSDN7zJSQqufgLOuOsrrod00WEAgKywQR5MB/E046Is/YTP4bgcPS4BioaSDBaLaTg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - '@esbuild/android-arm64@0.21.4': resolution: {integrity: sha512-fYFnz+ObClJ3dNiITySBUx+oNalYUT18/AryMxfovLkYWbutXsct3Wz2ZWAcGGppp+RVVX5FiXeLYGi97umisA==} engines: {node: '>=12'} cpu: [arm64] os: [android] - '@esbuild/android-arm@0.18.2': - resolution: {integrity: sha512-YAnQBHlY0IvYtvY0avnXjI8ywW23emEjk5XExqbFmypath+Snq9MgY1IS47rnqBKVSqnl0ElDt221ZgaeRrkXg==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - '@esbuild/android-arm@0.21.4': resolution: {integrity: sha512-E7H/yTd8kGQfY4z9t3nRPk/hrhaCajfA3YSQSBrst8B+3uTcgsi8N+ZWYCaeIDsiVs6m65JPCaQN/DxBRclF3A==} engines: {node: '>=12'} cpu: [arm] os: [android] - '@esbuild/android-x64@0.18.2': - resolution: {integrity: sha512-P047Mh3pj8uYVE3A/B3QDX6nG8dKbHLJ+48R6Y0CRXCJ5PkXJxdHOTaS8SYs6eSR3FFU6/YQ5TishQXVHX7F5A==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - '@esbuild/android-x64@0.21.4': resolution: {integrity: sha512-mDqmlge3hFbEPbCWxp4fM6hqq7aZfLEHZAKGP9viq9wMUBVQx202aDIfc3l+d2cKhUJM741VrCXEzRFhPDKH3Q==} engines: {node: '>=12'} cpu: [x64] os: [android] - '@esbuild/darwin-arm64@0.18.2': - resolution: {integrity: sha512-a3Rkqd0tGVYMEKNy9SstWEdeBmM60l8FVD5o4rmwHr3xO1LbLqtCJSrWGbnf37hevo6m437mURVmpEHOmkXeTA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - '@esbuild/darwin-arm64@0.21.4': resolution: {integrity: sha512-72eaIrDZDSiWqpmCzVaBD58c8ea8cw/U0fq/PPOTqE3c53D0xVMRt2ooIABZ6/wj99Y+h4ksT/+I+srCDLU9TA==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] - '@esbuild/darwin-x64@0.18.2': - resolution: {integrity: sha512-cvH58adz9L10JNsIcgtkWNS/1eutjRTi3rtWz1s3ZhR64BpdmkxJBAXE/UjqybyNAWLhaN8mPJdlYI2f+tQA7g==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - '@esbuild/darwin-x64@0.21.4': resolution: {integrity: sha512-uBsuwRMehGmw1JC7Vecu/upOjTsMhgahmDkWhGLWxIgUn2x/Y4tIwUZngsmVb6XyPSTXJYS4YiASKPcm9Zitag==} engines: {node: '>=12'} cpu: [x64] os: [darwin] - '@esbuild/freebsd-arm64@0.18.2': - resolution: {integrity: sha512-68rGMGUdgmq+c5IvseCMqY4yaa2CAY/DIILMBA6bEU1caISF7fXnV69B1uU4s3ERuVDcasVVwiAFyNxCtkS6Zg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - '@esbuild/freebsd-arm64@0.21.4': resolution: {integrity: sha512-8JfuSC6YMSAEIZIWNL3GtdUT5NhUA/CMUCpZdDRolUXNAXEE/Vbpe6qlGLpfThtY5NwXq8Hi4nJy4YfPh+TwAg==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] - '@esbuild/freebsd-x64@0.18.2': - resolution: {integrity: sha512-ZSR9On/rXoYuAtrXo5hYKy7OuZwKZyFh2rr6L3TX4UeR1tWLf84aLyAFt7e0tlRbh4zNgqFx+ePWmsSHw7L9Bw==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - '@esbuild/freebsd-x64@0.21.4': resolution: {integrity: sha512-8d9y9eQhxv4ef7JmXny7591P/PYsDFc4+STaxC1GBv0tMyCdyWfXu2jBuqRsyhY8uL2HU8uPyscgE2KxCY9imQ==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] - '@esbuild/linux-arm64@0.18.2': - resolution: {integrity: sha512-DFKavAzbu/n9HXWuetxmYN10XnfzW7FgOgpcrGD8eXaiu77KdgB+OVWA83x9FtDYtsoFpfdlDuVFAQFfrhu77A==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - '@esbuild/linux-arm64@0.21.4': resolution: {integrity: sha512-/GLD2orjNU50v9PcxNpYZi+y8dJ7e7/LhQukN3S4jNDXCKkyyiyAz9zDw3siZ7Eh1tRcnCHAo/WcqKMzmi4eMQ==} engines: {node: '>=12'} cpu: [arm64] os: [linux] - '@esbuild/linux-arm@0.18.2': - resolution: {integrity: sha512-jAbA75qJ70T5AOdmw9X8675ppeRfj7j57sOypoZ4mQlfQ/LKF8eoeLzTYVo8+aqLKqeIIl0vQ4hKOB0FyG98Zg==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - '@esbuild/linux-arm@0.21.4': resolution: {integrity: sha512-2rqFFefpYmpMs+FWjkzSgXg5vViocqpq5a1PSRgT0AvSgxoXmGF17qfGAzKedg6wAwyM7UltrKVo9kxaJLMF/g==} engines: {node: '>=12'} cpu: [arm] os: [linux] - '@esbuild/linux-ia32@0.18.2': - resolution: {integrity: sha512-VEaK3Z+vJyDwwPsP0sovaEw1foDzrMs7XQNYEIFkOwMjSe2BipKRKUUyrznil0p8qqsK7U8W+T7oNqZpgdnD2Q==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - '@esbuild/linux-ia32@0.21.4': resolution: {integrity: sha512-pNftBl7m/tFG3t2m/tSjuYeWIffzwAZT9m08+9DPLizxVOsUl8DdFzn9HvJrTQwe3wvJnwTdl92AonY36w/25g==} engines: {node: '>=12'} cpu: [ia32] os: [linux] - '@esbuild/linux-loong64@0.18.2': - resolution: {integrity: sha512-Af1uZdB0oeJo4PW67l9aw94oakSamFxhC6ltC2eDkndozd9QygVNMTF7s7uxTLjo+BJqyVqG9wjmLCYF1o4NmA==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - '@esbuild/linux-loong64@0.21.4': resolution: {integrity: sha512-cSD2gzCK5LuVX+hszzXQzlWya6c7hilO71L9h4KHwqI4qeqZ57bAtkgcC2YioXjsbfAv4lPn3qe3b00Zt+jIfQ==} engines: {node: '>=12'} cpu: [loong64] os: [linux] - '@esbuild/linux-mips64el@0.18.2': - resolution: {integrity: sha512-WcTbt61+9dREuOFKXac4Qg+3OuRhLxPL9lmkI2P7fGuq/fWS2qq+AvGGVLMyk+OtXGDjyQolcEDeYlRoOmjRYQ==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - '@esbuild/linux-mips64el@0.21.4': resolution: {integrity: sha512-qtzAd3BJh7UdbiXCrg6npWLYU0YpufsV9XlufKhMhYMJGJCdfX/G6+PNd0+v877X1JG5VmjBLUiFB0o8EUSicA==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] - '@esbuild/linux-ppc64@0.18.2': - resolution: {integrity: sha512-Ov+VHayvCPb52axma6+xm8QDawRjwHscPXedHg4U92DxlhKQ0H+6onRiC3J9kKI50p8pKKypprpCWrRrXjZN7Q==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - '@esbuild/linux-ppc64@0.21.4': resolution: {integrity: sha512-yB8AYzOTaL0D5+2a4xEy7OVvbcypvDR05MsB/VVPVA7nL4hc5w5Dyd/ddnayStDgJE59fAgNEOdLhBxjfx5+dg==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] - '@esbuild/linux-riscv64@0.18.2': - resolution: {integrity: sha512-qW37zzKKN9C5l5LnVDriOK0eZRzQeixhtrfd5C78PAsTE15GeHU9G0oyT/u/IkNjEBjXWpTZOOHKNbjhrvuL9g==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - '@esbuild/linux-riscv64@0.21.4': resolution: {integrity: sha512-Y5AgOuVzPjQdgU59ramLoqSSiXddu7F3F+LI5hYy/d1UHN7K5oLzYBDZe23QmQJ9PIVUXwOdKJ/jZahPdxzm9w==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] - '@esbuild/linux-s390x@0.18.2': - resolution: {integrity: sha512-izzEFMRO8LaQIlX22+fTgP5I7Os3T51mtAWsRNpZ5pMfQIa9PqtgFAoRcb10DV+/YkH/TMMxQIlevUvDS6E4vw==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - '@esbuild/linux-s390x@0.21.4': resolution: {integrity: sha512-Iqc/l/FFwtt8FoTK9riYv9zQNms7B8u+vAI/rxKuN10HgQIXaPzKZc479lZ0x6+vKVQbu55GdpYpeNWzjOhgbA==} engines: {node: '>=12'} cpu: [s390x] os: [linux] - '@esbuild/linux-x64@0.18.2': - resolution: {integrity: sha512-y5yqQ1ww4FfI9bQ1ZP/0k1rcgA6Ql2/AgzvqpowN0Q5tXDZkCavPdJbFXKrqA43vd1UTXt+AutTHYJ7km6e2Eg==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - '@esbuild/linux-x64@0.21.4': resolution: {integrity: sha512-Td9jv782UMAFsuLZINfUpoF5mZIbAj+jv1YVtE58rFtfvoKRiKSkRGQfHTgKamLVT/fO7203bHa3wU122V/Bdg==} engines: {node: '>=12'} cpu: [x64] os: [linux] - '@esbuild/netbsd-x64@0.18.2': - resolution: {integrity: sha512-usNjpKFf83X4o60gdMD47NCblaSZ6DARf31/FyCzxOgnF80mJ+RhDs9RTqgyfH8KyduO5mjgInw9+ct286ayYA==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - '@esbuild/netbsd-x64@0.21.4': resolution: {integrity: sha512-Awn38oSXxsPMQxaV0Ipb7W/gxZtk5Tx3+W+rAPdZkyEhQ6968r9NvtkjhnhbEgWXYbgV+JEONJ6PcdBS+nlcpA==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] - '@esbuild/openbsd-x64@0.18.2': - resolution: {integrity: sha512-6urzy1+VwcPuhG+5jwHA8lD9E87E5+ey3qKw2EhRS+qUmMxLvfwP8szWC2JHVGZDPEDge6fgn0pBj+y9rxDLwQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - '@esbuild/openbsd-x64@0.21.4': resolution: {integrity: sha512-IsUmQeCY0aU374R82fxIPu6vkOybWIMc3hVGZ3ChRwL9hA1TwY+tS0lgFWV5+F1+1ssuvvXt3HFqe8roCip8Hg==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] - '@esbuild/sunos-x64@0.18.2': - resolution: {integrity: sha512-SMZPTACsvpKYAIl9o8nhnmMn6/lp62iMeV/2EBMtj+sW6dXwW9b0cLjihkBv4PG1CCRlwWKPZo43imqZxC95ZA==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - '@esbuild/sunos-x64@0.21.4': resolution: {integrity: sha512-hsKhgZ4teLUaDA6FG/QIu2q0rI6I36tZVfM4DBZv3BG0mkMIdEnMbhc4xwLvLJSS22uWmaVkFkqWgIS0gPIm+A==} engines: {node: '>=12'} cpu: [x64] os: [sunos] - '@esbuild/win32-arm64@0.18.2': - resolution: {integrity: sha512-H2zzjPdzSDNwUnZdZf9/xfm0CYqHFXuenCMAx+tRzIRqWUT6MmZ9/q7722KnAZ6uPpq0RLs7EjCIIfmt6CaRGg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - '@esbuild/win32-arm64@0.21.4': resolution: {integrity: sha512-UUfMgMoXPoA/bvGUNfUBFLCh0gt9dxZYIx9W4rfJr7+hKe5jxxHmfOK8YSH4qsHLLN4Ck8JZ+v7Q5fIm1huErg==} engines: {node: '>=12'} cpu: [arm64] os: [win32] - '@esbuild/win32-ia32@0.18.2': - resolution: {integrity: sha512-lfyjTN+FrKgvNvrH7nOLtaz58J/8coZOo4LQwgBMP4D7ZOurhvluXS3GjePLzq9GbWnJDZdKCKbMKhZPPcdJJA==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - '@esbuild/win32-ia32@0.21.4': resolution: {integrity: sha512-yIxbspZb5kGCAHWm8dexALQ9en1IYDfErzjSEq1KzXFniHv019VT3mNtTK7t8qdy4TwT6QYHI9sEZabONHg+aw==} engines: {node: '>=12'} cpu: [ia32] os: [win32] - '@esbuild/win32-x64@0.18.2': - resolution: {integrity: sha512-Q4nIjqWXjxkELwd7kVepsJxbQ/6ERNsHpjz1j+IKjwSYw+g06U0RQOy5xh848AHvgr9itnGLa3cT2G5t0dBFsw==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - '@esbuild/win32-x64@0.21.4': resolution: {integrity: sha512-sywLRD3UK/qRJt0oBwdpYLBibk7KiRfbswmWRDabuncQYSlf8aLEEUor/oP6KRz8KEG+HoiVLBhPRD5JWjS8Sg==} engines: {node: '>=12'} @@ -923,15 +791,6 @@ packages: supports-color: optional: true - debug@4.3.4: - resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==} - engines: {node: '>=6.0'} - peerDependencies: - supports-color: '*' - peerDependenciesMeta: - supports-color: - optional: true - debug@4.3.5: resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} engines: {node: '>=6.0'} @@ -956,11 +815,6 @@ packages: es6-promise@3.3.1: resolution: {integrity: sha512-SOp9Phqvqn7jtEUxPWdWfWoLmyt2VaJ6MpvP9Comy1MceMXqE6bxvaTu4iaxpYYPzhny28Lc+M87/c2cPK6lDg==} - esbuild@0.18.2: - resolution: {integrity: sha512-1P4sK9gXVcjvrrUjE94Hbo9goU+T6U1sdzLf+JJ+3uI6GEb4e4n3Wrqto9hZHUWabblpT2ifmC61LhZnLyTNFw==} - engines: {node: '>=12'} - hasBin: true - esbuild@0.21.4: resolution: {integrity: sha512-sFMcNNrj+Q0ZDolrp5pDhH0nRPN9hLIM3fRPwgbLYJeSHHgnXSnbV3xYgSVuOeLWH9c73VwmEverVzupIv5xuA==} engines: {node: '>=12'} @@ -1380,11 +1234,6 @@ packages: rollup: ^3.29.4 || ^4 typescript: ^4.5 || ^5.0 - rollup@3.25.0: - resolution: {integrity: sha512-FnJkNRst2jEZGw7f+v4hFo6UTzpDKrAKcHZWcEfm5/GJQ5CK7wgb4moNLNAe7npKUev7yQn1AY/YbZRIxOv6Qg==} - engines: {node: '>=14.18.0', npm: '>=8.0.0'} - hasBin: true - rollup@4.0.2: resolution: {integrity: sha512-MCScu4usMPCeVFaiLcgMDaBQeYi1z6vpWxz0r0hq0Hv77Y2YuOTZldkuNJ54BdYBH3e+nkrk6j0Rre/NLDBYzg==} engines: {node: '>=18.0.0', npm: '>=8.0.0'} @@ -1596,15 +1445,18 @@ packages: tsconfig-paths@3.12.0: resolution: {integrity: sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==} - tsup@7.1.0: - resolution: {integrity: sha512-mazl/GRAk70j8S43/AbSYXGgvRP54oQeX8Un4iZxzATHt0roW0t6HYDVZIXMw0ZQIpvr1nFMniIVnN5186lW7w==} - engines: {node: '>=16.14'} + tsup@8.1.0: + resolution: {integrity: sha512-UFdfCAXukax+U6KzeTNO2kAARHcWxmKsnvSPXUcfA1D+kU05XDccCrkffCQpFaWDsZfV0jMyTsxU39VfCp6EOg==} + engines: {node: '>=18'} hasBin: true peerDependencies: + '@microsoft/api-extractor': ^7.36.0 '@swc/core': ^1 postcss: ^8.4.12 - typescript: '>=4.1.0' + typescript: '>=4.5.0' peerDependenciesMeta: + '@microsoft/api-extractor': + optional: true '@swc/core': optional: true postcss: @@ -1612,16 +1464,16 @@ packages: typescript: optional: true - typescript@5.0.2: - resolution: {integrity: sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==} - engines: {node: '>=12.20'} - hasBin: true - typescript@5.0.4: resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==} engines: {node: '>=12.20'} hasBin: true + typescript@5.5.3: + resolution: {integrity: sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==} + engines: {node: '>=14.17'} + hasBin: true + universalify@0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} @@ -1756,135 +1608,69 @@ snapshots: '@esbuild/aix-ppc64@0.21.4': optional: true - '@esbuild/android-arm64@0.18.2': - optional: true - '@esbuild/android-arm64@0.21.4': optional: true - '@esbuild/android-arm@0.18.2': - optional: true - '@esbuild/android-arm@0.21.4': optional: true - '@esbuild/android-x64@0.18.2': - optional: true - '@esbuild/android-x64@0.21.4': optional: true - '@esbuild/darwin-arm64@0.18.2': - optional: true - '@esbuild/darwin-arm64@0.21.4': optional: true - '@esbuild/darwin-x64@0.18.2': - optional: true - '@esbuild/darwin-x64@0.21.4': optional: true - '@esbuild/freebsd-arm64@0.18.2': - optional: true - '@esbuild/freebsd-arm64@0.21.4': optional: true - '@esbuild/freebsd-x64@0.18.2': - optional: true - '@esbuild/freebsd-x64@0.21.4': optional: true - '@esbuild/linux-arm64@0.18.2': - optional: true - '@esbuild/linux-arm64@0.21.4': optional: true - '@esbuild/linux-arm@0.18.2': - optional: true - '@esbuild/linux-arm@0.21.4': optional: true - '@esbuild/linux-ia32@0.18.2': - optional: true - '@esbuild/linux-ia32@0.21.4': optional: true - '@esbuild/linux-loong64@0.18.2': - optional: true - '@esbuild/linux-loong64@0.21.4': optional: true - '@esbuild/linux-mips64el@0.18.2': - optional: true - '@esbuild/linux-mips64el@0.21.4': optional: true - '@esbuild/linux-ppc64@0.18.2': - optional: true - '@esbuild/linux-ppc64@0.21.4': optional: true - '@esbuild/linux-riscv64@0.18.2': - optional: true - '@esbuild/linux-riscv64@0.21.4': optional: true - '@esbuild/linux-s390x@0.18.2': - optional: true - '@esbuild/linux-s390x@0.21.4': optional: true - '@esbuild/linux-x64@0.18.2': - optional: true - '@esbuild/linux-x64@0.21.4': optional: true - '@esbuild/netbsd-x64@0.18.2': - optional: true - '@esbuild/netbsd-x64@0.21.4': optional: true - '@esbuild/openbsd-x64@0.18.2': - optional: true - '@esbuild/openbsd-x64@0.21.4': optional: true - '@esbuild/sunos-x64@0.18.2': - optional: true - '@esbuild/sunos-x64@0.21.4': optional: true - '@esbuild/win32-arm64@0.18.2': - optional: true - '@esbuild/win32-arm64@0.21.4': optional: true - '@esbuild/win32-ia32@0.18.2': - optional: true - '@esbuild/win32-ia32@0.21.4': optional: true - '@esbuild/win32-x64@0.18.2': - optional: true - '@esbuild/win32-x64@0.21.4': optional: true @@ -2262,11 +2048,6 @@ snapshots: buffer-from@1.1.2: {} - bundle-require@4.0.0(esbuild@0.18.2): - dependencies: - esbuild: 0.18.2 - load-tsconfig: 0.2.3 - bundle-require@4.0.0(esbuild@0.21.4): dependencies: esbuild: 0.21.4 @@ -2338,10 +2119,6 @@ snapshots: dependencies: ms: 2.1.2 - debug@4.3.4: - dependencies: - ms: 2.1.2 - debug@4.3.5: dependencies: ms: 2.1.2 @@ -2356,31 +2133,6 @@ snapshots: es6-promise@3.3.1: {} - esbuild@0.18.2: - optionalDependencies: - '@esbuild/android-arm': 0.18.2 - '@esbuild/android-arm64': 0.18.2 - '@esbuild/android-x64': 0.18.2 - '@esbuild/darwin-arm64': 0.18.2 - '@esbuild/darwin-x64': 0.18.2 - '@esbuild/freebsd-arm64': 0.18.2 - '@esbuild/freebsd-x64': 0.18.2 - '@esbuild/linux-arm': 0.18.2 - '@esbuild/linux-arm64': 0.18.2 - '@esbuild/linux-ia32': 0.18.2 - '@esbuild/linux-loong64': 0.18.2 - '@esbuild/linux-mips64el': 0.18.2 - '@esbuild/linux-ppc64': 0.18.2 - '@esbuild/linux-riscv64': 0.18.2 - '@esbuild/linux-s390x': 0.18.2 - '@esbuild/linux-x64': 0.18.2 - '@esbuild/netbsd-x64': 0.18.2 - '@esbuild/openbsd-x64': 0.18.2 - '@esbuild/sunos-x64': 0.18.2 - '@esbuild/win32-arm64': 0.18.2 - '@esbuild/win32-ia32': 0.18.2 - '@esbuild/win32-x64': 0.18.2 - esbuild@0.21.4: optionalDependencies: '@esbuild/aix-ppc64': 0.21.4 @@ -2768,18 +2520,14 @@ snapshots: dependencies: glob: 7.1.6 - rollup-plugin-dts@6.1.0(rollup@4.0.2)(typescript@5.0.2): + rollup-plugin-dts@6.1.0(rollup@4.0.2)(typescript@5.5.3): dependencies: magic-string: 0.30.4 rollup: 4.0.2 - typescript: 5.0.2 + typescript: 5.5.3 optionalDependencies: '@babel/code-frame': 7.24.7 - rollup@3.25.0: - optionalDependencies: - fsevents: 2.3.3 - rollup@4.0.2: optionalDependencies: '@rollup/rollup-android-arm-eabi': 4.0.2 @@ -2913,7 +2661,7 @@ snapshots: supports-preserve-symlinks-flag@1.0.0: {} - svelte-preprocess@5.0.3(postcss-load-config@4.0.1(postcss@8.4.12))(postcss@8.4.12)(sass@1.62.1)(svelte@3.46.4)(typescript@5.0.2): + svelte-preprocess@5.0.3(postcss-load-config@4.0.1(postcss@8.4.12))(postcss@8.4.12)(sass@1.62.1)(svelte@3.46.4)(typescript@5.5.3): dependencies: '@types/pug': 2.0.6 detect-indent: 6.1.0 @@ -2925,7 +2673,7 @@ snapshots: postcss: 8.4.12 postcss-load-config: 4.0.1(postcss@8.4.12) sass: 1.62.1 - typescript: 5.0.2 + typescript: 5.5.3 svelte@3.46.4: {} @@ -2962,9 +2710,9 @@ snapshots: tree-kill@1.2.2: {} - ts-essentials@9.1.2(typescript@5.0.2): + ts-essentials@9.1.2(typescript@5.5.3): dependencies: - typescript: 5.0.2 + typescript: 5.5.3 ts-interface-checker@0.1.13: {} @@ -2975,34 +2723,35 @@ snapshots: minimist: 1.2.5 strip-bom: 3.0.0 - tsup@7.1.0(@swc/core@1.2.218)(postcss@8.4.12)(typescript@5.0.2): + tsup@8.1.0(@microsoft/api-extractor@7.38.3(@types/node@14.18.12))(@swc/core@1.2.218)(postcss@8.4.12)(typescript@5.5.3): dependencies: - bundle-require: 4.0.0(esbuild@0.18.2) - cac: 6.7.14 + bundle-require: 4.0.0(esbuild@0.21.4) + cac: 6.7.12 chokidar: 3.5.2 - debug: 4.3.4 - esbuild: 0.18.2 + debug: 4.3.2 + esbuild: 0.21.4 execa: 5.1.1 globby: 11.0.4 joycon: 3.0.1 postcss-load-config: 4.0.1(postcss@8.4.12) resolve-from: 5.0.0 - rollup: 3.25.0 + rollup: 4.0.2 source-map: 0.8.0-beta.0 sucrase: 3.20.3 tree-kill: 1.2.2 optionalDependencies: + '@microsoft/api-extractor': 7.38.3(@types/node@14.18.12) '@swc/core': 1.2.218 postcss: 8.4.12 - typescript: 5.0.2 + typescript: 5.5.3 transitivePeerDependencies: - supports-color - ts-node - typescript@5.0.2: {} - typescript@5.0.4: {} + typescript@5.5.3: {} + universalify@0.1.2: {} universalify@2.0.1: {} diff --git a/src/api-extractor.ts b/src/api-extractor.ts index f911cf1d5..2a16de907 100644 --- a/src/api-extractor.ts +++ b/src/api-extractor.ts @@ -12,7 +12,7 @@ import { } from './exports' import { loadPkg } from './load' import { createLogger } from './log' -import { Format, NormalizedOptions } from './options' +import type { Format, NormalizedOptions } from './options' import { defaultOutExtension, ensureTempDeclarationDir, diff --git a/src/cli-main.ts b/src/cli-main.ts index ce5b64d74..588754466 100644 --- a/src/cli-main.ts +++ b/src/cli-main.ts @@ -1,6 +1,6 @@ import { cac } from 'cac' import flat from 'flat' -import { Format, Options } from '.' +import type { Format, Options } from '.' import { version } from '../package.json' import { slash } from './utils' diff --git a/src/esbuild/external.ts b/src/esbuild/external.ts index c4255b377..1b26b1690 100644 --- a/src/esbuild/external.ts +++ b/src/esbuild/external.ts @@ -1,4 +1,4 @@ -import { Plugin } from 'esbuild' +import type { Plugin } from 'esbuild' import { tsconfigPathsToRegExp, match } from 'bundle-require' // Must not start with "/" or "./" or "../" or "C:\" or be the exact strings ".." or "." diff --git a/src/esbuild/index.ts b/src/esbuild/index.ts index 22ba0aaa2..28c30a2e9 100644 --- a/src/esbuild/index.ts +++ b/src/esbuild/index.ts @@ -2,13 +2,13 @@ import fs from 'fs' import path from 'path' import { build as esbuild, - BuildResult, + type BuildResult, formatMessages, - Plugin as EsbuildPlugin, + type Plugin as EsbuildPlugin, } from 'esbuild' -import { NormalizedOptions, Format } from '..' +import type { NormalizedOptions, Format } from '..' import { getProductionDeps, loadPkg } from '../load' -import { Logger, getSilent } from '../log' +import { type Logger, getSilent } from '../log' import { nodeProtocolPlugin } from './node-protocol' import { externalPlugin } from './external' import { postcssPlugin } from './postcss' @@ -18,7 +18,7 @@ import { defaultOutExtension, truthy } from '../utils' import { swcPlugin } from './swc' import { nativeNodeModulesPlugin } from './native-node-module' import { PluginContainer } from '../plugin' -import { OutExtensionFactory } from '../options' +import type { OutExtensionFactory } from '../options' const getOutputExtensionMap = ( options: NormalizedOptions, diff --git a/src/esbuild/native-node-module.ts b/src/esbuild/native-node-module.ts index 955921ce2..f77bade0f 100644 --- a/src/esbuild/native-node-module.ts +++ b/src/esbuild/native-node-module.ts @@ -1,5 +1,5 @@ import path from 'path' -import { Plugin } from 'esbuild' +import type { Plugin } from 'esbuild' // Copied from https://github.com/evanw/esbuild/issues/1051#issuecomment-806325487 export const nativeNodeModulesPlugin = (): Plugin => { diff --git a/src/esbuild/node-protocol.ts b/src/esbuild/node-protocol.ts index 885452df6..5c66c0d7e 100644 --- a/src/esbuild/node-protocol.ts +++ b/src/esbuild/node-protocol.ts @@ -1,4 +1,4 @@ -import { Plugin } from 'esbuild' +import type { Plugin } from 'esbuild' /** * The node: protocol was added to require in Node v14.18.0 diff --git a/src/esbuild/postcss.ts b/src/esbuild/postcss.ts index 1dbcc7a78..70ebdc537 100644 --- a/src/esbuild/postcss.ts +++ b/src/esbuild/postcss.ts @@ -1,4 +1,4 @@ -import { Loader, Plugin, transform } from 'esbuild' +import { type Loader, type Plugin, transform } from 'esbuild' import fs from 'fs' import type { Result } from 'postcss-load-config' import { getPostcss } from '../utils' diff --git a/src/esbuild/svelte.ts b/src/esbuild/svelte.ts index aa3d9d353..8672664d4 100644 --- a/src/esbuild/svelte.ts +++ b/src/esbuild/svelte.ts @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import { Plugin, transform } from 'esbuild' +import { type Plugin, transform } from 'esbuild' import { localRequire } from '../utils' const useSvelteCssExtension = (p: string) => diff --git a/src/esbuild/swc.ts b/src/esbuild/swc.ts index c03e30b9f..9822baaed 100644 --- a/src/esbuild/swc.ts +++ b/src/esbuild/swc.ts @@ -1,10 +1,10 @@ /** * Use SWC to emit decorator metadata */ -import { JscConfig } from '@swc/core' -import { Plugin } from 'esbuild' +import { type JscConfig } from '@swc/core' +import { type Plugin } from 'esbuild' import path from 'path' -import { Logger } from '../log' +import { type Logger } from '../log' import { localRequire } from '../utils' export const swcPlugin = ({ logger }: { logger: Logger }): Plugin => { diff --git a/src/index.ts b/src/index.ts index 3b981c555..7b4ce1f1a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,7 @@ import { removeFiles, debouncePromise, slash, - MaybePromise, + type MaybePromise, toObjectEntry, } from './utils' import { getAllDepsHash, loadTsupConfig } from './load' @@ -17,7 +17,7 @@ import execa from 'execa' import kill from 'tree-kill' import { version } from '../package.json' import { createLogger, setSilent } from './log' -import { NormalizedOptions, Format, Options, KILL_SIGNAL } from './options' +import type { NormalizedOptions, Format, Options, KILL_SIGNAL } from './options' import { runEsbuild } from './esbuild' import { shebang } from './plugins/shebang' import { cjsSplitting } from './plugins/cjs-splitting' @@ -265,7 +265,7 @@ export async function build(_options: Options) { const doOnSuccessCleanup = async () => { if (onSuccessProcess) { await killProcess({ - pid: onSuccessProcess.pid, + pid: onSuccessProcess.pid!, signal: options.killSignal || 'SIGTERM', }) } else if (onSuccessCleanup) { diff --git a/src/lib/report-size.ts b/src/lib/report-size.ts index 6f0d5504b..814cd3269 100644 --- a/src/lib/report-size.ts +++ b/src/lib/report-size.ts @@ -1,5 +1,5 @@ import * as colors from 'colorette' -import { Logger } from '../log' +import type { Logger } from '../log' const prettyBytes = (bytes: number) => { if (bytes === 0) return '0 B' diff --git a/src/options.ts b/src/options.ts index a362a1f04..f6f07d51f 100644 --- a/src/options.ts +++ b/src/options.ts @@ -1,7 +1,7 @@ import type { BuildOptions, Plugin as EsbuildPlugin, Loader } from 'esbuild' import type { InputOption } from 'rollup' import type { MinifyOptions } from 'terser' -import { MarkRequired } from 'ts-essentials' +import type { MarkRequired } from 'ts-essentials' import type { Plugin } from './plugin' import type { TreeshakingStrategy } from './plugins/tree-shaking' diff --git a/src/plugin.ts b/src/plugin.ts index 1a3222055..25c9384c8 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,11 +1,19 @@ import path from 'path' -import { OutputFile, BuildOptions as EsbuildOptions, Metafile } from 'esbuild' -import { SourceMapConsumer, SourceMapGenerator, RawSourceMap } from 'source-map' -import { Format, NormalizedOptions } from '.' +import type { + OutputFile, + BuildOptions as EsbuildOptions, + Metafile, +} from 'esbuild' +import { + SourceMapConsumer, + SourceMapGenerator, + type RawSourceMap, +} from 'source-map' +import type { Format, NormalizedOptions } from '.' import { outputFile } from './fs' -import { Logger } from './log' -import { MaybePromise } from './utils' -import { SourceMap } from 'rollup' +import type { Logger } from './log' +import type { MaybePromise } from './utils' +import type { SourceMap } from 'rollup' export type ChunkInfo = { type: 'chunk' diff --git a/src/plugins/cjs-interop.ts b/src/plugins/cjs-interop.ts index eae475ec2..dea18d3b2 100644 --- a/src/plugins/cjs-interop.ts +++ b/src/plugins/cjs-interop.ts @@ -1,4 +1,4 @@ -import { Plugin } from '../plugin' +import type { Plugin } from '../plugin' export const cjsInterop = (): Plugin => { return { diff --git a/src/plugins/cjs-splitting.ts b/src/plugins/cjs-splitting.ts index a6e0fc663..e2fd5b86c 100644 --- a/src/plugins/cjs-splitting.ts +++ b/src/plugins/cjs-splitting.ts @@ -1,7 +1,7 @@ // Workaround to enable code splitting for cjs format // Manually transform esm to cjs // TODO: remove this once esbuild supports code splitting for cjs natively -import { Plugin } from '../plugin' +import type { Plugin } from '../plugin' export const cjsSplitting = (): Plugin => { return { diff --git a/src/plugins/shebang.ts b/src/plugins/shebang.ts index 8869fdb80..2b916330f 100644 --- a/src/plugins/shebang.ts +++ b/src/plugins/shebang.ts @@ -1,4 +1,4 @@ -import { Plugin } from '../plugin' +import type { Plugin } from '../plugin' export const shebang = (): Plugin => { return { diff --git a/src/plugins/size-reporter.ts b/src/plugins/size-reporter.ts index ebc44a13b..94c576e18 100644 --- a/src/plugins/size-reporter.ts +++ b/src/plugins/size-reporter.ts @@ -1,4 +1,4 @@ -import { Plugin } from '../plugin' +import type { Plugin } from '../plugin' import { reportSize } from '../lib/report-size' export const sizeReporter = (): Plugin => { diff --git a/src/plugins/swc-target.ts b/src/plugins/swc-target.ts index cf0d629d2..4b7ca6c34 100644 --- a/src/plugins/swc-target.ts +++ b/src/plugins/swc-target.ts @@ -1,6 +1,6 @@ import type { ModuleConfig } from '@swc/core/types' import { PrettyError } from '../errors' -import { Plugin } from '../plugin' +import type { Plugin } from '../plugin' import { localRequire } from '../utils' const TARGETS = ['es5', 'es3'] as const diff --git a/src/plugins/terser.ts b/src/plugins/terser.ts index 6ed798912..c9ae773f3 100644 --- a/src/plugins/terser.ts +++ b/src/plugins/terser.ts @@ -1,8 +1,8 @@ -import { MinifyOptions } from 'terser' +import type { MinifyOptions } from 'terser' import { PrettyError } from '../errors' -import { Logger } from '../log' -import { Format, Options } from '../options' -import { Plugin } from '../plugin' +import type { Logger } from '../log' +import type { Format, Options } from '../options' +import type { Plugin } from '../plugin' import { localRequire } from '../utils' export const terserPlugin = ({ diff --git a/src/plugins/tree-shaking.ts b/src/plugins/tree-shaking.ts index 3826f1ce1..d3e7cf76e 100644 --- a/src/plugins/tree-shaking.ts +++ b/src/plugins/tree-shaking.ts @@ -1,5 +1,5 @@ -import { rollup, TreeshakingOptions, TreeshakingPreset } from 'rollup' -import { Plugin } from '../plugin' +import { rollup, type TreeshakingOptions, type TreeshakingPreset } from 'rollup' +import type { Plugin } from '../plugin' export type TreeshakingStrategy = | boolean diff --git a/src/rollup.ts b/src/rollup.ts index 947d6c2fa..619ece835 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -1,11 +1,11 @@ import { parentPort } from 'worker_threads' -import { InputOptions, OutputOptions, Plugin } from 'rollup' -import { NormalizedOptions } from './' +import type { InputOptions, OutputOptions, Plugin } from 'rollup' +import type { NormalizedOptions } from './' import ts from 'typescript' import jsonPlugin from '@rollup/plugin-json' import { handleError } from './errors' import { defaultOutExtension, removeFiles, toObjectEntry } from './utils' -import { TsResolveOptions, tsResolvePlugin } from './rollup/ts-resolve' +import { type TsResolveOptions, tsResolvePlugin } from './rollup/ts-resolve' import { createLogger, setSilent } from './log' import { getProductionDeps, loadPkg } from './load' import path from 'path' diff --git a/src/rollup/ts-resolve.ts b/src/rollup/ts-resolve.ts index 4b3339f84..5a450c180 100644 --- a/src/rollup/ts-resolve.ts +++ b/src/rollup/ts-resolve.ts @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -import { PluginImpl } from 'rollup' +import { type PluginImpl } from 'rollup' import _resolve from 'resolve' import createDebug from 'debug' import { builtinModules } from 'module' diff --git a/src/tsc.ts b/src/tsc.ts index c7677b029..edaae79da 100644 --- a/src/tsc.ts +++ b/src/tsc.ts @@ -1,9 +1,9 @@ import { loadTsConfig } from 'bundle-require' import ts from 'typescript' import { handleError } from './errors' -import { ExportDeclaration } from './exports' +import type { ExportDeclaration } from './exports' import { createLogger } from './log' -import { NormalizedOptions } from './options' +import type { NormalizedOptions } from './options' import { ensureTempDeclarationDir, toAbsolutePath } from './utils' import { dirname } from 'path' diff --git a/src/utils.ts b/src/utils.ts index de2be90b1..457c58fde 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,7 +3,7 @@ import glob from 'globby' import path from 'path' import resolveFrom from 'resolve-from' import strip from 'strip-json-comments' -import { Entry, Format } from './options' +import type { Entry, Format } from './options' export type MaybePromise = T | Promise diff --git a/test/example.test.ts b/test/example.test.ts index f47720e19..7c765f619 100644 --- a/test/example.test.ts +++ b/test/example.test.ts @@ -1,7 +1,7 @@ import { test } from 'vitest' import { getTestName, run } from './utils' -test('bundle vue and ts-essentials with --dts --dts-resolve flag', async () => { +test.concurrent('bundle vue and ts-essentials with --dts --dts-resolve flag', async () => { await run( getTestName(), { @@ -15,11 +15,11 @@ test('bundle vue and ts-essentials with --dts --dts-resolve flag', async () => { ) }) -test('bundle @egoist/path-parser with --dts --dts-resolve flag', async () => { +test.concurrent('bundle @egoist/path-parser with --dts --dts-resolve flag', async () => { await run( getTestName(), { - 'input.ts': `import { PathParser } from '@egoist/path-parser' + 'input.ts': `import type { PathParser } from '@egoist/path-parser' export type Opts = { parser: PathParser route: string diff --git a/tsconfig.json b/tsconfig.json index df1a32d97..6059c7c45 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -63,6 +63,8 @@ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */ /* Advanced Options */ - "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */ + "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */, + + "verbatimModuleSyntax": true } }