Skip to content

pawel-id/ts-esm-minimal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Typescript to build native ESM example

The goal of this is to combine the modern things of node.js in single project: ESM module system and Typescript.

Note that at this moment, the CommonJS module system is still the default target for Typescript https://www.typescriptlang.org/tsconfig#module '...You very likely want "CommonJS" for node projects'. Indeed it is reasonable to proceed with CommonJS for libraries for better compatibility, see default tsconfig.json node.js v18. However for applications, ESM should be fine and this is why that project has been created.

The key settings of 'tsconfig.json' is:

{
  "complilerOptions": {
    "module": "NodeNext"
  }
}

unit tests

The unit tests require some additional attention. The test folder is excluded in 'tsconfig.json'. They also need node --loader=ts-node/esm to run properly. Without this seeting it throws TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts". See package.json for detailed configuration. There are bothe node-tap and mocha tests.

resources

About

Minimal Typescript to build native ESM example

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published