-
-
Notifications
You must be signed in to change notification settings - Fork 44
fix: detect and display dual-module support in colorizer #326
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
hi, thank you for implementing this so fast! i can't find any dual package that doesn't use the |
Found myself fiddling with colors in the colorizer legends while working on #326, and ended up going all-in on the `oklch`. This is admittedly a bit of an experiment, an excuse to learn about the `oklch` colorspace. It's [kinda weird](https://lch.oklch.com/#0.576,78.78,216.36,100), but has the advantage of providing colors with a consistent brightness when you vary the H(ue) value. Also fixing up a few odds and ends that I turned up along the way ... * NPMSIO colorizer legend uses CSS gradient with `scoreColor()` computed endpoints * Use `color-mix` for color interpolation * Tweaks to colors and styling in release timeline chart * Wider color variation in treemap @fregante: The tl;dr: is "a bit more color"... Before:  After: 
| } else if (k === 'default') { | ||
| pkgType.esm = true; | ||
| pkgType.cjs = true; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this doesn't sound right, if a package were to have only the default export it would only have one of them, but it would show up as dual
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. I read through the node-modules.dev and npm-esm-vs-cjs code a bit more closely and have tried to follow their lead on this. (I'm not directly pulling in the code from those projects, however, as it doesn't quite do what I'm after.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW: https://npmgraph-git-dualmodules-broofas-projects.vercel.app/?q=webdriver#color=moduleType&zoom=w seems to have a pretty good selection of module types... if you wanted to click through some of the package.json files for some of the modules to verify the detection logic works correctly.
(And, yes, I know there should be unit tests for this, but that's time and energy I don't have at the moment. :-) )
Fixes #325.
@SuperchupuDev: If you could do some testing for this, that would be helpful (see Vercel preview build link below). The logic I've added for detecting ESM and CJS support is almost certainly imperfect. It just walks the
package.json#exportsfield looking forimportorrequirefields, or paths with.mjsor.cjs. I expect it's good enough to ship, but there's no real standard for how dual-module packages should be setup. Thus, I'm sure there will be edge cases that aren't properly detected.