Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
/ TS-ESNode Public archive
forked from K-FOSS/TS-ESNode

Node.JS Loader hook to transform typescript source and files as node loads them TS-ESNode. TS-Node for ESNext & ESModule Node.JS.

Notifications You must be signed in to change notification settings

qpost/TS-ESNode

 
 

Repository files navigation

TS-ESNode

This is a Node.JS Loader hook for Node.JS 13.7 or newer that transpiles TypeScript files into JavaScript using the getFormat, resolve, and transformSource hooks.

Usage

You should already have "type": "module" in your package.json

Install @k-foss/ts-esnode

Create a dev script in package.json

{
  "scripts": {
    "dev": "node --loader @k-foss/ts-esnode --experimental-specifier-resolution=node ./src/index.ts",
  }
}

Now when you run npm run dev then you should be running your TypeScript source without having to transpile it while still retaining Node.JS ESModule & ESNext module mode.

Development

Development is intened to be done using VSCode with the Remote - Containers extensions.

When you open this folder in VSCode you should get a notication to reopen in container. Click the reopen in container button to build the development contianer and launch VSCode in remote coding.

TODO

  • I would really like to remove the hack to support destructed imports of legacy node_modules, see this comment for more information.

  • Worker Threads to avoid the TypeScript compiling affecting main thread.

  • Performance improvements. (Better file/import finding.)

Testing

MUST HAVE NODE.JS v13.7 or newer

To try this out, clone repo

Install NPM modules

npm install

cd test && npm i && cd ..

Try it out

npm run try

About

Node.JS Loader hook to transform typescript source and files as node loads them TS-ESNode. TS-Node for ESNext & ESModule Node.JS.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%