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

269
Visualizações
Import a JavaScript file into another JavaScript file that is imported into another file

I need to import a file that imports code from another file and then import that file into a final file that adds code to an HTML button. How can I do this? When I try with the following example below no code runs.

// file 1
export function someFunction() {
    // more code
}

// file 2
import {someFunction} from './file1';
export function otherFunction() {
    someFunction();
    // more code
}

// file 3
import {otherFunction} from './file2';
document.getElementById('some-button').onclick = otherFunction;

// in index.html 
<script type='module' src='./file3.js'></script>
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The solution is to have all the files be included in the index.html as type="module"

<script type='module' src='./file1.js'></script>
<script type='module' src='./file2.js'></script>
<script type='module' src='./file3.js'></script>
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