From c844242b8200f3603d34f363273ef007d10be383 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 25 May 2023 18:45:32 +0100 Subject: [PATCH] Version Packages (#261) Co-authored-by: github-actions[bot] --- .changeset/fifty-geckos-eat.md | 5 -- .changeset/flat-bobcats-glow.md | 49 ----------------- .changeset/friendly-bikes-accept.md | 5 -- .changeset/fuzzy-flowers-smile.md | 5 -- .changeset/lucky-toys-confess.md | 16 ------ .changeset/rich-shirts-shake.md | 5 -- .changeset/small-bears-work.md | 5 -- .changeset/tender-rats-smash.md | 17 ------ CHANGELOG.md | 82 +++++++++++++++++++++++++++++ package.json | 2 +- 10 files changed, 83 insertions(+), 108 deletions(-) delete mode 100644 .changeset/fifty-geckos-eat.md delete mode 100644 .changeset/flat-bobcats-glow.md delete mode 100644 .changeset/friendly-bikes-accept.md delete mode 100644 .changeset/fuzzy-flowers-smile.md delete mode 100644 .changeset/lucky-toys-confess.md delete mode 100644 .changeset/rich-shirts-shake.md delete mode 100644 .changeset/small-bears-work.md delete mode 100644 .changeset/tender-rats-smash.md diff --git a/.changeset/fifty-geckos-eat.md b/.changeset/fifty-geckos-eat.md deleted file mode 100644 index ca11831f7..000000000 --- a/.changeset/fifty-geckos-eat.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -improve no nodejs_compat flag runtime error message diff --git a/.changeset/flat-bobcats-glow.md b/.changeset/flat-bobcats-glow.md deleted file mode 100644 index 51ec94b8a..000000000 --- a/.changeset/flat-bobcats-glow.md +++ /dev/null @@ -1,49 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -introduce wasm support - -introduce wasm support by tweaking how the wasm modules are imported, what `vercel build` does is adding dynamic -requires at the top of the func files, like for example: - -```js -// file: .vercel/output/functions/index.func/index.js -const wasm_fbeb8adedbc833032bda6f13925ba235b8d09114 = require('/wasm/wasm_fbeb8adedbc833032bda6f13925ba235b8d09114.wasm'); -``` - -then such identifier is used in the rest of the file (likely only inside chunks), as in: - -```js - // file: .vercel/output/functions/index.func/index.js - 649:e=>{e.exports=wasm_fbeb8adedbc833032bda6f13925ba235b8d09114} -``` - -the above can't work with next-on-pages because: - -- dynamic requires are not supported -- when we perform the chunks deduplication chunks containing such identifiers will not find their declaration causing - (e.g. a chunk file containing the `649` chunk code illustrated above won't know where `wasm_fbeb8adedbc833032bda6f13925ba235b8d09114` - comes from and would just provide a runtime error saying that it is not defined) -- `/wasm/...` isn't a real directory, just some sort of convention used by vercel, the wasm files are located in the same - directory as the func file - -the adopted solution consists in: - -- copying the wasm files from their func relative locations into the `__next-on-pages-dist/wasm` directory -- converting the func top level requires into standard relative esm imports, like for example: - ```js - // file: .vercel/output/functions/index.func/index.js - import wasm_fbeb8adedbc833032bda6f13925ba235b8d09114 from '../wasm/wasm_fbeb8adedbc833032bda6f13925ba235b8d09114.wasm'; - ``` - so that any part of the func file will be able to reference the variable (so that this works with chunks deduplication disabled) -- adding similar import statements to any chunk files that reference these wasm identifiers, like for example: - ```js - // file: .vercel/output/static/_worker.js/__next-on-pages-dist__/chunks/649.js - import wasm_fbeb8adedbc833032bda6f13925ba235b8d09114 from '../wasm/wasm_fbeb8adedbc833032bda6f13925ba235b8d09114.wasm'; - var a = b => { - b.exports = wasm_fbeb8adedbc833032bda6f13925ba235b8d09114; - }; - export { a as default }; - ``` - (so that this works with chunks deduplication enabled) diff --git a/.changeset/friendly-bikes-accept.md b/.changeset/friendly-bikes-accept.md deleted file mode 100644 index bab0530a0..000000000 --- a/.changeset/friendly-bikes-accept.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -update wrangler peer dependency (^2.20.0 -> ^3.0.0) diff --git a/.changeset/fuzzy-flowers-smile.md b/.changeset/fuzzy-flowers-smile.md deleted file mode 100644 index 6f9dcb2f1..000000000 --- a/.changeset/fuzzy-flowers-smile.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -Fix the issue of refetching the vercel package every single time when using yarn berry. diff --git a/.changeset/lucky-toys-confess.md b/.changeset/lucky-toys-confess.md deleted file mode 100644 index 9932efb2f..000000000 --- a/.changeset/lucky-toys-confess.md +++ /dev/null @@ -1,16 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -allow any node built-in module to be statically imported correctly - -currently only static imports from "node:buffer" work correctly, other -imports, although supported by the workers runtime, aren't handled correctly -(such as "node:events" and "node:util"), fix this by making sure we handle -imports from any of the node built-in modules - -> **Note** -> some node built-in modules supported by the workers runtime still cannot be -> correctly imported (like "node:path" for example), but this is because they -> seem to be not allowed by vercel/next itself (so it's something unrelated to -> next-on-pages) diff --git a/.changeset/rich-shirts-shake.md b/.changeset/rich-shirts-shake.md deleted file mode 100644 index 26a3d4780..000000000 --- a/.changeset/rich-shirts-shake.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -Fix non-dynamic trailing slash pages not matching when using `trailingSlash: true`. diff --git a/.changeset/small-bears-work.md b/.changeset/small-bears-work.md deleted file mode 100644 index c5edd4f2c..000000000 --- a/.changeset/small-bears-work.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -remove hacks/workarounds for runtime bugs which are no longer needed diff --git a/.changeset/tender-rats-smash.md b/.changeset/tender-rats-smash.md deleted file mode 100644 index 6d1eba0a4..000000000 --- a/.changeset/tender-rats-smash.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -'@cloudflare/next-on-pages': patch ---- - -fix getPackageVersion and use it to discern use of dlx - -fix the `getPackageVersion` function so that it doesn't wrongly produce `N/A` (thus -improving the `-i|--info` results) - -the when running `vercel build`, use the function to discern if `dlx` should be added -(for `yarn (berry)` and `pnpm` commands), ensuring that the vercel package is not -unnecessarily re-fetched/installed - -> **Note** -> Currently the aforementioned check (and build command) runs `next-on-pages-vercel-cli` -> anyways that's a temporary solution, the changes here will also apply when we switch -> back to the proper vercel cli package diff --git a/CHANGELOG.md b/CHANGELOG.md index 6323a54c6..52a534404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,87 @@ # @cloudflare/next-on-pages +## 1.0.1 + +### Patch Changes + +- 29b7547: improve no nodejs_compat flag runtime error message +- c0ecec3: introduce wasm support + + introduce wasm support by tweaking how the wasm modules are imported, what `vercel build` does is adding dynamic + requires at the top of the func files, like for example: + + ```js + // file: .vercel/output/functions/index.func/index.js + const wasm_fbeb8adedbc833032bda6f13925ba235b8d09114 = require('/wasm/wasm_fbeb8adedbc833032bda6f13925ba235b8d09114.wasm'); + ``` + + then such identifier is used in the rest of the file (likely only inside chunks), as in: + + ```js + // file: .vercel/output/functions/index.func/index.js + 649:e=>{e.exports=wasm_fbeb8adedbc833032bda6f13925ba235b8d09114} + ``` + + the above can't work with next-on-pages because: + + - dynamic requires are not supported + - when we perform the chunks deduplication chunks containing such identifiers will not find their declaration causing + (e.g. a chunk file containing the `649` chunk code illustrated above won't know where `wasm_fbeb8adedbc833032bda6f13925ba235b8d09114` + comes from and would just provide a runtime error saying that it is not defined) + - `/wasm/...` isn't a real directory, just some sort of convention used by vercel, the wasm files are located in the same + directory as the func file + + the adopted solution consists in: + + - copying the wasm files from their func relative locations into the `__next-on-pages-dist/wasm` directory + - converting the func top level requires into standard relative esm imports, like for example: + ```js + // file: .vercel/output/functions/index.func/index.js + import wasm_fbeb8adedbc833032bda6f13925ba235b8d09114 from '../wasm/wasm_fbeb8adedbc833032bda6f13925ba235b8d09114.wasm'; + ``` + so that any part of the func file will be able to reference the variable (so that this works with chunks deduplication disabled) + - adding similar import statements to any chunk files that reference these wasm identifiers, like for example: + ```js + // file: .vercel/output/static/_worker.js/__next-on-pages-dist__/chunks/649.js + import wasm_fbeb8adedbc833032bda6f13925ba235b8d09114 from '../wasm/wasm_fbeb8adedbc833032bda6f13925ba235b8d09114.wasm'; + var a = b => { + b.exports = wasm_fbeb8adedbc833032bda6f13925ba235b8d09114; + }; + export { a as default }; + ``` + (so that this works with chunks deduplication enabled) + +- 3f05e81: update wrangler peer dependency (^2.20.0 -> ^3.0.0) +- 4f43b9b: Fix the issue of refetching the vercel package every single time when using yarn berry. +- 81bfcdb: allow any node built-in module to be statically imported correctly + + currently only static imports from "node:buffer" work correctly, other + imports, although supported by the workers runtime, aren't handled correctly + (such as "node:events" and "node:util"), fix this by making sure we handle + imports from any of the node built-in modules + + > **Note** + > some node built-in modules supported by the workers runtime still cannot be + > correctly imported (like "node:path" for example), but this is because they + > seem to be not allowed by vercel/next itself (so it's something unrelated to + > next-on-pages) + +- 95b1704: Fix non-dynamic trailing slash pages not matching when using `trailingSlash: true`. +- fd51777: remove hacks/workarounds for runtime bugs which are no longer needed +- 97c8739: fix getPackageVersion and use it to discern use of dlx + + fix the `getPackageVersion` function so that it doesn't wrongly produce `N/A` (thus + improving the `-i|--info` results) + + the when running `vercel build`, use the function to discern if `dlx` should be added + (for `yarn (berry)` and `pnpm` commands), ensuring that the vercel package is not + unnecessarily re-fetched/installed + + > **Note** + > Currently the aforementioned check (and build command) runs `next-on-pages-vercel-cli` + > anyways that's a temporary solution, the changes here will also apply when we switch + > back to the proper vercel cli package + ## 1.0.0 ### Major Changes diff --git a/package.json b/package.json index 101a32cfc..e0497deea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cloudflare/next-on-pages", - "version": "1.0.0", + "version": "1.0.1", "bin": "./bin/index.js", "scripts": { "prettier": "npx prettier --ignore-unknown --ignore-path=.gitignore .",