When working on my TypeScript project, I've encountered an issue where I need to include the *.js extension when importing files. If I omit the extension, the project will build successfully but fail at runtime in the browser due to file not found errors.
Here's an example of how my TypeScript imports currently look:
import {MainApp} from './MainApp.js';
window.onload = () => {
var app = new MainApp(5);
app.doSomething();
};
After researching this issue (Appending .js extension on relative import statements during Typescript compilation (ES6 modules) for example), it appears that TypeScript prohibits me from using syntax like `import {MainApp} from './MainApp.js';`. However, I noticed that Angular allows a simpler import statement without the .js extension:
import {MainApp} from './MainApp';
This made me wonder, how does Angular achieve this behavior? Is there a way for me to replicate it in my non-Angular, pure TypeScript project?