Skip to content
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

fix: handle ModuleLoadError from hooks #836

Merged
merged 3 commits into from
Oct 19, 2023
Merged

fix: handle ModuleLoadError from hooks #836

merged 3 commits into from
Oct 19, 2023

Conversation

mdonnalley
Copy link
Contributor

@mdonnalley mdonnalley commented Oct 18, 2023

  • Never allow MODULE_NOT_FOUND error from hook to exit the process
  • Allow user plugins from github urls to be auto-transpiled in production (CJS only)

QA
(from salesforcecli/cli repo)

  • yarn link @oclif/core
  • bin/run.js plugins install https://github.com/oclif/plugin-test-esm-1.git
  • bin/run.js plugins
  • bin/run.js plugins install https://github.com/oclif/plugin-test-cjs-1.git
  • bin/run.js plugins

You should see no errors.
You should also see the hook text being output by the init hook from @oclif/plugin-test-cjs-1
You should not see the hook text being output by the init hook from @oclif/plugin-test-esm-1 since we can't auto-transpile ESM plugins in production. This will be fixed by this commit in plugin-plugins

Fixes #835

@W-14317382@

@mdonnalley mdonnalley changed the title Mdonnalley/835 fix: handle ModuleLoadError from hooks Oct 18, 2023
@iowillhoit
Copy link
Contributor

QA NOTES

  • 🟢 Was seeing error before
  • 🟢 Install esm1 and run sf plugins command without error
  • 🔴 ESM/Github warning shows in --json output
  • 🔴 Running any plugin install after either one of these (cjs or esm) are installed will throw
    • Error: Cannot find module '/Users/ewillhoit/.local/share/sf/node_modules/@oclif/plugin-test-cjs-1/node_modules/yarn/bin/yarn.js'
    • Assuming this is the "refresh installs"
  • 🟡 ESM/Github warning says it will use the "existing compiled source", but none exists in ~/.local/share/sf/node_modules/@oclif/plugin-test-esm-1
    • The sf esm1 command fails

@iowillhoit
Copy link
Contributor

Sorry, missed this note about compiled esm

This will be fixed by this commit in plugin-plugins

@mdonnalley
Copy link
Contributor Author

  • 🔴 Running any plugin install after either one of these (cjs or esm) are installed will throw

    • Error: Cannot find module '/Users/ewillhoit/.local/share/sf/node_modules/@oclif/plugin-test-cjs-1/node_modules/yarn/bin/yarn.js'

Created a new issue for this: oclif/plugin-plugins#684

@mdonnalley mdonnalley merged commit a068d9a into main Oct 19, 2023
34 checks passed
@mdonnalley mdonnalley deleted the mdonnalley/835 branch October 19, 2023 19:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI fails to start when plugin with init hook installed from github
2 participants