节点 v21.1.0(当前)| Node.js
[来源](https://nodejs.org/en/blog/release/v21.1.0“Node v21.1.0(当前)的永久链接| Node.js”)
2023-10-24,版本 21.1.0(当前),@targos
显着变化
自动检测并运行ESM语法
新标志 --experimental-detect-module
可用于在检测到 ES 模块的语法时自动运行 ES 模块。 对于“不明确”的文件,即“.js”或没有“package.json”且带有“type”字段的无扩展名文件,Node.js 将解析该文件以检测 ES 模块语法; 如果找到,它将作为 ES 模块运行该文件,否则它将作为 CommonJS 模块运行该文件。 这同样适用于通过“–eval”或“STDIN”输入的字符串。
我们希望在 Node.js 的未来版本中默认启用检测。 检测会增加启动时间,因此我们鼓励每个人(尤其是包作者)向“package.json”添加“type”字段,即使是默认的“type”:“commonjs”。 “type”字段或显式扩展名(例如“.mjs”或“.cjs”)的存在将选择退出检测。
由 Geoffrey Booth 在 #50096 中贡献。
vm:修复 vm.Script 的 V8 编译缓存支持
之前使用“vm.Script”重复编译相同的源代码在 v16.x 之后停止命中 V8 编译缓存,因为在“vm.Script”中添加了对“importModuleDynamically”的支持,导致性能下降,阻碍了用户(特别是 Jest 用户)从 v16.x 升级。
v21.1.0 中的最新修复允许在不使用 --experimental-vm-modules
时,即使存在 importModuleDynamically
选项,也会再次命中 vm.Script
的编译缓存,因此用户受到影响 通过性能回归现在可以升级了。 正在进行的工作也正在进行中,以启用对“vm.CompileFunction”的编译缓存支持。
由 Joyee Cheung 贡献于 https://github.com/nodejs/node/pull/50137
其他显着变化
- [
3729e33358
] - doc:将 H4ad 添加到协作者 (Vinícius Lourenço) [#50217](https:// github.com/nodejs/node/pull/50217) - [
18862e4d5d
] - (SEMVER-MINOR) fs: 将flush
选项添加到appendFile( )
函数 (Colin Ihrig) #50095 - [
5a52c518ef
] - (SEMVER-MINOR) lib: 添加navigator.userAgent
(Yagiz Nizipli ) #50200 - [
789372a072
] - (SEMVER-MINOR) stream:允许将流类传递给stream.compose
(亚历克斯·杨)#50187 - [
f3a9ea0bc4
] - stream:提高可读流读取的性能 (Raz Luvaton) [#50173](https: //github.com/nodejs/node/pull/50173)
其他提交
- [
9cd68b9083
] - buffer: remove unnecessary assignment in fromString (Tobias Nießen) #50199 - [
a362c276ec
] - crypto: ensure valid point on elliptic curve in SubtleCrypto.importKey (Filip Skokan) #50234 - [
f4da308f8d
] - deps: V8: cherry-pick f7d000a7ae7b (Luke Albao) #50302 - [
269e268c38
] - deps: update ada to 2.7.2 (Node.js GitHub Bot) #50338 - [
03a31ce41e
] - deps: update corepack to 0.22.0 (Node.js GitHub Bot) #50325 - [
000531781b
] - deps: update undici to 5.26.4 (Node.js GitHub Bot) #50274 - [
f050668c14
] - deps: update c-ares to 1.20.1 (Node.js GitHub Bot) #50082 - [
ba258b682b
] - deps: update c-ares to 1.20.0 (Node.js GitHub Bot) #50082 - [
571f7ef1fa
] - deps: patch V8 to 11.8.172.15 (Michaël Zasso) #50114 - [
943047e800
] - deps: V8: cherry-pick 25902244ad1a (Joyee Cheung) #50156 - [
db2a1cf1cb
] - doc: fixnavigator.hardwareConcurrency
example (Tobias Nießen) #50278 - [
6e537aeb44
] - doc: explain how to disable navigator (Geoffrey Booth) #50310 - [
c40de82d62
] - doc: add loong64 info into platform list (Shi Pujin) #50086 - [
1c21a1880b
] - doc: update release process LTS step (Richard Lau) #50299 - [
2473aa3672
] - doc: fix release process table of contents (Richard Lau) #50216 - [
ce9d84eae3
] - doc: update apistream.compose
(Alex Yang) #50206 - [
dacee4d9b5
] - doc: add ReflectConstruct to known perf issues (Vinicius Lourenço) #50111 - [
82363be2ac
] - doc: fix typo in dgram docs (Peter Johnson) #50211 - [
8c1a46c751
] - doc: fix H4ad collaborator sort (Vinicius Lourenço) #50218 - [
3729e33358
] - doc: add H4ad to collaborators (Vinícius Lourenço) #50217 - [
bac872cbd0
] - doc: update release-stewards with last sec-release (Rafael Gonzaga) #50179 - [
06b7724f14
] - doc: add command to keep major branch sync (Rafael Gonzaga) #50102 - [
47633ab086
] - doc: add loong64 to list of architectures (Shi Pujin) #50172 - [
1f40ca1b91
] - doc: update security release process (Michael Dawson) #50166 - [
998feda118
] - esm: do not give wrong hints when detecting file format (Antoine du Hamel) #50314 - [
e375063e01
] - (SEMVER-MINOR) esm: detect ESM syntax in ambiguous JavaScript (Geoffrey Booth) #50096 - [
c76eb27971
] - esm: improve check for ESM syntax (Geoffrey Booth) #50127 - [
7740bf820c
] - esm: rename error code related to import attributes (Antoine du Hamel) #50181 - [
0cc176ef25
] - fs: improve error performance forreadSync
(Jungku Lee) #50033 - [
5942edb774
] - fs: improve error performance forfsyncSync
(Jungku Lee) #49880 - [
6ec5abadc0
] - fs: improve error performance formkdirSync
(CanadaHonk) #49847 - [
c5ff000cb1
] - fs: improve error performance ofrealpathSync
(Yagiz Nizipli) #49962 - [
6eeaa02f5c
] - fs: improve error performance oflchownSync
(Yagiz Nizipli) #49962 - [
dc9ac8d41c
] - fs: improve error performance ofsymlinkSync
(Yagiz Nizipli) #49962 - [
bc6f279261
] - fs: improve error performance ofreadlinkSync
(Yagiz Nizipli) #49962 - [
275987841e
] - fs: improve error performance ofmkdtempSync
(Yagiz Nizipli) #49962 - [
81f15274e2
] - fs: improve error performance oflinkSync
(Yagiz Nizipli) #49962 - [
f766c04856
] - fs: improve error performance ofchownSync
(Yagiz Nizipli) #49962 - [
610036c67d
] - fs: improve error performance ofrenameSync
(Yagiz Nizipli) #49962 - [
18862e4d5d
] - (SEMVER-MINOR) fs: add flush option to appendFile() functions (Colin Ihrig) #50095 - [
3f8cbb15cb
] - http2: allow streams to complete gracefully after goaway (Michael Lumish) #50202 - [
1464eba1a0
] - lib: improve performance of validateStringArray and validateBooleanArray (Aras Abbasi) #49756 - [
5a52c518ef
] - (SEMVER-MINOR) lib: addnavigator.userAgent
(Yagiz Nizipli) #50200 - [
b6021ab8f6
] - lib: reduce overhead of blob clone (Vinicius Lourenço) #50110 - [
be19d9baa1
] - meta: move Trott to TSC regular member (Rich Trott) #50297 - [
91e373f8e9
] - node-api: return napi_exception_pending on proxy handlers (Chengzhong Wu) #48607 - [
531a3ae4b5
] - stream: simplify prefinish (Robert Nagy) #50204 - [
514ac86579
] - stream: reduce scope of readable bitmap details (Robert Nagy) #49963 - [
789372a072
] - (SEMVER-MINOR) stream: allow pass stream class tostream.compose
(Alex Yang) #50187 - [
f3a9ea0bc4
] - stream: call helper function from push and unshift (Raz Luvaton) #50173 - [
a9ca7b32e7
] - test: improve watch mode test (Moshe Atlow) #50319 - [
63b7059efd
] - test: settest-watch-mode-inspect
as flaky (Yagiz Nizipli) #50259 - [
7f87084b05
] - Revert “test: settest-esm-loader-resolve-type
as flaky” (Antoine du Hamel) #50315 - [
4d390e2de4
] - test: replace forEach with for…of in test-http-perf_hooks.js (Niya Shiyas) #49818 - [
67c599ec39
] - test: replace forEach with for…of in test-net-isipv4.js (Niya Shiyas) #49822 - [
19d3ce2494
] - test: deflaketest-esm-loader-resolve-type
(Antoine du Hamel) #50273 - [
2d8d6c5701
] - test: replace forEach with for…of in test-http2-server (Niya Shiyas) #49819 - [
af31d51e5a
] - test: replace forEach with for…of in test-http2-client-destroy.js (Niya Shiyas) #49820 - [
465ad2a5ce
] - test: updateurl
web platform tests (Yagiz Nizipli) #50264 - [
3b80a6894c
] - test: settest-emit-after-on-destroyed
as flaky (Yagiz Nizipli) #50246 - [
57adbdd156
] - test: set inspector async stack test as flaky (Yagiz Nizipli) #50244 - [
6507f66404
] - test: set test-worker-nearheaplimit-deadlock flaky (StefanStojanovic) #50277 - [
21a6ba548d
] - test: settest-cli-node-options
as flaky (Yagiz Nizipli) #50296 - [
c55f8f30cb
] - test: reduce the number of requests and parsers (Luigi Pinca) #50240 - [
5129bedfa2
] - test: set crypto-timing test as flaky (Yagiz Nizipli) #50232 - [
9bc5ab5e07
] - test: settest-structuredclone-*
as flaky (Yagiz Nizipli) #50261 - [
317e447ddc
] - test: deflaketest-loaders-workers-spawned
(Antoine du Hamel) #50251 - [
0c710daae2
] - test: improve code coverage of diagnostics_channel (Jithil P Ponnan) #50053 - [
7c6e4d7ec3
] - test: settest-esm-loader-resolve-type
as flaky (Yagiz Nizipli) #50226 - [
c8744909b0
] - test: set inspector async hook test as flaky (Yagiz Nizipli) #50252 - [
3e38001739
] - test: skip test-benchmark-os.js on IBM i (Abdirahim Musse) #50208 - [
dd66fdfb7b
] - test: set parallel http server test as flaky (Yagiz Nizipli) #50227 - [
a38d1311bf
] - test: set test-worker-nearheaplimit-deadlock flaky (Stefan Stojanovic) #50238 - [
8efb75fd80
] - test: settest-runner-watch-mode
as flaky (Yagiz Nizipli) #50221 - [
143ddded74
] - test: set sea snapshot tests as flaky (Yagiz Nizipli) #50223 - [
ae905a8f35
] - test: fix defect path traversal tests (Tobias Nießen) #50124 - [
ce27ee701b
] - tls: reduce TLS ‘close’ event listener warnings (Tim Perry) #50136 - [
ab4bae8e1f
] - tools: drop support for osx notarization with gon (Ulises Gascón) #50291 - [
5df3d5abcc
] - tools: update comment inupdate-uncidi.sh
andacorn_version.h
(Jungku Lee) #50175 - [
bf7b94f0b3
] - tools: refactor checkimports.py (Mohammed Keyvanzadeh) #50011 - [
5dc454a837
] - util: remove internal mime fns from benchmarks (Aras Abbasi) #50201 - [
8f7eb15603
] - vm: use import attributes instead of import assertions (Antoine du Hamel) #50141 - [
dda33c2bf1
] - vm: reject in importModuleDynamically without --experimental-vm-modules (Joyee Cheung) #50137 - [
3999362c59
] - vm: use internal versions of compileFunction and Script (Joyee Cheung) #50137 - [
a54179f0e0
] - vm: unify host-defined option generation in vm.compileFunction (Joyee Cheung) #50137 - [
87be790fa9
] - worker: handle detachedMessagePort
from a different context (Juan José) #49150
Windows 32-bit Installer: https://nodejs.org/dist/v21.1.0/node-v21.1.0-x86.msi
Windows 64-bit Installer: https://nodejs.org/dist/v21.1.0/node-v21.1.0-x64.msi
Windows ARM 64-bit Installer: https://nodejs.org/dist/v21.1.0/node-v21.1.0-arm64.msi
Windows 32-bit Binary: https://nodejs.org/dist/v21.1.0/win-x86/node.exe
Windows 64-bit Binary: https://nodejs.org/dist/v21.1.0/win-x64/node.exe
Windows ARM 64-bit Binary: https://nodejs.org/dist/v21.1.0/win-arm64/node.exe
macOS 64-bit Installer: https://nodejs.org/dist/v21.1.0/node-v21.1.0.pkg
macOS Apple Silicon 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-darwin-arm64.tar.gz
macOS Intel 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-darwin-x64.tar.gz
Linux 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-x64.tar.xz
Linux PPC LE 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-ppc64le.tar.xz
Linux s390x 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-s390x.tar.xz
AIX 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-aix-ppc64.tar.gz
ARMv7 32-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-armv7l.tar.xz
ARMv8 64-bit Binary: https://nodejs.org/dist/v21.1.0/node-v21.1.0-linux-arm64.tar.xz
Source Code: https://nodejs.org/dist/v21.1.0/node-v21.1.0.tar.gz
Other release files: https://nodejs.org/dist/v21.1.0/
Documentation: https://nodejs.org/docs/v21.1.0/api/