I am trying to access i18n assets in an Angular project I'm working on in TypeScript, and part of our e2e testing gets the language the app is currently in from a config. I would like to pass that language value into the require() statement so I collect the correct JSON contents based on which language is needed for that test.
This works:
const i18nAsset = require(`../../../../web/src/assets/i18n/en.json`); This results in the error Cannot find module '../../../../web/src/assets/i18n/en.json':
const i18nAsset = require(`../../../../web/src/assets/i18n/${"en"}.json`); As does this:
const i18nAsset = require("../../../../web/src/assets/i18n/" + "en" + ".json"); What could be causing this? If it makes a difference, my e2e project is using Browserify, and the Angular application is using Webpack.
en.jsonreferenced as a dependency it doesn't include it in the bundle.