Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

152
Vistas
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 Respuestas
Responde la pregunta

0

you can probably do this:

export * from components;
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda