A
A
Alexandroppolus2020-11-15 04:35:39
webpack
Alexandroppolus, 2020-11-15 04:35:39

Index files when importing to js. Is there such a plugin for the collector?

The essence of the problem with an example. There is a footer folder, it contains a footer.jsx file, and possibly some auxiliary files. In general, a React component is in a project, in its own folder. I want to import it in another component.
Options:
1) import { Footer } from '.../footer/footer' - ugly, you just want to specify the folder.
2) add an index.js file to the folder, it contains "export * from './footer'" - now you can import the folder, but you have to create an extra file.
3) rename the footer.jsx file to index.jsx. The worst option, because in the chrome debugger there are only "indexes" in the tab names, catastrophically inconvenient.

As you can see, all methods have small (and not so) minuses. The ideal option, in my opinion: if the folder has a file with the same name, then consider it an index if there is no index.** file. Does anyone know about such a plugin?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question