use require in the ts file to import json file dynamically

If you want a JSON string from a file at a relative address in the same origin as your web app, you can use this function:

TS Playground

export async function getJsonById(id: string):Promise<string> {
  const url = `./output/config/${id}something.json`;
  const json = (await fetch(url)).text(); // this is a string (JSON is a string)
  return json;
  // alternatively: to parse the JSON into a native JS data type
  // return JSON.parse(json);
}

// use:
const json = await getJsonById('id');