Repository navigation
feat: support Node.js 24 in the builder and unenv-preset - #500
Draft
jose-filho-azion wants to merge 11 commits into
Draft
jose-filho-azion wants to merge 11 commits into
jose-filho-azion wants to merge 11 commits into
Conversation
…m polyfill
The polyfill replaced the native implementations of the host node:stream, and
its Readable.fromWeb never pushed any data (it returned { done, value } from
read() instead of calling push()), so a stream created with it never emitted
data or end. Next.js 16.4+ builds the HTML with Readable.fromWeb and toWeb, so
the render never finished and ISR pages were never revalidated on azion dev.
Install the polyfill versions only when the host does not provide them, and
make the fromWeb fallback push the data.
The download:cli script pointed to ./cli/scripts/download-cli.mjs, and there is no cli folder in the repository. The scripts folder only had code-review.mjs, from the AI code review workflow that was already removed. Nothing references it and it imports @actions/github, which is not a dependency.
…sions.node to 22 Add stubs for the Node.js 24 APIs that unenv does not cover yet: - perf_hooks: timerify and eventLoopUtilization - url: URLPattern - v8: startCpuProfile - worker_threads: locks - fs: mkdtempDisposable, mkdtempDisposableSync and Utf8Stream The stubs that cannot work throw "[azion] <api> is not implemented yet!" when called, not when imported. process.versions.node changes from 18.3.1 to 22.23.4 so libraries that check the Node.js version no longer take the Node.js 18 path.
mock-fs 5.5.0 does not intercept the native fs.rmSync of Node.js 24, so the "Should delete telemtry files" test failed there. Use a temp dir created with fs.mkdtempSync, change into it and remove it in a finally block. The test passes on Node.js 22 and 24.
…olyfills - esbuild node polyfills plugin: build the built-in modules regex only with the modules that have an alias, a polyfill or an external entry. Node.js 24 lists node:test, node:test/reporters and node:sea in builtinModules and the build failed trying to read a file named after them. - fs dev polyfill: read F_OK, R_OK, W_OK and X_OK from fs.constants, because Node.js 24 removed them from the top level of fs. - crypto dev polyfill: export argon2, argon2Sync, encapsulate and decapsulate, which are undefined on a host without them.
…sion - ci.yml: run the unit tests with a matrix of Node.js 22 (latest patch) and 24. - install-dependencies action: default to Node.js 24, the same version used by the release workflow. - .nvmrc: point to lts/jod (Node.js 22), the minimum supported version. - package.json: set engines.node to >=22.0.0.
Contributor
SCC Complexity Analysis
|
commit: |
…e:sea Do not fail the build when the code imports node:test, node:test/reporters or node:sea, which have no polyfill. - unenv-preset: add stubs for node:test, node:test/reporters and node:sea. They throw "[azion] <api> is not implemented yet!" when called, not when imported. sea.isSea() returns false. - unenv-preset: in the fs polyfill, use mkdtempDisposable, mkdtempDisposableSync and Utf8Stream of the runtime when it has them, and define them with defineProperty because the runtime can define them as getters, as Node.js 24 does. - builder: match the modules that exist only with the node: prefix (node:test, node:sea, node:sqlite) only with the prefix, so an npm package named test, sea or sqlite is not taken as a built-in module. - builder: handle the same modules on Node.js 22 and 24 by also using the node: keys of the alias map, not only builtinModules.
Contributor
SCC Complexity Analysis
|
The fs polyfill used by azbundler dev exports a fixed list of names, so mkdtempDisposableSync and Utf8Stream were undefined and calling them failed with "(void 0) is not a function". Export them as stubs that throw "[azion] <api> is not implemented yet!" when called, the same error as the production polyfill.
…hangesets azion dev is the usage with the Azion CLI and azbundler dev is the usage with the bundler. The polyfills and the changesets are about the bundler.
Contributor
SCC Complexity Analysis
|
Contributor
SCC Complexity Analysis
|
Next.js reads the body of a server action with pipeline from node:stream/promises, and unenv only has stubs for it, so a server action failed with "[unenv] stream.promises.pipeline is not implemented yet!". - unenv-preset: add the stream/promises polyfill. It uses the promises of the node:stream of the runtime when it has them, and otherwise builds pipeline and finished on the callback versions. The end option is not supported by the fallback. - builder: pass pipeline, finished and promises of the host node:stream in the stream context used by azbundler dev, add the stream/promises polyfill for it and export them in the node:stream polyfill.
Contributor
SCC Complexity Analysis
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds Node.js 24 support to
@aziontech/builderand@aziontech/unenv-preset, for both building apps and running them (azion devand the Azion runtime). Node.js 22 stays supported and is now the minimum version.The difference between 22 and 24 is small, so most changes are guards and stubs:
@aziontech/buildernode:test,node:test/reportersandnode:seainbuiltinModules, and the build failed trying to read a file named after them. Behavior on Node.js 22 is unchanged.fsdev polyfill:F_OK,R_OK,W_OKandX_OKare read fromfs.constants, because Node.js 24 removed them from the top level offs.cryptodev polyfill: exportsargon2,argon2Sync,encapsulateanddecapsulate(undefinedon hosts without them).Readable.toWeb/fromWebstream polyfill.@aziontech/unenv-presetperf_hooks.timerifyandeventLoopUtilization,url.URLPattern,v8.startCpuProfile,worker_threads.locks,fs.mkdtempDisposable,mkdtempDisposableSyncandUtf8Stream. The ones that cannot work throw[azion] <api> is not implemented yet!when called, not when imported.process.versions.nodechanges from18.3.1to22.23.4, so libraries that check the Node.js version no longer take the Node.js 18 path. This is the one change that can alter the behavior of existing apps.Repo
install-dependenciesaction defaults to Node.js 24, the same as the release workflow..nvmrcpoints tolts/jod(Node.js 22) andengines.nodeis>=22.0.0.presets: the Vercel telemetry test uses a real temp dir, becausemock-fs5.5.0 does not intercept the nativefs.rmSyncof Node.js 24.download:cliscript and thescripts/folder.Not in this PR
2.0.0-rc.24.rc.25only fixes readonly values in presets and brings no Node.js 24 coverage.Cipher/Decipherincryptoneed no change: they are alreadyundefinedon Node.js 22.How it was verified
node:url,perf_hooks,v8andworker_threadsgenerates a byte-identical bundle when built on Node.js 22 and on Node.js 24.Type of change
feat:new featurefix:bug fixdocs:/refactor:/test:/ci:/chore:Bump
#major— breaking change#minor— new backward-compatible feature#patch— fix, refactor, docs#none— no release (CI, internal docs)Testing
Checklist
type: description, optional[TICKET]prefix)CHANGELOG.mdupdated, if the repository keeps one