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

220
Visualizações
Is it possible to replace variables by importing them on-the-fly from an updated version of a .js-file?

I have a .js-file which exports few arrays, like:

export const regularlyChangingArray1 = [ 'item1', 'item2', 'item3' ]
export const regularlyChangingArray2 = [ 'item4', 'item5' ]

I'm accessing those arrays by importing them:

import { regularlyChangingArray1 } from './mypath/myfilename.js'

My problem is that I need to change that single .js-file very often. However, I would not want to go through the full deployment pipeline each time those arrays (and only those) get changed. So, I've tried hosting the .js also separately and get the updated data somehow from there, on-the-fly, replacing the data which goes with the build. I'm not sure if replacing the original .js is even possible on-the-fly, let alone safe - is it?

I don't want to study the use of eval() due to security issues (ref. mozilla.org). What might be the most straight-forward way to get those up-to-date arrays imported? Or should I just restructure my whole code to use something else(?)

I have tried this and that and obviously best (but probably impossible) way might be to somehow import them like:

import { regularlyChangingArray1 } from 'www.address.here/myfilename_clone.js'
about 4 years ago · Juan Pablo Isaza
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