'parcel dynamic import with variable not working
I am trying to import a json config file depending on a variable using dynamic import from ES6 and using the bundler parcel.
If I use it with a hardcode string it works.
async function import() {
const config = await import('./configuration.json');
console.log(config);
}
But if I use it with the string in a variable it doesn't work
async function import() {
const path = './configuration.json';
const config = await import(path);
console.log(config);
}
And it throws me the following error
Uncaught (in promise) Error: Cannot find module './configuration.json'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
