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

206
Visualizações
Javascript how to use modules to Import/Export all from file?

With this code I am able to successfully import / access variables and functions when they are individually exported, but I want to be able to export the entire file in a single declaration. I've tried a number of variations from here but cannot achieve this.

script.js

import * as testImport from './test.js';

console.log( testImport.testVar ); // Returns 'Test Variable'
console.log( testImport.testFunc() ); // Returns 'Test Function'

test.js

export let testVar = 'Test Variable';

export function testFunc() {
    return 'Test Function';
}

desired ( without individual 'exports' )

let testVar = 'Test Variable';

function testFunc() {
    return 'Test Function';
}

export * // ?
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

There is no such thing like you ask for, because it conflicts diametrically with the intention behind modules.

The whole point of modules is to keep all variables private to the module with the exception of making those explicitly exported available for importing.

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