Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

148
Visualizações
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 Respostas
Responde à pergunta

0

you can probably do this:

export * from components;
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda