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

Use ESM syntax, and update deps to support it #26

Merged
merged 9 commits into from
Nov 8, 2024

Conversation

mrchrisadams
Copy link
Member

@mrchrisadams mrchrisadams commented Oct 26, 2024

This switches from the commonjs require() syntax to the newer ESM import syntax.

Jest did not work with the ESM syntax, so I updated the Jest config to use esbuild to transpile the ESM syntax to commonjs, so Jest can still run the tests.

We do this in the main CO2.js package, to it seemed an ok precedent to follow.

This also updates better-sqlite, to use a new version which seems to offer pre-builds, as of #1002 on the better sqlite repo - WiseLibs/better-sqlite3#1002

I think this would remove the need to compile it on a range of machines, including apple silicon macs.

@mrchrisadams
Copy link
Member Author

In order to update the developer docs with some guidance for Deno, I had to look into updating CO2.js, and then into updating this url2green library, because the build was failing when installing Deno.

I'll also open an issue on CO2.js to reflect the change I think might be needed in hosting.js file when used by Deno too.

@mrchrisadams
Copy link
Member Author

@fershad this was the dependency that kept failing when I tried to npm install i the dev dependencies of co2.js.

Would you mind casting an eye over this, and if there are no changes required, merge it in? I'd like to publish a new release to npm if possible, to see if it resolves the issue with co2.js

This switches from the commonjs require() syntax to the newer ESM
import syntax.

Jest did not work with the ESM syntax, so I updated the Jest config to
use esbuild to transpile the ESM syntax to commonjs, so Jest can still
run the tests.

We do this in the main CO2.js package, to it seemed an ok precedent to
follow.
This updates this to run CI tests for PRs made against master as well as main.

it also updates the github actions to use new versions
Wew update ES lint to check against ECMAScript 2020, and use the new config format
@mrchrisadams mrchrisadams force-pushed the ca-switch-to-import-syntax-update-deps branch from d83134d to b3d175e Compare November 2, 2024 08:47
@mrchrisadams
Copy link
Member Author

hey @fershad this would still be nice to have reviewed but I think the recent patch release of 0.4.1 means that this can be decoupled from getting the new release of CO2.js out the door.

@fershad fershad merged commit b69cf46 into master Nov 8, 2024
3 checks passed
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.

2 participants