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

能否手动指定 tsconfig 路径 #630

Open
Col0ring opened this issue Apr 17, 2023 · 9 comments
Open

能否手动指定 tsconfig 路径 #630

Col0ring opened this issue Apr 17, 2023 · 9 comments

Comments

@Col0ring
Copy link

在 monorepo 项目中使用 import() 动态引入包时打包结果有误(将 ’@xxx/foo‘ 替换为了 'packages/foo/', foo 是包名),测试发现是读取了 tsconfig.json 中的 paths 导致的,去掉 paths 即可。

预期结果是在开发过程中仍然保留 tsconfig 的 paths,希望提供一个手动指定 tsconfig 的配置项。

@PeachScript
Copy link
Member

是在 monorepo 根目录执行的 father?

@Col0ring
Copy link
Author

是在 monorepo 根目录执行的 father?

根目录运行统一的构建命令,子目录执行 father build,感觉应该是动态导入的 bug,不过我感觉提供一个手动指定 tsconfig 的配置项其实相对合理一点,这样也不会和 vscode 这类编辑器的 tsconfig 读取路径冲突。

@PeachScript
Copy link
Member

可以看下 father 是不是最新版,之前做过一个优化,超出 cwd 的 paths 不会做 replace,子包 A 肯定在子包 B 的 cwd 之外,ref: 18dacf1

我感觉提供一个手动指定 tsconfig 的配置项其实相对合理一点

这个暂时不会考虑,尽量保持用法和框架实现的简单,除非未来有解不了的场景

@Col0ring
Copy link
Author

解决了,核心问题就是在最外层的 tsconfig.json 内部写了 baseUrl,但是包内没写,extends 的时候使用了外部的 baseUrl,加上 baseUrl: '.'正常了,但是这样也导致开发模式下的 tsconfig.json paths 完全失效了。

复现仓库:https://github.com/Col0ring/father-tsconfig-example

@wozien
Copy link

wozien commented May 22, 2023

mark

@wozien
Copy link

wozien commented Jun 19, 2023

我也遇到这个问题了,请问有什么比较好的方案吗

解决了,核心问题就是在最外层的 tsconfig.json 内部写了 baseUrl,但是包内没写,extends 的时候使用了外部的 baseUrl,加上 baseUrl: '.'正常了,但是这样也导致开发模式下的 tsconfig.json paths 完全失效了。

复现仓库:https://github.com/Col0ring/father-tsconfig-example

@AllenPan03
Copy link

解决了,核心问题就是在最外层的 tsconfig.json 内部写了 baseUrl,但是包内没写,extends 的时候使用了外部的 baseUrl,加上 baseUrl: '.'正常了,但是这样也导致开发模式下的 tsconfig.json paths 完全失效了。

复现仓库:https://github.com/Col0ring/father-tsconfig-example

一样的问题,我的诉求还是:能否手动指定 tsconfig 路径?

@PopperLi
Copy link
Contributor

求支持手动指定

@cbbfcd
Copy link

cbbfcd commented Apr 29, 2024

使用 preact/compat 的时候也是有这个问题,

import React from 'react'

变成了

import React from "../../packages/foo/node_modules/preact/compat/src/index.d.ts";

应该是:

import React from "../../../node_modules/preact/compat/src/index.d.ts"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants