当我使用material-ui时我在 Webstorm 中得到了很好的自动完成功能(ctrl+space):
我认为这可能与该包包含一个index.es.js 文件有关:
import _AppBar from './AppBar';
export { _AppBar as AppBar };
import _AutoComplete from './AutoComplete';
export { _AutoComplete as AutoComplete };
import _Avatar from './Avatar';
export { _Avatar as Avatar };
import _Badge from './Badge';
export { _Badge as Badge };
import _BottomNavigation from './BottomNavigation';
...
因此,我在自定义 npm 模块中生成了自己的 index.es.js 并将其放在已转换的 index.js 旁边:
import {ActionTypes as _ActionTypesElements} from './reducers/elements/elements';
export { _ActionTypesElements as ActionTypes };
import {ActionTypes as _ActionTypesAppState} from './reducers/appState/appState';
export { _ActionTypesAppState as ActionTypesAppState };
import _appStateActions from './reducers/appState/appState_actions';
export { _appStateActions as appStateActions };
...
但我没有自动完成:
知道为什么吗?
最佳答案
找到答案:
必须将 jsnext:main 字段添加到 npm 模块的 package.json 中:
package.json:
...
"module": "./index.js",
"jsnext:main": "./index.es.js",
...
Webstorm 识别包的内部导出。
关于javascript - 在 Webstorm 中自动完成我的自定义 npm 模块 (ES6/Babel),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43805725/