Open dschmidt opened 1 year ago
ping :)
Anything wrong with this? Otherwise it would be great to merge this before conflicts are introduced or it becomes incomplete
I was exploring the @adobe/spectrum-adaptive-theme
package to see how it works, and I found it's broken too, because it depends on this package and it's imports, so it would be nice to see this merged.
Would be appreciated if you or anyone else could take this over. As this PR was completely ignored, while development and releases happened, I've given up.
This is still sorely needed
Description
Fix usage as commonjs and esm module and add dependencies of
contrast-colors
to itspackage.json
.As
.mjs
file extension is used for esm module files, the moduletype
can be set tocommonjs
, which is what.js
files are. Themain
property ofpackage.json
should now point to the commonjs file indist/
-index.js
was not working at all, as there isindex.mjs
in the package root andindex.js
only in the dist folder. Themodule
property obviously can point toindex.mjs
. Theexports
property apparently needsimport
andrequire
to make importing and requiring the module work, I tried all sorts of other combinations, but this was the only variant that worked for me.I had to adjust the imports, I assume bundlers handle it without the file extension, but using it in vanilla node requires the file extension:
.mjs
in this case - independently of thetype
property inpackage.json
.I did not update the lock files as I'm not sure where and how exactly I should run
npm
oryarn
- also my versions seemed newer than yours and caused a huge amount of changes in those files, so maybe it's better if you do it yourselves.See https://antfu.me/posts/publish-esm-and-cjs for further reference
Motivation
With version alpha.16 we're not able to use
leonardo-contrast-colors
anymore in a NodeJS script that's still using commonjs modules.Fixes https://github.com/adobe/leonardo/issues/173
Screenshots
To-do list