Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

147
Views
Exporting all object Values as Keys

I'm trying to export all object values as keys, in order to provide a tree-shakable import system for a plugin that I'm working on. I'm dynamically importing modules from folders and subfolders and putting them together in a giant object like this:

Object Structure

The structure of the object would be something like this:

components = {
   "MyPluginModule1": {...},
   "MyPluginModule2": {...},
   ...
   "MyPluginModule10000": {...},
}

The number of keys can be quite a lot and I certainly cannot export them one by one manually.

Tried Approach

I was trying to import the modules automatically from the directories (this works), but now the challenge is to export them.

const components = {};

// Now I dynamically import modules from different directories and add them in components

export {components};

However with this approach, I need to use import {components} from "...". Then I can access MyPluginModule1 as components. MyPluginModule1.

What's Needed

What I'd need is to be able to import MyPluginModule1 directly without needed to import the entire components array and then accessing this particular module through components.MyPluginModule1.

Goal is to import like this:

import { MyPluginModule1 } from "...";

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can probably do this:

export * from components;
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!