From 2e7705364b4dd71851458c20de8fc506c5d7f599 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Mon, 28 Aug 2023 09:30:33 +0200 Subject: [PATCH] feat: upgrade to `unbuild@2` --- .gitignore | 1 + example/package.json | 2 +- package.json | 8 +- pnpm-lock.yaml | 365 +++++++------------------------------------ src/build.ts | 15 +- test/build.spec.ts | 3 + 6 files changed, 78 insertions(+), 316 deletions(-) diff --git a/.gitignore b/.gitignore index d9dc939..779041b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist types package-lock.json .nuxt +.output diff --git a/example/package.json b/example/package.json index f95514c..dc324ed 100644 --- a/example/package.json +++ b/example/package.json @@ -26,9 +26,9 @@ "@nuxt/kit": "^3.7.0" }, "devDependencies": { - "@types/node": "^20.5.6", "@nuxt/module-builder": "workspace:*", "@nuxt/schema": "^3.7.0", + "@types/node": "^20.5.7", "nuxt": "^3.7.0" }, "build": { diff --git a/package.json b/package.json index 25cb7f0..ae65d70 100644 --- a/package.json +++ b/package.json @@ -28,13 +28,13 @@ "release": "pnpm test && standard-version && git push --follow-tags && npm publish", "test": "pnpm vitest" }, - "packageManager": "pnpm@8.6.12", + "packageManager": "pnpm@8.7.0", "dependencies": { "consola": "^3.2.3", "mlly": "^1.4.1", "mri": "^1.2.0", "pathe": "^1.1.1", - "unbuild": "^1.2.1" + "unbuild": "^2.0.0" }, "peerDependencies": { "@nuxt/kit": "^3.7.0", @@ -45,11 +45,11 @@ "@nuxt/schema": "^3.7.0", "@nuxtjs/eslint-config-typescript": "^12.0.0", "@types/mri": "^1.1.1", - "@types/node": "^20.5.6", + "@types/node": "^20.5.7", "@vitest/coverage-v8": "^0.34.3", "eslint": "^8.48.0", "jiti": "^1.19.3", - "nuxi": "^3.7.0", + "nuxi": "^3.7.2", "nuxt": "^3.7.0", "standard-version": "^9.5.0", "vitest": "^0.34.3" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ba8e470..605515a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -21,8 +21,8 @@ importers: specifier: ^1.1.1 version: 1.1.1 unbuild: - specifier: ^1.2.1 - version: 1.2.1 + specifier: ^2.0.0 + version: 2.0.0(typescript@5.1.6) devDependencies: '@nuxt/kit': specifier: ^3.7.0 @@ -37,8 +37,8 @@ importers: specifier: ^1.1.1 version: 1.1.1 '@types/node': - specifier: ^20.5.6 - version: 20.5.6 + specifier: ^20.5.7 + version: 20.5.7 '@vitest/coverage-v8': specifier: ^0.34.3 version: 0.34.3(vitest@0.34.3) @@ -49,11 +49,11 @@ importers: specifier: ^1.19.3 version: 1.19.3 nuxi: - specifier: ^3.7.0 - version: 3.7.0 + specifier: ^3.7.2 + version: 3.7.2 nuxt: specifier: ^3.7.0 - version: 3.7.0(@types/node@20.5.6)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6) + version: 3.7.0(@types/node@20.5.7)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6) standard-version: specifier: ^9.5.0 version: 9.5.0 @@ -74,11 +74,11 @@ importers: specifier: ^3.7.0 version: 3.7.0(rollup@3.28.1) '@types/node': - specifier: ^20.5.6 - version: 20.5.6 + specifier: ^20.5.7 + version: 20.5.7 nuxt: specifier: ^3.7.0 - version: 3.7.0(@types/node@20.5.6)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6) + version: 3.7.0(@types/node@20.5.7)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6) example/playground: dependencies: @@ -87,7 +87,7 @@ importers: version: link:.. nuxt: specifier: latest - version: 3.7.0(@types/node@20.5.6)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6) + version: 3.7.0(@types/node@20.5.7)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6) packages: @@ -371,15 +371,6 @@ packages: dependencies: mime: 3.0.0 - /@esbuild/android-arm64@0.17.19: - resolution: {integrity: sha512-KBMWvEZooR7+kzY0BtbTQn0OAYY7CsiydT63pVEaPtVYF0hXbUaOyZog37DKxK7NF3XacBJOpYT4adIJh+avxA==} - engines: {node: '>=12'} - cpu: [arm64] - os: [android] - requiresBuild: true - dev: false - optional: true - /@esbuild/android-arm64@0.18.20: resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} engines: {node: '>=12'} @@ -396,15 +387,6 @@ packages: requiresBuild: true optional: true - /@esbuild/android-arm@0.17.19: - resolution: {integrity: sha512-rIKddzqhmav7MSmoFCmDIb6e2W57geRsM94gV2l38fzhXMwq7hZoClug9USI2pFRGL06f4IOPHHpFNOkWieR8A==} - engines: {node: '>=12'} - cpu: [arm] - os: [android] - requiresBuild: true - dev: false - optional: true - /@esbuild/android-arm@0.18.20: resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} engines: {node: '>=12'} @@ -421,15 +403,6 @@ packages: requiresBuild: true optional: true - /@esbuild/android-x64@0.17.19: - resolution: {integrity: sha512-uUTTc4xGNDT7YSArp/zbtmbhO0uEEK9/ETW29Wk1thYUJBz3IVnvgEiEwEa9IeLyvnpKrWK64Utw2bgUmDveww==} - engines: {node: '>=12'} - cpu: [x64] - os: [android] - requiresBuild: true - dev: false - optional: true - /@esbuild/android-x64@0.18.20: resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} engines: {node: '>=12'} @@ -446,15 +419,6 @@ packages: requiresBuild: true optional: true - /@esbuild/darwin-arm64@0.17.19: - resolution: {integrity: sha512-80wEoCfF/hFKM6WE1FyBHc9SfUblloAWx6FJkFWTWiCoht9Mc0ARGEM47e67W9rI09YoUxJL68WHfDRYEAvOhg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - /@esbuild/darwin-arm64@0.18.20: resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} engines: {node: '>=12'} @@ -471,15 +435,6 @@ packages: requiresBuild: true optional: true - /@esbuild/darwin-x64@0.17.19: - resolution: {integrity: sha512-IJM4JJsLhRYr9xdtLytPLSH9k/oxR3boaUIYiHkAawtwNOXKE8KoU8tMvryogdcT8AU+Bflmh81Xn6Q0vTZbQw==} - engines: {node: '>=12'} - cpu: [x64] - os: [darwin] - requiresBuild: true - dev: false - optional: true - /@esbuild/darwin-x64@0.18.20: resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} engines: {node: '>=12'} @@ -496,15 +451,6 @@ packages: requiresBuild: true optional: true - /@esbuild/freebsd-arm64@0.17.19: - resolution: {integrity: sha512-pBwbc7DufluUeGdjSU5Si+P3SoMF5DQ/F/UmTSb8HXO80ZEAJmrykPyzo1IfNbAoaqw48YRpv8shwd1NoI0jcQ==} - engines: {node: '>=12'} - cpu: [arm64] - os: [freebsd] - requiresBuild: true - dev: false - optional: true - /@esbuild/freebsd-arm64@0.18.20: resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} engines: {node: '>=12'} @@ -521,15 +467,6 @@ packages: requiresBuild: true optional: true - /@esbuild/freebsd-x64@0.17.19: - resolution: {integrity: sha512-4lu+n8Wk0XlajEhbEffdy2xy53dpR06SlzvhGByyg36qJw6Kpfk7cp45DR/62aPH9mtJRmIyrXAS5UWBrJT6TQ==} - engines: {node: '>=12'} - cpu: [x64] - os: [freebsd] - requiresBuild: true - dev: false - optional: true - /@esbuild/freebsd-x64@0.18.20: resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} engines: {node: '>=12'} @@ -546,15 +483,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-arm64@0.17.19: - resolution: {integrity: sha512-ct1Tg3WGwd3P+oZYqic+YZF4snNl2bsnMKRkb3ozHmnM0dGWuxcPTTntAF6bOP0Sp4x0PjSF+4uHQ1xvxfRKqg==} - engines: {node: '>=12'} - cpu: [arm64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-arm64@0.18.20: resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} engines: {node: '>=12'} @@ -571,15 +499,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-arm@0.17.19: - resolution: {integrity: sha512-cdmT3KxjlOQ/gZ2cjfrQOtmhG4HJs6hhvm3mWSRDPtZ/lP5oe8FWceS10JaSJC13GBd4eH/haHnqf7hhGNLerA==} - engines: {node: '>=12'} - cpu: [arm] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-arm@0.18.20: resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} engines: {node: '>=12'} @@ -596,15 +515,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-ia32@0.17.19: - resolution: {integrity: sha512-w4IRhSy1VbsNxHRQpeGCHEmibqdTUx61Vc38APcsRbuVgK0OPEnQ0YD39Brymn96mOx48Y2laBQGqgZ0j9w6SQ==} - engines: {node: '>=12'} - cpu: [ia32] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-ia32@0.18.20: resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} engines: {node: '>=12'} @@ -621,15 +531,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-loong64@0.17.19: - resolution: {integrity: sha512-2iAngUbBPMq439a+z//gE+9WBldoMp1s5GWsUSgqHLzLJ9WoZLZhpwWuym0u0u/4XmZ3gpHmzV84PonE+9IIdQ==} - engines: {node: '>=12'} - cpu: [loong64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-loong64@0.18.20: resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} engines: {node: '>=12'} @@ -646,15 +547,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-mips64el@0.17.19: - resolution: {integrity: sha512-LKJltc4LVdMKHsrFe4MGNPp0hqDFA1Wpt3jE1gEyM3nKUvOiO//9PheZZHfYRfYl6AwdTH4aTcXSqBerX0ml4A==} - engines: {node: '>=12'} - cpu: [mips64el] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-mips64el@0.18.20: resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} engines: {node: '>=12'} @@ -671,15 +563,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-ppc64@0.17.19: - resolution: {integrity: sha512-/c/DGybs95WXNS8y3Ti/ytqETiW7EU44MEKuCAcpPto3YjQbyK3IQVKfF6nbghD7EcLUGl0NbiL5Rt5DMhn5tg==} - engines: {node: '>=12'} - cpu: [ppc64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-ppc64@0.18.20: resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} engines: {node: '>=12'} @@ -696,15 +579,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-riscv64@0.17.19: - resolution: {integrity: sha512-FC3nUAWhvFoutlhAkgHf8f5HwFWUL6bYdvLc/TTuxKlvLi3+pPzdZiFKSWz/PF30TB1K19SuCxDTI5KcqASJqA==} - engines: {node: '>=12'} - cpu: [riscv64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-riscv64@0.18.20: resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} engines: {node: '>=12'} @@ -721,15 +595,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-s390x@0.17.19: - resolution: {integrity: sha512-IbFsFbxMWLuKEbH+7sTkKzL6NJmG2vRyy6K7JJo55w+8xDk7RElYn6xvXtDW8HCfoKBFK69f3pgBJSUSQPr+4Q==} - engines: {node: '>=12'} - cpu: [s390x] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-s390x@0.18.20: resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} engines: {node: '>=12'} @@ -746,15 +611,6 @@ packages: requiresBuild: true optional: true - /@esbuild/linux-x64@0.17.19: - resolution: {integrity: sha512-68ngA9lg2H6zkZcyp22tsVt38mlhWde8l3eJLWkyLrp4HwMUr3c1s/M2t7+kHIhvMjglIBrFpncX1SzMckomGw==} - engines: {node: '>=12'} - cpu: [x64] - os: [linux] - requiresBuild: true - dev: false - optional: true - /@esbuild/linux-x64@0.18.20: resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} engines: {node: '>=12'} @@ -771,15 +627,6 @@ packages: requiresBuild: true optional: true - /@esbuild/netbsd-x64@0.17.19: - resolution: {integrity: sha512-CwFq42rXCR8TYIjIfpXCbRX0rp1jo6cPIUPSaWwzbVI4aOfX96OXY8M6KNmtPcg7QjYeDmN+DD0Wp3LaBOLf4Q==} - engines: {node: '>=12'} - cpu: [x64] - os: [netbsd] - requiresBuild: true - dev: false - optional: true - /@esbuild/netbsd-x64@0.18.20: resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} engines: {node: '>=12'} @@ -796,15 +643,6 @@ packages: requiresBuild: true optional: true - /@esbuild/openbsd-x64@0.17.19: - resolution: {integrity: sha512-cnq5brJYrSZ2CF6c35eCmviIN3k3RczmHz8eYaVlNasVqsNY+JKohZU5MKmaOI+KkllCdzOKKdPs762VCPC20g==} - engines: {node: '>=12'} - cpu: [x64] - os: [openbsd] - requiresBuild: true - dev: false - optional: true - /@esbuild/openbsd-x64@0.18.20: resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} engines: {node: '>=12'} @@ -821,15 +659,6 @@ packages: requiresBuild: true optional: true - /@esbuild/sunos-x64@0.17.19: - resolution: {integrity: sha512-vCRT7yP3zX+bKWFeP/zdS6SqdWB8OIpaRq/mbXQxTGHnIxspRtigpkUcDMlSCOejlHowLqII7K2JKevwyRP2rg==} - engines: {node: '>=12'} - cpu: [x64] - os: [sunos] - requiresBuild: true - dev: false - optional: true - /@esbuild/sunos-x64@0.18.20: resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} engines: {node: '>=12'} @@ -846,15 +675,6 @@ packages: requiresBuild: true optional: true - /@esbuild/win32-arm64@0.17.19: - resolution: {integrity: sha512-yYx+8jwowUstVdorcMdNlzklLYhPxjniHWFKgRqH7IFlUEa0Umu3KuYplf1HUZZ422e3NU9F4LGb+4O0Kdcaag==} - engines: {node: '>=12'} - cpu: [arm64] - os: [win32] - requiresBuild: true - dev: false - optional: true - /@esbuild/win32-arm64@0.18.20: resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} engines: {node: '>=12'} @@ -871,15 +691,6 @@ packages: requiresBuild: true optional: true - /@esbuild/win32-ia32@0.17.19: - resolution: {integrity: sha512-eggDKanJszUtCdlVs0RB+h35wNlb5v4TWEkq4vZcmVt5u/HiDZrTXe2bWFQUez3RgNHwx/x4sk5++4NSSicKkw==} - engines: {node: '>=12'} - cpu: [ia32] - os: [win32] - requiresBuild: true - dev: false - optional: true - /@esbuild/win32-ia32@0.18.20: resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} engines: {node: '>=12'} @@ -896,15 +707,6 @@ packages: requiresBuild: true optional: true - /@esbuild/win32-x64@0.17.19: - resolution: {integrity: sha512-lAhycmKnVOuRYNtRtatQR1LPQf2oYCkRGkSFnseDAKPl8lu5SOsK/e1sXe5a0Pc5kHIHe6P2I/ilntNv2xf3cA==} - engines: {node: '>=12'} - cpu: [x64] - os: [win32] - requiresBuild: true - dev: false - optional: true - /@esbuild/win32-x64@0.18.20: resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} engines: {node: '>=12'} @@ -1153,7 +955,7 @@ packages: /@nuxt/ui-templates@1.3.1: resolution: {integrity: sha512-5gc02Pu1HycOVUWJ8aYsWeeXcSTPe8iX8+KIrhyEtEoOSkY0eMBuo0ssljB8wALuEmepv31DlYe5gpiRwkjESA==} - /@nuxt/vite-builder@3.7.0(@types/node@20.5.6)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6)(vue@3.3.4): + /@nuxt/vite-builder@3.7.0(@types/node@20.5.7)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6)(vue@3.3.4): resolution: {integrity: sha512-bRJy3KarHrFm/xLGHoHeZyqI/h6c4UFRCF5ngRZ/R9uebJEHuL4UhAioxDLTFu7D0vEeK7XaDgx6+NPLhBg51g==} engines: {node: ^14.18.0 || >=16.10.0} peerDependencies: @@ -1190,8 +992,8 @@ packages: strip-literal: 1.3.0 ufo: 1.3.0 unplugin: 1.4.0 - vite: 4.4.9(@types/node@20.5.6) - vite-node: 0.33.0(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) + vite-node: 0.33.0(@types/node@20.5.7) vite-plugin-checker: 0.6.2(eslint@8.48.0)(typescript@5.1.6)(vite@4.4.9) vue: 3.3.4 vue-bundle-renderer: 2.0.0 @@ -1375,24 +1177,6 @@ packages: rollup: 3.28.1 slash: 4.0.0 - /@rollup/plugin-commonjs@24.1.0(rollup@3.28.1): - resolution: {integrity: sha512-eSL45hjhCWI0jCCXcNtLVqM5N1JlBGvlFfY0m6oOYnLCJ6N0qEXoZql4sY2MOUArzhH4SA/qBpTxvvZp2Sc+DQ==} - engines: {node: '>=14.0.0'} - peerDependencies: - rollup: ^2.68.0||^3.0.0 - peerDependenciesMeta: - rollup: - optional: true - dependencies: - '@rollup/pluginutils': 5.0.3(rollup@3.28.1) - commondir: 1.0.1 - estree-walker: 2.0.2 - glob: 8.1.0 - is-reference: 1.2.1 - magic-string: 0.27.0 - rollup: 3.28.1 - dev: false - /@rollup/plugin-commonjs@25.0.4(rollup@3.28.1): resolution: {integrity: sha512-L92Vz9WUZXDnlQQl3EwbypJR4+DM2EbsO+/KOcEkP4Mc6Ct453EeDB2uH9lgRwj4w5yflgNpq9pHOiY8aoUXBQ==} engines: {node: '>=14.0.0'} @@ -1536,7 +1320,7 @@ packages: /@types/http-proxy@1.17.11: resolution: {integrity: sha512-HC8G7c1WmaF2ekqpnFq626xd3Zz0uvaqFmBJNRZCGEZCXkvSdJoNFn/8Ygbd9fKNQj8UzLdCETaI0UWPAjK7IA==} dependencies: - '@types/node': 20.5.6 + '@types/node': 20.5.7 /@types/istanbul-lib-coverage@2.0.4: resolution: {integrity: sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==} @@ -1558,8 +1342,8 @@ packages: resolution: {integrity: sha512-nJOuiTlsvmClSr3+a/trTSx4DTuY/VURsWGKSf/eeavh0LRMqdsK60ti0TlwM5iHiGOK3/Ibkxsbr7i9rzGreA==} dev: true - /@types/node@20.5.6: - resolution: {integrity: sha512-Gi5wRGPbbyOTX+4Y2iULQ27oUPrefaB0PxGQJnfyWN3kvEDGM3mIB5M/gQLmitZf7A9FmLeaqxD3L1CXpm3VKQ==} + /@types/node@20.5.7: + resolution: {integrity: sha512-dP7f3LdZIysZnmvP3ANJYTSwg+wLLl8p7RqniVlV7j+oXSXAbt9h0WIBFmJy5inWZoX9wZN6eXx+YXd9Rh3RBA==} /@types/normalize-package-data@2.4.1: resolution: {integrity: sha512-Gj7cI7z+98M282Tqmp2K5EIsoouUEzbBJhQQzDE3jSIRk6r9gsz0oUokqIUR4u1R3dMHo0pDHM7sNOHyhulypw==} @@ -1766,7 +1550,7 @@ packages: '@babel/core': 7.22.10 '@babel/plugin-transform-typescript': 7.22.10(@babel/core@7.22.10) '@vue/babel-plugin-jsx': 1.1.5(@babel/core@7.22.10) - vite: 4.4.9(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) vue: 3.3.4 transitivePeerDependencies: - supports-color @@ -1778,7 +1562,7 @@ packages: vite: ^4.0.0 vue: ^3.2.25 dependencies: - vite: 4.4.9(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) vue: 3.3.4 /@vitest/coverage-v8@0.34.3(vitest@0.34.3): @@ -1794,7 +1578,7 @@ packages: istanbul-reports: 3.1.6 magic-string: 0.30.3 picocolors: 1.0.0 - std-env: 3.4.2 + std-env: 3.4.3 test-exclude: 6.0.0 v8-to-istanbul: 9.1.0 vitest: 0.34.3 @@ -2421,12 +2205,6 @@ packages: resolution: {integrity: sha512-eXTggHWSooYhq49F2opQhuHWgzucfF2YgODK4e1566GQs5BIfP30B0oenwBJHfWxAs2fyPB1s7Mg949zLf61Yw==} engines: {node: '>=8'} - /citty@0.1.2: - resolution: {integrity: sha512-Me9nf0/BEmMOnuQzMOVXgpzkMUNbd0Am8lTl/13p0aRGAoLGk5T5sdet/42CrIGmWdG67BgHUhcKK1my1ujUEg==} - dependencies: - consola: 3.2.3 - dev: false - /citty@0.1.3: resolution: {integrity: sha512-tb6zTEb2BDSrzFedqFYFUKUuKNaxVJWCm7o02K4kADGkBDyyiz7D40rDMpguczdZyAN3aetd5fhpB01HkreNyg==} dependencies: @@ -3171,36 +2949,6 @@ packages: is-symbol: 1.0.4 dev: true - /esbuild@0.17.19: - resolution: {integrity: sha512-XQ0jAPFkK/u3LcVRcvVHQcTIqD6E2H1fvZMA5dQPSOWb3suUbWbfbRf94pjc0bNzRYLfIrDRQXr7X+LHIm5oHw==} - engines: {node: '>=12'} - hasBin: true - requiresBuild: true - optionalDependencies: - '@esbuild/android-arm': 0.17.19 - '@esbuild/android-arm64': 0.17.19 - '@esbuild/android-x64': 0.17.19 - '@esbuild/darwin-arm64': 0.17.19 - '@esbuild/darwin-x64': 0.17.19 - '@esbuild/freebsd-arm64': 0.17.19 - '@esbuild/freebsd-x64': 0.17.19 - '@esbuild/linux-arm': 0.17.19 - '@esbuild/linux-arm64': 0.17.19 - '@esbuild/linux-ia32': 0.17.19 - '@esbuild/linux-loong64': 0.17.19 - '@esbuild/linux-mips64el': 0.17.19 - '@esbuild/linux-ppc64': 0.17.19 - '@esbuild/linux-riscv64': 0.17.19 - '@esbuild/linux-s390x': 0.17.19 - '@esbuild/linux-x64': 0.17.19 - '@esbuild/netbsd-x64': 0.17.19 - '@esbuild/openbsd-x64': 0.17.19 - '@esbuild/sunos-x64': 0.17.19 - '@esbuild/win32-arm64': 0.17.19 - '@esbuild/win32-ia32': 0.17.19 - '@esbuild/win32-x64': 0.17.19 - dev: false - /esbuild@0.18.20: resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} engines: {node: '>=12'} @@ -3905,7 +3653,7 @@ packages: defu: 6.1.2 https-proxy-agent: 5.0.1 mri: 1.2.0 - node-fetch-native: 1.2.0 + node-fetch-native: 1.4.0 pathe: 1.1.1 tar: 6.1.15 transitivePeerDependencies: @@ -4486,6 +4234,7 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + requiresBuild: true /js-yaml@4.1.0: resolution: {integrity: sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==} @@ -4882,7 +4631,7 @@ packages: typescript: optional: true dependencies: - citty: 0.1.2 + citty: 0.1.3 defu: 6.1.2 esbuild: 0.18.20 fs-extra: 11.1.1 @@ -5031,9 +4780,6 @@ packages: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} - /node-fetch-native@1.2.0: - resolution: {integrity: sha512-5IAMBTl9p6PaAjYCnMv5FmqIF6GcZnawAVnzaCG0rX2aYZJ4CxEkZNtVPuTRug7fL7wyM5BQYTlAzcyMPi6oTQ==} - /node-fetch-native@1.4.0: resolution: {integrity: sha512-F5kfEj95kX8tkDhUCYdV8dg3/8Olx/94zB8+ZNthFs6Bz31UpUi8Xh40TN3thLwXgrwXry1pEg9lJ++tLWTcqA==} @@ -5126,14 +4872,14 @@ packages: dependencies: boolbase: 1.0.0 - /nuxi@3.7.0: - resolution: {integrity: sha512-FZEwNCGeEdE+CyKCoThZm+Lv+u4TnbClTyYvvby3a2joK5t8nc7upNiZ7hsd+xoOeNuZW7CZHsQp9szJm2ev9Q==} + /nuxi@3.7.2: + resolution: {integrity: sha512-WNczi4X5ms8v63BTlCH+ZZDPzoFI0/V5KW8an4Zv6qOngtONHALw1u6qvtcAqG2tuMDu8gdJuzxMZL2845Dbig==} engines: {node: ^14.18.0 || >=16.10.0} hasBin: true optionalDependencies: fsevents: 2.3.3 - /nuxt@3.7.0(@types/node@20.5.6)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6): + /nuxt@3.7.0(@types/node@20.5.7)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6): resolution: {integrity: sha512-y0/xHYqwuJt20r26xezjpr74FLWR144dMpwSxZ/O2XXUrQUnyO7vHm3fEY4vi+miKbf343YMH5B78GXAELO/Vw==} engines: {node: ^14.18.0 || >=16.10.0} hasBin: true @@ -5151,8 +4897,8 @@ packages: '@nuxt/schema': 3.7.0(rollup@3.28.1) '@nuxt/telemetry': 2.4.1(rollup@3.28.1) '@nuxt/ui-templates': 1.3.1 - '@nuxt/vite-builder': 3.7.0(@types/node@20.5.6)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6)(vue@3.3.4) - '@types/node': 20.5.6 + '@nuxt/vite-builder': 3.7.0(@types/node@20.5.7)(eslint@8.48.0)(rollup@3.28.1)(typescript@5.1.6)(vue@3.3.4) + '@types/node': 20.5.7 '@unhead/dom': 1.3.7 '@unhead/ssr': 1.3.7 '@unhead/vue': 1.3.7(vue@3.3.4) @@ -5177,7 +4923,7 @@ packages: magic-string: 0.30.3 mlly: 1.4.1 nitropack: 2.6.1 - nuxi: 3.7.0 + nuxi: 3.7.2 nypm: 0.3.1 ofetch: 1.3.3 ohash: 1.1.3 @@ -6049,12 +5795,12 @@ packages: dependencies: glob: 7.2.3 - /rollup-plugin-dts@5.3.1(rollup@3.28.1)(typescript@5.1.6): - resolution: {integrity: sha512-gusMi+Z4gY/JaEQeXnB0RUdU82h1kF0WYzCWgVmV4p3hWXqelaKuCvcJawfeg+EKn2T1Ie+YWF2OiN1/L8bTVg==} - engines: {node: '>=v14.21.3'} + /rollup-plugin-dts@6.0.0(rollup@3.28.1)(typescript@5.1.6): + resolution: {integrity: sha512-A996xSZDAqnx/KfFttzC8mDEuyMjsRpiLCrlGc8effhK8KhE3AG0g1woQiITgFc5HSE8HWU7ccR9CiQ3vXgUlQ==} + engines: {node: '>=v18.17.1'} peerDependencies: - rollup: ^3.0 - typescript: ^4.1 || ^5.0 + rollup: ^3.25.0 + typescript: ^4.5 || ^5.0 dependencies: magic-string: 0.30.3 rollup: 3.28.1 @@ -6315,10 +6061,6 @@ packages: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} engines: {node: '>= 0.8'} - /std-env@3.4.2: - resolution: {integrity: sha512-Cw6eJDX9AxEEL0g5pYj8Zx9KXtDf60rxwS2ze0HBanS0aKhj1sBlzcsmg+R0qYy8byFa854/yR2X5ZmBSClVmg==} - dev: true - /std-env@3.4.3: resolution: {integrity: sha512-f9aPhy8fYBuMN+sNfakZV18U39PbalgjXG3lLB9WkaYTxijru61wb57V9wxxNthXM5Sd88ETBWi29qLAsHO52Q==} @@ -6697,32 +6439,37 @@ packages: which-boxed-primitive: 1.0.2 dev: true - /unbuild@1.2.1: - resolution: {integrity: sha512-J4efk69Aye43tWcBPCsLK7TIRppGrEN4pAlDzRKo3HSE6MgTSTBxSEuE3ccx7ixc62JvGQ/CoFXYqqF2AHozow==} + /unbuild@2.0.0(typescript@5.1.6): + resolution: {integrity: sha512-JWCUYx3Oxdzvw2J9kTAp+DKE8df/BnH/JTSj6JyA4SH40ECdFu7FoJJcrm8G92B7TjofQ6GZGjJs50TRxoH6Wg==} hasBin: true + peerDependencies: + typescript: ^5.1.6 + peerDependenciesMeta: + typescript: + optional: true dependencies: '@rollup/plugin-alias': 5.0.0(rollup@3.28.1) - '@rollup/plugin-commonjs': 24.1.0(rollup@3.28.1) + '@rollup/plugin-commonjs': 25.0.4(rollup@3.28.1) '@rollup/plugin-json': 6.0.0(rollup@3.28.1) '@rollup/plugin-node-resolve': 15.2.1(rollup@3.28.1) '@rollup/plugin-replace': 5.0.2(rollup@3.28.1) '@rollup/pluginutils': 5.0.3(rollup@3.28.1) chalk: 5.3.0 + citty: 0.1.3 consola: 3.2.3 defu: 6.1.2 - esbuild: 0.17.19 + esbuild: 0.19.2 globby: 13.2.2 hookable: 5.5.3 jiti: 1.19.3 magic-string: 0.30.3 mkdist: 1.3.0(typescript@5.1.6) mlly: 1.4.1 - mri: 1.2.0 pathe: 1.1.1 pkg-types: 1.0.3 pretty-bytes: 6.1.1 rollup: 3.28.1 - rollup-plugin-dts: 5.3.1(rollup@3.28.1)(typescript@5.1.6) + rollup-plugin-dts: 6.0.0(rollup@3.28.1)(typescript@5.1.6) scule: 1.0.0 typescript: 5.1.6 untyped: 1.4.0 @@ -6934,7 +6681,7 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /vite-node@0.33.0(@types/node@20.5.6): + /vite-node@0.33.0(@types/node@20.5.7): resolution: {integrity: sha512-19FpHYbwWWxDr73ruNahC+vtEdza52kA90Qb3La98yZ0xULqV8A5JLNPUff0f5zID4984tW7l3DH2przTJUZSw==} engines: {node: '>=v14.18.0'} hasBin: true @@ -6944,7 +6691,7 @@ packages: mlly: 1.4.1 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.9(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) transitivePeerDependencies: - '@types/node' - less @@ -6955,7 +6702,7 @@ packages: - supports-color - terser - /vite-node@0.34.3(@types/node@20.5.6): + /vite-node@0.34.3(@types/node@20.5.7): resolution: {integrity: sha512-+0TzJf1g0tYXj6tR2vEyiA42OPq68QkRZCu/ERSo2PtsDJfBpDyEfuKbRvLmZqi/CgC7SCBtyC+WjTGNMRIaig==} engines: {node: '>=v14.18.0'} hasBin: true @@ -6965,7 +6712,7 @@ packages: mlly: 1.4.1 pathe: 1.1.1 picocolors: 1.0.0 - vite: 4.4.9(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) transitivePeerDependencies: - '@types/node' - less @@ -7023,13 +6770,13 @@ packages: strip-ansi: 6.0.1 tiny-invariant: 1.3.1 typescript: 5.1.6 - vite: 4.4.9(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) vscode-languageclient: 7.0.0 vscode-languageserver: 7.0.0 vscode-languageserver-textdocument: 1.0.8 vscode-uri: 3.0.7 - /vite@4.4.9(@types/node@20.5.6): + /vite@4.4.9(@types/node@20.5.7): resolution: {integrity: sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==} engines: {node: ^14.18.0 || >=16.0.0} hasBin: true @@ -7057,7 +6804,7 @@ packages: terser: optional: true dependencies: - '@types/node': 20.5.6 + '@types/node': 20.5.7 esbuild: 0.18.20 postcss: 8.4.28 rollup: 3.28.1 @@ -7097,7 +6844,7 @@ packages: dependencies: '@types/chai': 4.3.5 '@types/chai-subset': 1.3.3 - '@types/node': 20.5.6 + '@types/node': 20.5.7 '@vitest/expect': 0.34.3 '@vitest/runner': 0.34.3 '@vitest/snapshot': 0.34.3 @@ -7112,12 +6859,12 @@ packages: magic-string: 0.30.3 pathe: 1.1.1 picocolors: 1.0.0 - std-env: 3.4.2 + std-env: 3.4.3 strip-literal: 1.3.0 tinybench: 2.5.0 tinypool: 0.7.0 - vite: 4.4.9(@types/node@20.5.6) - vite-node: 0.34.3(@types/node@20.5.6) + vite: 4.4.9(@types/node@20.5.7) + vite-node: 0.34.3(@types/node@20.5.7) why-is-node-running: 2.2.2 transitivePeerDependencies: - less diff --git a/src/build.ts b/src/build.ts index 5f797ff..20afadb 100644 --- a/src/build.ts +++ b/src/build.ts @@ -41,7 +41,7 @@ export async function buildModule (opts: BuildModuleOptions) { ], hooks: { async 'rollup:done' (ctx) { - // Generate CommonJS stup + // Generate CommonJS stub await writeCJSStub(ctx.options.outDir) // Load module meta @@ -53,6 +53,7 @@ export async function buildModule (opts: BuildModuleOptions) { consola.error('Cannot load module. Please check dist:', moduleEntryPath) return null }) + if (!moduleFn) { return } @@ -81,6 +82,7 @@ export async function buildModule (opts: BuildModuleOptions) { async function writeTypes (distDir: string, meta: ModuleMeta) { const dtsFile = resolve(distDir, 'types.d.ts') + const dtsFileMts = resolve(distDir, 'types.d.mts') if (existsSync(dtsFile)) { return } @@ -88,7 +90,13 @@ async function writeTypes (distDir: string, meta: ModuleMeta) { // Read generated module types const moduleTypesFile = resolve(distDir, 'module.d.ts') const moduleTypes = await fsp.readFile(moduleTypesFile, 'utf8').catch(() => '') - const typeExports = findExports(moduleTypes) + const typeExports = findExports( + // Replace `export { type Foo }` with `export { Foo }` + moduleTypes + .replace(/export\s*{.*?}/sg, match => + match.replace(/\btype\b/g, '') + ) + ) const isStub = moduleTypes.includes('export *') const schemaShims = [] @@ -124,6 +132,9 @@ export { ${typeExports[0].names.join(', ')} } from './module' ` await fsp.writeFile(dtsFile, dtsContents, 'utf8') + if (!existsSync(dtsFileMts)) { + await fsp.writeFile(dtsFileMts, dtsContents, 'utf8') + } } async function writeCJSStub (distDir: string) { diff --git a/test/build.spec.ts b/test/build.spec.ts index 53ee99a..9d40103 100644 --- a/test/build.spec.ts +++ b/test/build.spec.ts @@ -19,11 +19,14 @@ describe('module builder', () => { expect(files).toMatchInlineSnapshot(` [ "module.cjs", + "module.d.mts", "module.d.ts", "module.json", "module.mjs", "runtime", + "types.d.mts", "types.d.ts", + "utils.d.mts", "utils.d.ts", "utils.mjs", ]