1

Hi i have something like this:

enter image description here

I would like to import everything in directory (expect index.ts) to index.ts and then export it I don't want to import everything like this:

import * as Network from './network';
import * as FirewallRule from './firewall-rule';

export { Network, FirewallRule };

Because it could be a lot of imports and export. Is it possible to do this automatically with fs npm module ?

Marcin Warzybok
  • 357
  • 4
  • 16
  • see this. https://stackoverflow.com/questions/29722270/is-it-possible-to-import-modules-from-all-files-in-a-directory-using-a-wildcard – Or Assayag Nov 30 '20 at 18:12
  • Unfortunately it doesn't help me so much, becuase i have to write extra export in index.ts. I'm looking for some kind of loader or hand-writing snippet of nodejs code that let me import and export everything. It could be done even with require statement. – Marcin Warzybok Nov 30 '20 at 18:28
  • OK, maybe this? https://stackoverflow.com/questions/55337568/how-do-i-import-all-files-in-a-folder-as-an-module-and-export-all-as-an-object/55338300 – Or Assayag Nov 30 '20 at 18:37
  • https://stackoverflow.com/questions/55337568/how-do-i-import-all-files-in-a-folder-as-an-module-and-export-all-as-an-object/55338300 - duplicate – Marcin Warzybok Dec 01 '20 at 09:39

0 Answers0