Skip to content

feat: switch to ESM-only and import attributes#471

Merged
43081j merged 2 commits intomainfrom
esm-only
Mar 25, 2026
Merged

feat: switch to ESM-only and import attributes#471
43081j merged 2 commits intomainfrom
esm-only

Conversation

@43081j
Copy link
Contributor

@43081j 43081j commented Mar 22, 2026

This switches to ESM only, which means:

  • We drop tshy and just use TypeScript directly
  • Use import attributes (i.e. import the JSON directly using import)

This does mean we require a newer Node, one that can require(esm) and
use import attributes (specifically JSON).

🔗 Linked issue

📚 Description

This switches to ESM only, which means:

- We drop `tshy` and just use TypeScript directly
- Use import attributes (i.e. import the JSON directly using `import`)

This does mean we require a newer Node, one that can `require(esm)` and
use import attributes (specifically JSON).
@43081j
Copy link
Contributor Author

43081j commented Mar 22, 2026

@bluwy this does mean our ESLint plugin will also require Node 20.

so if we wanted to keep 18.x support, i think we'd need one of the following:

  • tell people to read the JSON file manually (as we would still ship it in the package)
  • have a second entrypoint that uses readFile like we used to

thoughts?

"require": {
"types": "./dist/commonjs/main.d.ts",
"default": "./dist/commonjs/main.js"
"types": "./dist/main.d.ts",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of us also adding to the package json the node version minimum for the package ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should but maybe lets do it in a follow up once we agree on the right one

@bluwy
Copy link
Contributor

bluwy commented Mar 25, 2026

@bluwy this does mean our ESLint plugin will also require Node 20.

so if we wanted to keep 18.x support, i think we'd need one of the following:

  • tell people to read the JSON file manually (as we would still ship it in the package)
  • have a second entrypoint that uses readFile like we used to

thoughts?

I think telling to read the JSON file manually should be ok. There's still createRequire to require the json which shouldn't make it that hard.

@43081j
Copy link
Contributor Author

43081j commented Mar 25, 2026

that works for me 👍

we can add it to the export map too

@43081j 43081j merged commit eb5511c into main Mar 25, 2026
4 checks passed
@43081j 43081j deleted the esm-only branch March 25, 2026 03:37
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.

3 participants