-1

I am trying to use babel standalone and Babel.transform with a json file but getting an error. Does anyone know what config options I could use? The following just results in an empty object when I try to import the json file in my actual code.

any json file...

{
  "name": "value 1"
}
  import code from './myJsonFile.json';

  const OPTIONS = {
    plugins: [
      'proposal-json-strings',
      'transform-modules-commonjs',
    ],
  };
  

  const code = Babel.transform(code, OPTIONS);
cbutler
  • 833
  • 13
  • 36

1 Answers1

-1

So it turned out I did not need a different configuration than what I use for JavaScript. Instead, I convert the JSON to JavaScript with some handy regex which I picked up from this question: JSON.stringify without quotes on properties?

cbutler
  • 833
  • 13
  • 36