Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: --verbose mode #117

Open
scarf005 opened this issue Aug 8, 2023 · 2 comments
Open

feature request: --verbose mode #117

scarf005 opened this issue Aug 8, 2023 · 2 comments

Comments

@scarf005
Copy link

scarf005 commented Aug 8, 2023

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
@garronej
Copy link
Owner

garronej commented Aug 8, 2023

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.

@scarf005
Copy link
Author

scarf005 commented Aug 8, 2023

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.

denoify/src/lib/denoify.ts

Lines 150 to 158 in 5ad3bb2

(
await resolvePathsWithWildcards({
"pathWithWildcards": strIncludes
})
).forEach(resolvedPath => fsCopy(resolvedPath, path.join(denoDistPath, resolvedPath)));
objIncludes.forEach(({ src, destDir, destBasename }) =>
fsCopy(src, path.join(denoDistPath, path.join(destDir ?? path.dirname(src), destBasename ?? path.basename(src))))
);

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

No branches or pull requests

2 participants