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

Fix usage of contrast-colors with commonjs and esm #185

Open
wants to merge 192 commits into
base: main
Choose a base branch
from

Conversation

dschmidt
Copy link

@dschmidt dschmidt commented Nov 30, 2022

Description

Fix usage as commonjs and esm module and add dependencies of contrast-colors to its package.json.

As .mjs file extension is used for esm module files, the module type can be set to commonjs, which is what .js files are.
The main property of package.json should now point to the commonjs file in dist/ - index.js was not working at all, as there is index.mjs in the package root and index.js only in the dist folder.
The module property obviously can point to index.mjs.
The exports property apparently needs import and require 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 the type property in package.json.

I did not update the lock files as I'm not sure where and how exactly I should run npm or yarn - 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 #173

Screenshots

To-do list

  • This pull request is ready to merge.

NateBaldwinDesign and others added 30 commits December 6, 2019 15:51
Merge branch 'master' of github.com:adobe/leonardo
style: fixed issue with tabs indicator color fallback
feat: adding link to demo app in UI
style: Updated demo app to a calendar with more colors to demonstrate
style: updated styles of links
…ize-to-js-3.0.2

build(deps): bump serialize-to-js from 3.0.0 to 3.0.2
style: dropdown width override to correct width
NateBaldwinDesign and others added 14 commits May 23, 2022 11:00
* installed apca-w3

* feat: converted contrast-colors to es6 modules

* feat: converted commonjs to es6 modules
* added tests and updated getContrast function for APCA support

* feat: updated support for APCA with tests and UI
* added tests and updated getContrast function for APCA support

* feat: added parameter support (URL) for formula
* added tests and updated getContrast function for APCA support

* fix: polarity switch in APCA
* added initial form fill for contrast. WCAG 2 formula works

* added apca to bulk contrast

Co-authored-by: Nathan Baldwin <[email protected]>
@dschmidt
Copy link
Author

dschmidt commented Jan 9, 2023

ping :)

@dschmidt
Copy link
Author

dschmidt commented Feb 3, 2023

Anything wrong with this? Otherwise it would be great to merge this before conflicts are introduced or it becomes incomplete

@dsmmcken
Copy link

dsmmcken commented Aug 2, 2023

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.

@dschmidt
Copy link
Author

dschmidt commented Aug 2, 2023

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.

@xaddict
Copy link

xaddict commented Aug 4, 2023

This is still sorely needed

@GarthDB GarthDB force-pushed the main branch 8 times, most recently from 500acc1 to ed3e3c3 Compare March 15, 2024 18:49
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

Successfully merging this pull request may close these issues.

Module not found: Error: Can't resolve '@adobe/leonardo-contrast-colors'