-
Notifications
You must be signed in to change notification settings - Fork 126
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
Clinic does not work with CJS modules: generates incomplete report #447
Comments
What's the content of |
Dosn't really matter. Just a simple hello world reproduces the issue. "use strict";
function main() {
console.log('Hello, World!');
}
void main(); |
I couldn't reproduce it locally. You are getting - Run clinic flame: pnpm exec clinic flame -- node ./src/index/js
+ Run clinic flame: pnpm exec clinic flame -- node ./src/index.js |
The typo was only in the GitHub issue, not the command I was running. Sorry about that. |
Here is the repo that reproduces the issue: https://github.com/valeneiko/clinic-bug I couldn't reproduce the issue initially either, but |
I'm not a |
I added equivalent |
So I ran into this same issue. It's worth mentioning that using pnpm / pnpx for everything is necessary in a pnpm project. My guess is that clinic is having issues resolving pnpm node_modules structure (symlinks) when npm / npx is used. Running it raw without pnpx also fails FYI. Does not work:
Does work:
I would recommend detected a pnpm project and print a warning under these conditions. |
Summary
If I install clinic as a project dependency for a CJS project, or use
pnpm exec
from inside a CJS project to run it, clinic fails to generate report with no obvious error. It fails to build CSS styles, because it tries to load ESM version ofd3-color
(from theirsrc
folder instead ofdist
), which results in an invalid syntax error that is never surfaced. Instead clinic just exits with an incomplete report andundefined
log in the console.Expected Behavior
Clinic correctly generates report (by loading appropriate version of the library depending of the environment), or prints an error explaining how to fix it: installing clinic globally and invoking it directly.
Current Behavior
Process encounters an error, prints
undefined
to console and exits. The generated HTML report is cut at the opening<style>
tag, like shown below (this is the entire contents of the file):Steps to Reproduce (for bugs)
pnpm i -D clinic
pnpm exec clinic flame -- node ./src/index.js
undefined
log in console and an incomplete HTML reportEnvironment
The text was updated successfully, but these errors were encountered: