@dev-to/react-plugin 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -31,7 +31,7 @@ export default defineConfig({
31
31
  })
32
32
  ```
33
33
 
34
- ### devComponentMap 形态
34
+ ### components 参数形态
35
35
 
36
36
  - `devToReactPlugin()`:通配符模式(默认 `'*': '/'`),便于开发;但 `vite build --mode lib` 需要显式 componentName。
37
37
  - `devToReactPlugin('MyCard')`:字符串快捷模式,等价于 `{ MyCard: '/' }`。
@@ -50,7 +50,7 @@ export default defineConfig({
50
50
 
51
51
  ## 生产构建(Library Mode)
52
52
 
53
- 执行 `vite build --mode lib` 时,插件会按 `devComponentMap` 为每个组件产出一个 UMD bundle,默认输出到 `dist/<component>/`。
53
+ 执行 `vite build --mode lib` 时,插件会按 `components` 参数为每个组件产出一个 UMD bundle,默认输出到 `dist/<component>/`。
54
54
 
55
55
  > 提示:`'*': '/'` 的通配符模式仅适合开发;lib 构建请显式列出组件名。
56
56
 
@@ -1 +1 @@
1
- {"version":3,"file":"debugTools.d.ts","sourceRoot":"","sources":["../src/debugTools.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAG/H,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,cAAc,CAAA;IACxB,KAAK,EAAE,WAAW,CAAA;IAClB,KAAK,EAAE,iBAAiB,CAAA;IACxB,cAAc,EAAE,0BAA0B,CAAA;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAqFD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,QAwUxG"}
1
+ {"version":3,"file":"debugTools.d.ts","sourceRoot":"","sources":["../src/debugTools.ts"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,MAAM,CAAA;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAA;AAG/H,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,cAAc,CAAA;IACxB,KAAK,EAAE,WAAW,CAAA;IAClB,KAAK,EAAE,iBAAiB,CAAA;IACxB,cAAc,EAAE,0BAA0B,CAAA;IAC1C,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AA4ID,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG,EAAE,iBAAiB,EAAE,KAAK,EAAE,iBAAiB,QA6TxG"}
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import node_path from "node:path";
4
4
  import picocolors from "picocolors";
5
5
  import { mergeConfig } from "vite";
6
6
  import { exec } from "node:child_process";
7
+ import { createRequire } from "node:module";
7
8
  import { fileURLToPath } from "node:url";
8
9
  import node_os from "node:os";
9
10
  import typescript from "typescript";
@@ -255,14 +256,14 @@ function renderDebugHtml(params) {
255
256
  <summary>插件参数与配置说明 (Plugin API)</summary>
256
257
  <div class="parameter-desc">
257
258
  <div style="margin-bottom: 24px;">
258
- <pre style="background: #ebf8ff; color: #2c5282; border-color: #bee3f8; font-size: 14px; font-weight: 600;">reactHmrHostPlugin(devComponentMap?, options?)</pre>
259
+ <pre style="background: #ebf8ff; color: #2c5282; border-color: #bee3f8; font-size: 14px; font-weight: 600;">devToReactPlugin(components?, options?)</pre>
259
260
  <div class="muted" style="margin-top: 8px;">
260
261
  支持单组件简写、对象全量映射,以及透传 Vite 原生配置。
261
262
  </div>
262
263
  </div>
263
264
 
264
265
  <div class="parameter-item">
265
- <span class="parameter-name">1. devComponentMap (第一个参数)</span>
266
+ <span class="parameter-name">1. components (第一个参数)</span>
266
267
  <div class="parameter-info">
267
268
  定义组件名与本地入口文件的映射:
268
269
  <ul style="margin-top: 8px;">
@@ -271,10 +272,10 @@ function renderDebugHtml(params) {
271
272
  <li><b>多组件映射</b>:支持具体的相对/绝对路径。</li>
272
273
  </ul>
273
274
  <pre><span class="cmt">// Option 1: Shorthand (Default)</span>
274
- reactHmrHostPlugin(<span class="str">'Demo'</span>)
275
+ devToReactPlugin(<span class="str">'Demo'</span>)
275
276
 
276
277
  <span class="cmt">// Option 2: Explicit Mapping with Wildcard</span>
277
- reactHmrHostPlugin({
278
+ devToReactPlugin({
278
279
  <span class="str">'*'</span>: <span class="str">'/'</span>, <span class="cmt">// Wildcard to default entry</span>
279
280
  <span class="str">'Card'</span>: <span class="str">'src/Card.tsx'</span> <span class="cmt">// Specific file</span>
280
281
  })</pre>
@@ -295,8 +296,8 @@ reactHmrHostPlugin({
295
296
  <li>详细配置请参考 <a href="https://cn.vite.dev/config/shared-options#css-modules" target="_blank" style="color:#3b82f6;">Vite CSS 官方文档 ↗</a></li>
296
297
  </ul>
297
298
  <pre><span class="cmt">// Disable plugin CSS config or provide custom overrides</span>
298
- reactHmrHostPlugin(<span class="str">'Demo'</span>, { css: <span class="kw">false</span> })
299
- reactHmrHostPlugin(<span class="str">'Demo'</span>, { css: { ... } })</pre>
299
+ devToReactPlugin(<span class="str">'Demo'</span>, { css: <span class="kw">false</span> })
300
+ devToReactPlugin(<span class="str">'Demo'</span>, { css: { ... } })</pre>
300
301
  </li>
301
302
  <li style="margin-top: 12px;"><code class="kw">build</code>:
302
303
  <ul>
@@ -308,7 +309,7 @@ globals: { react: <span class="str">'React'</span>, <span class="str">'react-dom
308
309
  <li>详细配置请参考 <a href="https://cn.vite.dev/config/build-options" target="_blank" style="color:#3b82f6;">Vite 构建官方文档 ↗</a></li>
309
310
  </ul>
310
311
  <pre><span class="cmt">// Example: Disable asset inlining during build</span>
311
- reactHmrHostPlugin(<span class="str">'Demo'</span>, {
312
+ devToReactPlugin(<span class="str">'Demo'</span>, {
312
313
  build: { assetsInlineLimit: <span class="val">0</span> }
313
314
  })</pre>
314
315
  </li>
@@ -318,7 +319,7 @@ reactHmrHostPlugin(<span class="str">'Demo'</span>, {
318
319
  <li>是否在启动 Vite 开发服务器后自动在浏览器中打开此调试面板。</li>
319
320
  </ul>
320
321
  <pre><span class="cmt">// Enable auto-open</span>
321
- reactHmrHostPlugin(<span class="str">'Demo'</span>, { open: <span class="kw">true</span> })</pre>
322
+ devToReactPlugin(<span class="str">'Demo'</span>, { open: <span class="kw">true</span> })</pre>
322
323
  </li>
323
324
  </ul>
324
325
  </div>
@@ -1140,6 +1141,27 @@ function openBrowser(url) {
1140
1141
  if ('win32' === process.platform) return void exec(`start "" "${url}"`);
1141
1142
  exec(`xdg-open "${url}"`);
1142
1143
  }
1144
+ function getReactLoaderUmdPath() {
1145
+ const require = createRequire(import.meta.url);
1146
+ try {
1147
+ const loaderPkgPath = require.resolve('@dev-to/react-loader/package.json');
1148
+ const loaderPkgDir = node_path.dirname(loaderPkgPath);
1149
+ const umdPath = node_path.join(loaderPkgDir, 'dist/index.umd.js');
1150
+ if (node_fs.existsSync(umdPath)) return umdPath;
1151
+ } catch {}
1152
+ try {
1153
+ const loaderMainPath = require.resolve('@dev-to/react-loader');
1154
+ const loaderPkgDir = node_path.dirname(node_path.dirname(loaderMainPath));
1155
+ const umdPath = node_path.join(loaderPkgDir, 'dist/index.umd.js');
1156
+ if (node_fs.existsSync(umdPath)) return umdPath;
1157
+ } catch {}
1158
+ try {
1159
+ const __dirname = node_path.dirname(fileURLToPath(import.meta.url));
1160
+ const umdPath = node_path.resolve(__dirname, '../../react-loader/dist/index.umd.js');
1161
+ if (node_fs.existsSync(umdPath)) return umdPath;
1162
+ } catch {}
1163
+ throw new Error(`${constants_PLUGIN_LOG_PREFIX} react-loader UMD not found. Run 'pnpm build' in react-loader package.`);
1164
+ }
1143
1165
  const globalState = globalThis;
1144
1166
  let didOpenBrowser = Boolean(globalState[DEV_TO_REACT_DID_OPEN_BROWSER_KEY]);
1145
1167
  function installDebugTools(server, ctx, state) {
@@ -1266,32 +1288,25 @@ function installDebugTools(server, ctx, state) {
1266
1288
  },
1267
1289
  tips: [
1268
1290
  '宿主侧需设置 localStorage.VITE_DEV_SERVER_ORIGIN(可从 originCandidates 里选择一个可访问的 origin)。',
1269
- 'devComponentMap key 必须与后端返回的 componentName 完全一致(严格匹配)。',
1291
+ 'components 参数的 key 必须与后端返回的 componentName 完全一致(严格匹配)。',
1270
1292
  'Fast Refresh 关键:必须先 import init.js(安装 react-refresh preamble),再 import react-dom/client。',
1271
- '如需产出可分发 UMD 包:使用 `vite build --mode lib`(仅构建 componentMap 指定的组件,输出到 dist/<component>/)。'
1293
+ '如需产出可分发 UMD 包:使用 `vite build --mode lib`(仅构建 components 指定的组件,输出到 dist/<component>/)。'
1272
1294
  ]
1273
1295
  }, null, 2));
1274
1296
  return;
1275
1297
  }
1276
1298
  if (pathname === `${STABLE_BASE_PATH}/react-loader.js`) try {
1277
- const __filename = fileURLToPath(import.meta.url);
1278
- const __dirname = node_path.dirname(__filename);
1279
- const reactLoaderUmdPath = node_path.resolve(__dirname, '../../react-loader/dist/index.umd.js');
1280
- if (node_fs.existsSync(reactLoaderUmdPath)) {
1281
- const umdCode = node_fs.readFileSync(reactLoaderUmdPath, 'utf-8');
1282
- res.statusCode = 200;
1283
- res.setHeader('Content-Type', "application/javascript; charset=utf-8");
1284
- res.setHeader('Access-Control-Allow-Origin', '*');
1285
- res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
1286
- res.end(umdCode);
1287
- return;
1288
- }
1289
- res.statusCode = 404;
1290
- res.end(`react-loader UMD not found at ${reactLoaderUmdPath}. Run 'pnpm build' in react-loader package.`);
1299
+ const reactLoaderUmdPath = getReactLoaderUmdPath();
1300
+ const umdCode = node_fs.readFileSync(reactLoaderUmdPath, 'utf-8');
1301
+ res.statusCode = 200;
1302
+ res.setHeader('Content-Type', "application/javascript; charset=utf-8");
1303
+ res.setHeader('Access-Control-Allow-Origin', '*');
1304
+ res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate');
1305
+ res.end(umdCode);
1291
1306
  return;
1292
1307
  } catch (error) {
1293
- res.statusCode = 500;
1294
- res.end(`Error loading react-loader UMD: ${error}`);
1308
+ res.statusCode = 404;
1309
+ res.end(`${error instanceof Error ? error.message : String(error)}`);
1295
1310
  return;
1296
1311
  }
1297
1312
  if (pathname.startsWith(STABLE_LOADER_BASE_PATH)) {
@@ -1580,7 +1595,7 @@ function createContractVirtualModuleCode(contract) {
1580
1595
  console.log('Events:', CONTRACT.events);
1581
1596
  console.log('Dev mode:', CONTRACT?.dev?.mode);
1582
1597
  console.log('Default entry:', CONTRACT?.dev?.defaultEntry);
1583
- console.log('devComponentMap keys:', Object.keys(CONTRACT?.dev?.componentMap || {}));
1598
+ console.log('Components:', Object.keys(CONTRACT?.dev?.componentMap || {}));
1584
1599
  console.log('Tip: open', ORIGIN + '${STABLE_DEBUG_HTML_PATH}');
1585
1600
  console.groupEnd();
1586
1601
  }
@@ -1680,7 +1695,9 @@ function createReactRuntimeVirtualModuleCode() {
1680
1695
  export default React;
1681
1696
  `;
