Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions web/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
},
"include": ["src/**/*"]
}
6 changes: 6 additions & 0 deletions web/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ For commercial licensing, please contact support@quantumnous.com
import react from '@vitejs/plugin-react';
import { defineConfig, transformWithEsbuild } from 'vite';
import pkg from '@douyinfe/vite-plugin-semi';
import path from 'path';
const { vitePluginSemi } = pkg;

// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
Comment on lines +23 to +32

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.

plugins: [
{
name: 'treat-js-files-as-jsx',
Expand Down