Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can not resolve ts files using their corresponding js extesions #54

Closed
wight554 opened this issue May 6, 2022 · 3 comments
Closed

can not resolve ts files using their corresponding js extesions #54

wight554 opened this issue May 6, 2022 · 3 comments
Labels
upstream bug Bug caused by a dependency

Comments

@wight554
Copy link

wight554 commented May 6, 2022

Support for .ts to .js alias was added in vite upstream
But it doesn't work with vite-tsconfig-paths:

// from vite.config.ts
  plugins: [
    preact({
      include: '{test/,}src/**/*.{ts,tsx}',
    }),
    !isTest && tsconfigPaths(),
    !isTest &&
      checker({
        typescript: { tsconfigPath: 'src/tsconfig.json' },
        eslint: {
          lintCommand: 'eslint "./src/**/*.{ts,tsx}"',
        },
      }),
    isTest && typescript(),
  ],
// from tsconfig.json

"paths": {
  "@src/*": ["./src/*"],
  "@server/*": ["./server/*"],
  "@test/*": ["./test/*"]
},

Currently I can fix it by:

resolve: {
    alias: [{ find: /^(@.*\/.*)\.js$/, replacement: '$1.ts' }]
}

Repro can be found here:
wight554/blog-template#50

See this issue for more details:
vitejs/vite#7918

@aleclarson
Copy link
Owner

This is a bug in tsconfig-paths

See here: dividab/tsconfig-paths#213

@tianyingchun
Copy link

Are there any temporary solutions at the moment?

@wight554
Copy link
Author

Are there any temporary solutions at the moment?

Alias, check issue description for example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream bug Bug caused by a dependency
Projects
None yet
Development

No branches or pull requests

3 participants