-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
chore: add exports fields #12944
base: main
Are you sure you want to change the base?
chore: add exports fields #12944
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #12944 +/- ##
==========================================
- Coverage 89.65% 89.62% -0.03%
==========================================
Files 257 257
Lines 6977 6979 +2
Branches 1718 1719 +1
==========================================
Hits 6255 6255
- Misses 383 386 +3
+ Partials 339 338 -1 ☔ View full report in Codecov by Sentry. |
添加 exports field 会导致无法引用子目录,比如 |
"require": "./lib/*.js", | ||
"types": "./lib/*.d.ts" | ||
}, | ||
"./es/*.mjs": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
es/*.mjs
只能导出 lib 下面一级的文件,但是没法导出 es/button/style/index.mjs
这种多级目录的文件
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
参考 #10348
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
是可以导出多级目录的。node 文档
- maps expose nested subpaths as it is a string replacement syntax only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现在没有后缀的地址会增加 /index.m?js
这样会出现一个问题
如 vant/es/button/Button
-> vant/es/button/Button/index.mjs
只有 vant/es/button/Button.mjs
-> vant/es/button/Button.mjs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯,添加 exports fields 还是会有潜在的 breaking 风险,通常来说放在大版本里发布比较合适,我们可以先看一下 Nuxt 全局方法的类型问题有没有其他解决方法。。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, 我先看看官方提供的增加类型可以用不
Before submitting a pull request, please read the contributing guide.
在提交 pull request 之前,请阅读 贡献指南。
fix vant-nuxt#31
unimport 中解析 vant 的目录大致为
../../../node_modules/.pnpm/[email protected][email protected]/node_modules/vant/lib/vant.cjs
,这使得自动导入的方法没有类型提示增加导入后解析的目录变为
../../../node_modules/.pnpm/[email protected][email protected]/node_modules/vant
类型提示正常