Skip to content

fix: resolve Vite import errors and safely handle process.env#17

Open
sprzedawcaMily wants to merge 1 commit into
DRFR0ST:mainfrom
sprzedawcaMily:Vite-error-fix
Open

fix: resolve Vite import errors and safely handle process.env#17
sprzedawcaMily wants to merge 1 commit into
DRFR0ST:mainfrom
sprzedawcaMily:Vite-error-fix

Conversation

@sprzedawcaMily

Copy link
Copy Markdown

Description

This PR addresses issues where the library crashed or failed to resolve when imported in modern browser-based environments like Vite or React.

Changes Made

  • Fix Vite Import Error: Removed the "module": "src/index.ts" entry from package.json that was causing ESM resolution failures, and replaced it with a proper "exports" map to correctly route to compiled .ts declarations and .js bundles.
  • Safe Environment Variables: Replaced direct hardcoded process.env references in config.ts with a safe getEnv function. It now smoothly falls back when process is undefined instead of throwing a critical ReferenceError.
  • Extended Options: Added apiUrl and verbose fallback properties directly into the LibreLinkClientOptions interface, allowing developers to cleanly pass config keys via the constructor without needing Node environment processes.
  • Updated Tests: Refactored the unit and integration testing suite to explicitly configure LibreLinkClient instances with mock credentials, ensuring tests continue to pass with the new fallback behavior.

How to Test

  1. Clone the branch and build the bundle (npm run build).
  2. Run tests to see they pass successfully (npm run test).
  3. Import the output dist files inside a fresh Vite template (e.g., npm create vite@latest) and verify the library doesn't throw a module or process error in the browser console.

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.

1 participant