Deno 1.29 已正式发布。
主要变化
自 1.28.0 以来,此版本具有多项 npm 兼容性改进和 30 多个错误修复。
- 通过环境变量以实现对自定义 registry 的支持
Deno 现在会遵守NPM_CONFIG_REGISTRY
环境变量,允许指定自定义 npm registry。
# change this to a custom registry
NPM_CONFIG_REGISTRY=https://registry.npmjs.org deno run main.ts
在未来的版本中,将支持在每个包范围内使用不同的 registry,并能够设置凭据。
- 支持
deno install
npm 说明符现在可以与 deno install
搭配使用:
> deno install -A npm:[email protected]
✅ Successfully installed cowsay
C:\Users\david\.deno\bin\cowsay.cmd
C:\Users\david\.deno\bin\cowsay (shell)
> cowsay Hello from deno!
__________________
< Hello from deno! >
------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
这将在第一次运行时额外为命令创建一个锁定文件,以确保每次后续运行都使用相同的 npm 依赖版本。
- 改进
deno init
deno init
子命令是在 v1.25 版本中添加的,用户使用它能够快速搭建新项目的脚手架。虽然此子命令非常方便,但它也非常简约——仅生成 main.ts
和main_test.ts
文件。
为了让它更有用,并让 IDE 发现开发者刚刚初始化了一个新的 Deno 项目,deno init
现在会生成一个deno.jsonc
文件和一个 main_bench.ts
文件。
此外,该子命令的输出也被刷新。
deno init
在 Deno v1.28 中:
$ deno init ./my_deno_project
✅ Project initialized
Run these commands to get started
cd ./my_deno_project
deno run main.ts
deno test
deno init
在 Deno v1.29 中:
$ deno init ./my_deno_project
✅ Project initialized
Run these commands to get started
cd ./my_deno_project
// Run the program
deno run main.ts
// Run the program and watch for file changes
deno task dev
// Run the tests
deno test
// Run the benchmarks
deno bench