Comments (3)
子项目用不了主项目的别名,你的子包代码应该是纯净的,假如你的子包带了主项目的配置相关的约定,这个包发布到 npm 上就不是通用的包了。
现在 TS 的项目如果你需要导入什么,输入关键词后, IDE 会帮你提示然后确认,将自动添加相对导入路径的 import ,一半的情况不需要手动输入相对路径。
如果你非要使用别名,就需要使用一种打包器,比如 vite / rollup 等,来将产物打包成 js 单文件产物,然后 watch build 产物来开发,不开启 monorepoRedirect
,配置到 mfsu.exclude
里就可以热更新:
// .umirc.ts
mfsu: { exclude: ['@note/react'] }
但这种 watch build 单文件产物的方案,在 build 时会有一定延时,当子包很大时可能花费时间比较长。
from umi.
@fz6m 子项目 b-utils
使用的是自己的配置
"paths": {
"@/*": [
"./src/*"
],
}
能否monorepoRedirect开启的时候吗,读下这个配置做下映射。
构建单文件这个大项目开发确实不太友好
from umi.
-
子包是不会支持读取 alias 的,因为这样这个包就有了前提的约束,不再清真、纯净了,单独发布到 npm 后不再是任何人都可以直接使用。
-
目前 umi 的项目里还有一个约定,就是在第三方包里不能使用 umi 导入的方法,这也是同上一样的道理,要保证第三方包里的代码纯净性,不可以被污染。
tsc 等 bundleless 工具一直不支持 alias 甚至连插件都不支持是有原因的,因为要保证代码的纯净性,只做转译输出,当你的依赖包前提约束越多,后面就越难以维护,也无法被其他人所直接使用,所以发布的第三方包都应该尽量趋近于纯净,谁下载了都可以用,而不是还需要 alias 等前提条件;这也是除了 bundleless 派以外还有 bundle 派工具,比如 vite 和 rollup 等,这些工具有插件机制可以帮你构建更复杂约定的产物,所以如果你需要这个功能,就需要 bundle 。
from umi.
Related Issues (20)
- umijs 怎么打包配置多个页面呢? HOT 1
- [Bug] umi^4.2.5怎么把id="app" 自定义其他名称,比如叫id="app1" HOT 2
- [Feature] 优先使用用户安装的 `babel-plugin-react-compiler` HOT 1
- [Task] PR #12398 代码修复 HOT 1
- [Feature Request] 支持 qiankun 多实例的保活 HOT 3
- umi 官方文档 ->blog(博客)->Umi 4 RC ->《比 Vite 更快的 MFSU》 文档出现问题 HOT 1
- 使用umimax时,使用了装饰器的代码无法被esbuild编译 HOT 2
- [Bug] umi3升级umi4遇到的微前端问题 HOT 1
- umi项目开启了MFSU后,如果浏览的页面打开了控制台热更新很慢,当我关闭控制台后它特别快 HOT 1
- 滚动条
- [Bug] umi4启动时的动画 HOT 1
- chainWebpack 配置devServer.set('contentBase', './public-demo');无效 HOT 1
- [Feature Request] chainWebpack 配置devServer.set 无效
- [Bug] umijs/max max dev 报错 TypeError: The 'compilation' argument must be an instance of Compilation HOT 1
- 期望能保持umi3的特性,使用自定义的parentId, id HOT 1
- umi 添加国际化后 本地正常 线上报错 页面空白"umi": "^3.4.8",
- Request调用POST请求的时候异常`Cannot convert object to primitive value` HOT 1
- umi3升级umi4后,项目启动报错:ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION is not defined HOT 1
- umi3升级冘 HOT 1
- umi3升级umi4后,项目启动报错:ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION is not defined
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from umi.