teraslice icon indicating copy to clipboard operation
teraslice copied to clipboard

Update Blocked ESM Dependencies where possible

Open jsnoble opened this issue 2 years ago • 4 comments

There are packages that are being published in pure ESM module format (import and export syntax). The problem is that our compiler is not set to handle these types of packages. Most compilers like babel and ours convert code into CJS format (require statements) .

We can change our compiler to export ESM modules instead but it will most likely require us to convert all our js files to use the ESM module format

Things to investigate:

  • How will this affect loading and executing assets?
  • Are there ways to use old CJS formatted code despite the switch?
  • Take in consideration on our private assets and how feasible it is to convert those
  • how well can jest be used, it read somewhere it is having some issues

Overall, code that is already written in typescript should be able to easily convert over with a few setting changes to the build logic.

From what I found we need to use typescript v4.7 and higher for this, currently we are using 4.6

jsnoble avatar Sep 22 '22 16:09 jsnoble

List of packages converted to ESM with no CJS exports:

  • got v12
  • nanoid v4
  • is-ip v5
  • is-cidr v5
  • auto-bind v5
  • chalk v5
  • execa v6
  • pkg-up v4
  • package-json v8
  • p-map v5
  • p-event v5
  • pretty-bytes v6
  • ip-bigint v5 (starts at v4)
  • globby
  • ajv?
  • latlon-geohash

jsnoble avatar Sep 23 '22 18:09 jsnoble

sort-package-json starting from v2

busma13 avatar Nov 13 '23 15:11 busma13

@busma13 you could be referencing this issue in your PRs.

godber avatar Oct 01 '24 20:10 godber

I will from now on.

busma13 avatar Oct 01 '24 21:10 busma13

I think enough of these are updated now that this is good. We're far less blocked on these and we're regularly updated. The few long running exceptions like socket.io have their own issues or will get some.

godber avatar Oct 17 '24 22:10 godber