-
Notifications
You must be signed in to change notification settings - Fork 994
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore(cli): convert the cli to ESM #10409
base: main
Are you sure you want to change the base?
Conversation
It looks like we can't use |
@@ -39,6 +40,8 @@ export const handler = async ({ | |||
const useFragments = rwjsConfig.graphql?.fragments | |||
const useTrustedDocuments = rwjsConfig.graphql?.trustedDocuments | |||
|
|||
const require = createRequire(path.join(getPaths().base, 'node_modules')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll probably refactor this into a helper once I have a better idea of where it's used
import { timedTelemetry } from '@redwoodjs/telemetry' | ||
|
||
import { getPaths, getConfig } from '../lib' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ESM-specific. Implicit imports like this (this is really '../lib/index.js'
) don't work
@@ -693,7 +693,7 @@ export const handler = async (yargs) => { | |||
verbose: yargs.verbose, | |||
}) | |||
|
|||
const { NodeSSH } = require('node-ssh') | |||
const { NodeSSH } = await import('node-ssh') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has to be tested still
@cannikin @thedavidprice I think we should probably close this PR, I don't really see anyone picking this up and it's diverged somewhat. |
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 theconst { ... } = 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