admin管理员组文章数量:1432275
I have a lot of folders with an index.js file that consist of many lines of:
export * from './filename'
And because I want to do this for every single file in the folder I was wondering if there is a way to just have one line that just exports everything in the whole folder instead of having to do one line for each file.
Some people think the question has been answered elsewhere, but no the answer given elsewhere is to do what I am doing which is to name every file in the index. What I want is a way to say 'my index exports * from every .js file in this folder'
I have a lot of folders with an index.js file that consist of many lines of:
export * from './filename'
And because I want to do this for every single file in the folder I was wondering if there is a way to just have one line that just exports everything in the whole folder instead of having to do one line for each file.
Some people think the question has been answered elsewhere, but no the answer given elsewhere is to do what I am doing which is to name every file in the index. What I want is a way to say 'my index exports * from every .js file in this folder'
Share Improve this question edited Jan 19, 2018 at 12:52 Odin Thorsen asked Jan 19, 2018 at 12:04 Odin ThorsenOdin Thorsen 2893 silver badges11 bronze badges 4- 1 This doesn't make much sense. You have "a lot" of identically named files in the same folder? – Matt Morgan Commented Jan 19, 2018 at 12:07
- Possible duplicate of import modules from files in directory – Liam Commented Jan 19, 2018 at 12:08
-
Yep, your desire is right. Makes sense to have a regex as
from
argument. But it defies ES6 standards. Please see this. – abdul-wahab Commented Jan 19, 2018 at 12:09 - @MattMorgan No I have a lot of folders with index files that I use to export all the functions and constants that are being exported in the files contained within the folder. I'll edit the post for clarity – Odin Thorsen Commented Jan 19, 2018 at 12:31
1 Answer
Reset to default 5Quick answer is no. Unfortunately. Reason is that you are getting a module or parts of one with the import mand and every file is a module.
Sorry.
本文标签: javascriptExport all from folderStack Overflow
版权声明:本文标题:javascript - Export all from folder - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744619335a2615927.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论