I have been working on a project called "hack" which is available publicly at https://github.com/chdelucia/hack
Recently, I've encountered an issue while trying to import modules dynamically. When I hardcode the path as a string, everything works fine:
const a = await import(`../data/ctfbanditi`);
However, when I attempt to use a variable for the path like this:
let b = 'ctfbanditi';
const a = await import(`../data/${b}`);
An error occurs that says:
Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: C:\MYlocalpath\data\ctfbanditi.ts is missing from the TypeScript compilation.
Please make sure it is in your tsconfig via the 'files' or 'include' property. at ivy\loader.js
I have checked for common mistakes like typos, but couldn't find any. The goal is to create a function that takes a name attribute and reads a specific module accordingly:
async getBlogHtmlbyId(name: string): Promise<string> {
let code= '';
const a = await import(`../data/${name}`);
return code;
}
If you have any suggestions or solutions, I would greatly appreciate it. Thank you.