-
Notifications
You must be signed in to change notification settings - Fork 280
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
[引入antd组件 打包出错]:No name was provided for external + error TS2307: Cannot find module #218
Comments
我也报这个错,试一下,好像也没有什么影响,组件也能正常使用 |
依然不行 |
我找到原因了: 看图, // babel.js
function isTsFile(path) {
console.log('isTsFile::',path)
// return /\.tsx?$/.test(path) && !path.endsWith('.d.ts');
return path.endsWith('typings.d.ts') || (/\.tsx?$/.test(path) && !path.endsWith('.d.ts'));
} 感觉这个算是bug吧。 总结一下解决步骤(改father-build源码):
|
至于 |
当然是改的 babel.js,你那边如果有问题的话,检查一下
|
我复现的仓库就是 disableTypeCheck: false 且 declaration:true的,你可以clone下,试试看 |
组件开发,不应该在 错误示例: import React from 'react';
import Styles from './index.less';
import Classnames from 'classnames';
import { Divider } from 'antd';
export default ({ title }: { title: string }) => (
<h1 className={Classnames(Styles['foo-center'])}>
<Divider type="vertical" />
{title}
<Divider type="vertical" />
</h1>
); 正确示例: import React from 'react';
// import Styles from './index.less';
import Classnames from 'classnames';
import { Divider } from 'antd';
export default ({ title }: { title: string }) => (
<h1 className={Classnames('foo-center')}>
<Divider type="vertical" />
{title}
<Divider type="vertical" />
</h1>
); |
这个问题解决我吗?我也遇到了 |
@chenguzhen87 TS2307 看这个: #227 (comment) |
What happens?
使用 yarn create @umijs/dumi-lib 创建的项目
背景:
打包 抛出错误:
可以看到有两处:
1. No name was provided for external module 'antd/lib/divider' in output.globals – guessing '_Divider'
2. error TS2307: Cannot find module './index.less' or its corresponding type declarations.
针对2 我看源码,
disableTypeCheck
为true
,跳过类型检查,就会跳过 ts 编译,导致没有d.ts
文件,显然不是我想要的;disableTypeCheck
为false
,就会抛出上面的错误。Mini Showcase Repository(REQUIRED)
Context
The text was updated successfully, but these errors were encountered: