You can use dynamic import()
to load modules or resources like JSON files asynchronously at runtime. For example:
const config = await import('./config.json', {
assert: { type: 'json' }
});
console.log(config.default);
Why use this:
Works in modern environments (Node ≥17.5 with flags, browsers with module support)
Useful for conditional or dynamic imports