Skip to content

perf: replace unneeded dependencies#378

Merged
danielroe merged 5 commits intomainfrom
perf/slim
Feb 7, 2026
Merged

perf: replace unneeded dependencies#378
danielroe merged 5 commits intomainfrom
perf/slim

Conversation

@danielroe
Copy link
Copy Markdown
Member

@danielroe danielroe commented Feb 7, 2026

🔗 Linked issue

closes #340
closes #276

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

this significantly cleans up our dependency tree 🔥

we can do more when we release a new version without support for nuxt/bridge

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

This PR removes several external dependencies (destr, dotenv, git-url-parse, is-docker, package-manager-detector, pathe) and replaces them with internal implementations and Node.js built-ins. It adds a local Docker detection utility, custom environment parsing helpers (isTruthy, parseDotenv), a lightweight Git URL parser, and package manager detection via lockfile/package.json. Path resolution uses node:path. The Node engine requirement is lowered to >=18.12.0, citty is bumped to ^0.2.0, and the Context type nuxtMajorVersion is widened from 2 | 3 to number.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.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
Title check ✅ Passed The title 'perf: replace unneeded dependencies' directly reflects the main objective of removing unnecessary dependencies from the project.
Description check ✅ Passed The description explains the purpose of cleaning up the dependency tree and references linked issues #276 and #340, providing context for the changes.
Linked Issues check ✅ Passed The PR successfully removes git-url-parse dependency and replaces it with a custom parseGitUrl function [#276], and removes other unneeded dependencies including dotenv, destr, is-docker, and pathe by implementing custom alternatives.
Out of Scope Changes check ✅ Passed All changes are directly related to the dependency removal objectives. The PR only adds custom implementations to replace removed dependencies with no extraneous modifications.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch perf/slim

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@package.json`:
- Around line 75-77: The package.json engines entry currently pins "node" to
">=18.12.0" which targets an EOL Node release; update the engines field so it
requires a supported LTS (for example change the "node" value to ">=22.0.0") to
ensure maintained security updates and compatibility; modify the "engines" →
"node" value in package.json accordingly and run CI/test to verify no runtime
breakages.

In `@src/context.ts`:
- Line 21: The assignment to nuxtMajorVersion may yield undefined if
nuxt.options._majorVersion is missing; update the nuxtMajorVersion
initialization (the expression using isNuxtMajorVersion and
nuxt.options._majorVersion) to coerce/guard that value and provide a numeric
fallback (e.g., default to 2 or another safe number) so it always satisfies the
Context interface's required number type; reference isNuxtMajorVersion,
nuxtMajorVersion and nuxt.options._majorVersion and ensure the result is
explicitly a number.
🧹 Nitpick comments (3)
src/cli.ts (1)

20-36: parseDotenv doesn't handle the export prefix.

Some .env files use export KEY=value syntax (common when .env files are also sourced by shell scripts). The current parser would produce a key of export KEY instead of KEY. This is a minor gap since the only consumer checks a specific key name.

Proposed fix
     const key = trimmed.slice(0, eqIndex).trim()
+    // strip optional `export` prefix
+    const cleanKey = key.startsWith('export ') ? key.slice(7).trim() : key
     let value = trimmed.slice(eqIndex + 1).trim()
     // Remove surrounding quotes
     if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith('\'') && value.endsWith('\''))) {
       value = value.slice(1, -1)
     }
-    result[key] = value
+    result[cleanKey] = value
src/context.ts (2)

105-136: Use path.join for constructing file paths.

String template concatenation (${rootDir}/${file}) works in practice because Node's fs APIs normalize separators on Windows, but path.join is the idiomatic and safer approach. Since the PR already removed pathe, consider importing join from node:path.

Proposed fix

Add to imports:

import { join } from 'node:path'

Then in detectPackageManager and when reading package.json:

-    if (existsSync(`${rootDir}/${file}`)) {
+    if (existsSync(join(rootDir, file))) {
-    const pkgJson = JSON.parse(readFileSync(`${rootDir}/package.json`, 'utf8'))
+    const pkgJson = JSON.parse(readFileSync(join(rootDir, 'package.json'), 'utf8'))

38-38: Redundant fallback: detectPackageManager already returns 'unknown'.

detectPackageManager returns 'unknown' at Line 135 as its final fallback, so the || 'unknown' here is unreachable. Harmless, but slightly misleading.

Comment thread package.json
Comment thread src/context.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In `@src/cli.ts`:
- Around line 16-18: The isTruthy function currently only matches exact
case-sensitive values and misses variants like "TRUE" or "True"; update isTruthy
to normalize string inputs (e.g., convert to lowercase) before comparison and
handle numeric values consistently: for non-boolean inputs coerce to string,
.toLowerCase() it, and compare against 'true' and '1', while still accepting
boolean true and numeric 1; modify the isTruthy function so it first checks
typeof val and uses a lowercase string comparison for case-insensitive matches.
- Around line 20-36: The parseDotenv function fails to handle lines prefixed
with "export" and inline comments; update parseDotenv so for each non-empty,
non-# line it first removes a leading "export " token from the start of the
trimmed line before splitting on '=', then when extracting the value strip an
inline comment only if the value is not enclosed in matching single or double
quotes (i.e., remove any unquoted " #..." suffix after trimming), then remove
surrounding quotes and unescape any escaped quotes; ensure the key is the
cleaned left-hand side and the value is the cleaned right-hand side so isTruthy
checks work as expected.

Comment thread src/cli.ts
Comment on lines +16 to +18
function isTruthy(val: unknown): boolean {
return val === true || val === 'true' || val === '1' || val === 1
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

isTruthy doesn't handle case-insensitive variants like 'TRUE' or 'True'.

Environment variables are commonly set with varying cases. A user writing NUXT_TELEMETRY_DISABLED=TRUE would bypass this check. Consider normalizing:

Suggested fix
 function isTruthy(val: unknown): boolean {
-  return val === true || val === 'true' || val === '1' || val === 1
+  return val === true || val === 1 || (typeof val === 'string' && (val.toLowerCase() === 'true' || val === '1'))
 }
🤖 Prompt for AI Agents
In `@src/cli.ts` around lines 16 - 18, The isTruthy function currently only
matches exact case-sensitive values and misses variants like "TRUE" or "True";
update isTruthy to normalize string inputs (e.g., convert to lowercase) before
comparison and handle numeric values consistently: for non-boolean inputs coerce
to string, .toLowerCase() it, and compare against 'true' and '1', while still
accepting boolean true and numeric 1; modify the isTruthy function so it first
checks typeof val and uses a lowercase string comparison for case-insensitive
matches.

Comment thread src/cli.ts
Comment on lines +20 to +36
function parseDotenv(src: string): Record<string, string> {
const result: Record<string, string> = {}
for (const line of src.split('\n')) {
const trimmed = line.trim()
if (!trimmed || trimmed.startsWith('#')) continue
const eqIndex = trimmed.indexOf('=')
if (eqIndex === -1) continue
const key = trimmed.slice(0, eqIndex).trim()
let value = trimmed.slice(eqIndex + 1).trim()
// Remove surrounding quotes
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith('\'') && value.endsWith('\''))) {
value = value.slice(1, -1)
}
result[key] = value
}
return result
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

parseDotenv doesn't handle export prefix or inline comments.

Two common .env patterns supported by the dotenv library this replaces are missing:

  1. export prefix: export NUXT_TELEMETRY_DISABLED=true would produce the key export NUXT_TELEMETRY_DISABLED, never matching the expected key.
  2. Inline comments: NUXT_TELEMETRY_DISABLED=true # enable this would store the value as true # enable this, which would fail the isTruthy check.

Since this replaces a well-tested library, it's worth covering these edge cases to avoid subtle regressions.

Suggested fix
 function parseDotenv(src: string): Record<string, string> {
   const result: Record<string, string> = {}
   for (const line of src.split('\n')) {
-    const trimmed = line.trim()
+    let trimmed = line.trim()
     if (!trimmed || trimmed.startsWith('#')) continue
+    // Strip optional `export` prefix
+    if (trimmed.startsWith('export ')) {
+      trimmed = trimmed.slice(7).trim()
+    }
     const eqIndex = trimmed.indexOf('=')
     if (eqIndex === -1) continue
     const key = trimmed.slice(0, eqIndex).trim()
     let value = trimmed.slice(eqIndex + 1).trim()
     // Remove surrounding quotes
     if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith('\'') && value.endsWith('\''))) {
       value = value.slice(1, -1)
     }
+    else {
+      // Strip inline comments for unquoted values
+      const hashIndex = value.indexOf(' #')
+      if (hashIndex !== -1) {
+        value = value.slice(0, hashIndex).trim()
+      }
+    }
     result[key] = value
   }
   return result
 }
🤖 Prompt for AI Agents
In `@src/cli.ts` around lines 20 - 36, The parseDotenv function fails to handle
lines prefixed with "export" and inline comments; update parseDotenv so for each
non-empty, non-# line it first removes a leading "export " token from the start
of the trimmed line before splitting on '=', then when extracting the value
strip an inline comment only if the value is not enclosed in matching single or
double quotes (i.e., remove any unquoted " #..." suffix after trimming), then
remove surrounding quotes and unescape any escaped quotes; ensure the key is the
cleaned left-hand side and the value is the cleaned right-hand side so isTruthy
checks work as expected.

@danielroe danielroe merged commit 297bf72 into main Feb 7, 2026
5 checks passed
@danielroe danielroe deleted the perf/slim branch February 7, 2026 13:24
This was referenced Feb 7, 2026
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.

Drop git-url-parse dependency

1 participant