-
Notifications
You must be signed in to change notification settings - Fork 35
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
refactor: migrate to using esms #83
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It's easier to read and make changes to a consistently formatted `package.json` file. Refs: https://www.npmjs.com/package/sort-package-json
What motivated the change is that it wasn't clear from the `readme.md` nor the CI job that `pnpm` is the main package manager for the project. In addition to updating the CI job & docs, the `packageManager` field of the `package.json` was updated to help signify the intended package manager used to develop the project. BREAKING CHANGE: Dropped support for Node.js versions lower than 18. Node.js 16's security updates ended on 2023-09-11. Refs: https://github.com/nodejs/Release#end-of-life-releases
To address #69, I read through an article about how to convert packages to pure ESM [^1]. `cjstoesm` was quite helpful here [^2]. But it didn't talk about how to still support being imported by CJS modules without the use of dynamic imports. It's annoying being forced to change the color of a function [^3]. I came across another article discussing a more streamlined way to build a package for consumers of either module format [^4], and I wanted to try out `unbuild` [^5]. The current version of `ava` used doesn't support ESMs. Given that updating to a major version that does support it would lead to more code changes from breaking changes, I decided to switch to using Vitest. There were also issues with importing older versions of `chalk` into ESMs, so I opted to update `chalk` to v5 (ESM). `titleize` was removed as an unused dependency. Resolves #69. [^1]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c [^2]: https://github.com/wessberg/cjstoesm [^3]: https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ [^4]: https://antfu.me/posts/publish-esm-and-cjs [^5]: https://github.com/unjs/unbuild
Given it's a project from vercel, we may as well start following the company's style for the project to help with enforcing consistency. Also had to do some configuration around import assertions/attributes for ESLint.
To run fix formatting & lint issues before commits are made.
Adds clipboard support for WSL & fixes vulnerabilities for using `exec` v0.8.0.
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.
Orca Security Scan Summary
Status | Check | Issues by priority | |
---|---|---|---|
Passed | Secrets | 0 0 0 0 | View in Orca |
Largely replaced by #86. Although, I would be open to a separate PR building off of that PR to move to Vitest! |
leerob
pushed a commit
that referenced
this pull request
Nov 26, 2024
Based on a suggestion from @leerob [^1], I re-implemented the change I made in #83. I also attempted to improve the descriptions of each of the test cases. [^1]: #83 (comment)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
To address #69, I read through an article about how to convert packages
to pure ESM 1.
cjstoesm
was quite helpful here 2.But it didn't talk about how to still support being imported by CJS
modules without the use of dynamic imports. It's annoying being forced
to change the color of a function 3.
I came across another article discussing a more streamlined way to build
a package for consumers of either module format 4, and I wanted to
try out
unbuild
5.The current version of
ava
used doesn't support ESMs. Given thatupdating to a major version that does support it would lead to more code
changes from breaking changes, I decided to switch to using Vitest.
There were also issues with importing older versions of
chalk
intoESMs, so I opted to update
chalk
to v5 (ESM).titleize
was removed as an unused dependency.Resolves #69.
Footnotes
https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c ↩
https://github.com/wessberg/cjstoesm ↩
https://journal.stuffwithstuff.com/2015/02/01/what-color-is-your-function/ ↩
https://antfu.me/posts/publish-esm-and-cjs ↩
https://github.com/unjs/unbuild ↩