Skip to content

fix(design-system): don't break icons if process is not defined - #3525

Merged
AlexAndBear merged 1 commit into
mainfrom
fix/design-system-docs-process
Oct 2, 2026
Merged

AlexAndBear merged 1 commit into
mainfrom
fix/design-system-docs-process

Conversation

@AlexAndBear

@AlexAndBear AlexAndBear commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Description

Many live code examples in the design system docs were not rendered. The browser console showed ReferenceError: process is not defined.

addVersionToAssetUrl() reads process.env.PACKAGE_VERSION to add a cache-busting parameter to icon URLs (introduced in #3082). The value is only injected via define in the root vite.config.ts. The VitePress config of the docs doesn't inject it, so process doesn't exist in the browser there. As a result, every OcIcon threw during rendering and Vue dropped the whole example. This affected every example that renders an icon somewhere (23 of 51 component pages, e.g. OcButton, OcSelect, OcPagination, OcTextInput).

What changed Why
The process.env.PACKAGE_VERSION access is wrapped in try/catch and falls back to undefined Environments without an injected version (docs, consumers not defining it) no longer crash, the URL is simply returned without version
A typeof process check is deliberately not used Vite's define only replaces the process.env.PACKAGE_VERSION expression, so typeof process would be undefined in the web build and break the cache busting
Added assets.spec.ts Covers version handling and the missing process case

Related Issue

  • None

How Has This Been Tested?

  • test environment: design system docs dev server (pnpm docs:dev), production build served by the local OpenCloud backend on port 9200, Chrome
  • test case 1: loaded all 51 component pages of the docs and collected console errors: no errors with the fix, 23 pages failing with process is not defined without it
  • test case 2: pnpm build, checked that the bundle still contains the injected version (try{return`8.0.0`}) and that all icon requests on 9200 still have ?v=8.0.0 in their URLs
  • test case 3: new unit tests in assets.spec.ts, the missing process case fails without the fix

Types of changes

  • Bugfix
  • Enhancement (a change that doesn't break existing code or deployments)
  • Breaking change (a modification that affects current functionality)
  • Technical debt (addressing code that needs refactoring or improvements)
  • Tests (adding or improving tests)
  • Documentation (updates or additions to documentation)
  • Maintenance (like dependency updates or tooling adjustments)

@AlexAndBear AlexAndBear self-assigned this Oct 1, 2026
@AlexAndBear
AlexAndBear merged commit 418e179 into main Oct 2, 2026
32 checks passed
@AlexAndBear
AlexAndBear deleted the fix/design-system-docs-process branch October 2, 2026 07:04
@openclouders openclouders mentioned this pull request Oct 2, 2026
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants