Skip to content

feat: add jsconfig.json and configure path aliases#1810

Merged
creamlike1024 merged 1 commit into
QuantumNous:mainfrom
QuentinHsu:feature/alias-path
Sep 23, 2025
Merged

feat: add jsconfig.json and configure path aliases#1810
creamlike1024 merged 1 commit into
QuantumNous:mainfrom
QuentinHsu:feature/alias-path

Conversation

@QuentinHsu
Copy link
Copy Markdown
Collaborator

@QuentinHsu QuentinHsu commented Sep 15, 2025

Summary by CodeRabbit

  • Chores
    • Configured path aliasing in the web project to simplify module imports (e.g., using a concise alias for the source directory).
    • Updated build tooling to recognize the new alias during development and build processes.
    • Improves developer experience and maintainability.
    • No user-facing changes or behavior impacts.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Sep 15, 2025

Walkthrough

Introduces path aliasing for the web project: adds jsconfig.json with baseUrl and "@/" -> "src/", and updates Vite config to resolve "@" to "./src". No other behavior changes.

Changes

Cohort / File(s) Summary of changes
Path alias configuration
web/jsconfig.json, web/vite.config.js
Added jsconfig with baseUrl "./", paths mapping "@/" to "src/", and include "src/**/*". Updated Vite resolve.alias to map "@" to path.resolve(__dirname, "./src"); imported path.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I hop through code with nimble feet,
Now “@” shows me src so neat.
Paths untangled, trails aligned,
Imports quick, no burrow blind.
Carrot in paw, I nod with cheer—
Fewer dots, the way is clear! 🥕✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "feat: add jsconfig.json and configure path aliases" is a concise, single-sentence description that directly summarizes the primary change in the PR (adding web/jsconfig.json and enabling path aliases), matches the changes shown in the diff, and contains no extraneous or misleading information.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
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

🧹 Nitpick comments (2)
web/jsconfig.json (1)

1-9: Exclude build artifacts to speed up language tooling.
Add excludes to avoid VS Code/tsserver crawling large dirs.

Apply this diff:

   },
-  "include": ["src/**/*"]
+  "include": ["src/**/*"],
+  "exclude": ["node_modules", "dist", "build"]
 }
web/vite.config.js (1)

28-32: Optional: tighten alias match to '@/…' to avoid scoped-package collisions.
Safer pattern if you import scoped libs like '@mui/' or '@douyinfe/'.

Alternative diff:

-  resolve: {
-    alias: {
-      '@': fileURLToPath(new URL('./src', import.meta.url)),
-    },
-  },
+  resolve: {
+    alias: [
+      { find: /^@\//, replacement: fileURLToPath(new URL('./src/', import.meta.url)) },
+    ],
+  },

This ensures only paths starting with @/ are rewritten. See Rollup alias behavior. (npmjs.com)

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 18a385f and dfa27f3.

📒 Files selected for processing (2)
  • web/jsconfig.json (1 hunks)
  • web/vite.config.js (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
web/vite.config.js (1)
web/src/helpers/api.js (1)
  • path (220-220)
🔇 Additional comments (1)
web/jsconfig.json (1)

1-9: LGTM overall — alias config matches Vite runtime.
Consistent with the Vite alias for '@'. Good addition.

Comment thread web/vite.config.js
Comment on lines +23 to +32
import path from 'path';
const { vitePluginSemi } = pkg;

// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix ESM '__dirname' usage — it’s undefined in ESM configs.
Using __dirname here will break config loading in ESM. Prefer fileURLToPath(new URL('./src', import.meta.url)), which is Vite’s recommended pattern.

Apply this diff:

-import path from 'path';
+import { fileURLToPath } from 'node:url';
@@
-  resolve: {
-    alias: {
-      '@': path.resolve(__dirname, './src'),
-    },
-  },
+  resolve: {
+    alias: {
+      '@': fileURLToPath(new URL('./src', import.meta.url)),
+    },
+  },

References: Vite docs recommend this alias form; ES modules don’t define __dirname. (vitejs.dev)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
import path from 'path';
const { vitePluginSemi } = pkg;
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
import { fileURLToPath } from 'node:url';
const { vitePluginSemi } = pkg;
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
🤖 Prompt for AI Agents
In web/vite.config.js around lines 23 to 32, the config uses __dirname which is
undefined in ESM; replace the alias resolution to use fileURLToPath(new
URL('./src', import.meta.url)) instead: import fileURLToPath from 'url' (or
destructure { fileURLToPath } from 'url') and construct the path via
path.resolve(fileURLToPath(new URL('./src', import.meta.url'))) (or set the
alias value directly to fileURLToPath(new URL('./src', import.meta.url)));
remove any reliance on __dirname so the config works in ESM.

@creamlike1024 creamlike1024 merged commit c0fb3bf into QuantumNous:main Sep 23, 2025
1 check passed
x22x22 pushed a commit to x22x22/new-api that referenced this pull request Apr 24, 2026
feat: add jsconfig.json and configure path aliases
jiutubaba pushed a commit to jiutubaba/fx-api that referenced this pull request May 17, 2026
…bindings-i18n

fix(payment,profile,admin): 修复支付二维码流程、绑定提示与后台配置说明
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.

2 participants