@electron-internal/extract-zip

中文文档
1.0.8发布于 2026/10/29MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2995.5万

Fast, safe, native zip extraction for Node.js. Drop-in replacement for extract-zip.

原始使用文档
文档目录8 节
  1. Install
  2. Usage
  3. Security
  4. Benchmarks
  5. Distribution
  6. Building from source
  7. Releasing
  8. License

@electron-internal/extract-zip

[!WARNING] Internal to the Electron project. This package exists to serve Electron's own tooling. Use from non-Electron packages is not supported: the API may change to suit Electron's needs, and bug reports or feature requests from outside use cases may be closed without action. If you need a general-purpose extractor, use extract-zip.

Fast, safe, native zip extraction for Node.js. Drop-in replacement for extract-zip.

  • Native: Rust core via N-API, decompression runs off the event loop.
  • Fast: ~2x faster on entry-heavy archives, never slower. See benchmarks.
  • Safe: hardened against Zip Slip, symlink escapes, absolute paths, NUL injection, Windows reserved names, and zip bombs.
  • Zero runtime deps: no debug/yauzl/get-stream in your tree.
  • Cross-platform: prebuilt binaries for macOS, Linux (glibc/musl), and Windows (x64/arm64).

Install

yarn add @electron-internal/extract-zip

Usage

ESM only:

import extract from '@electron-internal/extract-zip';

await extract('archive.zip', { dir: '/absolute/output/path' });

dir (required, absolute) is the only option. Everything else is fixed: existing files are overwritten, archive mode bits (masked to 0o777) and mtimes are preserved, symlinks are created (skipped on Windows without symlink privilege), and writes are parallelised across min(cpus, 8) workers. The original's onEntry, defaultDirMode, and defaultFileMode are not supported, since no consumer in the electron org uses them.

Security

This package is hardened for extracting trusted Electron distribution archives, enforcing path containment against Zip Slip, symlink escapes, absolute paths, NUL injection, Windows reserved names, and zip bombs. Its threat model and the full list of containment guarantees are documented in SECURITY.md.

Extracting untrusted or unverified archives is out of scope — see SECURITY.md for details.

Benchmarks

yarn bench (Apple M-series, Node 24, median of 5):

CorpusZip sizeextract-zip (JS)thisSpeedup
electron-v42.2.0-darwin-arm64112 MB817 ms441 ms1.9x
8 x 4 MB compressible0.1 MB24 ms3 ms9.4x
2000 small text files0.4 MB372 ms199 ms1.9x
200 incompressible files6.2 MB40 ms22 ms1.8x
node_modules2.9 MB68 ms37 ms1.9x

Extraction runs in phases: validate paths and create directories, inflate and write files in parallel with zlib-ng, then apply symlinks and directory metadata. The Electron number is gated by its single 182 MB framework binary, which can't be split further.

Distribution

One package ships all prebuilt binaries (~2 MB gzipped): macOS darwin-universal, Windows x64/arm64, and Linux x64/arm64 for both glibc and musl. binding.js picks the right one at load time. No optionalDependencies, no postinstall, no network at install.

Building from source

Requires a Rust toolchain (and cmake for zlib-ng).

yarn install
yarn build     # builds index.<your-platform>.node
yarn test

Releasing

Releases are driven by semantic-release on every push to main: conventional commit messages decide the version bump, CI builds all targets, and the fat package is published to npm via trusted publishing. No manual version bumps or tags.

License

MIT

版本与发布记录

@electron-internal/extract-zip 共发布 9 个版本,首次发布于 2026/06/05;过去 12 个月发布了 9 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.0.8latest2026/10/2915 天前
1.0.72026/10/2915 天前
1.0.62026/10/2222 天前
1.0.52026/07/293 个月前
1.0.42026/06/244 个月前
1.0.32026/06/125 个月前

关于 @electron-internal/extract-zip 的常见问题

@electron-internal/extract-zip 是什么?

Fast, safe, native zip extraction for Node.js. Drop-in replacement for extract-zip.

如何安装 @electron-internal/extract-zip?

在项目目录运行 npm install @electron-internal/extract-zip,或使用 pnpm add / yarn add / bun add。

@electron-internal/extract-zip 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@electron-internal/extract-zip 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@electron-internal/extract-zip 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22.12.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@electron-internal/extract-zip 可以商用吗?

@electron-internal/extract-zip 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@electron-internal/extract-zip 的下载量有多少?

根据 npm 官方下载统计,@electron-internal/extract-zip 在 2026/10/14 – 2026/11/12 这 30 天内被下载 29,954,670 次,日均约 998,489 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@electron-internal/extract-zip 还在维护吗?

最新版本 1.0.8 发布于 2026/10/29(15 天前);至今共发布 9 个版本,其中过去 12 个月发布了 9 个;首次发布于 2026/06/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。