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

222
Vistas
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 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