Skip to content

feat: add cleaning cache for plugin files#2732

Open
kanoru3101 wants to merge 70 commits into
mainfrom
chore/add-clean-cache
Open

feat: add cleaning cache for plugin files#2732
kanoru3101 wants to merge 70 commits into
mainfrom
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 introduces cache-busting behavior for both CJS and ESM (with Node-version-dependent hooks), which could affect plugin reload semantics and module singletons.

Overview
Adds a dedicated plugins-cache module and wires resolvePlugins to use it, enabling explicit cache management instead of the previous in-function map and removing the special __webpack_require__ path.

Introduces clearPluginsCache() (CJS require.cache eviction for local deps + ESM cache-busting via ?v= versioning and a Node registerHooks resolver that propagates the version to nested file: imports while skipping node_modules). Exposes clearPluginsCache/getPluginCacheVersion via config/core exports and adds tests/fixtures to cover reload behavior and dependency eviction, plus a changeset bump.

Reviewed by Cursor Bugbot for commit 28eb234. 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: 28eb234

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.72% (🎯 80%) 7231 / 8958
🔵 Statements 80.08% (🎯 80%) 7515 / 9384
🔵 Functions 83.78% (🎯 83%) 1447 / 1727
🔵 Branches 72.34% (🎯 72%) 4897 / 6769
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/core/src/config/config-resolvers.ts 76.54% 61.45% 94.11% 77.35% 73, 101-104, 154, 193, 201, 257, 268, 277, 290, 300, 303-307, 312-321, 344-346, 356, 359, 362, 365, 368, 381-383, 387, 393, 396, 399-402, 405-408, 411-414, 428-430, 437, 440, 443, 446, 449, 452, 477-479, 484-490
packages/core/src/config/plugins-cache.ts 80.35% 60% 100% 85.1% 27, 33-42, 51-55, 82
Generated in workflow #9832 for commit 28eb234 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 1.914s ± 0.026s ▓ 1.00x (Fastest)
cli-next 1.927s ± 0.021s ▓ 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.

Comment thread packages/core/src/config/plugin-import-tree.ts Outdated
Comment thread packages/core/src/config/plugin-import-tree.ts Outdated
@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

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

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

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

Install with NPM:

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

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

@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

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

@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

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

Comment thread packages/core/src/config/__tests__/plugins-cache.test.ts Outdated
Comment thread packages/core/src/config/plugins-cache.ts
Comment thread packages/core/src/config/plugins-cache.ts
Comment thread packages/core/src/config/plugins-cache.ts Outdated

let isEsmCacheBustHookRegistered = false;

function registerEsmCacheBustHook(): void {
Copy link
Copy Markdown
Contributor Author

@kanoru3101 kanoru3101 May 14, 2026

Choose a reason for hiding this comment

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

Check if one project is opened in two different IDEs. How it works. Test with Cursor and VS-code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It works. Added video to PR

@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

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

@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

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

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

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

Install with NPM:

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

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

Comment thread packages/core/src/config/__tests__/plugins-cache.test.ts
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 073052e. Configure here.

@github-actions
Copy link
Copy Markdown
Contributor

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

Install with NPM:

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

⚠️ 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