Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

221
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!