@domscribe/transform

中文文档
0.7.0发布于 2026/10/28TypeScriptES Module构建来源已验证近 30 天下载 14.1万

AST injection of stable element IDs and bundler plugins for Domscribe

原始使用文档
文档目录11 节
  1. Install
  2. Bundler Support
  3. Configuration
  4. Shared Options — Relay
  5. Shared Options — Overlay
  6. Vite Plugin
  7. Webpack Plugin
  8. Turbopack Loader
  9. Subpath Exports
  10. Links
  11. License

@domscribe/transform

AST injection of stable element IDs and bundler plugins for Domscribe.

Install

npm install -D @domscribe/transform

Note: You probably want a framework adapter instead (@domscribe/react, @domscribe/vue, @domscribe/next, @domscribe/nuxt). Those packages wrap this one and handle framework-specific wiring automatically.

Bundler Support

BundlerPluginParser
Vite 5-8@domscribe/transform/plugins/viteAcorn (JS/JSX) or VueSFC
Webpack 5@domscribe/transform/plugins/webpackBabel (TS/JSX) or VueSFC
TurbopackSelf-initializing loaderBabel (TS/JSX)

Vite 8 compatibility requires Domscribe 0.7.0 or later; npm 0.6.1 declares Vite 5-7 support.

Configuration

Shared Options — Relay

These options apply to the relay field across all bundler plugins.

OptionTypeDefaultDescription
autoStartbooleantrueAuto-start the relay daemon if not running
portnumber0 (dynamic)Relay server port (only used when starting)
hoststring'127.0.0.1'Relay server host (only used when starting)
bodyLimitnumber10485760 (10MB)Max request body size in bytes (only used when starting)

Shared Options — Overlay

These options apply when overlay is set to an object instead of a boolean.

OptionTypeDefaultDescription
initialMode'collapsed' | 'expanded''collapsed'Initial display mode for the overlay
debugbooleanfalseEnable debug logging in the overlay

Vite Plugin

import { domscribe } from '@domscribe/transform/plugins/vite';

domscribe({
  include: /\.(jsx|tsx|vue)$/i,
  exclude: /node_modules|\.test\.|\.spec\./i,
  debug: false,
  relay: { autoStart: true, port: 0, host: '127.0.0.1', bodyLimit: 10485760 },
  overlay: true,
  rootDir: undefined, // Override root directory for .domscribe/ artifacts
});
OptionTypeDefaultDescription
includeRegExp/\.(jsx|tsx|vue)$/iFile pattern to include
excludeRegExp/node_modules|\.test\.|\.spec\./iFile pattern to exclude
debugbooleanfalseEnable debug logging
relayRelayPluginOptionsSee sharedRelay server config
overlayboolean | OverlayPluginOptionstrueOverlay UI config
rootDirstringVite's config.rootOverride root directory for .domscribe/ artifacts. Needed when Vite root differs from project root (e.g., Nuxt with a custom srcDir).

Webpack Plugin

import { DomscribeWebpackPlugin } from '@domscribe/transform/plugins/webpack';

new DomscribeWebpackPlugin({
  enabled: true,
  debug: false,
  relay: { autoStart: true, port: 0, host: '127.0.0.1' },
  overlay: true,
});
OptionTypeDefaultDescription
enabledbooleantrue in dev, false in productionEnable the plugin
debugbooleanfalseEnable debug logging
relayRelayPluginOptionsSee sharedRelay server config
overlayboolean | OverlayPluginOptionstrueOverlay UI config

Webpack Loader Options

The webpack loader is managed internally by DomscribeWebpackPlugin. If you need to configure it directly via @domscribe/transform/webpack-loader:

OptionTypeDefaultDescription
debugbooleanfalseEnable debug logging
enabledbooleantrueEnable transformation

Turbopack Loader

Turbopack has no plugin system, so the loader is self-initializing — it manages relay lifecycle and overlay injection directly.

// next.config.ts (turbopack)
{
  turbopack: {
    rules: {
      '*.{tsx,jsx}': {
        loaders: [{
          loader: '@domscribe/transform/turbopack-loader',
          options: {
            enabled: true,
            debug: false,
            relay: { autoStart: true, port: 0, host: '127.0.0.1' },
            overlay: false,
            autoInitPath: undefined,
          },
        }],
      },
    },
  },
}
OptionTypeDefaultDescription
enabledbooleantrueEnable transformation
debugbooleanfalseEnable debug logging
relayRelayPluginOptionsSee sharedRelay server config
overlayboolean | OverlayPluginOptionsfalseOverlay UI config. Defaults to false unlike Vite/Webpack — overlay injection must be handled by the meta-framework wrapper.
autoInitPathstringundefined (falls back to @domscribe/next/auto-init)Absolute filesystem path to the auto-init module. Used in pnpm monorepos where transformed files don't directly depend on the auto-init package. Meta-framework wrappers should resolve this via require.resolve().

getInitResult()

import { getInitResult } from '@domscribe/transform/plugins/turbopack';

const result = getInitResult();
// { relayHost: string | undefined, relayPort: number | undefined }

Returns the relay host and port detected during loader initialization. Available after the first file is processed. Used by meta-framework wrappers (e.g., @domscribe/next) to read relay connection info after the loader has initialized.


Subpath Exports

SubpathDescription
@domscribe/transform/plugins/viteVite plugin (domscribe)
@domscribe/transform/plugins/webpackWebpack plugin (DomscribeWebpackPlugin)
@domscribe/transform/webpack-loaderWebpack loader path (string, for direct use)
@domscribe/transform/plugins/turbopackTurbopack exports (getInitResult)
@domscribe/transform/turbopack-loaderTurbopack loader path (string, for direct use)

Part of Domscribe.

License

MIT

版本与发布记录

@domscribe/transform 共发布 16 个版本,首次发布于 2026/03/18;过去 12 个月发布了 16 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.7.0latest2026/10/2816 天前
0.6.12026/10/2519 天前
0.5.22026/04/017 个月前
0.5.12026/04/017 个月前
0.5.02026/03/277 个月前
0.4.02026/03/277 个月前

关于 @domscribe/transform 的常见问题

@domscribe/transform 是什么?

AST injection of stable element IDs and bundler plugins for Domscribe

如何安装 @domscribe/transform?

在项目目录运行 npm install @domscribe/transform,或使用 pnpm add / yarn add / bun add。

@domscribe/transform 支持 TypeScript 吗?

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

@domscribe/transform 支持 ESM 还是 CommonJS?

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

@domscribe/transform 需要什么版本的 Node.js?

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

@domscribe/transform 可以商用吗?

@domscribe/transform 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@domscribe/transform 的下载量有多少?

根据 npm 官方下载统计,@domscribe/transform 在 2026/10/13 – 2026/11/11 这 30 天内被下载 140,719 次,日均约 4,691 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@domscribe/transform 还在维护吗?

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