{"name":"@rc-component/father-plugin","version":"2.4.0","description":"🧱 Shared father build plugin for rc-component packages.","keywords":[],"repository":{"type":"git","url":"git+https://github.com/react-component/father-plugin.git"},"license":"MIT","main":"dist/index.js","types":"types.d.ts","scripts":{"build":"father build","dev":"father dev","lint":"npm run lint:es","lint:es":"eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"","prepare":"husky","prepublishOnly":"father doctor && npm run build && npm test && rc-np","test":"node --test"},"commitlint":{"extends":["@commitlint/config-conventional"]},"lint-staged":{"*.{md,json}":["prettier --write --no-error-on-unmatched-pattern"],"*.{js,jsx}":["eslint --fix","prettier --write"],"*.{ts,tsx}":["eslint --fix","prettier --parser=typescript --write"]},"dependencies":{"@ampproject/remapping":"^2.3.0","acorn":"^8.18.0","cjs-module-lexer":"^2.2.1","enhanced-resolve":"^5.24.5","fs-extra":"^11.3.0","magic-string":"^0.30.21"},"devDependencies":{"@babel/core":"^7.29.7","@commitlint/cli":"^21.2.0","@commitlint/config-conventional":"^21.2.0","@eslint/compat":"^2.1.0","@eslint/js":"^10.0.1","@jridgewell/trace-mapping":"^0.3.31","@rc-component/np":"^1.0.4","@swc/core":"^1.16.2","@types/fs-extra":"^11.0.4","eslint":"^10.6.0","eslint-config-prettier":"^10.1.8","eslint-plugin-jest":"^29.15.4","eslint-plugin-react":"^7.37.5","eslint-plugin-react-hooks":"^7.1.1","father":"^4.6.24","globals":"^17.7.0","husky":"^9.1.7","lint-staged":"^17.0.8","prettier":"^3.9.4","prettier-plugin-organize-imports":"^4.3.0","prettier-plugin-packagejson":"^3.0.2","typescript-eslint":"^8.62.1"},"peerDependencies":{"father":"^4.0.0"},"publishConfig":{"access":"public"},"authors":["PeachScript <scdzwyxst@gmail.com>"],"gitHead":"77d3d4a23b6921bdfad270b71db1384fdf02e8b6","_id":"@rc-component/father-plugin@2.4.0","bugs":{"url":"https://github.com/react-component/father-plugin/issues"},"homepage":"https://github.com/react-component/father-plugin#readme","_nodeVersion":"24.19.0","_npmVersion":"11.17.0","dist":{"integrity":"sha512-icXxnZqxs8CnvajlOrF0HXU+J0yO5worBencAE1bXkDQG1B8UgAZvhjdWl2i2/zN59U0s7eVH4nWXx8+Drlwrg==","shasum":"b90fd195045b9b525644728d94c3369d528ac237","tarball":"http://registry-npm.ywwl.com/@rc-component/father-plugin/download/@rc-component/father-plugin-2.4.0.tgz","fileCount":9,"unpackedSize":29127,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDEeHJy4pkkDICwqAppCY/uFyI0nB8BS4j2JTgs8r2yUAIhAMfMd27YBh91Gn183GlNmttYfwzchcfAD/SHUa+kct1a"}],"size":9684,"noattachment":false,"key":"/@rc-component/father-plugin/-/@rc-component/father-plugin-2.4.0.tgz"},"_npmUser":{"name":"zombiej","email":"smith3816@gmail.com"},"directories":{},"maintainers":[{"name":"zombiej","email":"smith3816@gmail.com"},{"name":"afc163","email":"afc163@gmail.com"},{"name":"madccc","email":"1075746765@qq.com"},{"name":"peachscript","email":"scdzwyxst@gmail.com"},{"name":"chenshuai2144","email":"wasd2144@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/father-plugin_2.4.0_1788775339335_0.13082764121743495"},"_hasShrinkwrap":false,"readme":"<div align=\"center\">\n  <h1>@rc-component/father-plugin</h1>\n  <p><sub><a href=\"https://ant.design\"><img alt=\"Ant Design\" height=\"14\" src=\"https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg\" style=\"vertical-align: -0.125em;\" /></a> Ant Design 生态的一部分。</sub></p>\n  <p>🧱 rc-component 包共享的 father 构建插件。</p>\n\n  <p>\n    <a href=\"https://npmjs.org/package/@rc-component/father-plugin\"><img alt=\"NPM version\" src=\"https://img.shields.io/npm/v/@rc-component/father-plugin.svg?style=flat-square\"></a>\n    <a href=\"https://npmjs.org/package/@rc-component/father-plugin\"><img alt=\"npm downloads\" src=\"https://img.shields.io/npm/dm/@rc-component/father-plugin.svg?style=flat-square\"></a>\n    <a href=\"https://bundlephobia.com/package/@rc-component/father-plugin\"><img alt=\"bundle size\" src=\"https://img.shields.io/bundlephobia/minzip/%40rc-component%2Ffather-plugin?style=flat-square\"></a>\n    <a href=\"https://github.com/react-component/father-plugin/actions/workflows/test.yml\"><img alt=\"build status\" src=\"https://github.com/react-component/father-plugin/actions/workflows/test.yml/badge.svg\"></a>\n    <a href=\"https://app.codecov.io/gh/react-component/father-plugin\"><img alt=\"Codecov\" src=\"https://img.shields.io/codecov/c/github/react-component/father-plugin/main.svg?style=flat-square\"></a>\n  </p>\n</div>\n\n<p align=\"center\"><a href=\"./README.md\">English</a> | 简体中文</p>\n\n## 亮点\n\n| 方向 | 支持                                    |\n| ---- | --------------------------------------- |\n| 定位 | rc-component 包共享的 father 构建插件。 |\n| 包名 | `@rc-component/father-plugin`           |\n| 发布 | `@rc-component/np` / `rc-np`            |\n\n## 安装\n\n```bash\nnpm install @rc-component/father-plugin --save-dev\n```\n\n## 用法\n\n```ts | pure\nimport { defineConfig } from 'father';\n\nexport default defineConfig({\n  plugins: ['@rc-component/father-plugin'],\n});\n```\n\n## API\n\n### 原生 ESM 的默认导入\n\n`cjsDefaultInterop` **默认关闭**。不配置或设为 `false` 时，插件不注册 interop 编译处理，也不加载相关检查依赖，保留原有编译产物和导入语义。\n\n需要让转译后的 CommonJS 默认导入在原生 Node ESM 中工作时，由组件库显式开启。使用 Father 4.6.37 或更高版本：\n\n```ts | pure\nimport type {} from '@rc-component/father-plugin';\nimport { defineConfig } from 'father';\n\nexport default defineConfig({\n  plugins: ['@rc-component/father-plugin'],\n  cjsDefaultInterop: true,\n  esm: { platform: 'node', autoExtension: true },\n});\n```\n\n类型导入为 `defineConfig` 加载插件的配置类型，不产生运行时导入。开关位于配置顶层，与 `esm`、`cjs` 同级。切换开关也会改变 Father 的文件构建缓存键。\n\n开启后，仅对 **Node ESM 产物** 中能静态识别的转译后 CommonJS 依赖处理默认导入。插件按照 Node 的 **import** 条件解析依赖入口，检查 `__esModule` 和 `default` 导出，全程不执行依赖代码。不维护包名白名单，支持带 scope 的包、包子路径和可静态识别的 CommonJS 转导出入口。\n\nFather 继续使用 Node 平台默认的 esbuild；显式选择 Babel 或 SWC 时也会在 TypeScript/JSX 编译完成后执行相同的处理，并将 source map 合并回原始源码。每个涉及的产物文件只生成一个小型兼容函数，组件源码保持普通默认导入，包括 `import { default as Name }`。\n\n构建时识别为原生 ESM 的入口和普通 CommonJS 导出保持原样。规则不处理命名导入、命名空间导入、纯类型导入、相对路径、内置模块、动态导入以及消费方源码中的依赖再导出语句。无法解析的依赖、无法静态识别的导出结构以及检查用解析器不支持的产物语法也保持原样。面向浏览器的构建和 CommonJS 构建继续使用原有编译产物。\n\n**开启此选项会改变默认导入语义。** 对于识别到的 CommonJS 依赖，`import pkg from 'legacy'` 拿到的是内部的 `default` 值，原本的 CommonJS 导出对象会被解包。因此，已有的 `pkg.default()` 调用或对该对象其他属性的访问需要先检查。如果构建时识别为 CommonJS，下游实际却选择了原生 ESM 入口，生成的局部变量会保存初始值，无法反映默认导出的后续更新；运行时检查不能保留这种情况下的 ESM 实时绑定。组件库应验证其支持的消费方式后再开启。\n\n这是一项过渡措施，待依赖提供原生 ESM 入口后可移除。产物仍会在运行时检查导出值。解析相关依赖只在组件库构建时运行，产物不会额外导入 helper 包。\n\n| 名称 | 默认值 | 说明 |\n| --- | --- | --- |\n| `plugins` | — | 在 father 配置中注册 `@rc-component/father-plugin`。 |\n| `cjsDefaultInterop` | `false` | 显式开启 Node ESM 产物的 CommonJS 默认导入兼容处理。 |\n\n## 本地开发\n\n```bash\nnpm install\nnpm run lint\nnpm run build\n```\n\n## 发布\n\n```bash\nnpm run prepublishOnly\n```\n\n发布流程通过 `@rc-component/np` 提供的 `rc-np` 命令处理。\n\n## 许可证\n\n@rc-component/father-plugin 基于 [MIT](./LICENSE) 协议发布。\n","publish_time":1788775339500,"_cnpm_publish_time":1788775339500,"dist-tags":{"alpha":"1.2.0-alpha.0","latest":"2.4.0"}}