Appearance
开发服务器
¥Dev Server
Meteor Dev Server 在开发过程中提供实时文件监控,并通过 HMR、打包可视化工具、调试工具、Mongo 内置实例、命令行工具等提供快速反馈。在运行时,它提供了一个完整的服务器环境,支持 SSR 和基于 Express 的现代 API。
¥Meteor Dev Server provides real-time file watching during development, with fast feedback through HMR, bundle visualizers, debug tools, Mongo built-in instance, CLI tools and more. At runtime, it offers a complete server environment supporting SSR and modern Express-based APIs.
作为现代构建堆栈的一部分,我们更新了每个组件,以提高性能、提供更智能的工具以及更好的打包器可观察性和调试能力。虽然 Meteor Dev Server 仍然是核心,但我们将集成现代工具和新的打包器来增强你的应用开发。
¥As part of the modern build stack, we update each component for improved performance, smarter tooling, and better bundle observability and debugging. While Meteor Dev Server remains at the core, we’ll integrate modern tools and a new bundler to enhance your app development.
监视器
¥Watcher
信息
从 Meteor 3.3 开始
¥Starting with Meteor 3.3
监视器会监听应用代码文件中的更改并触发快速重新编译。
¥The watcher listens for changes in your app’s code files and triggers quick recompilations.
新应用使用现代的跨平台监听器:@parcel/watcher
。它使用原生文件监视快速响应文件更改。通过轮询支持符号链接更改和所有遍历文件。
¥New apps use a modern, cross-platform watcher: @parcel/watcher
. It responds quickly to file changes using native file watching. Symbolic link changes and all traversed files are supported via polling.
对于现有应用,请通过添加到 package.json
来启用此功能:
¥For existing apps, enable this by adding to package.json
:
json
"meteor": {
"modern": true
}
如果你在使用新的监视器时遇到问题,可以恢复到之前的实现,以便更好地检测文件更改。要禁用新的监视器,请在 package.json 中设置 "watcher": false
。
¥If you run into issues with the new watcher, you can revert to the previous implementation for better file change detection. To disable the new watcher, set "watcher": false
in your package.json.
json
"meteor": {
"modern": {
"watcher": false
}
}
现代监视程序使用操作系统的原生文件监视功能,并采用性能优先的方法。现代和旧版监视器都支持使用环境变量进行轮询,这在 WSL 等带有主机、卷或远程设置的边缘情况下非常有用。
¥The modern watcher uses the OS's native file watching with a performance-first approach. Both modern and legacy watchers support environment variables for polling, useful in edge cases like WSL with host, volumes, or remote setups.
要启用轮询,请使用以下命令运行 Meteor 应用:
¥To enable polling, run your Meteor app with:
shell
# enable polling
METEOR_WATCH_FORCE_POLLING=true meteor run
# set polling interval (in ms)
METEOR_WATCH_POLLING_INTERVAL_MS=1000 METEOR_WATCH_FORCE_POLLING=true meteor run
轮询会占用更多 CPU 和 RAM,但在某些环境中它是最可靠的选择。
¥Polling uses more CPU and RAM, but it's the most reliable option in some environments.