0

I'm writing a chrome extension and most of my code is javascript, built by gulp with browserify.

Given a class I can add:

var a = require('../locales/en-US.json');

And this json will be loaded correctly, but when I try to make it dynamically, ie:

for (var name in valid_locales) {
   require(`../locales/${name}.json`);
}

I get errors in runtime that can't load the file. I'm assuming the cause is that on the first code it runs it executes the require in "gulp compile" time, any thoughts? What can I do to get my second code working?

lgsanjos
  • 39
  • 8

0 Answers0