Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

father-build 构建产物重复导出问题 #356

Closed
billfeller opened this issue May 21, 2021 · 2 comments
Closed

father-build 构建产物重复导出问题 #356

billfeller opened this issue May 21, 2021 · 2 comments
Labels

Comments

@billfeller
Copy link
Contributor

billfeller commented May 21, 2021

问题描述

基于 dumi 开发组件库,如果在 src 声明需要导出的对象,在内部通过 @ 别名路径引导,导致通过 father-build 构建的产物存在重复导出问题。

复现步骤

  1. 基于 dumi 初始化组件脚手架:$ npx @umijs/create-dumi-lib
  2. src 目录中新增 config.ts 文件:
    export const config = { test: 12 };
  3. 在 src/index.ts 导出声明:
    export { default as Foo } from './Foo';
    export * from './config';
  4. 在 src/Foo/index.ts 中通过 @/ 引入 config.ts 文件:
       import React from 'react';
       import { config } from '@/config';
       
       export default ({ title }: { title: string }) => {
         return (
           <h1>
             {title} {config.test}
           </h1>
         );
       };
  5. 执行 npm run build ,对照 dist/index.esm.js 存在多份 config 拷贝;
    image

潜在的问题
引用的对象不是同一个,可能导致对象更新操作,不会触发对应更新操作,比如,这里的对象是一个 ReactContext 对象。

@billfeller
Copy link
Contributor Author

需要通过 @rollup/plugin-alias 兼容 @ 路径别名

This was referenced May 21, 2021
@PeachScript
Copy link
Member

father 4 已发布,可尝试升级到最新版:https://github.com/umijs/father/blob/master/docs/guide/migrate.md

旧版本不再维护,感谢支持

@PeachScript PeachScript closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants