redwood icon indicating copy to clipboard operation
redwood copied to clipboard

chore(cli): convert the cli to ESM

Open jtoar opened this issue 10 months ago • 3 comments

This PR starts on getting the CLI to ESM. The CLI isn't consumed by any other packages it's just invoked so it doesn't have to be dual published.

So far most of the changes are adding file extensions and changing the way we import CJS packages. Some packages that we've told renovate to ignore because they're ESM-only may only be used by the CLI and could be upgraded to their latest versions.

The bin proxies in @redwoodjs/core were tricky since we can't require files from the CLI. That part I'd still like to think more about. (And the const { ... } = pkg workarounds.) CI will tell us if the existing strategy works on Windows.

So far this is one of those PRs where, as I fix one thing, another thing comes up. It looks like I still have to deal with

  • require
  • __dirname
  • commandDir
  • review dist again; there's some files that don't need to be there

jtoar avatar Apr 03 '24 19:04 jtoar

It looks like we can't use commandDir with ESM which is something I've tried to refactor out before so, it's just time to do it across the board. Source: https://github.com/yargs/yargs/blob/main/docs/advanced.md#commanddirdirectory-opts.

jtoar avatar Apr 03 '24 20:04 jtoar

@cannikin @thedavidprice I think we should probably close this PR, I don't really see anyone picking this up and it's diverged somewhat.

peterp avatar May 11 '24 09:05 peterp

@peterp Dom reviewed outstanding PRs, this one included, with @Tobbe. Looping him now for status update.

thedavidprice avatar May 11 '24 18:05 thedavidprice