diff --git a/package.json b/package.json index c1222bd3e..e6d0d279a 100644 --- a/package.json +++ b/package.json @@ -38,13 +38,13 @@ "joycon": "^3.0.1", "postcss-load-config": "^4.0.1", "resolve-from": "^5.0.0", - "rollup": "^3.2.5", + "rollup": "^4.0.2", "source-map": "0.8.0-beta.0", "sucrase": "^3.20.3", "tree-kill": "^1.2.2" }, "devDependencies": { - "@rollup/plugin-json": "5.0.1", + "@rollup/plugin-json": "6.0.1", "@swc/core": "1.2.218", "@types/debug": "4.1.7", "@types/flat": "5.0.2", @@ -59,8 +59,7 @@ "postcss-simple-vars": "6.0.3", "prettier": "2.5.1", "resolve": "1.20.0", - "rollup-plugin-dts": "5.3.0", - "rollup-plugin-hashbang": "3.0.0", + "rollup-plugin-dts": "6.1.0", "sass": "1.62.1", "strip-json-comments": "4.0.0", "svelte": "3.46.4", @@ -76,7 +75,7 @@ "peerDependencies": { "@swc/core": "^1", "postcss": "^8.4.12", - "typescript": ">=4.1.0" + "typescript": ">=4.5.0" }, "peerDependenciesMeta": { "typescript": { @@ -90,7 +89,7 @@ } }, "engines": { - "node": ">=16.14" + "node": ">=18" }, "packageManager": "pnpm@8.6.0" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44aeb509e..bd222eb67 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -36,8 +36,8 @@ dependencies: specifier: ^5.0.0 version: 5.0.0 rollup: - specifier: ^3.2.5 - version: 3.8.1 + specifier: ^4.0.2 + version: 4.0.2 source-map: specifier: 0.8.0-beta.0 version: 0.8.0-beta.0 @@ -50,8 +50,8 @@ dependencies: devDependencies: '@rollup/plugin-json': - specifier: 5.0.1 - version: 5.0.1(rollup@3.8.1) + specifier: 6.0.1 + version: 6.0.1(rollup@4.0.2) '@swc/core': specifier: 1.2.218 version: 1.2.218 @@ -95,11 +95,8 @@ devDependencies: specifier: 1.20.0 version: 1.20.0 rollup-plugin-dts: - specifier: 5.3.0 - version: 5.3.0(rollup@3.8.1)(typescript@5.0.2) - rollup-plugin-hashbang: - specifier: 3.0.0 - version: 3.0.0(rollup@3.8.1) + specifier: 6.1.0 + version: 6.1.0(rollup@4.0.2)(typescript@5.0.2) sass: specifier: 1.62.1 version: 1.62.1 @@ -136,26 +133,27 @@ devDependencies: packages: - /@babel/code-frame@7.18.6: - resolution: {integrity: sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==} + /@babel/code-frame@7.22.13: + resolution: {integrity: sha512-XktuhWlJ5g+3TJXc5upd9Ks1HutSArik6jf2eAjYFyIOf4ej3RN+184cZbzDvbPnuTJIUhPKKJE3cIsYTiAT3w==} engines: {node: '>=6.9.0'} requiresBuild: true dependencies: - '@babel/highlight': 7.18.6 + '@babel/highlight': 7.22.20 + chalk: 2.4.2 dev: true optional: true - /@babel/helper-validator-identifier@7.19.1: - resolution: {integrity: sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==} + /@babel/helper-validator-identifier@7.22.20: + resolution: {integrity: sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==} engines: {node: '>=6.9.0'} dev: true optional: true - /@babel/highlight@7.18.6: - resolution: {integrity: sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==} + /@babel/highlight@7.22.20: + resolution: {integrity: sha512-dkdMCN3py0+ksCgYmGG8jKeGA/8Tk+gJwSYYlFGxG5lmhfKNoAy004YpLxpS1W2J8m/EK2Ew+yOs9pVRwO89mg==} engines: {node: '>=6.9.0'} dependencies: - '@babel/helper-validator-identifier': 7.19.1 + '@babel/helper-validator-identifier': 7.22.20 chalk: 2.4.2 js-tokens: 4.0.0 dev: true @@ -562,7 +560,7 @@ packages: engines: {node: '>=6.0.0'} dependencies: '@jridgewell/set-array': 1.1.2 - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/sourcemap-codec': 1.4.15 '@jridgewell/trace-mapping': 0.3.17 dev: true @@ -587,6 +585,10 @@ packages: resolution: {integrity: sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==} dev: true + /@jridgewell/sourcemap-codec@1.4.15: + resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: true + /@jridgewell/trace-mapping@0.3.17: resolution: {integrity: sha512-MCNzAp77qzKca9+W/+I0+sEpaUnZoeasnghNeVc41VZCEKaCH73Vq3BZZ/SzWIgrqE4H4ceI+p+b6C0mHf9T4g==} dependencies: @@ -612,24 +614,24 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.13.0 - /@rollup/plugin-json@5.0.1(rollup@3.8.1): - resolution: {integrity: sha512-QCwhZZLvM8nRcTHyR1vOgyTMiAnjiNj1ebD/BMRvbO1oc/z14lZH6PfxXeegee2B6mky/u9fia4fxRM4TqrUaw==} + /@rollup/plugin-json@6.0.1(rollup@4.0.2): + resolution: {integrity: sha512-RgVfl5hWMkxN1h/uZj8FVESvPuBJ/uf6ly6GTj0GONnkfoBN5KC0MSz+PN2OLDgYXMhtG0mWpTrkiOjoxAIevw==} engines: {node: '>=14.0.0'} peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0 + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true dependencies: - '@rollup/pluginutils': 5.0.2(rollup@3.8.1) - rollup: 3.8.1 + '@rollup/pluginutils': 5.0.5(rollup@4.0.2) + rollup: 4.0.2 dev: true - /@rollup/pluginutils@5.0.2(rollup@3.8.1): - resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} + /@rollup/pluginutils@5.0.5(rollup@4.0.2): + resolution: {integrity: sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==} engines: {node: '>=14.0.0'} peerDependencies: - rollup: ^1.20.0||^2.0.0||^3.0.0 + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true @@ -637,9 +639,93 @@ packages: '@types/estree': 1.0.0 estree-walker: 2.0.2 picomatch: 2.3.1 - rollup: 3.8.1 + rollup: 4.0.2 dev: true + /@rollup/rollup-android-arm-eabi@4.0.2: + resolution: {integrity: sha512-xDvk1pT4vaPU2BOLy0MqHMdYZyntqpaBf8RhBiezlqG9OjY8F50TyctHo8znigYKd+QCFhCmlmXHOL/LoaOl3w==} + cpu: [arm] + os: [android] + requiresBuild: true + optional: true + + /@rollup/rollup-android-arm64@4.0.2: + resolution: {integrity: sha512-lqCglytY3E6raze27DD9VQJWohbwCxzqs9aSHcj5X/8hJpzZfNdbsr4Ja9Hqp6iPyF53+5PtPx0pKRlkSvlHZg==} + cpu: [arm64] + os: [android] + requiresBuild: true + optional: true + + /@rollup/rollup-darwin-arm64@4.0.2: + resolution: {integrity: sha512-nkBKItS6E6CCzvRwgiKad+j+1ibmL7SIInj7oqMWmdkCjiSX6VeVZw2mLlRKIUL+JjsBgpATTfo7BiAXc1v0jA==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + optional: true + + /@rollup/rollup-darwin-x64@4.0.2: + resolution: {integrity: sha512-vX2C8xvWPIbpEgQht95+dY6BReKAvtDgPDGi0XN0kWJKkm4WdNmq5dnwscv/zxvi+n6jUTBhs6GtpkkWT4q8Gg==} + cpu: [x64] + os: [darwin] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-arm-gnueabihf@4.0.2: + resolution: {integrity: sha512-DVFIfcHOjgmeHOAqji4xNz2wczt1Bmzy9MwBZKBa83SjBVO/i38VHDR+9ixo8QpBOiEagmNw12DucG+v55tCrg==} + cpu: [arm] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.0.2: + resolution: {integrity: sha512-GCK/a9ItUxPI0V5hQEJjH4JtOJO90GF2Hja7TO+EZ8rmkGvEi8/ZDMhXmcuDpQT7/PWrTT9RvnG8snMd5SrhBQ==} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-arm64-musl@4.0.2: + resolution: {integrity: sha512-cLuBp7rOjIB1R2j/VazjCmHC7liWUur2e9mFflLJBAWCkrZ+X0+QwHLvOQakIwDymungzAKv6W9kHZnTp/Mqrg==} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.0.2: + resolution: {integrity: sha512-Zqw4iVnJr2naoyQus0yLy7sLtisCQcpdMKUCeXPBjkJtpiflRime/TMojbnl8O3oxUAj92mxr+t7im/RbgA20w==} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-x64-musl@4.0.2: + resolution: {integrity: sha512-jJRU9TyUD/iMqjf8aLAp7XiN3pIj5v6Qcu+cdzBfVTKDD0Fvua4oUoK8eVJ9ZuKBEQKt3WdlcwJXFkpmMLk6kg==} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-win32-arm64-msvc@4.0.2: + resolution: {integrity: sha512-ZkS2NixCxHKC4zbOnw64ztEGGDVIYP6nKkGBfOAxEPW71Sji9v8z3yaHNuae/JHPwXA+14oDefnOuVfxl59SmQ==} + cpu: [arm64] + os: [win32] + requiresBuild: true + optional: true + + /@rollup/rollup-win32-ia32-msvc@4.0.2: + resolution: {integrity: sha512-3SKjj+tvnZ0oZq2BKB+fI+DqYI83VrRzk7eed8tJkxeZ4zxJZcLSE8YDQLYGq1tZAnAX+H076RHHB4gTZXsQzw==} + cpu: [ia32] + os: [win32] + requiresBuild: true + optional: true + + /@rollup/rollup-win32-x64-msvc@4.0.2: + resolution: {integrity: sha512-MBdJIOxRauKkry7t2q+rTHa3aWjVez2eioWg+etRVS3dE4tChhmt5oqZYr48R6bPmcwEhxQr96gVRfeQrLbqng==} + cpu: [x64] + os: [win32] + requiresBuild: true + optional: true + /@swc/core-android-arm-eabi@1.2.218: resolution: {integrity: sha512-Q/uLCh262t3xxNzhCz+ZW9t+g2nWd0gZZO4jMYFWJs7ilKVNsBfRtfnNGGACHzkVuWLNDIWtAS2PSNodl7VUHQ==} engines: {node: '>=10'} @@ -917,7 +1003,7 @@ packages: engines: {node: '>= 8'} dependencies: normalize-path: 3.0.0 - picomatch: 2.3.0 + picomatch: 2.3.1 /array-union@2.1.0: resolution: {integrity: sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==} @@ -1648,12 +1734,6 @@ packages: get-func-name: 2.0.0 dev: true - /magic-string@0.25.9: - resolution: {integrity: sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ==} - dependencies: - sourcemap-codec: 1.4.8 - dev: true - /magic-string@0.27.0: resolution: {integrity: sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==} engines: {node: '>=12'} @@ -1661,11 +1741,11 @@ packages: '@jridgewell/sourcemap-codec': 1.4.14 dev: true - /magic-string@0.30.0: - resolution: {integrity: sha512-LA+31JYDJLs82r2ScLrlz1GjSgu66ZV518eyWT+S8VhyQn/JL0u9MeBOvQMGYiPk1DBiSN9DDMOcXvigJZaViQ==} + /magic-string@0.30.4: + resolution: {integrity: sha512-Q/TKtsC5BPm0kGqgBIF9oXAs/xEf2vRKiIB4wCRQTJOQIByZ1d+NnUOotvJOvNpi5RNIgVOMC3pOuaP1ZTDlVg==} engines: {node: '>=12'} dependencies: - '@jridgewell/sourcemap-codec': 1.4.14 + '@jridgewell/sourcemap-codec': 1.4.15 dev: true /merge-stream@2.0.0: @@ -1680,7 +1760,7 @@ packages: engines: {node: '>=8.6'} dependencies: braces: 3.0.2 - picomatch: 2.3.0 + picomatch: 2.3.1 /mimic-fn@2.1.0: resolution: {integrity: sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==} @@ -1804,14 +1884,9 @@ packages: /picocolors@1.0.0: resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==} - /picomatch@2.3.0: - resolution: {integrity: sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==} - engines: {node: '>=8.6'} - /picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} - dev: true /pirates@4.0.1: resolution: {integrity: sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==} @@ -1899,7 +1974,7 @@ packages: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} dependencies: - picomatch: 2.3.0 + picomatch: 2.3.1 /resolve-from@5.0.0: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} @@ -1932,28 +2007,18 @@ packages: glob: 7.1.6 dev: true - /rollup-plugin-dts@5.3.0(rollup@3.8.1)(typescript@5.0.2): - resolution: {integrity: sha512-8FXp0ZkyZj1iU5klkIJYLjIq/YZSwBoERu33QBDxm/1yw5UU4txrEtcmMkrq+ZiKu3Q4qvPCNqc3ovX6rjqzbQ==} - engines: {node: '>=v14'} + /rollup-plugin-dts@6.1.0(rollup@4.0.2)(typescript@5.0.2): + resolution: {integrity: sha512-ijSCPICkRMDKDLBK9torss07+8dl9UpY9z1N/zTeA1cIqdzMlpkV3MOOC7zukyvQfDyxa1s3Dl2+DeiP/G6DOw==} + engines: {node: '>=16'} peerDependencies: - rollup: ^3.0.0 - typescript: ^4.1 || ^5.0 + rollup: ^3.29.4 || ^4 + typescript: ^4.5 || ^5.0 dependencies: - magic-string: 0.30.0 - rollup: 3.8.1 + magic-string: 0.30.4 + rollup: 4.0.2 typescript: 5.0.2 optionalDependencies: - '@babel/code-frame': 7.18.6 - dev: true - - /rollup-plugin-hashbang@3.0.0(rollup@3.8.1): - resolution: {integrity: sha512-nNC2NeNcvkklPhPCUF8Yb+2a19xI0dSBBJJ2x814+Al2BqIEWOyaGIgEjPVSjjgxhoabkJC5vbO4AeI3cxx3wg==} - engines: {node: '>=14'} - peerDependencies: - rollup: '>=2' - dependencies: - magic-string: 0.25.9 - rollup: 3.8.1 + '@babel/code-frame': 7.22.13 dev: true /rollup@2.77.0: @@ -1970,6 +2035,26 @@ packages: hasBin: true optionalDependencies: fsevents: 2.3.2 + dev: true + + /rollup@4.0.2: + resolution: {integrity: sha512-MCScu4usMPCeVFaiLcgMDaBQeYi1z6vpWxz0r0hq0Hv77Y2YuOTZldkuNJ54BdYBH3e+nkrk6j0Rre/NLDBYzg==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.0.2 + '@rollup/rollup-android-arm64': 4.0.2 + '@rollup/rollup-darwin-arm64': 4.0.2 + '@rollup/rollup-darwin-x64': 4.0.2 + '@rollup/rollup-linux-arm-gnueabihf': 4.0.2 + '@rollup/rollup-linux-arm64-gnu': 4.0.2 + '@rollup/rollup-linux-arm64-musl': 4.0.2 + '@rollup/rollup-linux-x64-gnu': 4.0.2 + '@rollup/rollup-linux-x64-musl': 4.0.2 + '@rollup/rollup-win32-arm64-msvc': 4.0.2 + '@rollup/rollup-win32-ia32-msvc': 4.0.2 + '@rollup/rollup-win32-x64-msvc': 4.0.2 + fsevents: 2.3.2 /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -2056,11 +2141,6 @@ packages: dependencies: whatwg-url: 7.1.0 - /sourcemap-codec@1.4.8: - resolution: {integrity: sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==} - deprecated: Please use @jridgewell/sourcemap-codec instead - dev: true - /stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} dev: true diff --git a/src/plugins/tree-shaking.ts b/src/plugins/tree-shaking.ts index 935d24a68..f1c9a9efe 100644 --- a/src/plugins/tree-shaking.ts +++ b/src/plugins/tree-shaking.ts @@ -1,5 +1,4 @@ import { rollup, TreeshakingOptions, TreeshakingPreset } from 'rollup' -import hashbang from 'rollup-plugin-hashbang' import { Plugin } from '../plugin' export type TreeshakingStrategy = @@ -25,7 +24,6 @@ export const treeShakingPlugin = ({ const bundle = await rollup({ input: [info.path], plugins: [ - hashbang(), { name: 'tsup', resolveId(source) { diff --git a/src/rollup.ts b/src/rollup.ts index 28672fb22..35fdea1e1 100644 --- a/src/rollup.ts +++ b/src/rollup.ts @@ -2,7 +2,6 @@ import { parentPort } from 'worker_threads' import { InputOptions, OutputOptions, Plugin } from 'rollup' import { NormalizedOptions } from './' import ts from 'typescript' -import hashbangPlugin from 'rollup-plugin-hashbang' import jsonPlugin from '@rollup/plugin-json' import { handleError } from './errors' import { defaultOutExtension, removeFiles } from './utils' @@ -167,7 +166,6 @@ const getRollupConfig = async ( plugins: [ tsupCleanPlugin, tsResolveOptions && tsResolvePlugin(tsResolveOptions), - hashbangPlugin(), jsonPlugin(), ignoreFiles, dtsPlugin.default({ diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 8ec15c03f..554afdb20 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -45,7 +45,7 @@ exports[`enable --dts-resolve for specific module 1`] = ` type MarkRequired<T, RK extends keyof T> = Exclude<T, RK> & Required<Pick<T, RK>> -export { MarkRequired }; +export type { MarkRequired }; " `; diff --git a/test/index.test.ts b/test/index.test.ts index df2c19d73..fcbc17828 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1269,7 +1269,7 @@ test(`should generate export {} when there are no exports in source file`, async `, }) expect(outFiles).toEqual(['input.d.mts', 'input.mjs']) - expect(await getFileContent('dist/input.d.mts')).toContain('export { }') + expect(await getFileContent('dist/input.d.mts')).toMatch(/export {\s*}/) }) test('custom inject style function', async () => { diff --git a/tsup.config.ts b/tsup.config.ts index 8a3546c4d..796981e8e 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -2,7 +2,7 @@ import { defineConfig } from 'tsup' export default defineConfig({ name: 'tsup', - target: 'node16.14', + target: 'node18', dts: { resolve: true, // build types for `src/index.ts` only