diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d7ab24d33..8df0976698 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,73 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## v2.9.5 + +[compare changes](https://github.com/unjs/nitro/compare/v2.9.4...v2.9.5) + +### 🚀 Enhancements + +- **openapi:** Add experimental `/_nitro/scalar` endpoint ([#2252](https://github.com/unjs/nitro/pull/2252)) + +### 🩹 Fixes + +- **openapi:** Use dynamic host + port ([#2216](https://github.com/unjs/nitro/pull/2216)) +- **openapi:** Add `schema` to generated parameters ([#2235](https://github.com/unjs/nitro/pull/2235)) +- **openapi:** Avoid double slash for base ([fdf7e70a](https://github.com/unjs/nitro/commit/fdf7e70a)) +- **options:** Set `scheduledTasks` to an empty object by default ([#2285](https://github.com/unjs/nitro/pull/2285)) +- **prerender:** Call `nitroApp` close hook when done prerendering ([#2287](https://github.com/unjs/nitro/pull/2287)) +- **types:** Return `T` from `Serialize` when it extends `undefined` ([#2286](https://github.com/unjs/nitro/pull/2286)) +- **raw:** Exclude yaml from raw plugin ([#2275](https://github.com/unjs/nitro/pull/2275)) +- **externals:** Check explicit inline rules on resolved id ([#2288](https://github.com/unjs/nitro/pull/2288)) +- **raw:** Allow importing relative paths ([#2289](https://github.com/unjs/nitro/pull/2289)) +- **types:** Make c12 env types available for `NitroConfig` ([#2292](https://github.com/unjs/nitro/pull/2292)) +- **netlify-edge:** Write `_headers` and `_redirects` ([#2291](https://github.com/unjs/nitro/pull/2291)) +- **cloudflare-pages:** Write `_headers` and `_redirects` for non static builds ([#2290](https://github.com/unjs/nitro/pull/2290)) +- **netlify:** Allow writing `config.json` ([#2264](https://github.com/unjs/nitro/pull/2264)) +- Allow importing utils from `nitropack/runtime` ([#2314](https://github.com/unjs/nitro/pull/2314)) + +### 💅 Refactors + +- **openapi:** Upgrade to openapi 3.1 ([#2297](https://github.com/unjs/nitro/pull/2297)) + +### 📖 Documentation + +- **routing:** Add note about middleware execution order ([#2282](https://github.com/unjs/nitro/pull/2282)) +- **routing:** Fx link to h3 object syntax handler ([#2281](https://github.com/unjs/nitro/pull/2281)) +- Update tasks return value ([8a62e7db](https://github.com/unjs/nitro/commit/8a62e7db)) +- **cache:** Add a note for serverless environment ([dc83a2e2](https://github.com/unjs/nitro/commit/dc83a2e2)) +- Fix typo ([#2298](https://github.com/unjs/nitro/pull/2298)) + +### 📦 Build + +- Use `.d.ts` for runtime generated types ([#2313](https://github.com/unjs/nitro/pull/2313)) + +### 🏡 Chore + +- Lint ([f7330329](https://github.com/unjs/nitro/commit/f7330329)) +- Update docs ([00c308c1](https://github.com/unjs/nitro/commit/00c308c1)) +- Update deps and lockfile ([55fd222b](https://github.com/unjs/nitro/commit/55fd222b)) +- Remove unused imports ([#2293](https://github.com/unjs/nitro/pull/2293)) +- Update deps and lockfile ([40883766](https://github.com/unjs/nitro/commit/40883766)) +- Update radix3 and lockfile ([7429465f](https://github.com/unjs/nitro/commit/7429465f)) + +### ❤️ Contributors + +- Pooya Parsa ([@pi0](http://github.com/pi0)) +- Matt Kane +- Hans Pagel +- Jamaluddin Rumi <16121031@student.mercubuana-yogya.ac.id> +- Julien Huang +- Bobbie Goede +- Damian Głowala ([@DamianGlowala](http://github.com/DamianGlowala)) +- Daniel Roe ([@danielroe](http://github.com/danielroe)) +- Sébastien Chopin ([@Atinux](http://github.com/Atinux)) +- Neil Richter ([@noook](http://github.com/noook)) +- Samuel Burkhard +- Shoshana Connack ([@moshetanzer](http://github.com/moshetanzer)) +- Yuurin ([@byyuurin](http://github.com/byyuurin)) +- Markthree ([@markthree](http://github.com/markthree)) + ## v2.9.4 [compare changes](https://github.com/unjs/nitro/compare/v2.9.3...v2.9.4) diff --git a/docs/2.deploy/20.providers/netlify.md b/docs/2.deploy/20.providers/netlify.md index 878ab46cd8..5ffb94bc53 100644 --- a/docs/2.deploy/20.providers/netlify.md +++ b/docs/2.deploy/20.providers/netlify.md @@ -46,3 +46,7 @@ Make sure the publish directory is set to `dist` when creating a new project. On-demand Builders are serverless functions used to generate web content as needed that’s automatically cached on Netlify’s Edge CDN. They enable you to build pages for your site when a user visits them for the first time and then cache them at the edge for subsequent visits. :read-more{title="Netlify On-demand Builders" to="https://docs.netlify.com/configure-builds/on-demand-builders/"} + +## Custom deploy configuration + +You can provide additional deploy configuration using the `netlify` key inside `nitro.config`. It will be merged with built-in auto-generated config. Currently the only supported value is `images.remote_images`, for [configuring Netlify Image CDN](https://docs.netlify.com/image-cdn/create-integration/). diff --git a/package.json b/package.json index e404819610..f6ce7c98da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nitropack", - "version": "2.9.4", + "version": "2.9.5", "description": "Build and Deploy Universal JavaScript Servers", "repository": "unjs/nitro", "license": "MIT", @@ -18,12 +18,16 @@ "types": "./dist/cli/index.d.mts", "import": "./dist/cli/index.mjs" }, + "./runtime": { + "types": "./dist/runtime/index.d.ts", + "import": "./dist/runtime/index.mjs" + }, "./runtime/*": { - "types": "./dist/runtime/*.d.mts", + "types": "./dist/runtime/*.d.ts", "import": "./dist/runtime/*.mjs" }, "./dist/runtime/*": { - "types": "./dist/runtime/*.d.mts", + "types": "./dist/runtime/*.d.ts", "import": "./dist/runtime/*.mjs" }, "./package.json": "./package.json" @@ -111,7 +115,7 @@ "perfect-debounce": "^1.0.0", "pkg-types": "^1.0.3", "pretty-bytes": "^6.1.1", - "radix3": "^1.1.1", + "radix3": "^1.1.2", "rollup": "^4.13.0", "rollup-plugin-visualizer": "^5.12.0", "scule": "^1.3.0", @@ -181,4 +185,4 @@ ] } } -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 148a6a1c92..04cb8e61ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -169,8 +169,8 @@ importers: specifier: ^6.1.1 version: 6.1.1 radix3: - specifier: ^1.1.1 - version: 1.1.1 + specifier: ^1.1.2 + version: 1.1.2 rollup: specifier: ^4.13.0 version: 4.13.0 @@ -285,7 +285,7 @@ importers: version: 3.1.2 miniflare: specifier: ^3.20240314.0 - version: 3.20240314.0 + version: 3.20240320.0 prettier: specifier: ^3.2.5 version: 3.2.5 @@ -542,8 +542,8 @@ packages: '@azure/core-tracing': 1.1.1 '@azure/core-util': 1.8.1 '@azure/logger': 1.1.1 - '@azure/msal-browser': 3.10.0 - '@azure/msal-node': 2.6.4 + '@azure/msal-browser': 3.11.0 + '@azure/msal-node': 2.6.5 events: 3.3.0 jws: 4.0.0 open: 8.4.2 @@ -560,15 +560,15 @@ packages: tslib: 2.6.2 dev: true - /@azure/msal-browser@3.10.0: - resolution: {integrity: sha512-mnmi8dCXVNZI+AGRq0jKQ3YiodlIC4W9npr6FCB9WN6NQT+6rq+cIlxgUb//BjLyzKsnYo+i4LROGeMyU+6v1A==} + /@azure/msal-browser@3.11.0: + resolution: {integrity: sha512-Xc0g1gdB2gdscPeuUGKmlGMgP1L/AWDeuxaToWkeautPdZqKvzeE82ggqLMctKZ0yq6e7F1XfGhUDCcUo7Db9w==} engines: {node: '>=0.8.0'} dependencies: - '@azure/msal-common': 14.7.1 + '@azure/msal-common': 14.8.0 dev: true - /@azure/msal-common@14.7.1: - resolution: {integrity: sha512-v96btzjM7KrAu4NSEdOkhQSTGOuNUIIsUdB8wlyB9cdgl5KqEKnTonHUZ8+khvZ6Ap542FCErbnTyDWl8lZ2rA==} + /@azure/msal-common@14.8.0: + resolution: {integrity: sha512-FIghuAzpgmc5ZAW2rCTAHKdhGcCRqg/UyroidTgGgSRrG1gOsEbUTW+7lmEFTz84ttCv5RnjOAUUi/SQjUTw0w==} engines: {node: '>=0.8.0'} dev: true @@ -577,11 +577,11 @@ packages: engines: {node: '>=0.8.0'} dev: true - /@azure/msal-node@2.6.4: - resolution: {integrity: sha512-nNvEPx009/80UATCToF+29NZYocn01uKrB91xtFr7bSqkqO1PuQGXRyYwryWRztUrYZ1YsSbw9A+LmwOhpVvcg==} + /@azure/msal-node@2.6.5: + resolution: {integrity: sha512-cVyQqKW75RnAd2ew31STlMOHa+g9su1Fddno7h86B9nEvJjkIhiGBKkS5VVR/3WeSbLzBLGKInTunW6gEY+yDg==} engines: {node: '>=16'} dependencies: - '@azure/msal-common': 14.7.1 + '@azure/msal-common': 14.8.0 jsonwebtoken: 9.0.2 uuid: 8.3.2 dev: true @@ -845,8 +845,8 @@ packages: mime: 3.0.0 dev: false - /@cloudflare/workerd-darwin-64@1.20240314.0: - resolution: {integrity: sha512-19xW64AmkjGnp9ZSwa5RPMTBJ0eqadY/oLs3RcdC8J+R8vT766U2bgxyuf3VATlOf+T7t28aGYzW/QcBRls9eg==} + /@cloudflare/workerd-darwin-64@1.20240320.1: + resolution: {integrity: sha512-ioG5k2M17xyiAlK/k3L21NZLMVeSHMjwlmGtZyCyzSLL5/zGINcgZ5yPLV0UuWiysw07/6Jjzm5Sx94hzMVybg==} engines: {node: '>=16'} cpu: [x64] os: [darwin] @@ -854,8 +854,8 @@ packages: dev: true optional: true - /@cloudflare/workerd-darwin-arm64@1.20240314.0: - resolution: {integrity: sha512-gq78D30GlNSg55YRzCzNHPuLp87L7xmYCYa5hIuIE7xpqhqGN6FV/mRtp2TQ5VoDXiuq1F+VdEZDwQFvrNAvtg==} + /@cloudflare/workerd-darwin-arm64@1.20240320.1: + resolution: {integrity: sha512-Ga6RDdnFEIsN4WuWsaP9bLGvK9K7pEIVoSIgmw6vweVlD8UK/a2MPGrsF1ogwdeCTCOMY8wUh9poL/Yu48IPpg==} engines: {node: '>=16'} cpu: [arm64] os: [darwin] @@ -863,8 +863,8 @@ packages: dev: true optional: true - /@cloudflare/workerd-linux-64@1.20240314.0: - resolution: {integrity: sha512-1PYddg+lGGOUkXNt3LEHB0GvIBWjilTNwmbacGyyVRm+zaWGKqt2bS3bW/TY6cHJ1lxFe/fDMrQOgnSBB7jGIw==} + /@cloudflare/workerd-linux-64@1.20240320.1: + resolution: {integrity: sha512-KFof5H8eU0NXv+pUAU7Lk/OLtOmfsioTJqu0v6kPL7QsTGsgzj5sEQNcQ8DONSze549Yflu5W00qpA2cPz9eWQ==} engines: {node: '>=16'} cpu: [x64] os: [linux] @@ -872,8 +872,8 @@ packages: dev: true optional: true - /@cloudflare/workerd-linux-arm64@1.20240314.0: - resolution: {integrity: sha512-GIyyO+TKYQ7TsM/DgpoHP2uQrJuPEc/cpRaXYeOzHerGAdQRej6iS2+LAnTJgLTXgOC4DE622mKBL3tnZvuKVQ==} + /@cloudflare/workerd-linux-arm64@1.20240320.1: + resolution: {integrity: sha512-t+kGc6dGdkKvVMGcHCPhlCsUZF5dj8xbAFvLB7DAJ8T79ys30rmY2Lu/C8vKlhjH9TJhbzgKmPaJ0wC/K4euvw==} engines: {node: '>=16'} cpu: [arm64] os: [linux] @@ -881,8 +881,8 @@ packages: dev: true optional: true - /@cloudflare/workerd-windows-64@1.20240314.0: - resolution: {integrity: sha512-NWZeVXEXJfPuLAXfMTiFusJNOMnsHkBae0C4hlqzwIzYiQ0PYnQ+BEWFS5eWy5dZihhFrsW3VRYqnTbgESIkzw==} + /@cloudflare/workerd-windows-64@1.20240320.1: + resolution: {integrity: sha512-9xDylCOsuzWqGuANkuUByiJ5RHeMqgw37FiI7rn8I6zdGAc/alOB9B4Bh7B73WC2uEpFL+XCEjcHZ6NmsO4NaQ==} engines: {node: '>=16'} cpu: [x64] os: [win32] @@ -3179,7 +3179,7 @@ packages: hasBin: true dependencies: caniuse-lite: 1.0.30001600 - electron-to-chromium: 1.4.715 + electron-to-chromium: 1.4.716 node-releases: 2.0.14 update-browserslist-db: 1.0.13(browserslist@4.23.0) dev: true @@ -3705,8 +3705,8 @@ packages: engines: {node: '>=8'} dev: true - /css-declaration-sorter@7.1.1(postcss@8.4.38): - resolution: {integrity: sha512-dZ3bVTEEc1vxr3Bek9vGwfB5Z6ESPULhcRvO472mfjVnj8jRcTnKO8/JTczlvxM10Myb+wBM++1MtdO76eWcaQ==} + /css-declaration-sorter@7.2.0(postcss@8.4.38): + resolution: {integrity: sha512-h70rUM+3PNFuaBDTLe8wF/cdWu+dOZmb7pJt8Z2sedYbAcQVQV/tEchueg3GWxwqS0cxtbxmaHEdkNACqcvsow==} engines: {node: ^14 || ^16 || >=18} peerDependencies: postcss: ^8.0.9 @@ -3751,14 +3751,14 @@ packages: hasBin: true dev: true - /cssnano-preset-default@6.1.1(postcss@8.4.38): - resolution: {integrity: sha512-XW/dYN2p8Jdkp1lovFd0UVRh6RB0iMyXJbAE9Qm+taR3p2LGu492AW34lVaukUrXoK9IxK5aK3CUmFpUorU4oA==} + /cssnano-preset-default@6.1.2(postcss@8.4.38): + resolution: {integrity: sha512-1C0C+eNaeN8OcHQa193aRgYexyJtU8XwbdieEjClw+J9d94E41LwT6ivKH0WT+fYwYWB0Zp3I3IZ7tI/BbUbrg==} engines: {node: ^14 || ^16 || >=18.0} peerDependencies: postcss: ^8.4.31 dependencies: browserslist: 4.23.0 - css-declaration-sorter: 7.1.1(postcss@8.4.38) + css-declaration-sorter: 7.2.0(postcss@8.4.38) cssnano-utils: 4.0.2(postcss@8.4.38) postcss: 8.4.38 postcss-calc: 9.0.1(postcss@8.4.38) @@ -3799,13 +3799,13 @@ packages: postcss: 8.4.38 dev: true - /cssnano@6.1.1(postcss@8.4.38): - resolution: {integrity: sha512-paTFZuiVohpaXJuau8l7buFt9+FTmfjwEO70EKitzYOQw3frib/It4sb6cQ+gJyDEyY+myDSni6IbBvKZ0N8Lw==} + /cssnano@6.1.2(postcss@8.4.38): + resolution: {integrity: sha512-rYk5UeX7VAM/u0lNqewCdasdtPK81CgX8wJFLEIXHbV2oldWRgJAsZrdhRXkV1NJzA2g850KiFm9mMU2HxNxMA==} engines: {node: ^14 || ^16 || >=18.0} peerDependencies: postcss: ^8.4.31 dependencies: - cssnano-preset-default: 6.1.1(postcss@8.4.38) + cssnano-preset-default: 6.1.2(postcss@8.4.38) lilconfig: 3.1.1 postcss: 8.4.38 dev: true @@ -4193,8 +4193,8 @@ packages: /ee-first@1.1.1: resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} - /electron-to-chromium@1.4.715: - resolution: {integrity: sha512-XzWNH4ZSa9BwVUQSDorPWAUQ5WGuYz7zJUNpNif40zFCiCl20t8zgylmreNmn26h5kiyw2lg7RfTmeMBsDklqg==} + /electron-to-chromium@1.4.716: + resolution: {integrity: sha512-t/MXMzFKQC3UfMDpw7V5wdB/UAB8dWx4hEsy+fpPYJWW3gqh3u5T1uXp6vR+H6dGCPBxkRo+YBcapBLvbGQHRw==} dev: true /emoji-regex@8.0.0: @@ -4811,7 +4811,6 @@ packages: /event-target-shim@5.0.1: resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==} engines: {node: '>=6'} - requiresBuild: true /eventemitter3@4.0.7: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} @@ -4879,8 +4878,8 @@ packages: engines: {node: '>=12.0.0'} dev: true - /express@4.19.1: - resolution: {integrity: sha512-K4w1/Bp7y8iSiVObmCrtq8Cs79XjJc/RU2YYkZQ7wpUu5ZyZ7MtPHkqoMz4pf+mgXfNvo2qft8D9OnrH2ABk9w==} + /express@4.19.2: + resolution: {integrity: sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==} engines: {node: '>= 0.10.0'} dependencies: accepts: 1.3.8 @@ -5053,7 +5052,7 @@ packages: '@types/cors': 2.8.17 '@types/express': 4.17.3 cors: 2.8.5 - express: 4.19.1 + express: 4.19.2 firebase-admin: 12.0.0 node-fetch: 2.7.0 protobufjs: 7.2.6 @@ -5541,7 +5540,7 @@ packages: destr: 2.0.3 iron-webcrypto: 1.1.0 ohash: 1.1.3 - radix3: 1.1.1 + radix3: 1.1.2 ufo: 1.5.3 uncrypto: 0.1.3 unenv: 1.9.0 @@ -6673,8 +6672,8 @@ packages: engines: {node: '>=4'} dev: true - /miniflare@3.20240314.0: - resolution: {integrity: sha512-vjjiCEgNy4rfE8VP2C9xngT3eQY4HQg5eiXL+I845voM+6m67a7sZaGl2MspANNHXAKVi71m5bAzFgPcb2Jw9w==} + /miniflare@3.20240320.0: + resolution: {integrity: sha512-4M2QRxs+J5sUsybBzKT++tlbrjjjGZdtWxKmj2sqLsT26dGaKDz7DxjAeF5XIhKa5cADcffygjxx4EvfWocMmw==} engines: {node: '>=16.13'} hasBin: true dependencies: @@ -6686,7 +6685,7 @@ packages: glob-to-regexp: 0.4.1 stoppable: 1.1.0 undici: 6.10.1 - workerd: 1.20240314.0 + workerd: 1.20240320.1 ws: 8.16.0 youch: 3.3.3 zod: 3.22.4 @@ -6768,7 +6767,7 @@ packages: dependencies: autoprefixer: 10.4.19(postcss@8.4.38) citty: 0.1.6 - cssnano: 6.1.1(postcss@8.4.38) + cssnano: 6.1.2(postcss@8.4.38) defu: 6.1.4 esbuild: 0.19.12 fs-extra: 11.2.0 @@ -7753,8 +7752,8 @@ packages: resolution: {integrity: sha512-kJt5qhMxoszgU/62PLP1CJytzd2NKetjSRnyuj31fDd3Rlcz3fzlFdFLD1SItunPwyqEOkca6GbV612BWfaBag==} dev: false - /radix3@1.1.1: - resolution: {integrity: sha512-yUUd5VTiFtcMEx0qFUxGAv5gbMc1un4RvEO1JZdP7ZUl/RHygZK6PknIKntmQRZxnMY3ZXD2ISaw1ij8GYW1yg==} + /radix3@1.1.2: + resolution: {integrity: sha512-b484I/7b8rDEdSDKckSSBA8knMpcdsXudlE/LNL639wFoHKwLbEkQFZHWEYwDC0wa0FKUcCY+GAF73Z7wxNVFA==} dev: false /randombytes@2.1.0: @@ -8680,8 +8679,8 @@ packages: resolution: {integrity: sha512-N8hW3PG/3aOoZAN5V/NSAEDz0ZixDSSt5b/a05iqtpgfLWMSVuCo7w0k2vVvEjdrIoeGqZzweX2WlyioNIHchA==} dev: true - /tinypool@0.8.2: - resolution: {integrity: sha512-SUszKYe5wgsxnNOVlBYO6IC+8VGWdVGZWAqUxp3UErNBtptZvWbwyUOyzNL59zigz2rCA92QiL3wvG+JDSdJdQ==} + /tinypool@0.8.3: + resolution: {integrity: sha512-Ud7uepAklqRH1bvwy22ynrliC7Dljz7Tm8M/0RBUW+YRa4YHhZ6e4PpgE+fu1zr/WqB1kbeuVrdfeuyIBpy4tw==} engines: {node: '>=14.0.0'} dev: true @@ -9193,7 +9192,7 @@ packages: debug: 4.3.4 pathe: 1.1.2 picocolors: 1.0.0 - vite: 5.2.2 + vite: 5.2.6 transitivePeerDependencies: - '@types/node' - less @@ -9205,8 +9204,8 @@ packages: - terser dev: true - /vite@5.2.2: - resolution: {integrity: sha512-FWZbz0oSdLq5snUI0b6sULbz58iXFXdvkZfZWR/F0ZJuKTSPO7v72QPXt6KqYeMFb0yytNp6kZosxJ96Nr/wDQ==} + /vite@5.2.6: + resolution: {integrity: sha512-FPtnxFlSIKYjZ2eosBQamz4CbyrTizbZ3hnGJlh/wMtCrlp1Hah6AzBLjGI5I2urTfNnpovpHdrL6YRuBOPnCA==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: @@ -9281,8 +9280,8 @@ packages: std-env: 3.7.0 strip-literal: 2.0.0 tinybench: 2.6.0 - tinypool: 0.8.2 - vite: 5.2.2 + tinypool: 0.8.3 + vite: 5.2.6 vite-node: 1.4.0 why-is-node-running: 2.2.2 transitivePeerDependencies: @@ -9397,17 +9396,17 @@ packages: string-width: 4.2.3 dev: true - /workerd@1.20240314.0: - resolution: {integrity: sha512-5vXqDe6vJTMpfPVW8Vtcy2zcVIBnOIMv0D+Z0gVPMPq++KwEyQWzCIVLpIyc28EUc5bW3gEO49E8BN1PQebgfw==} + /workerd@1.20240320.1: + resolution: {integrity: sha512-nuavAGGjh0qqM6RF5zxTHyUwEqdLCHchodbrpbh/xlJpFGnJVY5C1YgSi2S9aLkJJoa0/25Ta/+EzXEbApA/3w==} engines: {node: '>=16'} hasBin: true requiresBuild: true optionalDependencies: - '@cloudflare/workerd-darwin-64': 1.20240314.0 - '@cloudflare/workerd-darwin-arm64': 1.20240314.0 - '@cloudflare/workerd-linux-64': 1.20240314.0 - '@cloudflare/workerd-linux-arm64': 1.20240314.0 - '@cloudflare/workerd-windows-64': 1.20240314.0 + '@cloudflare/workerd-darwin-64': 1.20240320.1 + '@cloudflare/workerd-darwin-arm64': 1.20240320.1 + '@cloudflare/workerd-linux-64': 1.20240320.1 + '@cloudflare/workerd-linux-arm64': 1.20240320.1 + '@cloudflare/workerd-windows-64': 1.20240320.1 dev: true /wrap-ansi@7.0.0: diff --git a/runtime.d.ts b/runtime.d.ts new file mode 100644 index 0000000000..3e2f05a9a7 --- /dev/null +++ b/runtime.d.ts @@ -0,0 +1 @@ +export * from "./dist/runtime/index"; diff --git a/src/presets/netlify.ts b/src/presets/netlify.ts index ba06d8aefb..951f638ab7 100644 --- a/src/presets/netlify.ts +++ b/src/presets/netlify.ts @@ -25,6 +25,19 @@ export const netlify = defineNitroPreset({ await writeHeaders(nitro); await writeRedirects(nitro); + if (nitro.options.netlify) { + const configPath = join( + nitro.options.output.dir, + "../deploy/v1/config.json" + ); + await fsp.mkdir(dirname(configPath), { recursive: true }); + await fsp.writeFile( + configPath, + JSON.stringify(nitro.options.netlify), + "utf8" + ); + } + const functionConfig = { config: { nodeModuleFormat: "esm" }, version: 1, diff --git a/src/rollup/config.ts b/src/rollup/config.ts index 79aea03e79..c1369ee3c9 100644 --- a/src/rollup/config.ts +++ b/src/rollup/config.ts @@ -419,6 +419,7 @@ export const plugins = [ "~~", "@@/", "virtual:", + "nitropack/runtime", ...(nitro.options.experimental.wasm ? [(id) => id.endsWith(".wasm")] : []), diff --git a/src/types/presets/index.ts b/src/types/presets/index.ts index bb817aaa6b..990bb99ffb 100644 --- a/src/types/presets/index.ts +++ b/src/types/presets/index.ts @@ -2,12 +2,14 @@ import { AWSAmplifyOptions } from "./aws-amplify"; import { AzureOptions } from "./azure"; import { CloudflareOptions } from "./cloudflare"; import { FirebaseOptions } from "./firebase"; +import { NetlifyOptions } from "./netlify"; import { VercelOptions } from "./vercel"; export interface PresetOptions { + awsAmplify: AWSAmplifyOptions; azure: AzureOptions; cloudflare: CloudflareOptions; firebase: FirebaseOptions; + netlify: NetlifyOptions; vercel: VercelOptions; - awsAmplify: AWSAmplifyOptions; } diff --git a/src/types/presets/netlify.ts b/src/types/presets/netlify.ts new file mode 100644 index 0000000000..9554a50fe4 --- /dev/null +++ b/src/types/presets/netlify.ts @@ -0,0 +1,12 @@ +/** + * Netlify options + */ +export interface NetlifyOptions { + images?: { + /** + * Permitted remote image sources. Array of regex strings. + * @see https://docs.netlify.com/image-cdn/overview/#remote-path + */ + remote_images?: string[]; + }; +} diff --git a/test/presets/netlify.test.ts b/test/presets/netlify.test.ts index d2a0a50e60..a96eb8a6d9 100644 --- a/test/presets/netlify.test.ts +++ b/test/presets/netlify.test.ts @@ -11,6 +11,11 @@ describe("nitro:preset:netlify", async () => { output: { publicDir: resolve(getPresetTmpDir("netlify"), "dist"), }, + netlify: { + images: { + remote_images: ["https://example.com/.*"], + }, + }, }, }); testNitro( @@ -90,6 +95,20 @@ describe("nitro:preset:netlify", async () => { `); /* eslint-enable no-tabs */ }); + it("should write config.json", async () => { + const config = await fsp + .readFile(resolve(ctx.outDir, "../deploy/v1/config.json"), "utf8") + .then((r) => JSON.parse(r)); + expect(config).toMatchInlineSnapshot(` + { + "images": { + "remote_images": [ + "https://example.com/.*", + ], + }, + } + `); + }); } ); });