Skip to content

feat: add cleaning cache for plugin files#2732

Open
kanoru3101 wants to merge 54 commits intomainfrom
chore/add-clean-cache
Open

feat: add cleaning cache for plugin files#2732
kanoru3101 wants to merge 54 commits intomainfrom
chore/add-clean-cache

Conversation

@kanoru3101
Copy link
Copy Markdown
Contributor

@kanoru3101 kanoru3101 commented Apr 9, 2026

What/Why/How?

In VSCE, we have a problem with clean cache for plugin files. This PR adds cleaning the general cache for plugin files, cjs files, and esm files.

  • Moved all logic with plugin caches to separate files and covered by tests
  • Cleaning cache for ESM and СJS files, cover cases with nested imports.
  • Removed __webpack_require__

Reference

Issue Redocly/redocly-vs-code#10
VSCE Part https://github.com/Redocly/redocly/pull/22293

Testing

Tested in VSCE part

Screenshots (optional)

Check yourself

  • This PR follows the contributing guide
  • All new/updated code is covered by tests
  • Core code changed? - Tested with other Redocly products (internal contributions only)
  • New package installed? - Tested in different environments (browser/node)
  • Documentation update has been considered

Security

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

Note

Medium Risk
Touches plugin loading/caching and Node module resolution (including module.registerHooks for ESM cache-busting), which can affect runtime behavior across environments. Tests cover core scenarios, but the process-wide hook and cache eviction logic could have edge-case compatibility risks.

Overview
Adds a centralized plugin cache implementation (plugins-cache.ts) and a new public clearPluginsCache API (exported from config/index.ts and core/index.ts) to force reloading plugin modules.

Updates resolvePlugins to use the new cache + loadPluginModule (mtime-based cache busting for ESM, targeted require.cache eviction for CJS) and removes the legacy __webpack_require__ path. Adds dedicated tests for cache reuse/clearing behavior and updates fixtures to cover both ESM and CJS plugin init cases.

Also introduces a temporary plugin-import-tree.ts debug logger wired into plugin loading to print plugin import graphs to stderr.

Reviewed by Cursor Bugbot for commit 1155164. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 9, 2026

🦋 Changeset detected

Latest commit: 1155164

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

This PR includes changesets to release 3 packages
Name Type
@redocly/openapi-core Minor
@redocly/cli Minor
@redocly/respect-core Minor

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

@kanoru3101 kanoru3101 added the snapshot Create experimental release PR label Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

📦 A new experimental 🧪 version v0.0.0-snapshot.1775733825 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775733825
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775733825
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775733825

⚠️ Note: This is a development build and may contain unstable features.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 80.15% (🎯 80%) 7247 / 9041
🔵 Statements 79.49% (🎯 79%) 7536 / 9480
🔵 Functions 83.66% (🎯 83%) 1455 / 1739
🔵 Branches 71.61% (🎯 71%) 4882 / 6817
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/config/config-resolvers.ts 76.68% 61.45% 94.11% 77.5% 76, 104-107, 157, 196, 204, 263, 274, 283, 296, 306, 309-313, 318-327, 350-352, 362, 365, 368, 371, 374, 387-389, 393, 399, 402, 405-408, 411-414, 417-420, 434-436, 443, 446, 449, 452, 455, 458, 483-485, 490-496
packages/core/src/config/plugin-import-tree.ts 86.58% 71.42% 90.9% 91.54% 31, 34, 37-43, 61, 76, 89-90, 96, 115
packages/core/src/config/plugins-cache.ts 72.36% 59.37% 100% 76.92% 22, 28, 31-43, 65, 75, 99, 120, 124-128
Generated in workflow #9747 for commit 1155164 by the Vitest Coverage Report Action

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

CLI Version Mean Time ± Std Dev (s) Relative Performance (Lower is Faster)
cli-latest 2.033s ± 0.029s ▓ 1.00x (Fastest)
cli-next 2.053s ± 0.053s ▓ 1.01x

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 9, 2026

📦 A new experimental 🧪 version v0.0.0-snapshot.1775739903 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775739903
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775739903
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775739903

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775814315 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775814315
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775814315
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775814315

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 10, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1775819371 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1775819371
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1775819371
# or
npm install @redocly/respect-core@0.0.0-snapshot.1775819371

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1776082389 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1776082389
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1776082389
# or
npm install @redocly/respect-core@0.0.0-snapshot.1776082389

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1776085657 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1776085657
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1776085657
# or
npm install @redocly/respect-core@0.0.0-snapshot.1776085657

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 13, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1776087574 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1776087574
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1776087574
# or
npm install @redocly/respect-core@0.0.0-snapshot.1776087574

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added the snapshot Create experimental release PR label Apr 28, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1777399620 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1777399620
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777399620
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777399620

⚠️ Note: This is a development build and may contain unstable features.

Comment thread packages/core/src/config/plugins-cache.ts
@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1777470128 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1777470128
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777470128
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777470128

⚠️ Note: This is a development build and may contain unstable features.

Comment thread packages/core/src/config/config-resolvers.ts Outdated
@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1777472433 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1777472433
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777472433
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777472433

⚠️ Note: This is a development build and may contain unstable features.

@kanoru3101 kanoru3101 added snapshot Create experimental release PR and removed snapshot Create experimental release PR labels Apr 29, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 A new experimental 🧪 version v0.0.0-snapshot.1777474661 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1777474661
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1777474661
# or
npm install @redocly/respect-core@0.0.0-snapshot.1777474661

⚠️ Note: This is a development build and may contain unstable features.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

📦 A new experimental 🧪 version v0.0.0-snapshot.1778237731 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1778237731
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1778237731
# or
npm install @redocly/respect-core@0.0.0-snapshot.1778237731

⚠️ Note: This is a development build and may contain unstable features.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

There are 2 total unresolved issues (including 1 from previous review).

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 7e44cfe. Configure here.

Comment thread packages/core/src/config/plugins-cache.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

📦 A new experimental 🧪 version v0.0.0-snapshot.1778250423 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1778250423
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1778250423
# or
npm install @redocly/respect-core@0.0.0-snapshot.1778250423

⚠️ Note: This is a development build and may contain unstable features.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

📦 A new experimental 🧪 version v0.0.0-snapshot.1778253852 of Redocly CLI has been published for testing.

Install with NPM:

npm install @redocly/cli@0.0.0-snapshot.1778253852
# or
npm install @redocly/openapi-core@0.0.0-snapshot.1778253852
# or
npm install @redocly/respect-core@0.0.0-snapshot.1778253852

⚠️ Note: This is a development build and may contain unstable features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

snapshot Create experimental release PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants