From 2acfd82e3f12ac06a10e03c5735ac2e67e831fcf Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 21 Dec 2023 22:19:51 +0100 Subject: [PATCH 1/6] test(cloudflare): migrate to miniflare v3 --- package.json | 2 +- pnpm-lock.yaml | 467 +++++++------------------ test/presets/cloudflare-module.test.ts | 17 +- test/presets/cloudflare-pages.test.ts | 26 +- test/presets/cloudflare.test.ts | 6 +- 5 files changed, 157 insertions(+), 361 deletions(-) diff --git a/package.json b/package.json index 3aeb7443c7..63b77c196c 100644 --- a/package.json +++ b/package.json @@ -143,7 +143,7 @@ "firebase-admin": "^12.0.0", "firebase-functions": "^4.5.0", "get-port-please": "^3.1.1", - "miniflare": "^2.14.1", + "miniflare": "^3.20231030.4", "prettier": "^3.1.1", "typescript": "^5.3.3", "unbuild": "^2.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1ddb41239a..82edddb12d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -260,8 +260,8 @@ importers: specifier: ^3.1.1 version: 3.1.1 miniflare: - specifier: ^2.14.1 - version: 2.14.1 + specifier: ^3.20231030.4 + version: 3.20231030.4 prettier: specifier: ^3.1.1 version: 3.1.1 @@ -568,6 +568,51 @@ packages: mime: 3.0.0 dev: false + /@cloudflare/workerd-darwin-64@1.20231030.0: + resolution: {integrity: sha512-J4PQ9utPxLya9yHdMMx3AZeC5M/6FxcoYw6jo9jbDDFTy+a4Gslqf4Im9We3aeOEdPXa3tgQHVQOSelJSZLhIw==} + engines: {node: '>=16'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@cloudflare/workerd-darwin-arm64@1.20231030.0: + resolution: {integrity: sha512-WSJJjm11Del4hSneiNB7wTXGtBXI4QMCH9l5qf4iT5PAW8cESGcCmdHtWDWDtGAAGcvmLT04KNvmum92vRKKQQ==} + engines: {node: '>=16'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + + /@cloudflare/workerd-linux-64@1.20231030.0: + resolution: {integrity: sha512-2HUeRTvoCC17fxE0qdBeR7J9dO8j4A8ZbdcvY8pZxdk+zERU6+N03RTbk/dQMU488PwiDvcC3zZqS4gwLfVT8g==} + engines: {node: '>=16'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@cloudflare/workerd-linux-arm64@1.20231030.0: + resolution: {integrity: sha512-4/GK5zHh+9JbUI6Z5xTCM0ZmpKKHk7vu9thmHjUxtz+o8Ne9DoD7DlDvXQWgMF6XGaTubDWyp3ttn+Qv8jDFuQ==} + engines: {node: '>=16'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@cloudflare/workerd-windows-64@1.20231030.0: + resolution: {integrity: sha512-fb/Jgj8Yqy3PO1jLhk7mTrHMkR8jklpbQFud6rL/aMAn5d6MQbaSrYOCjzkKGp0Zng8D2LIzSl+Fc0C9Sggxjg==} + engines: {node: '>=16'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /@cloudflare/workers-types@4.20231218.0: resolution: {integrity: sha512-Vs1FKjfUjXYGbCsXzkl+ITp0Iyb6QiW6+vTERTNThC+v96T0IvPVAioH4tT20rXwoxAfxh380mAaxYtTrJUNVg==} dev: true @@ -997,10 +1042,6 @@ packages: resolution: {integrity: sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==} dev: true - /@iarna/toml@2.2.5: - resolution: {integrity: sha512-trnsAYxU3xnS1gPHPyU961coFyLkh4gAD/0zQ5mymY4yOZ+CYvsPqUbOFSw0aDM4y0tV7tiFxL/1XfXPNC6IPg==} - dev: true - /@ioredis/commands@1.2.0: resolution: {integrity: sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==} dev: false @@ -1067,178 +1108,6 @@ packages: - supports-color dev: false - /@miniflare/cache@2.14.1: - resolution: {integrity: sha512-f/o6UBV6UX+MlhjcEch73/wjQvvNo37dgYmP6Pn2ax1/mEHhJ7allNAqenmonT4djNeyB3eEYV3zUl54wCEwrg==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - http-cache-semantics: 4.1.1 - undici: 6.2.0 - dev: true - - /@miniflare/cli-parser@2.14.1: - resolution: {integrity: sha512-MLvMuvxQPL/uw94Dg6CR3CM62uGoxxCkgF7aDtBYF9zb6YCfjOQn0q5d7zWxydpYAb5Dn1N1hZMnjAy7mlpNdQ==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/shared': 2.14.1 - kleur: 4.1.5 - dev: true - - /@miniflare/core@2.14.1: - resolution: {integrity: sha512-d+SGAda/VoXq+SKz04oq8ATUwQw5755L87fgPR8pTdR2YbWkxdbmEm1z2olOpDiUjcR86aN6NtCjY6tUC7fqaw==} - engines: {node: '>=16.13'} - dependencies: - '@iarna/toml': 2.2.5 - '@miniflare/queues': 2.14.1 - '@miniflare/shared': 2.14.1 - '@miniflare/watcher': 2.14.1 - busboy: 1.6.0 - dotenv: 10.0.0 - kleur: 4.1.5 - set-cookie-parser: 2.6.0 - undici: 6.2.0 - urlpattern-polyfill: 4.0.3 - dev: true - - /@miniflare/d1@2.14.1: - resolution: {integrity: sha512-MulDDBsDD8o5DwiqdMeJZy2vLoMji+NWnLcuibSag2mayA0LJcp0eHezseZNkW+knciWR1gMP8Xpa4Q1KwkbKA==} - engines: {node: '>=16.7'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - dev: true - - /@miniflare/durable-objects@2.14.1: - resolution: {integrity: sha512-T+oHGw5GcEIilkzrf0xDES7jzLVqcXJzSGsEIWqnBFLtdlKmrZF679ulRLBbyMVgvpQz6FRONh9jTH1XIiuObQ==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - '@miniflare/storage-memory': 2.14.1 - undici: 6.2.0 - dev: true - - /@miniflare/html-rewriter@2.14.1: - resolution: {integrity: sha512-vp4uZXuEKhtIaxoXa7jgDAPItlzjbfoUqYWp+fwDKv4J4mfQnzzs/5hwjbE7+Ihm/KNI0zNi8P0sSWjIRFl6ng==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - html-rewriter-wasm: 0.4.1 - undici: 6.2.0 - dev: true - - /@miniflare/http-server@2.14.1: - resolution: {integrity: sha512-ICT9KuecAF5+AHs9dTnk7DRxCPYLfI3QCtfHOcGQWFuOoe4MCtQk4joo0pxMaSgAJ4TiOOxz3KRWO0G2FwgiPQ==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - '@miniflare/web-sockets': 2.14.1 - kleur: 4.1.5 - selfsigned: 2.4.1 - undici: 6.2.0 - ws: 8.15.1 - youch: 2.2.2 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - - /@miniflare/kv@2.14.1: - resolution: {integrity: sha512-Gp07Wcszle7ptsoO8mCtKQRs0AbQnYo1rgnxUcsTL3xJJaHXEA/B9EKSADS2XzJMeY4PgUOHU6Rf08OOF2yWag==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/shared': 2.14.1 - dev: true - - /@miniflare/queues@2.14.1: - resolution: {integrity: sha512-uBzrbBkIgtNoztDpmMMISg/brYtxLHRE7oTaN8OVnq3bG+3nF9kQC42HUz+Vg+sf65UlvhSaqkjllgx+fNtOxQ==} - engines: {node: '>=16.7'} - dependencies: - '@miniflare/shared': 2.14.1 - dev: true - - /@miniflare/r2@2.14.1: - resolution: {integrity: sha512-grOMnGf2XSicbgxMYMBfWE37k/e7l5NnwXZIViQ+N06uksp+MLA8E6yKQNtvrWQS66TM8gBvMnWo96OFmYjb6Q==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - undici: 6.2.0 - dev: true - - /@miniflare/runner-vm@2.14.1: - resolution: {integrity: sha512-UobsGM0ICVPDlJD54VPDSx0EXrIY3nJMXBy2zIFuuUOz4hQKXvMQ6jtAlJ8UNKer+XXI3Mb/9R/gfU8r6kxIMA==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/shared': 2.14.1 - dev: true - - /@miniflare/scheduler@2.14.1: - resolution: {integrity: sha512-mCFUkGpPcV74tbDAuDLSrLPDiRei7hIIPQL53C4rtCDyLfxYgwLQFDecllQs5IvDzAx4qFpu835Ppc6tbHR5Mw==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - cron-schedule: 3.0.6 - dev: true - - /@miniflare/shared@2.14.1: - resolution: {integrity: sha512-73GnLtWn5iP936ctE6ZJrMqGu134KOoIIveq5Yd/B+NnbFfzpuzjCpkLrnqjkDdsxDbruXSb5eTR/SmAdpJxZQ==} - engines: {node: '>=16.13'} - dependencies: - '@types/better-sqlite3': 7.6.8 - kleur: 4.1.5 - npx-import: 1.1.4 - picomatch: 2.3.1 - dev: true - - /@miniflare/sites@2.14.1: - resolution: {integrity: sha512-AbbIcU6VBeaNqVgMiLMWN2a09eX3jZmjaEi0uKqufVDqW/QIz47/30aC0O9qTe+XYpi3jjph/Ux7uEY8Z+enMw==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/kv': 2.14.1 - '@miniflare/shared': 2.14.1 - '@miniflare/storage-file': 2.14.1 - dev: true - - /@miniflare/storage-file@2.14.1: - resolution: {integrity: sha512-faZu9tRSW6c/looVFI/ZhkdGsIc9NfNCbSl3jJRmm7xgyZ+/S+dQ5JtGVbVsUIX8YGWDyE2j3oWCGCjxGLEpkg==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/shared': 2.14.1 - '@miniflare/storage-memory': 2.14.1 - dev: true - - /@miniflare/storage-memory@2.14.1: - resolution: {integrity: sha512-lfQbQwopVWd4W5XzrYdp0rhk3dJpvSmv1Wwn9RhNO20WrcuoxpdSzbmpBahsgYVg+OheVaEbS6RpFqdmwwLTog==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/shared': 2.14.1 - dev: true - - /@miniflare/watcher@2.14.1: - resolution: {integrity: sha512-dkFvetm5wk6pwunlYb/UkI0yFNb3otLpRm5RDywMUzqObEf+rCiNNAbJe3HUspr2ncZVAaRWcEaDh82vYK5cmw==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/shared': 2.14.1 - dev: true - - /@miniflare/web-sockets@2.14.1: - resolution: {integrity: sha512-3N//L5EjF7+xXd7qCLR2ylUwm8t2MKyGPGWEtRBrQ2xqYYWhewKTjlquHCOPU5Irnnd/4BhTmFA55MNrq7m4Nw==} - engines: {node: '>=16.13'} - dependencies: - '@miniflare/core': 2.14.1 - '@miniflare/shared': 2.14.1 - undici: 6.2.0 - ws: 8.15.1 - transitivePeerDependencies: - - bufferutil - - utf-8-validate - dev: true - /@netlify/functions@2.4.1: resolution: {integrity: sha512-sRFYBaz6dJP1MdUtk/5QNmshhg5UDmB+DUssmH6v9WUG85MrwyExEfGfJA5eClXATjXm0coTvO5nLAlyCpK7QQ==} engines: {node: '>=14.0.0'} @@ -1812,12 +1681,6 @@ packages: resolution: {integrity: sha512-HxTfLeGvD1wTJqIGwcBCpNmHKenja+We1e0cuzeIDFfbEj3ixnlTInyPR/81zAe0Ss/Ip12rFK6XNeMLVucOSg==} dev: true - /@types/better-sqlite3@7.6.8: - resolution: {integrity: sha512-ASndM4rdGrzk7iXXqyNC4fbwt4UEjpK0i3j4q4FyeQrLAthfB6s7EF135ZJE0qQxtKIMFwmyT6x0switET7uIw==} - dependencies: - '@types/node': 20.10.5 - dev: true - /@types/body-parser@1.19.5: resolution: {integrity: sha512-fB3Zu92ucau0iQ0JMCFQE7b/dv8Ot07NI3KaZIkIUNXq82k4eBAqUaneXfleGY9JWskeS9y+u0nXMyspcuQrCg==} dependencies: @@ -1940,12 +1803,6 @@ packages: form-data: 4.0.0 dev: true - /@types/node-forge@1.3.10: - resolution: {integrity: sha512-y6PJDYN4xYBxwd22l+OVH35N+1fCYWiuC3aiP2SlXVE6Lo7SS+rSx9r89hLxrP4pn6n1lBGhHJ12pj3F3Mpttw==} - dependencies: - '@types/node': 20.10.5 - dev: true - /@types/node@20.10.5: resolution: {integrity: sha512-nNPsNE65wjMxEKI93yOP+NPGGBJz/PoN3kZsVLee0XMiJolxSekEVD8wRwBUBqkwc7UWop0edW50yrCQW4CyRw==} dependencies: @@ -1996,10 +1853,6 @@ packages: '@types/node': 20.10.5 dev: true - /@types/stack-trace@0.0.29: - resolution: {integrity: sha512-TgfOX+mGY/NyNxJLIbDWrO9DjGoVSW9+aB8H2yy1fy32jsvxijhmyJI9fDFgvz3YP4lvJaq9DzdR/M1bOgVc9g==} - dev: true - /@types/tough-cookie@4.0.5: resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==} requiresBuild: true @@ -2453,6 +2306,12 @@ packages: dev: true optional: true + /as-table@1.0.55: + resolution: {integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==} + dependencies: + printable-characters: 1.0.42 + dev: true + /assertion-error@1.1.0: resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} dev: true @@ -2624,13 +2483,6 @@ packages: run-applescript: 5.0.0 dev: true - /busboy@1.6.0: - resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} - engines: {node: '>=10.16.0'} - dependencies: - streamsearch: 1.1.0 - dev: true - /bytes@3.1.2: resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} engines: {node: '>= 0.8'} @@ -2684,6 +2536,15 @@ packages: resolution: {integrity: sha512-tYq/6MoXhdezDLFZuCO/TKboTzuQ/xR5cFdgXPfDtM7/kchBO3b4VWghE/OAi/DV7tTdhmLjZiZBZi1fA/GheQ==} dev: true + /capnp-ts@0.7.0: + resolution: {integrity: sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g==} + dependencies: + debug: 4.3.4 + tslib: 2.6.2 + transitivePeerDependencies: + - supports-color + dev: true + /chai@4.3.10: resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} engines: {node: '>=4'} @@ -2920,11 +2781,6 @@ packages: resolution: {integrity: sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==} dev: true - /cookie@0.4.2: - resolution: {integrity: sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==} - engines: {node: '>= 0.6'} - dev: true - /cookie@0.5.0: resolution: {integrity: sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==} engines: {node: '>= 0.6'} @@ -2956,10 +2812,6 @@ packages: readable-stream: 3.6.2 dev: false - /cron-schedule@3.0.6: - resolution: {integrity: sha512-izfGgKyzzIyLaeb1EtZ3KbglkS6AKp9cv7LxmiyoOu+fXfol1tQDC0Cof0enVZGNtudTHW+3lfuW9ZkLQss4Wg==} - dev: true - /cross-spawn@7.0.3: resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==} engines: {node: '>= 8'} @@ -3079,6 +2931,10 @@ packages: css-tree: 2.2.1 dev: true + /data-uri-to-buffer@2.0.2: + resolution: {integrity: sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==} + dev: true + /debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -3271,11 +3127,6 @@ packages: type-fest: 3.13.1 dev: false - /dotenv@10.0.0: - resolution: {integrity: sha512-rlBi9d8jpv9Sf1klPjNfFAuWDjKLwTIJJ/VxtoTwIR6hnZxcEOQCZg2oIL3MWBYw5GpUDKOEnND7LXTbIpQ03Q==} - engines: {node: '>=10'} - dev: true - /dotenv@16.3.1: resolution: {integrity: sha512-IPzF4w4/Rd94bA9imS68tZBaYyBWSCE47V1RGuMrB94iyTOIEwRmVL2x/4An+6mETpLrKJ5hQkB8W4kFAadeIQ==} engines: {node: '>=12'} @@ -3883,21 +3734,6 @@ packages: signal-exit: 3.0.7 strip-final-newline: 2.0.0 - /execa@6.1.0: - resolution: {integrity: sha512-QVWlX2e50heYJcCPG0iWtf8r0xjEYfz/OYLGDYH+IyjWezzPNxz63qNFOu0l4YftGWuizFVZHHs8PrLU5p2IDA==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dependencies: - cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 3.0.1 - is-stream: 3.0.0 - merge-stream: 2.0.0 - npm-run-path: 5.2.0 - onetime: 6.0.0 - signal-exit: 3.0.7 - strip-final-newline: 3.0.0 - dev: true - /execa@7.2.0: resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} @@ -3928,6 +3764,11 @@ packages: strip-final-newline: 3.0.0 dev: true + /exit-hook@2.2.1: + resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} + engines: {node: '>=6'} + dev: true + /expect-type@0.17.3: resolution: {integrity: sha512-K0ZdZJ97jiAtaOwhEHHz/f0N6Xbj5reRz5g6+5BO7+OvqQ7PMQz0/c8bFSJs1zPotNJL5HJaC6t6lGPEAtGyOw==} engines: {node: '>=12.0.0'} @@ -4283,6 +4124,13 @@ packages: /get-port-please@3.1.1: resolution: {integrity: sha512-3UBAyM3u4ZBVYDsxOQfJDxEa6XTbpBDrOjp4mf7ExFRt5BKs/QywQQiJsh2B+hxcZLSapWqCRvElUe8DnKcFHA==} + /get-source@2.0.12: + resolution: {integrity: sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==} + dependencies: + data-uri-to-buffer: 2.0.2 + source-map: 0.6.1 + dev: true + /get-stream@6.0.1: resolution: {integrity: sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==} engines: {node: '>=10'} @@ -4333,6 +4181,10 @@ packages: is-glob: 4.0.3 dev: true + /glob-to-regexp@0.4.1: + resolution: {integrity: sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==} + dev: true + /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} dependencies: @@ -4551,14 +4403,6 @@ packages: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} dev: true - /html-rewriter-wasm@0.4.1: - resolution: {integrity: sha512-lNovG8CMCCmcVB1Q7xggMSf7tqPCijZXaH4gL6iE8BFghdQCbaY5Met9i1x2Ex8m/cZHDUtXK9H6/znKamRP8Q==} - dev: true - - /http-cache-semantics@4.1.1: - resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} - dev: true - /http-errors@2.0.0: resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==} engines: {node: '>= 0.8'} @@ -4617,11 +4461,6 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} - /human-signals@3.0.1: - resolution: {integrity: sha512-rQLskxnM/5OCldHo+wNXbpVgDn5A17CUoKX+7Sokwaknlq7CdSnphy0W39GU8dw59XiCXmFXDg4fRuckQRKewQ==} - engines: {node: '>=12.20.0'} - dev: true - /human-signals@4.3.1: resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} engines: {node: '>=14.18.0'} @@ -5091,11 +4930,6 @@ packages: json-buffer: 3.0.1 dev: true - /kleur@4.1.5: - resolution: {integrity: sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==} - engines: {node: '>=6'} - dev: true - /klona@2.0.6: resolution: {integrity: sha512-dhG34DXATL5hSxJbIexCft8FChFXtmskoZYnoPWjXQuebWYCNkVeV3KkGegCK9CP1oswI/vQibS2GY7Em/sJJA==} engines: {node: '>= 8'} @@ -5389,45 +5223,26 @@ packages: engines: {node: '>=4'} dev: true - /miniflare@2.14.1: - resolution: {integrity: sha512-8Yqms4OZp1J1k0SGhOQ6MKWptWSXCm8Yh4kfFh11zZIlT1PoE0qXWQmAzwZnT5hFNmS3tsghu3GOgToxM+jCnA==} + /miniflare@3.20231030.4: + resolution: {integrity: sha512-7MBz0ArLuDop1WJGZC6tFgN6c5MRyDOIlxbm3yp0TRBpvDS/KsTuWCQcCjsxN4QQ5zvL3JTkuIZbQzRRw/j6ow==} engines: {node: '>=16.13'} hasBin: true - peerDependencies: - '@miniflare/storage-redis': 2.14.1 - cron-schedule: ^3.0.4 - ioredis: ^4.27.9 - peerDependenciesMeta: - '@miniflare/storage-redis': - optional: true - cron-schedule: - optional: true - ioredis: - optional: true dependencies: - '@miniflare/cache': 2.14.1 - '@miniflare/cli-parser': 2.14.1 - '@miniflare/core': 2.14.1 - '@miniflare/d1': 2.14.1 - '@miniflare/durable-objects': 2.14.1 - '@miniflare/html-rewriter': 2.14.1 - '@miniflare/http-server': 2.14.1 - '@miniflare/kv': 2.14.1 - '@miniflare/queues': 2.14.1 - '@miniflare/r2': 2.14.1 - '@miniflare/runner-vm': 2.14.1 - '@miniflare/scheduler': 2.14.1 - '@miniflare/shared': 2.14.1 - '@miniflare/sites': 2.14.1 - '@miniflare/storage-file': 2.14.1 - '@miniflare/storage-memory': 2.14.1 - '@miniflare/web-sockets': 2.14.1 - kleur: 4.1.5 - semiver: 1.1.0 + acorn: 8.11.2 + acorn-walk: 8.3.1 + capnp-ts: 0.7.0 + exit-hook: 2.2.1 + glob-to-regexp: 0.4.1 source-map-support: 0.5.21 + stoppable: 1.1.0 undici: 6.2.0 + workerd: 1.20231030.0 + ws: 8.15.1 + youch: 3.3.3 + zod: 3.22.4 transitivePeerDependencies: - bufferutil + - supports-color - utf-8-validate dev: true @@ -5629,15 +5444,6 @@ packages: set-blocking: 2.0.0 dev: false - /npx-import@1.1.4: - resolution: {integrity: sha512-3ShymTWOgqGyNlh5lMJAejLuIv3W1K3fbI5Ewc6YErZU3Sp0PqsNs8UIU1O8z5+KVl/Du5ag56Gza9vdorGEoA==} - dependencies: - execa: 6.1.0 - parse-package-name: 1.0.0 - semver: 7.5.4 - validate-npm-package-name: 4.0.0 - dev: true - /nth-check@2.1.1: resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} dependencies: @@ -5840,10 +5646,6 @@ packages: engines: {node: '>=6'} dev: true - /parse-package-name@1.0.0: - resolution: {integrity: sha512-kBeTUtcj+SkyfaW4+KBe0HtsloBJ/mKTPoxpVdA57GZiPerREsUWJOhVj9anXweFiJkm5y8FG1sxFZkZ0SN6wg==} - dev: true - /parseurl@1.3.3: resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} engines: {node: '>= 0.8'} @@ -6257,6 +6059,10 @@ packages: parse-ms: 2.1.0 dev: true + /printable-characters@1.0.42: + resolution: {integrity: sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==} + dev: true + /process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} dev: false @@ -6615,19 +6421,6 @@ packages: /scule@1.1.1: resolution: {integrity: sha512-sHtm/SsIK9BUBI3EFT/Gnp9VoKfY6QLvlkvAE6YK7454IF8FSgJEAnJpVdSC7K5/pjI5NfxhzBLW2JAfYA/shQ==} - /selfsigned@2.4.1: - resolution: {integrity: sha512-th5B4L2U+eGLq1TVh7zNRGBapioSORUeymIydxgFpwww9d2qyKvtuPU2jJuHvYAwwqi2Y596QBL3eEqcPEYL8Q==} - engines: {node: '>=10'} - dependencies: - '@types/node-forge': 1.3.10 - node-forge: 1.3.1 - dev: true - - /semiver@1.1.0: - resolution: {integrity: sha512-QNI2ChmuioGC1/xjyYwyZYADILWyW6AmS1UH6gDj/SFUUUS4MBAWs/7mxnkRPc/F4iHezDP+O8t0dO8WHiEOdg==} - engines: {node: '>=6'} - dev: true - /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} hasBin: true @@ -6691,10 +6484,6 @@ packages: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} dev: false - /set-cookie-parser@2.6.0: - resolution: {integrity: sha512-RVnVQxTXuerk653XfuliOxBP81Sf0+qfQE73LIYKcyMYHG94AuH0kgrQpRDuTZnSmjpysHmzxJXKNfa6PjFhyQ==} - dev: true - /set-function-length@1.1.1: resolution: {integrity: sha512-VoaqjbBJKiWtg4yRcKBQ7g7wnGnLV3M8oLvVWwOk2PdYY6PEFegR1vezXR0tw6fZGF9csVakIRjrJiy2veSBFQ==} engines: {node: '>= 0.4'} @@ -6812,14 +6601,17 @@ packages: resolution: {integrity: sha512-eWN+LnM3GR6gPu35WxNgbGl8rmY1AEmoMDvL/QD6zYmPWgywxWqJWNdLGT+ke8dKNWrcYgYjPpG5gbTfghP8rw==} dev: true - /stack-trace@0.0.10: - resolution: {integrity: sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==} - dev: true - /stackback@0.0.2: resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==} dev: true + /stacktracey@2.1.8: + resolution: {integrity: sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==} + dependencies: + as-table: 1.0.55 + get-source: 2.0.12 + dev: true + /standard-as-callback@2.1.0: resolution: {integrity: sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==} dev: false @@ -6831,6 +6623,11 @@ packages: /std-env@3.6.0: resolution: {integrity: sha512-aFZ19IgVmhdB2uX599ve2kE6BIE3YMnQ6Gp6BURhW/oIzpXGKr878TQfAQZn1+i0Flcc/UKUy1gOlcfaUBCryg==} + /stoppable@1.1.0: + resolution: {integrity: sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==} + engines: {node: '>=4', npm: '>=6'} + dev: true + /stream-events@1.0.5: resolution: {integrity: sha512-E1GUzBSgvct8Jsb3v2X15pjzN1tYebtbLaMg+eBOUOAxgbLoSbT2NS91ckc5lJD1KfLjId+jXJRgo0qnV5Nerg==} requiresBuild: true @@ -6845,11 +6642,6 @@ packages: dev: true optional: true - /streamsearch@1.1.0: - resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} - engines: {node: '>=10.0.0'} - dev: true - /streamx@2.15.6: resolution: {integrity: sha512-q+vQL4AAz+FdfT137VF69Cc/APqUbxy+MDOImRrMvchJpigHj9GksgDU2LYbO9rx7RX6osWgxJB2WxhYv4SZAw==} dependencies: @@ -7452,10 +7244,6 @@ packages: punycode: 2.3.1 dev: true - /urlpattern-polyfill@4.0.3: - resolution: {integrity: sha512-DOE84vZT2fEcl9gqCUTcnAw5ZY5Id55ikUcziSUntuEFL3pRvavg5kwDmTEUJkeCHInTlV/HexFomgYnzO5kdQ==} - dev: true - /urlpattern-polyfill@8.0.2: resolution: {integrity: sha512-Qp95D4TPJl1kC9SKigDcqgyM2VDVO4RiJc2d4qe5GrYm+zbIQCWWKAFaJNQ4BhdFeDGwBmAxqJBwWSJDb9T3BQ==} dev: false @@ -7495,13 +7283,6 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /validate-npm-package-name@4.0.0: - resolution: {integrity: sha512-mzR0L8ZDktZjpX4OB46KT+56MAhl4EIazWP/+G/HPGuvfdaqg4YsCdtOm6U9+LOFyYDoh4dpnpxZRB9MQQns5Q==} - engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} - dependencies: - builtins: 5.0.1 - dev: true - /vary@1.1.2: resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} engines: {node: '>= 0.8'} @@ -7694,6 +7475,19 @@ packages: string-width: 4.2.3 dev: false + /workerd@1.20231030.0: + resolution: {integrity: sha512-+FSW+d31f8RrjHanFf/R9A+Z0csf3OtsvzdPmAKuwuZm/5HrBv83cvG9fFeTxl7/nI6irUUXIRF9xcj/NomQzQ==} + engines: {node: '>=16'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@cloudflare/workerd-darwin-64': 1.20231030.0 + '@cloudflare/workerd-darwin-arm64': 1.20231030.0 + '@cloudflare/workerd-linux-64': 1.20231030.0 + '@cloudflare/workerd-linux-arm64': 1.20231030.0 + '@cloudflare/workerd-windows-64': 1.20231030.0 + dev: true + /wrap-ansi@7.0.0: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} @@ -7778,13 +7572,12 @@ packages: engines: {node: '>=12.20'} dev: true - /youch@2.2.2: - resolution: {integrity: sha512-/FaCeG3GkuJwaMR34GHVg0l8jCbafZLHiFowSjqLlqhC6OMyf2tPJBu8UirF7/NI9X/R5ai4QfEKUCOxMAGxZQ==} + /youch@3.3.3: + resolution: {integrity: sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA==} dependencies: - '@types/stack-trace': 0.0.29 - cookie: 0.4.2 + cookie: 0.5.0 mustache: 4.2.0 - stack-trace: 0.0.10 + stacktracey: 2.1.8 dev: true /zip-stream@5.0.1: @@ -7795,3 +7588,7 @@ packages: compress-commons: 5.0.1 readable-stream: 3.6.2 dev: false + + /zod@3.22.4: + resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} + dev: true diff --git a/test/presets/cloudflare-module.test.ts b/test/presets/cloudflare-module.test.ts index ba45918004..47a9a07a32 100644 --- a/test/presets/cloudflare-module.test.ts +++ b/test/presets/cloudflare-module.test.ts @@ -15,17 +15,16 @@ describe("nitro:preset:cloudflare-module", async () => { scriptPath: resolve(ctx.outDir, "server/index.mjs"), sitePath: resolve(ctx.outDir, "public"), compatibilityFlags: ["streams_enable_constructors"], - globals: { __env__: {} }, bindings: { ...ctx.env, - ASSETS: { - fetch: async (request) => { - const contents = await fsp.readFile( - join(ctx.outDir, new URL(request.url).pathname) - ); - return new _Response(contents); - }, - }, + // ASSETS: { + // fetch: async (request) => { + // const contents = await fsp.readFile( + // join(ctx.outDir, new URL(request.url).pathname) + // ); + // return new _Response(contents); + // }, + // }, }, }); diff --git a/test/presets/cloudflare-pages.test.ts b/test/presets/cloudflare-pages.test.ts index 9180cdc011..384f349b1f 100644 --- a/test/presets/cloudflare-pages.test.ts +++ b/test/presets/cloudflare-pages.test.ts @@ -13,22 +13,22 @@ describe("nitro:preset:cloudflare-pages", async () => { const mf = new Miniflare({ modules: true, scriptPath: resolve(ctx.outDir, "_worker.js", "index.js"), - globals: { __env__: {} }, compatibilityFlags: ["streams_enable_constructors"], + modulesRules: [{ type: "CompiledWasm", include: ["**/*.wasm"] }], bindings: { ...ctx.env, - ASSETS: { - fetch: async (request) => { - try { - const contents = await fsp.readFile( - join(ctx.outDir, new URL(request.url).pathname) - ); - return new _Response(contents); - } catch { - return new _Response(null, { status: 404 }); - } - }, - }, + // ASSETS: { + // fetch: async (request) => { + // try { + // const contents = await fsp.readFile( + // join(ctx.outDir, new URL(request.url).pathname) + // ); + // return new _Response(contents); + // } catch { + // return new _Response(null, { status: 404 }); + // } + // }, + // }, }, }); diff --git a/test/presets/cloudflare.test.ts b/test/presets/cloudflare.test.ts index 670482b02d..af6163a2a1 100644 --- a/test/presets/cloudflare.test.ts +++ b/test/presets/cloudflare.test.ts @@ -1,7 +1,6 @@ -import { promises as fsp } from "node:fs"; import { resolve } from "pathe"; import { Miniflare } from "miniflare"; -import { describe, it, expect } from "vitest"; +import { describe } from "vitest"; import { setupTest, testNitro } from "../tests"; @@ -10,13 +9,14 @@ describe("nitro:preset:cloudflare", async () => { testNitro(ctx, () => { const mf = new Miniflare({ scriptPath: resolve(ctx.outDir, "server/index.mjs"), - globals: { ...ctx.env }, + bindings: { ...ctx.env }, compatibilityFlags: ["streams_enable_constructors"], }); return async ({ url, headers, method, body }) => { const res = await mf.dispatchFetch("http://localhost" + url, { headers: headers || {}, method: method || "GET", + redirect: "manual", body, }); return res as unknown as Response; From c284169bb027e5fd3240958638843a00a1fb2562 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 21 Dec 2023 22:26:07 +0100 Subject: [PATCH 2/6] upgrade undici --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 623610d792..705d6114c0 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,7 @@ }, "resolutions": { "nitropack": "link:.", - "undici": "^5" + "undici": "^6" }, "dependencies": { "@cloudflare/kv-asset-handler": "^0.3.0", @@ -147,7 +147,7 @@ "prettier": "^3.1.1", "typescript": "^5.3.3", "unbuild": "^2.0.0", - "undici": "^5", + "undici": "^6", "vitest": "1.1.0", "xml2js": "^0.6.2" }, From db7073659daad9250b52f84d7a56ad4d30cc2d58 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 21 Dec 2023 22:26:16 +0100 Subject: [PATCH 3/6] update lock --- pnpm-lock.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f594daaa67..6a0de51ef6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -6,7 +6,7 @@ settings: overrides: nitropack: link:. - undici: ^5 + undici: ^6 importers: @@ -272,8 +272,8 @@ importers: specifier: ^2.0.0 version: 2.0.0(typescript@5.3.3) undici: - specifier: ^5 - version: 5.28.2 + specifier: ^6 + version: 6.2.0 vitest: specifier: 1.1.0 version: 1.1.0 @@ -5235,7 +5235,7 @@ packages: glob-to-regexp: 0.4.1 source-map-support: 0.5.21 stoppable: 1.1.0 - undici: 5.28.2 + undici: 6.2.0 workerd: 1.20231030.0 ws: 8.15.1 youch: 3.3.3 @@ -5568,7 +5568,7 @@ packages: fast-glob: 3.3.2 js-yaml: 4.1.0 supports-color: 9.4.0 - undici: 5.28.2 + undici: 6.2.0 yargs-parser: 21.1.1 dev: false @@ -7081,9 +7081,9 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - /undici@5.28.2: - resolution: {integrity: sha512-wh1pHJHnUeQV5Xa8/kyQhO7WFa8M34l026L5P/+2TYiakvGy5Rdc8jWZVyG7ieht/0WgJLEd3kcU5gKx+6GC8w==} - engines: {node: '>=14.0'} + /undici@6.2.0: + resolution: {integrity: sha512-bglzaehBOLMe+BfK+Gv5Vpwpgdq2skaEBbSH92tcAv37wHHHTEGu43boyfTaHB+mwSo3VjyD/8d+ytPGeqsFIg==} + engines: {node: '>=18.0'} dependencies: '@fastify/busboy': 2.1.0 From 03f50236c46156a0245c6bd4e5fcb230e81f17c3 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Thu, 11 Jan 2024 23:45:09 +0100 Subject: [PATCH 4/6] build in local `.tmp` to workaround miniflare issue --- test/tests.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/test/tests.ts b/test/tests.ts index 55f7a41a1c..a938acdf2e 100644 --- a/test/tests.ts +++ b/test/tests.ts @@ -45,11 +45,18 @@ export const fixtureDir = fileURLToPath( new URL("fixture", import.meta.url).href ); -export const getPresetTmpDir = (preset: string) => - resolve( +export const getPresetTmpDir = (preset: string) => { + if (preset.startsWith("cloudflare")) { + return fileURLToPath( + new URL(`.tmp/${preset}`, import.meta.url) as any /* remove me */ + ); + } + + return resolve( process.env.NITRO_TEST_TMP_DIR || join(tmpdir(), "nitro-tests"), preset ); +}; export async function setupTest( preset: string, From 22511779dea42cd18d88e1a1e669f7dd4f3fad64 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 12 Jan 2024 00:05:39 +0100 Subject: [PATCH 5/6] update tests --- src/runtime/entries/cloudflare-pages.ts | 2 +- test/presets/cloudflare-module.test.ts | 13 ++----------- test/presets/cloudflare-pages.test.ts | 18 +++--------------- test/tests.ts | 5 ++--- 4 files changed, 8 insertions(+), 30 deletions(-) diff --git a/src/runtime/entries/cloudflare-pages.ts b/src/runtime/entries/cloudflare-pages.ts index 2c420f2a44..743b8e44ca 100644 --- a/src/runtime/entries/cloudflare-pages.ts +++ b/src/runtime/entries/cloudflare-pages.ts @@ -27,7 +27,7 @@ export default { context: EventContext ) { const url = new URL(request.url); - if (isPublicAssetURL(url.pathname)) { + if (env.ASSETS /* !miniflare */ && isPublicAssetURL(url.pathname)) { return env.ASSETS.fetch(request); } diff --git a/test/presets/cloudflare-module.test.ts b/test/presets/cloudflare-module.test.ts index ba9e7f7a58..4cb8f13dad 100644 --- a/test/presets/cloudflare-module.test.ts +++ b/test/presets/cloudflare-module.test.ts @@ -16,23 +16,14 @@ describe("nitro:preset:cloudflare-module", async () => { modulesRules: [{ type: "CompiledWasm", include: ["**/*.wasm"] }], sitePath: resolve(ctx.outDir, "public"), compatibilityFlags: ["streams_enable_constructors"], - bindings: { - ...ctx.env, - // ASSETS: { - // fetch: async (request) => { - // const contents = await fsp.readFile( - // join(ctx.outDir, new URL(request.url).pathname) - // ); - // return new _Response(contents); - // }, - // }, - }, + bindings: { ...ctx.env }, }); return async ({ url, headers, method, body }) => { const res = await mf.dispatchFetch("http://localhost" + url, { headers: headers || {}, method: method || "GET", + redirect: "manual", body, }); return res as unknown as Response; diff --git a/test/presets/cloudflare-pages.test.ts b/test/presets/cloudflare-pages.test.ts index 3a644325b3..72a725f915 100644 --- a/test/presets/cloudflare-pages.test.ts +++ b/test/presets/cloudflare-pages.test.ts @@ -16,27 +16,15 @@ describe("nitro:preset:cloudflare-pages", async () => { modulesRules: [{ type: "CompiledWasm", include: ["**/*.wasm"] }], globals: { __env__: {} }, compatibilityFlags: ["streams_enable_constructors"], - bindings: { - ...ctx.env, - // ASSETS: { - // fetch: async (request) => { - // try { - // const contents = await fsp.readFile( - // join(ctx.outDir, new URL(request.url).pathname) - // ); - // return new _Response(contents); - // } catch { - // return new _Response(null, { status: 404 }); - // } - // }, - // }, - }, + sitePath: "", + bindings: { ...ctx.env }, }); return async ({ url, headers, method, body }) => { const res = await mf.dispatchFetch("http://localhost" + url, { headers: headers || {}, method: method || "GET", + redirect: "manual", body, }); return res as unknown as Response; diff --git a/test/tests.ts b/test/tests.ts index a938acdf2e..8b8bfd228f 100644 --- a/test/tests.ts +++ b/test/tests.ts @@ -454,8 +454,7 @@ export function testNitro( "server-config": true, }, runtimeConfig: { - // Cloudflare environment variables are only available within the fetch event - dynamic: ctx.preset.startsWith("cloudflare-") ? "initial" : "from-env", + dynamic: "from-env", url: "https://test.com", app: { baseURL: "/", @@ -640,7 +639,7 @@ export function testNitro( }); }); - describe("wasm", () => { + describe.skipIf(ctx.preset === "cloudflare")("wasm", () => { it("dynamic import wasm", async () => { expect((await callHandler({ url: "/wasm/dynamic-import" })).data).toBe( "2+3=5" From a95aca4f99a6341b4fa4aefb22bc9eb91bfb7165 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Fri, 12 Jan 2024 00:08:35 +0100 Subject: [PATCH 6/6] fix type issue --- test/presets/cloudflare-pages.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/test/presets/cloudflare-pages.test.ts b/test/presets/cloudflare-pages.test.ts index 72a725f915..2ae5a9db35 100644 --- a/test/presets/cloudflare-pages.test.ts +++ b/test/presets/cloudflare-pages.test.ts @@ -14,7 +14,6 @@ describe("nitro:preset:cloudflare-pages", async () => { modules: true, scriptPath: resolve(ctx.outDir, "_worker.js", "index.js"), modulesRules: [{ type: "CompiledWasm", include: ["**/*.wasm"] }], - globals: { __env__: {} }, compatibilityFlags: ["streams_enable_constructors"], sitePath: "", bindings: { ...ctx.env },