umijs / father Goto Github PK
View Code? Open in Web Editor NEWNPM package development tool
License: MIT License
NPM package development tool
License: MIT License
假设我有一个组件Test
,我要在这个组件里面引入一个样式,写成下面这种写法:
import styles from './index.module.less';
export default function Test() {
return (
<div className={styles.title}>test</div>
);
}
index.module.less
的内容是:
.title {
color: red;
}
我的.fatherrc.js
的内容是:
export default {
entry: 'src/index.tsx',
esm: {
type: 'babel',
},
cjs: 'babel',
cssModules: true,
extractCSS: true,
lessInBabelMode: true,
extraBabelPlugins: [
['babel-plugin-import', {
libraryName: 'antd',
style: true,
}]
],
};
执行father build
的时候会报错:
Cannot find module './index.module.less'.
请问会是什么问题引起的?我应该怎么改呢?
I worked with rc-tree which is using father package for creating storybook and i'v got this error when i ran npm start:
Cannot find module 'C:UsersHamedDocumentsProjects ree ERR! ode_modules atherlibdocstorybook-webpack'
rc-tree package.json:
"scripts": { "start": "cross-env NODE_ENV=development father doc dev --storybook", "build": "father doc build --storybook", "compile": "father build", "prepublishOnly": "npm run compile && np --no-cleanup --yolo --no-publish", "lint": "eslint src/ examples/ --ext .tsx,.ts,.jsx,.js", "test": "father test", "now-build": "npm run build" },
there seems to be a problem in storybook generator :
module.exports = function(...args) {
return require('${join(__dirname, 'storybook-webpack')}')(...args);
};
and
const configJs =
function loadStories() { require('${entryPath}'); }
that generate webpack.config in .storybook directory like this:
module.exports = function(...args) { return require('C:\Users\Hamed\Documents\Projects\tree\node_modules\father\lib\doc\storybook-webpack')(...args); };
and when this file runs i have got above error .
I think __dirname and path.join in windows return path with back slash "\" that must be replace with forward slash "/" to work properly with require. I have tested it and it works fine with str replace or slash package.
错误详情
./README.en.md
SyntaxError: unknown: Unterminated JSX contents (148:16)
146 | <p>{`Pass in a deep copy of the rules, only to assist in comparison, use the props.form.patchRule method when you need to dynamically modify the rules.`}</p>
147 | <p><inlineCode parentName="p">{`<validatejsRules>`}</inlineCode></p>
> 148 | </MDXLayout>
| ^
149 | )
150 | };
151 | MDXContent.isMDXComponent = true
-| library
-| xxx.xx
-| README.md
-| README.en.md
重现步骤:
semantic error TS2307: Cannot find module './index.less'.
执行father build --watch失败
Error: ENOENT: no such file or directory, rename '/private/var/folders/bz/pksgsq8j6zj0x7w5lxknc3700000gn/T/.rollup_plugin_typescript2_cache/rpt2_8d5c6c4b586394ea612d61d4ced8d17302c715ee/code/cache_' -> '/private/var/folders/bz/pksgsq8j6zj0x7w5lxknc3700000gn/T/.rollup_plugin_typescript2_cache/rpt2_8d5c6c4b586394ea612d61d4ced8d17302c715ee/code/cache'
father builld可以成功
修改 .fatherrc.js
不会自动刷新。
build报错
error TS7016: Could not find a declaration file for module 'dom-helpers'. 'E:/nodeproject/ds/node_modules/[email protected]@dom-helpers/index.js' implicitly has an 'any' type.
ℹ info [smr] Clean dist directory
ℹ info [smr] Build esm with undefined
✖ error Error: failed to open 'undefined'
at parseTsConfig (/work/smr/node_modules/rollup-plugin-typescript2/src/parse-tsconfig.ts:17:9)
at Object.options (/work/smr/node_modules/rollup-plugin-typescript2/src/index.ts:80:64)
at applyOptionHook (/work/smr/node_modules/rollup/dist/rollup.js:17127:31)
at Array.reduce (<anonymous>)
at getInputOptions$1 (/work/smr/node_modules/rollup/dist/rollup.js:17145:41)
at rollup (/work/smr/node_modules/rollup/dist/rollup.js:17189:30)
at /work/smr/node_modules/father-build/lib/rollup.js:70:51
at Generator.next (<anonymous>)
at asyncGeneratorStep (/work/smr/node_modules/father-build/lib/rollup.js:26:103)
at _next (/work/smr/node_modules/father-build/lib/rollup.js:28:194)
SyntaxError: Unexpected token (1:7) 1 : (<React.Fragment>
when i use father build,how can i build with source-map ?
项目是基于 antd 的二次开发,一个业务组件库,tsx 和样式(less)分离
配置文件
entry: 'src/index.ts',
cjs: 'babel',
esm: 'babel',
umd: {
name: "xxx",
globals: {
react: 'React',
antd: 'antd'
},
file:"index"
},
extractCSS: true,
打包后生成 dist lib es
三个目录
dist 目录下只有 js 和 .d.ts ,没有 less或者css文件,比如像andt的 antd.css
antd.less
导致项目中想全局引入样式时,没有途径
已配置了
extractCSS: true,
但我猜测是不是还缺少了什么配置?
father 版本:2.2.1
Node 版本:10.15.1
操作系统:win10
father build --watch
father-build build --watch
更改文件后,控制台无文件rebuild的输出,未重新对文件进行build?
windows 10 powershell
使用father test
进行单元测试,在jest.config.js
中指定collectCoverageFrom
没有生效。
看到
father
包中 传入了collectCoverageFrom: 'src/**/*'
作为umi-test
的默认参数。最终会覆盖jest.config.js
中的配置。
https://github.com/umijs/father/blob/master/packages/father/src/test.ts#L6
https://github.com/umijs/umi/blob/master/packages/umi-test/src/index.js#L80
babel方式无法继承其他tsconfig.json,配置文件申明了 extends,任然不会处理
在 umi 看文档发现404,看提交记录才发现迁到这了。
提出来可以,bug和版本也比较容易维护。
就是不知道为什么要叫father
= =,用umi-lib
这类的不是更好么
从 [email protected] 改为 [email protected] 后,在 .fatherrc.js 中配置 docz 的属性未达到官方文档呈现的效果。
Use this option to specify the order of your documents in the menu. You can pass a simple string or if you want to order a nested menu you can pass an object with the name of your document and the menu order of it.
// config
export default {
menu: [
'Getting Started',
{ name: 'Components', menu: ['Alert', 'Button'] }
]
}
export default {
doc: {
menu: [
'首页',
'更新日志',
{
name: '组件',
menu: [
'LinkBtn',
]
}
]
},
}
我的开发环境连不上外网,项目里的react和react-dom引用的地址是阿里cdn的地址,开发环境连不上,希望可以自定义地址。
father/packages/father/src/doc/docz.ts
Line 16 in 3495fba
father/packages/father/src/doc/doczrc.ts
Line 14 in 3495fba
这两处应该是 fatherrc.json
吧
安装 father 包,终端报警告nomnom
包已经废弃了。
npm WARN deprecated [email protected]: Package no longer supported.
Contact [email protected] for more info.
npm WARN deprecated [email protected]: 🙌 Thanks for using Babel:
we recommend using babel-preset-env now: please read babeljs.io/env to update!
我在 package-lock.json 中查找了包依赖关系
father => @storybook/cli 4.1.3 => jscodeshift 0.5.1 => nomnom
father => @storybook/cli 4.1.3 => jscodeshift 0.5.1 => babel-preset-es2015
@storybook/cli 最新版本为 5.2.1,内部将 jscodeshift 升级到了 0.6.3,这个版本已经移除了 nomnom 包的使用,也将 babel-preset-es2015 替换成了 babel-preset-env
希望 father 能升级下 @storybook/cli 版本号,消除安装报警告问题。
https://github.com/ycjcl868/father-ui-build-lerna-bug
yarn build
是 ok 的, yarn build --watch
有问题。在 lerna
下。
我的/packages目录下有组件库也有web网站,当我在项目根目录 father build
时会报错,提示web网站这个package
木有正确配置father
;
期望不要处理那些木有包含.fatherrc.js
的package
我不清楚是否已有该功能;
https://github.com/DiamondYuan/switch
无论怎么配置,都是编译 src/index.js 的内容
重现的github地址:https://github.com/chj-damon/umi-father-issue-reproduce-demo.git
issue发生的环境:windows,macOS上表现正常
重现步骤:
clone项目之后,yarn install && yarn doc:dev
执行之后在打开的页面发现,windows下浏览器看到Antd的Button的样式没有加载,macOS下antd的button样式正常加载;
打开.fatherrc.js,将cssModules注释掉,然后再次运行yarn doc:dev,在打开的页面发现,windows和macOS的浏览器里面,antd的button的样式都正常加载。
所以我怀疑cssModules这个配置项会导致extraBabelPlugins引入的插件有bug
因为生成的是单页应用,只有一个 index.html,访问页面后刷新会显示 404.
版本: "2.15.1"
.fatherrc.js配置:
export default {
cjs: 'babel',
esm: { type: 'babel', importLibToEs: true, minify: true, },
preCommit: {
eslint: true,
prettier: true,
},
};
输出的es代码没有压缩。
这里是typescript提供的findConfigFile的实现。
源码:
export function findConfigFile(searchPath: string, fileExists: (fileName: string) => boolean, configName = "tsconfig.json"): string | undefined {
return forEachAncestorDirectory(searchPath, ancestor => {
const fileName = combinePaths(ancestor, configName);
return fileExists(fileName) ? fileName : undefined;
});
}
index.module.less变更时,开启watch模式,不会重新编译
场景:微前端开发,主项目采用father build --watch,子项目采用umi,并且npm link主项目,子项目追踪主项目dist目录变更时,自动执行编译
//子项目特殊配置
.umirc.ts dll exclude主项目
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.