Skip to content

refactor: drop trivial Node API usage in library code - #1745

Merged
cossssmin merged 1 commit into
masterfrom
refactor/reduce-node-apis
Jun 8, 2026
Merged

refactor: drop trivial Node API usage in library code#1745
cossssmin merged 1 commit into
masterfrom
refactor/reduce-node-apis

Conversation

@cossssmin

@cossssmin cossssmin commented Jun 8, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Chores
    • Migrated path resolution utilities across the codebase to a dedicated library for consistent cross-platform file path handling
    • Optimized HTML file size calculations using modern encoding standards
    • Refined CSS preprocessing with updated encoding/decoding mechanisms
    • Updated dependencies to enhance platform compatibility

- Replace Buffer with TextEncoder/TextDecoder (compileTailwindCss, serve).
- Switch node:path to pathe in the render/transformer/config library code,
  dropping the now-redundant \\-to-/ normalizations (pathe is POSIX-only).
  Node-only dev-server/build files stay on node:path.
@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d4d06d34-8cee-4017-9c69-71992231b59b

📥 Commits

Reviewing files that changed from the base of the PR and between 15c85cb and cd8f6fc.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • package.json
  • src/config/index.ts
  • src/render/index.ts
  • src/serve.ts
  • src/transformers/tailwindComponent.ts
  • src/transformers/tailwindcss.ts
  • src/utils/compileTailwindCss.ts
  • src/utils/componentSources.ts
  • src/utils/watchPaths.ts

📝 Walkthrough

Walkthrough

This PR introduces a cross-platform compatibility migration by replacing Node.js built-in path utilities with the pathe library and Web standard APIs. The change adds pathe as a dependency, migrates path imports across the codebase, removes manual path separator normalization that pathe handles natively, and replaces Node Buffer methods with TextEncoder/TextDecoder for better platform independence.

Changes

pathe and Web API Migration

Layer / File(s) Summary
Dependency addition and import migration
package.json, src/config/index.ts, src/render/index.ts, src/transformers/tailwindComponent.ts, src/transformers/tailwindcss.ts, src/utils/componentSources.ts, src/utils/watchPaths.ts
Add pathe ^2.0.3 to dependencies and update all node:path imports to use pathe for resolve, dirname, relative, and extname utilities.
Path resolution normalization updates
src/config/index.ts, src/utils/componentSources.ts, src/utils/watchPaths.ts
Remove manual replace(/\\/g, '/') backslash-to-forward-slash normalization from merged.content, merged.static.source in config; from componentNameFromPath relative path computation; and from glob matching in file watcher, as pathe returns forward-slash paths natively.
Buffer to TextEncoder/TextDecoder conversion
src/serve.ts, src/utils/compileTailwindCss.ts
Replace Buffer.byteLength(html, 'utf-8') with new TextEncoder().encode(html).length in serve stats; replace Buffer.from(css) and result.code.toString() with TextEncoder and TextDecoder in Tailwind CSS transform pipeline.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main objective of the PR: replacing Node.js built-in APIs (node:path, Buffer) with cross-platform alternatives (pathe, TextEncoder/TextDecoder) across multiple files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/reduce-node-apis

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cossssmin
cossssmin merged commit b79e56f into master Jun 8, 2026
6 checks passed
@cossssmin
cossssmin deleted the refactor/reduce-node-apis branch June 10, 2026 13:01
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