Latest Typescript and Node - as bare-bone as possible example app
I wanted to start a simple Node project where I can install the latest things I want and using as little compilation from Typescript as possible.
I remembered Node announced Node 13 support ESModules without experimental flags, checked out the official documentation but couldn't find a simple bare bone example, so maybe that would help someone.
I've committed the dist folder as well to see how the output from Typescript.
Would love suggestions on how to make it better or to point to a better example!
type: module
: Tell Node that.js
files are ES Modules--es-module-specifier-resolution=node
: By default, Node wants file extensions in import but TypeScript doesn't include file extension in it's output. so this enable automatic extension resolution in Node.
"module": "esnext"
: Make Typescript output ES Modules"target": "es2020"
: Highest target (from3.8.0-beta
)
- Install latest Node (Notice that I've placed the
engines
field onpackage.json
so try to make sure you have the exact version or simply delete it frompackage.json
- Install dependencies -
yarn
- Compile with
tsc -w
and run Node withnodemon
-yarn dev
- You can also use
yarn compile
andyarn start
separately
Here is a branch of the example with including a commonjs pacakge (pg
):
The renovate.json file has nothing to do with the project itself. It's a file to activate RenovateBot to automatically PR this repository when a new version of any dependency of that project has been published