Conversation
test/deno/smoke-test.ts 使用 import.meta.url,仅供 Deno 直接运行, 不应纳入 CommonJS 模式的 tsc 编译范围。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deno 在未声明模块类型时默认将 .js 文件视为 ESM, 即使通过 createRequire 加载也会走 loadESMFromCJS 路径并抛出 "exports is not defined"。显式声明 "type": "commonjs" 后 Deno 可正确识别并加载 CommonJS 格式的 dist 产物。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Deno 的 --allow-read 默认不授权读取 /proc/meminfo, 原先直接 throw 导致 memory.info() 返回 failure。 现改为降级到 os.totalmem()/os.freemem() 并发出 warnDegradation, 与 CPU 和 Windows 适配器的处理策略保持一致。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- 添加 "type": "commonjs" 声明,解决 Deno 加载 CJS 产物失败 - Linux/macOS 适配器在 /proc/meminfo 不可读时降级到 os 模块 - CommandExecutor 处理 Deno 兼容层抛出的非对象异常 - 修复 getNetworkStats 静默返回空数组的错误行为 - cpu.average() 标记为 @deprecated,引导迁移到 cpu.usage() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
增强 Deno 兼容性,添加降级处理逻辑以支持在无法执行原生命令时返回基础数据,同时更新文档以反映这些更改。
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.
Background
Issue #43 报告 2.0 版本无法在 Deno 运行时下使用,Deno 的 Node.js 兼容层在执行 shell
命令失败时会抛出非标准异常,且默认将
.js文件视为 ESM 导致 CJS 产物加载失败。Key Changes
"type": "commonjs"声明,解决 Deno 将.js产物误判为 ESM 的问题CommandExecutor处理非对象异常(null/string/undefined),兼容 Deno 抛出的非标准错误os模块,发出warnDegradation警告getNetworkStats静默返回[]的错误行为,改为抛出MonitorErrorcpu.average()标记@deprecated,引导用户迁移到cpu.usage()Test Matrix
npm run buildnpm run test:unitnpm run test:unit(Node 18/20/22)npm run lint:checkRelated Issues
Platform & Permissions
Deno 运行时需要
--allow-read --allow-env --allow-sys权限,库在权限受限时自动降级,不要求--allow-all。Documentation
README.md/README-zh.md(新增 Deno Compatibility 章节及降级行为说明)Additional Notes
降级时会输出
console.warn(每个 key 仅一次),用户可通过监听来感知当前运行环境的限制。回滚只需 revert"type": "commonjs"和适配器降级逻辑。