Skip to content

Register hook for node -r and mocha -r#60

Open
ccorcos wants to merge 2 commits into
rsms:masterfrom
ccorcos:master
Open

Register hook for node -r and mocha -r#60
ccorcos wants to merge 2 commits into
rsms:masterfrom
ccorcos:master

Conversation

@ccorcos

@ccorcos ccorcos commented Oct 25, 2022

Copy link
Copy Markdown

See #59 for more info.

Example usage:

  • node -r estrella/register program.ts
  • mocha -r estrella/register 'src/**/*.test.ts'

This is much faster than using ts-node/register 😄

@ccorcos

ccorcos commented Oct 25, 2022

Copy link
Copy Markdown
Author

Probably worth mentioning in the documentation somewhere too

@ccorcos

ccorcos commented Oct 26, 2022

Copy link
Copy Markdown
Author
❯❯❯ time npm run build

> html-editor@0.1.12 build
> ts-node src/tools/buildSrc.ts

+ mkdir -p build
Wrote build/preload.js (0B, 9.52ms)
Wrote build/main.js (0B, 81.36ms)
Wrote build/renderer.js (0B, 98.20ms)
npm run build  2.13s user 0.12s system 192% cpu 1.172 total

❯❯❯ time ./esb-node src/tools/buildSrc.ts
+ mkdir -p build
Wrote build/preload.js (0B, 9.41ms)
Wrote build/main.js (0B, 81.39ms)
Wrote build/renderer.js (0B, 104.45ms)
./esb-node src/tools/buildSrc.ts  0.14s user 0.03s system 70% cpu 0.244 total

I just want to mention that I'm soooo happy with this. 15x faster!!!

@ccorcos

ccorcos commented Oct 26, 2022

Copy link
Copy Markdown
Author

My unit tests are 7.8x faster too!

./node_modules/.bin/mocha -r 'ts-node/register' './src/**/*.test.ts' --verbos  12.32s user 0.41s system 215% cpu 5.915 total
./node_modules/.bin/mocha -r ./esbuild-register.js './src/**/*.test.ts'   1.58s user 0.38s system 85% cpu 2.303 total

@ccorcos

ccorcos commented Oct 26, 2022

Copy link
Copy Markdown
Author

This is my esb-node script...

#!/bin/bash
node -r ./esbuild-register.js "$@"

@ccorcos

ccorcos commented Oct 31, 2022

Copy link
Copy Markdown
Author

Apparently this is pretty much the same thing... https://github.com/esbuild-kit/tsx/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant