Specifications:
Angular CLI: 11.0.4
Node: 15.12.0
OS: win32 x64
Angular: 11.2.3
Typescript: 4.0.7
Currently, I have the following imports:
import * as ts from "typescript";
and the following method is in place:
testingTranspile(){
const sanitized: string= leadLocation.replace(/[^a-zA-Z0-9.\[\]]/g, "");
let code: string=`try{ console.log('works') } catch(e){ console.log(e.toString()) } `;
let result = ts.transpile(code);
eval(result);
}
This method is functional and displays 'works' on the console when ng serve
is executed.
However, upon attempting to build the application (using
ng build --prod --output-hashing none --extract-css
), a warning is generated:
Warning: ./node_modules/typescript/lib/typescript.js 6116:41-60
Critical dependency: the request of a dependency is an expression
at CommonJsRequireContextDependency.getWarnings (...\node_modules\webpack\lib\dependencies\ContextDependency.js:40:18) at Compilation.reportDependencyErrorsAndWarnings (...\node_modules\webpack\lib\Compilation.js:1454:24)
...
The app still builds successfully, but eliminating warnings is preferred. Upon investigation, it was found that the mentioned method contributes to the warning. When the content within testingTranspile()
is cleared, no warnings appear during build.
What steps can be taken to address this warning? A search for transpile/eval related warnings did not yield any relevant solutions.