denoify icon indicating copy to clipboard operation
denoify copied to clipboard

feature request: `--verbose` mode

Open scarf005 opened this issue 2 years ago • 2 comments

it would be great to have a --verbose debug output so it would be possible to profile bottlenecks when denoifying node projects. for example, it took 17~25 seconds to convert this 800 loc program with 2 dependencies, which i believe to be bottlenecked by my configuration.

Details
$ tokei src/*
===============================================================================
 Language            Files        Lines         Code     Comments       Blanks
===============================================================================
 TypeScript              5          789          684           19           86
===============================================================================
 Total                   5          789          684           19           86
===============================================================================
$ time pnpm denoify
> [email protected] denoify /home/scarf/repo/etc/one-time-contribution/ts-rest-hono
> rimraf deno_dist && denoify && rimraf --glob 'deno_dist/**/*.test.ts'

Denoify is reading sources files from src
Configurations from /home/scarf/repo/etc/one-time-contribution/ts-rest-hono/denoify.config.js are used
Deno distribution will be generated at deno_dist

________________________________________________________
Executed in   17.93 secs    fish           external
   usr time    1.74 secs  260.00 micros    1.74 secs
   sys time    0.34 secs   96.00 micros    0.34 secs

$ cat denoify.config.js
// @ts-check

/** @type { import('denoify/lib/config/parseParams').DenoifyParams } */
const config = {
  out: 'deno_dist',
  index: './src/index.ts',
  ports: {
    zod: 'https://deno.land/x/zod/mod.ts',
    hono: 'https://deno.land/x/hono/mod.ts',
  },
}

module.exports = config

scarf005 avatar Aug 08 '23 06:08 scarf005

I concur with the suggestion of introducing a --verbose mode. For now, to track the duration, you can insert the following line within the Denoify distribution:

console.log(`Duration: ${Date.now() - start}`);

Since it's transpiled to ES2021, the JavaScript remains relatively readable.

Regarding potential performance bottlenecks, I believe the issue might be located here: denoifySingleFile.ts

For enhancing performance and flexibility, I should transition to using grubber. This would offer a superior alternative to regular expressions without resorting to an AST, which might introduce frequent breaking changes.

garronej avatar Aug 08 '23 09:08 garronej

I see. Also, would it be possible for denoify to transform files concurrently? Using asynchronous fs functions with Promise.all could improve performance if IO also bottlenecks.

https://github.com/garronej/denoify/blob/5ad3bb2e08d59317f1132e9aeb9d469e60fd72ef/src/lib/denoify.ts#L150-L158

scarf005 avatar Aug 08 '23 09:08 scarf005