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: resolve plugins from npm packages correctly #1749

Merged
merged 11 commits into from
Oct 4, 2024

Conversation

volodymyr-rutskyi
Copy link
Contributor

What/Why/How?

When the CLI is installed globally and tries to resolve a plugin from NPM package, it can't find it because by default the require.resolve tries to look for the package from the CLI installation location. This would cause errors like below even though the plugin package is installed in the project's node_modules directory:

Something went wrong when processing :

  - Failed to load plugin "@redocly/portal-plugin-async-api/plugin.js": Cannot find module '@redocly/portal-plugin-async-api/plugin.js'

Added the config directory as an additional path to look for NPM packages when resolving plugins.

Reference

Reported in internal conversation

Testing

Screenshots (optional)

Check yourself

  • Code changed? - Tested with redoc/reference-docs/workflows (internal)
  • All new/updated code is covered with tests
  • New package installed? - Tested in different environments (browser/node)

Security

  • Security impact of change has been considered
  • Code follows company security practices and guidelines

@volodymyr-rutskyi volodymyr-rutskyi requested review from a team as code owners October 3, 2024 12:00
Copy link

changeset-bot bot commented Oct 3, 2024

🦋 Changeset detected

Latest commit: 8c43dd2

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@redocly/openapi-core Patch
@redocly/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Contributor

github-actions bot commented Oct 3, 2024

Command Mean [ms] Min [ms] Max [ms] Relative
redocly lint packages/core/src/benchmark/benches/rebilly.yaml 994.5 ± 13.2 963.3 1012.8 1.00
redocly-next lint packages/core/src/benchmark/benches/rebilly.yaml 998.2 ± 26.6 955.8 1055.4 1.00 ± 0.03

Copy link
Contributor

github-actions bot commented Oct 3, 2024

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements 78.56% 4993/6356
🟡 Branches 67.19% 2062/3069
🟡 Functions 72.98% 824/1129
🟡 Lines 78.85% 4711/5975

Test suite run success

809 tests passing in 121 suites.

Report generated by 🧪jest coverage report action from 8c43dd2

Copy link
Contributor

@tatomyr tatomyr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left an optional suggestion. Otherwise looks good.

.github/workflows/smoke.yaml Outdated Show resolved Hide resolved
scripts/prepare-smoke.sh Outdated Show resolved Hide resolved
@volodymyr-rutskyi volodymyr-rutskyi force-pushed the fix/npm-plugins-resolving branch from fd38cca to 8c43dd2 Compare October 4, 2024 10:19
@volodymyr-rutskyi volodymyr-rutskyi merged commit 81ca339 into main Oct 4, 2024
40 checks passed
@volodymyr-rutskyi volodymyr-rutskyi deleted the fix/npm-plugins-resolving branch October 4, 2024 11:05
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.

4 participants