Closed crhistianramirez closed 1 year ago
Do you have something like this log in the terminal?
vite-tsconfig-paths resolved: {
id: '@backend/src/main',
importer: '/home/kasir/projects/node.js.developers.kh/apps/frontend/src/pages/contactUs/contactUsApi.slice.tsx',
resolvedId: '/home/kasir/projects/node.js.developers.kh/apps/backend/src/main.ts',
configPath: '/home/kasir/projects/node.js.developers.kh/apps/frontend/tsconfig.json'
} +164ms
BTW I am facing a weird issue with this lib, here is what I did:
{
"compileOnSave": true,
"compilerOptions": {
"noUnusedLocals": true,
"allowJs": false,
"noUnusedParameters": true,
"isolatedModules": true,
"noImplicitReturns": false,
"skipDefaultLibCheck": true,
"incremental": true,
"target": "es2017",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"module": "commonjs",
"baseUrl": "./",
"resolveJsonModule": true,
"declaration": true,
"sourceMap": true,
"outDir": "./dist",
"removeComments": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": false,
"strictNullChecks": true,
"strictBindCallApply": true,
"strictPropertyInitialization": false,
"alwaysStrict": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"moduleResolution": "node"
},
"exclude": [
"node_modules",
"**/*.d.ts",
"__tests__",
"test",
"jest.config.ts",
"dist",
"**/*spec.ts"
]
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"outDir": "./dist",
"baseUrl": "./",
"paths": {
"shared/*": ["./src/shared/*"]
},
"composite": true
},
"exclude": [
"node_modules",
"__tests__",
"test",
"jest.config.ts",
"dist",
"**/*spec.ts"
]
}
{
"compilerOptions": {
"noUnusedLocals": true,
"allowJs": false,
"noUnusedParameters": true,
"noImplicitReturns": false,
"skipDefaultLibCheck": true,
"incremental": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true,
"sourceMap": true,
"removeComments": true,
"esModuleInterop": true,
"noImplicitAny": false,
"strictNullChecks": true,
"strictBindCallApply": true,
"strictPropertyInitialization": false,
"alwaysStrict": true,
"noFallthroughCasesInSwitch": true,
"target": "ESNext",
"useDefineForClassFields": true,
"outDir": "./dist",
"baseUrl": "./",
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"paths": {
"components/*": ["./src/components/*"],
"pages/*": ["./src/pages/*"],
"backend/*": ["../backend/*"]
}
},
"references": [
{ "path": "./tsconfig.node.json" },
{
"path": "../backend/tsconfig.json"
}
]
}
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [tsconfigPaths(), react()],
// resolve: {
// alias: {
// 'backend': resolve(__dirname, '../backend/src/'),
// },
// },
});
I can resolve the issue with the commented code but TBH I am just curious why it is not working in one project while it is working in another one.
I realized that when I use the commented solution it wont complain when start the project but the thing is that it cannot show the react app in the browser since it throw an error in the terminal when I open index page.
Hey Kasir, I can help if you reproduce the issue in a simple demo and open another issue with a description of the expected behavior and the actual behavior.
Could not reproduce the original issue
In my tsconfig.json I have the following:
And in my src directory I have multiple subfolders such as
components
andutils
which I can then import like so:This is particularly nice because I don't need to update my tsconfig file if a new folder is created under
src
it will just work. I tried to use this library but got a bunch of import errors. I also ran it with theDEBUG
flag and it correctly found my tsconfig.json file but just doesn't seem to be working. Any ideas? Here is the debug output: