我正在尝试将我的react应用程序升级到Material-UI的最新版本。material UI项目包含一个使用jscodeshift的迁移助手脚本。(https://github.com/mui-org/material-ui/tree/master/packages/material-ui-codemod)
然而,我所有的文件都被jscodeshift跳过了,我不知道为什么。我尝试了各种参数和标志,不管怎样,所有的文件都被跳过了。
例如,下面是我使用的命令:
jscodeshift -t import-path.js Foo.js -v 2
Processing 1 files...
Spawning 1 workers...
Sending 1 files to free worker...
SKIP Foo.js
All done.
Results:
0 errors
0 unmodified
1 skipped
0 ok
Time elapsed: 0.696seconds
Foo.js的内容是一个非常基本的react组件。我试图消除尽可能多的变量。我创建了最基本的组件。
import React from 'react';
import Button from 'material-ui/Button'
const Foo = (props) =>
<Button>Hello</Button>;
export default Foo;
但是,始终会跳过该文件。我甚至尝试了详细的日志记录,仍然没有得到文件被跳过的任何原因。任何帮助都将不胜感激。
发布于 2018-06-27 03:45:22
这里有两个问题。
第一
要使codemod正常工作,您必须执行一个手动步骤,详见import-path的自述文件:
注意:如果您从V1.0之前的版本迁移,并且您的导入使用material-ui,则需要手动查找代码中对material-ui的所有引用并将其替换为@material-ui/。例如:
-import Typography from 'material-ui/Typography';
+import Typography from '@material-ui/core/Typography';
第二
material-ui的codemod似乎不包括Button
的修复。我用StepButton
测试了你的例子,它工作得很好。
import React from 'react';
import StepButton from '@material-ui/StepButton';
const Foo = (props) =>
<StepButton>Hello</StepButton>;
export default Foo;
请注意,该列表可以在here中找到。
https://stackoverflow.com/questions/50591706
复制相似问题