ES6 Modules
Understand how ES6 Modules work
ES6 Modules
This base uses "type": "module"
in the package.json. It's important to remember to use the .js
extension when importing files via relative paths (even if they are TypeScript files).
If you export a function from a TypeScript file:
src/functions/math/mycustumfunc.ts
.js
extension at the end:
src/functions/index.ts
We can also use the await
keyword at the top level of the code:
hello.ts
If for some reason you need dynamic imports, you can use import
as a function in the code:
handler.ts