1682
1697
  }
1683
- const devToReactPlugin = (devComponentMap = {}, options = {})=>{
1698
+ function devToReactPlugin(components, options) {
1699
+ const componentsMap = components ?? {};
1700
+ const opts = options ?? {};
1684
1701
  const stats = {
1685
1702
  contract: {
1686
1703
  count: 0,
@@ -1700,7 +1717,7 @@ const devToReactPlugin = (devComponentMap = {}, options = {})=>{
1700
1717
  };
1701
1718
  let configDir = process.cwd();
1702
1719
  let currentRootDir = configDir;
1703
- let resolvedConfig = resolveDevComponentConfig(currentRootDir, devComponentMap, configDir);
1720
+ let resolvedConfig = resolveDevComponentConfig(currentRootDir, componentsMap, configDir);
1704
1721
  let version = '0.0.0';
1705
1722
  try {
1706
1723
  const pkgPath = node_path.join(configDir, 'package.json');
@@ -1814,14 +1831,14 @@ const devToReactPlugin = (devComponentMap = {}, options = {})=>{
1814
1831
  audit: resolvedConfig.audit,
1815
1832
  resolvedConfig,
1816
1833
  configDir,
1817
- open: options.open
1834
+ open: opts.open
1818
1835
  }, debugState);
1819
1836
  },
1820
1837
  config (userConfig, env) {
1821
1838
  const rootDir = configDir;
1822
1839
  if (rootDir !== currentRootDir) {
1823
1840
  currentRootDir = rootDir;
1824
- resolvedConfig = resolveDevComponentConfig(rootDir, devComponentMap, configDir);
1841
+ resolvedConfig = resolveDevComponentConfig(rootDir, componentsMap, configDir);
1825
1842
  const isDev = !isLibBuild(env);
1826
1843
  contract = createContract(resolvedConfig.componentMap, resolvedConfig.defaultEntryAbs, isDev);
1827
1844
  }
@@ -1836,11 +1853,11 @@ const devToReactPlugin = (devComponentMap = {}, options = {})=>{
1836
1853
  }
1837
1854
  }
1838
1855
  };
1839
- if (false === options.css) next.css = void 0;
1840
- else if (options.css) next.css = mergeConfig({
1856
+ if (false === opts.css) next.css = void 0;
1857
+ else if (opts.css) next.css = mergeConfig({
1841
1858
  css: next.css
1842
1859
  }, {
1843
- css: options.css
1860
+ css: opts.css
1844
1861
  }).css;
1845
1862
  if (isLibBuild(env)) {
1846
1863
  const actualNames = Object.keys(contract.dev.componentMap).filter((n)=>'*' !== n);
@@ -1869,7 +1886,7 @@ const devToReactPlugin = (devComponentMap = {}, options = {})=>{
1869
1886
  picked,
1870
1887
  componentMap: contract.dev.componentMap,
1871
1888
  resolvedConfig,
1872
- options,
1889
+ options: opts,
1873
1890
  userConfig
1874
1891
  });
1875
1892
  Object.assign(libBuildState, {
@@ -1901,7 +1918,7 @@ const devToReactPlugin = (devComponentMap = {}, options = {})=>{
1901
1918
  if (nextConfigDir !== configDir) {
1902
1919
  configDir = nextConfigDir;
1903
1920
  currentRootDir = configDir;
1904
- resolvedConfig = resolveDevComponentConfig(currentRootDir, devComponentMap, configDir);
1921
+ resolvedConfig = resolveDevComponentConfig(currentRootDir, componentsMap, configDir);
1905
1922
  const isDev = 'serve' === resolved.command;
1906
1923
  contract = createContract(resolvedConfig.componentMap, resolvedConfig.defaultEntryAbs, isDev);
1907
1924
  }
@@ -2031,6 +2048,6 @@ const devToReactPlugin = (devComponentMap = {}, options = {})=>{
2031
2048
  devCssAssetPlugin,
2032
2049
  libPostPlugin
2033
2050
  ];
2034
- };
2051
+ }
2035
2052
  const viteHostReactBridgePlugin = devToReactPlugin;
2036
2053
  export { EVENT_FULL_RELOAD, EVENT_HMR_UPDATE, PLUGIN_NAME, STABLE_BASE_PATH, STABLE_DEBUG_HTML_PATH, STABLE_DEBUG_JSON_PATH, STABLE_INIT_PATH, STABLE_REACT_RUNTIME_PATH, constants_PLUGIN_LOG_PREFIX as PLUGIN_LOG_PREFIX, constants_STABLE_CONTRACT_PATH as STABLE_CONTRACT_PATH, devToReactPlugin, viteHostReactBridgePlugin };
package/dist/plugin.d.ts CHANGED
@@ -1,6 +1,46 @@
1
- import { type Plugin } from 'vite';
2
1
  import type { DevComponentMapInput, DevToReactPluginOptions } from './types.js';
3
- export declare const devToReactPlugin: (devComponentMap?: DevComponentMapInput, options?: DevToReactPluginOptions) => Plugin[];
2
+ /**
3
+ * Dev-to React Plugin for Vite
4
+ *
5
+ * Enables rapid development and library building of React components with hot module replacement.
6
+ * Supports single or multiple component configurations with customizable CSS and build options.
7
+ *
8
+ * Compatible with Vite 4.0.0+
9
+ *
10
+ * @param components - Component configuration
11
+ * - `string`: Single component name as wildcard (e.g. `'Button'`)
12
+ * - `Record<string, string>`: Component name to file path mapping (e.g. `{ Button: 'src/Button.tsx' }`)
13
+ * - `undefined`: Fallback to root index file
14
+ * @param options - Plugin options for CSS and build configuration
15
+ * @returns Array of Vite plugins (compatible with all Vite versions)
16
+ *
17
+ * @example
18
+ * // Single component with wildcard
19
+ * devToReactPlugin('Button')
20
+ *
21
+ * @example
22
+ * // Multiple components
23
+ * devToReactPlugin({
24
+ * Button: 'src/Button.tsx',
25
+ * Dialog: 'src/Dialog.tsx',
26
+ * Input: 'src/Input.tsx',
27
+ * })
28
+ *
29
+ * @example
30
+ * // With custom options
31
+ * devToReactPlugin(
32
+ * { Button: 'src/Button.tsx' },
33
+ * {
34
+ * css: { modules: { localsConvention: 'camelCase' } },
35
+ * open: true,
36
+ * }
37
+ * )
38
+ *
39
+ * @example
40
+ * // Fallback to root entry
41
+ * devToReactPlugin(undefined, { css: false })
42
+ */
43
+ export declare function devToReactPlugin(components?: DevComponentMapInput, options?: DevToReactPluginOptions): any;
4
44
  /** @deprecated Use `devToReactPlugin` instead. */
5
- export declare const viteHostReactBridgePlugin: (devComponentMap?: DevComponentMapInput, options?: DevToReactPluginOptions) => Plugin[];
45
+ export declare const viteHostReactBridgePlugin: typeof devToReactPlugin;
6
46
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAA+B,KAAK,MAAM,EAAwC,MAAM,MAAM,CAAA;AA4BrG,OAAO,KAAK,EAIV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,YAAY,CAAA;AA0BnB,eAAO,MAAM,gBAAgB,GAC3B,kBAAiB,oBAAyB,EAC1C,UAAS,uBAA4B,KACpC,MAAM,EA8fR,CAAA;AAED,kDAAkD;AAClD,eAAO,MAAM,yBAAyB,qBAngBnB,oBAAoB,YAC5B,uBAAuB,KAC/B,MAAM,EAigBgD,CAAA"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAIV,oBAAoB,EACpB,uBAAuB,EACxB,MAAM,YAAY,CAAA;AA0BnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,CAAC,EAAE,oBAAoB,EACjC,OAAO,CAAC,EAAE,uBAAuB,GAChC,GAAG,CAggBL;AAED,kDAAkD;AAClD,eAAO,MAAM,yBAAyB,yBAAmB,CAAA"}
package/dist/types.d.ts CHANGED
@@ -1,34 +1,94 @@
1
1
  import type { BuildOptions, CSSOptions } from 'vite';
2
+ /**
3
+ * Plugin options for dev-to React plugin
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * devToReactPlugin('Button', {
8
+ * css: { modules: { localsConvention: 'camelCase' } },
9
+ * open: true,
10
+ * })
11
+ * ```
12
+ */
2
13
  export interface DevToReactPluginOptions {
3
14
  /**
4
- * 透传给 Vite `css` 配置(开发与构建态均生效)。
15
+ * CSS configuration passed to Vite (applies in both dev and build modes).
5
16
  *
6
- * 默认提供稳定的 CSS Modules 命名规则:
17
+ * By default, stable CSS Modules naming rule is provided:
7
18
  * `[name]__[local]___[hash:base64:5]`
8
19
  *
9
- * - `false`:禁用插件注入的所有 CSS 配置
10
- * - 传对象:与插件默认配置深度合并
20
+ * - `false`: Disable all CSS configuration injected by the plugin
21
+ * - `CSSOptions`: Deep merge with plugin's default configuration (user config takes precedence)
22
+ *
23
+ * @example
24
+ * ```typescript
25
+ * // Custom CSS Modules naming
26
+ * { css: { modules: { localsConvention: 'camelCase' } } }
27
+ *
28
+ * // Disable CSS configuration
29
+ * { css: false }
30
+ * ```
11
31
  */
12
32
  css?: CSSOptions | false;
13
33
  /**
14
- * 透传给 Vite `build` 配置(仅在 `vite build --mode lib` 时生效)。
34
+ * Build configuration passed to Vite (only applies when running `vite build --mode lib`).
35
+ *
36
+ * Typical use cases:
37
+ * - Adjust asset inlining: `assetsInlineLimit`
38
+ * - Configure rollup: `rollupOptions`
39
+ * - Configure minification/output: `minify` / `sourcemap` / `target` etc.
15
40
  *
16
- * 典型用途:
17
- * - 调整资源内联:`assetsInlineLimit`
18
- * - 调整 rollup:`rollupOptions`
19
- * - 调整压缩/产物:`minify` / `sourcemap` / `target` 等
41
+ * This config will be deep merged with the plugin's internal `next.build` config
42
+ * (user config takes precedence).
20
43
  *
21
- * 插件会将此配置与内部生成的 `next.build` 做深度合并(以这里传入的为准)。
44
+ * @example
45
+ * ```typescript
46
+ * {
47
+ * build: {
48
+ * assetsInlineLimit: 0,
49
+ * rollupOptions: { external: ['react', 'react-dom'] }
50
+ * }
51
+ * }
52
+ * ```
22
53
  */
23
54
  build?: BuildOptions;
24
55
  /**
25
- * 启动开发服务器后,是否自动在浏览器中打开调试面板。
56
+ * Whether to automatically open the debug panel in browser after starting dev server.
57
+ *
26
58
  * @default false
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * { open: true } // Opens debug panel automatically
63
+ * ```
27
64
  */
28
65
  open?: boolean;
29
66
  }
30
67
  /** @deprecated Use `DevToReactPluginOptions` instead. */
31
68
  export type ViteHostReactBridgePluginOptions = DevToReactPluginOptions;
69
+ /**
70
+ * Component configuration input type
71
+ *
72
+ * Can be one of:
73
+ * - `string`: Single component name used as wildcard pattern
74
+ * - `Record<string, string>`: Map of component names to their file paths
75
+ * - `undefined` or `null`: Use default entry point
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * // Single component
80
+ * 'Button'
81
+ *
82
+ * // Multiple components
83
+ * {
84
+ * Button: 'src/Button.tsx',
85
+ * Dialog: 'src/Dialog.tsx',
86
+ * }
87
+ *
88
+ * // Default entry
89
+ * undefined
90
+ * ```
91
+ */
32
92
  export type DevComponentMapInput = Record<string, string> | string | undefined | null;
33
93
  export interface DevComponentAudit {
34
94
  defaultEntryAbs: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAEpD,MAAM,WAAW,uBAAuB;IACtC;;;;;;;;OAQG;IACH,GAAG,CAAC,EAAE,UAAU,GAAG,KAAK,CAAA;IAExB;;;;;;;;;OASG;IACH,KAAK,CAAC,EAAE,YAAY,CAAA;IAEpB;;;OAGG;IACH,IAAI,CAAC,EAAE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3B;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE;QACL,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,CAAA;QAClB,YAAY,EAAE,MAAM,CAAA;KACrB,CAAA;IACD,MAAM,EAAE;QACN,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;KAClB,CAAA;IACD,GAAG,EAAE;QACH,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KACrC,CAAA;CACF;AAED,MAAM,WAAW,iBAAiB;IAChC,uBAAuB,EAAE,OAAO,CAAA;CACjC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dev-to/react-plugin",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",