question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestion: an integration with esbuild to replace `ts-node/register` and `@babel/register`

See original GitHub issue

Since one of the main aim of uvu is fast, use esbuild to replace babel or tsc would make unit tests with uvu much faster for end users.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
eyelidlessnesscommented, Jan 22, 2021

Just want to report that I was able to get this working fairly painlessly with Estrella, like so:

// ./scripts/test.js
// @ts-check

import del      from 'del';
import estrella from 'estrella';
import globby   from 'globby';
import path     from 'path';

(async () => {
  const cwd = process.cwd();

  const [ , args ] = estrella.cliopts.parse();
  const [ testDirName = 'test' ] = args;
  const entry = await globby(path.resolve(cwd, testDirName, '**/*.test.ts'));
  const outDir = path.resolve(cwd, './.test');

  estrella.build({
    cwd,
    entry,
    minify:    false,
    outdir:    outDir,
    run:       `npx uvu ${JSON.stringify(outDir)}`,
    sourcemap: 'inline',

    async onStart() {
      await del(outDir);
    },
  });
})();

Usage:

node ./scripts/test.js

Watch:

node ./scripts/test.js -w

Easy peasy! Obviously, any of the details of this may be changed. It does write to the filesystem, so if that’s something you’re really trying to avoid you’ll want something like esbuild-register or ts-eager. But wanted to share my solution in case it helps.

1reaction
osdevisnotcommented, Jun 8, 2021

It seems esbuild-register works ok, at least with minimal examples I tried it with. Made an example PR in #119.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node: Support esbuild/register hook? #260 - GitHub
Hey! Are you interested in offering an esbuild/register hook, or should I plan on creating my own package for this?
Read more >
Plugins - esbuild
This property lets you replace this plugin's name with another name for this path resolution operation. It's useful for proxying another plugin through...
Read more >
webpack or esbuild: Why not both? - LogRocket Blog
There will be two: one for TypeScript/JavaScript application code (we want to replace this) and one for nonapplication JavaScript code. It's not ...
Read more >
Using esbuild As Your New Bundler
Thoughts regarding esbuild as replacement of existing bundlers & babel for developing packages.
Read more >
esbuild-plugin-replace - npm
Replace strings in files while bundling. Latest version: 1.3.0, last published: 2 months ago. Start using esbuild-plugin-replace in your ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found