Skip to content

refactor: extract shared files, move test files, prepare for lsp#80

Merged
9romise merged 3 commits intomainfrom
refactor
Mar 14, 2026
Merged

refactor: extract shared files, move test files, prepare for lsp#80
9romise merged 3 commits intomainfrom
refactor

Conversation

@9romise
Copy link
Member

@9romise 9romise commented Mar 13, 2026

Prepare for lsp

  • Move test files to src
  • Extract some shared files

@9romise 9romise changed the title refactor: move test & shared files, prepare for lsp refactor: extract shared files, move test files, prepare for lsp Mar 13, 2026
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 13, 2026

📝 Walkthrough

Walkthrough

This pull request moves metadata, types and constants into a new shared directory and updates import paths to the new aliases (for example #shared/constants, #shared/meta, #shared/types). It adds a PackageManager type to shared/types and removes the duplicate from src/types/context.ts, introduces tsconfig.base.json and tsconfig.app.json and switches tsconfig.json to a references-based layout, adjusts many test import paths to use local or test-utils modules, and applies small safety updates (non-null assertions) and logger usage changes. The .gitignore and package.json scripts were also updated.

Possibly related PRs

  • npmx-dev/vscode-npmx PR 76: Changes to src/core/workspace.ts around PackageManager imports and getPackageManager error handling that overlap this PR’s import and logging adjustments.
  • npmx-dev/vscode-npmx PR 68: Refactors PackageManager/type locations and workspace-context imports; directly related to the type relocation performed here.
  • npmx-dev/vscode-npmx PR 22: Touches SPACER usage/import in hover providers; relates to this PR’s migration of constants to the shared constants module.
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description is directly related to the changeset, detailing refactoring efforts to prepare for LSP, move test files, and extract shared files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

CodeRabbit can generate a title for your PR based on the changes with custom instructions.

Set the reviews.auto_title_instructions setting to generate a title for your PR based on the changes in the PR with custom instructions.

Copy link
Contributor

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b0ca6a64-aec6-4e56-b862-af24aaf8a55d

📥 Commits

Reviewing files that changed from the base of the PR and between 36abe63 and 7cb68ec.

📒 Files selected for processing (45)
  • .gitignore
  • package.json
  • shared/constants.ts
  • shared/types.ts
  • src/api/package.ts
  • src/api/replacement.ts
  • src/api/vulnerability.ts
  • src/commands/add-to-ignore.ts
  • src/commands/open-file-in-npmx.ts
  • src/commands/open-in-browser.ts
  • src/composables/workspace-context.ts
  • src/core/workspace.ts
  • src/index.ts
  • src/providers/code-actions/index.ts
  • src/providers/code-actions/quick-fix.test.ts
  • src/providers/code-actions/quick-fix.ts
  • src/providers/completion-item/index.ts
  • src/providers/completion-item/version.ts
  • src/providers/definition/index.ts
  • src/providers/diagnostics/index.ts
  • src/providers/diagnostics/rules/deprecation.test.ts
  • src/providers/diagnostics/rules/dist-tag.test.ts
  • src/providers/diagnostics/rules/engine-mismatch.test.ts
  • src/providers/diagnostics/rules/replacement.test.ts
  • src/providers/diagnostics/rules/upgrade.test.ts
  • src/providers/diagnostics/rules/vulnerability.test.ts
  • src/providers/document-link/index.ts
  • src/providers/hover/index.ts
  • src/providers/hover/npmx.ts
  • src/state.ts
  • src/types/context.ts
  • src/utils/batch.test.ts
  • src/utils/dependency.test.ts
  • src/utils/file.ts
  • src/utils/ignore.test.ts
  • src/utils/links.ts
  • src/utils/package.test.ts
  • src/utils/package.ts
  • src/utils/version.test.ts
  • tests/__setup__/msw.ts
  • tests/utils/diagnostics.ts
  • tsconfig.app.json
  • tsconfig.base.json
  • tsconfig.json
  • vitest.config.ts
💤 Files with no reviewable changes (1)
  • src/types/context.ts

Copy link
Contributor

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fb6964be-5fba-4c9d-a2cf-2ff0831d4f94

📥 Commits

Reviewing files that changed from the base of the PR and between 7cb68ec and ad01415.

📒 Files selected for processing (1)
  • tsconfig.base.json

"target": "ESNext",
"lib": ["ESNext"],
"module": "ESNext",
"moduleResolution": "Bundler",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate relevant config files
TS_APP="$(fd -HI '^tsconfig\.app\.json$' | head -n1 || true)"
TS_DOWN="$(fd -HI '^tsdown\.config\.ts$' | head -n1 || true)"
VITEST="$(fd -HI '^vitest\.config\.ts$' | head -n1 || true)"

echo "tsconfig.app.json: ${TS_APP:-NOT FOUND}"
echo "tsdown.config.ts: ${TS_DOWN:-NOT FOUND}"
echo "vitest.config.ts: ${VITEST:-NOT FOUND}"
echo

# Show TS path aliases
if [[ -n "${TS_APP}" ]]; then
  echo "=== paths in tsconfig.app.json ==="
  rg -n -C2 '"paths"|#shared|#api|#types|#utils|#core|#composables|#test-utils' "$TS_APP"
  echo
fi

# Show bundler resolver/alias settings
if [[ -n "${TS_DOWN}" ]]; then
  echo "=== resolver settings in tsdown.config.ts ==="
  rg -n -C3 'alias|resolve|tsconfig|paths|plugin' "$TS_DOWN"
  echo
fi

# Confirm test-only alias support exists
if [[ -n "${VITEST}" ]]; then
  echo "=== alias support in vitest.config.ts ==="
  rg -n -C2 'vite-tsconfig-paths|plugins' "$VITEST"
fi

Repository: npmx-dev/vscode-npmx

Length of output: 1363


Add path alias mappings to tsdown.config.ts to match tsconfig.app.json

Line 6 ("moduleResolution": "Bundler") is correct, but tsdown.config.ts is missing the path alias mappings defined in tsconfig.app.json. Vitest will resolve aliases like #shared/* and #api/* via vite-tsconfig-paths, but the production bundler will fail at runtime unless tsdown is configured with equivalent aliases. Add the following to tsdown.config.ts alias object:

'#shared/*': resolve('./shared/*'),
'#state': resolve('./src/state.ts'),
'#api/*': resolve('./src/api/*'),
'#types/*': resolve('./src/types/*'),
'#utils/*': resolve('./src/utils/*'),
'#core/*': resolve('./src/core/*'),
'#composables/*': resolve('./src/composables/*'),
'#test-utils/*': resolve('./tests/utils/*'),

@9romise 9romise added this pull request to the merge queue Mar 14, 2026
Merged via the queue into main with commit 0e1a17d Mar 14, 2026
11 checks passed
@9romise 9romise deleted the refactor branch March 14, 2026 08:02
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