Sometimes you can't omit trailing index
, but luckily this babel plugin can do it for you.
// if './foo' is a directory
import foo from './foo';
require('./foo');
import foo from './foo/index';
require('./foo/index');
This plugin will ignore non-relative path.
yarn add babel-plugin-autocomplete-index --dev
# OR
npm install babel-plugin-autocomplete-index --save-dev
babel.config.js
'use strict';
module.exports = {
plugins: [
'autocomplete-index',
// other plugins
],
};