I have a Lambda function written in NodeJS that i'm shifting to ESM.
I'm importing a local file, import { fetchUrl } from './lib/fetch';
but as the main file is ESM, I believe it needs to be import { fetchUrl } from './lib/fetch.js';
.
But I'm writing everything in TS, including the file fetch.ts
(which gets compiled to fetch.js
.
How can I reference the JS file in the main TS file before the JS file exists? Will it just "know" that the file will exist when its eventually compiled?
This answer might help you, https://stackoverflow.com/a/45934667/4518630
Just use import { ProjectList } from "./components/project-list.js";
in your TypeScript code and it should work