seek-oss / skuba

🤿 SEEK development toolkit for backend applications and packages
https://seek-oss.github.io/skuba/
MIT License
60 stars 33 forks source link

Consider switching to ESM #398

Open 72636c opened 3 years ago

72636c commented 3 years ago

Some packages in the Node.js ecosystem are starting to go ESM-only, e.g. https://github.com/seek-oss/skuba/pull/397.

We can probably move most internal CLI code over to ESM without a breaking change; we already require Node.js 12+ and therefore ESM support via "type": "module" in package.json. The tricky part will be maintaining CommonJS compatibility in src/api and src/wrapper as consumers call this code from their own module context and we don't want to force a switch at this time.

samchungy commented 2 years ago

Just dropping this issue here in case someone asks about this. We are still waiting on Jest to fully support ESM https://github.com/facebook/jest/issues/9430

samchungy commented 3 months ago

Last time I tried switching Jest -> Vitest it did not properly support CJS. So it seemed like I would have to both switch to ESM and Vitest at the same time which gives me lower confidence that the move worked.

samchungy commented 2 months ago

https://github.com/seek-oss/skuba/blob/48c4208616e4dcd349670131fcad1fc9827e3ce7/src/skuba.ts#L38-L40

This bit of code would need to be re-written as ESM doesn't support importing from directories/magic index.js files.

samchungy commented 2 weeks ago

ESM requires file extensions within the imports.

  1. We would either need to lint all of our existing code to add file extensions.

Or

  1. Start bundling