Project Goal

ECMAScript modules, also known as ESM, is the official standard format(opens in a new tab) to package JavaScript, and fortunately Node.js supports it(opens in a new tab) šŸŽ‰.

Have the redwood support the ESM standard.

Peteā€™s Summary Notes re: ESM Work and Research

ā€£

ā€œback of the napkinā€ rough source lines of code (SLOC) view

Using as a rough estimate to try and quantify the amount of work that might be needed for this project. While not a fully accurate way to estimate, it does give a rough estimate of the amount of files we are talking about. Note: this does not take into account the details of those files. Some might need little to no work, others might need a lot.

ran:

du -a packages/ | awk -F'[.[:space:]]' '/\\.[a-zA-Z0-9]+$/ { a[$NF]+=$1; b[$NF]++ }
     END{for (i in a) print i, b[i], (a[i]/b[i])}

in the packages/ directory. Here is the slimmed down output:

File extension Files in packages/ Average file size (KB) Notes
cjs 4 2180
js 1080 15.8148
jsx 7 6.85714 Need to check on if we can ignore these
mjs 9 11.5556 Should be able to ignore as these are already in ESM
mts 1 24 Should be able to ignore
ts 925 9.46162 Should be able to ignore
tsx 159 12.5283 Should be able to ignore

What this means is that there are a decent number of js files to convert over.

Suggestion

Pick a folder (preferably small to start) under packages/ and convert it to either .mjs or .ts (probably vote .mjs to start as porting to typescript kind of feels like scope creep [although I can see an argument where since we are already doing this work to port to esm, why not just go all the way to have it be typescript] ).

Definition of ā€œDoneā€

How will you know when this is done?

This is a good question, and needs some open questions answered first.