-
Notifications
You must be signed in to change notification settings - Fork 91
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
Invalid imports in generated d.ts for project with tsconfig path alias defined for any module #330
Comments
Just confirmed this problem still exists with version |
The problem is still here. Are there any updates/workarounds? |
Temp fix:
Note the And the generated |
* test(transform): add failing integration test for transformCode * fix(utils): correct issue with failing integration test * test(utils): add tests for parseTsAliases * test(transform): refactor process aliases test with helper and descriptions, add more cases * test: adds test cases from issue and fixes #330 * test(utils): handle windows path
See note on #376
@k-i-m, @giuvincenzi, @kristof-mattei Could you all try this update? |
To start, thanks for releasing a bugfix. Then, sorry for the late reply. I've tested with the old 4.0.3 and my Unfortunately it doesn't work for me. ❯ diff dist-4.0.3/core.d.ts dist-4.1.1/core.d.ts
1,6c1,6
< export * as checks from './checks';
< export * from './commands/base-program';
< export * from './commands/cargo';
< export * from './commands/cross';
< export * from './commands/rustup';
< export * as input from './input';
---
> export * as checks from '@/checks';
> export * from '@/commands/base-program';
> export * from '@/commands/cargo';
> export * from '@/commands/cross';
> export * from '@/commands/rustup';
> export * as input from '@/input'; Maybe I'm doing something wrong? |
Thanks @kristof-mattei. No worries, I find most gh issues happen quite async. Could you post your tsconfig? |
https://github.com/actions-rs-plus/core/blob/main/tsconfig.json In that project you can do and then in vite |
Ahh ok, looks like it goes away with the |
Let me know if you want me to retest stuff / help out. |
The problem still exists in v 4.2.3 I have exact same output as was described in the issue Please note that I have '*" in my path alias, not "@"
|
@k-i-m do you have a I did add a test case for the "*" alias: vite-plugin-dts/tests/transform.spec.ts Line 191 in a7e1c0c
|
I added a PR to hopefully fix the issue |
@k-i-m can you retest your issue with this version? @kristof-mattei the tsconfig file should no longer require the baseUrl now, either! |
The main issue is solved but I still get some weird imports for my 3rd party depencendies, like for React: |
Ah yes, that's a great point. It seems that there isn't really a way to support top level @qmhc what do you think? |
OH, an intractable disease. Let me think... |
Just confirmed this problem still exists with version 4.3.0 |
@qmhc would you accept a solution that adds a check for this specific condition (top-level Example:
Does that sound like it would work? |
@lachieh Yes, my thoughts are very similar to yours. Would you like to try this solution? |
Added a PR (#396) which probably needs some closer attention. I wanted to try to use the TS program to resolve the paths and see if they had a better way, but in this solution I just used the |
Describe the bug
I have a project, where I have path aliases defined in
tsconfig.json
to simplify usage of any module within src folder:This setting allows to simplify the imports, so that instead of:
import { Sample } from 'src/components/Sample';
(or evenimport { Sample } from '@/components/Sample';
)we can use:
import { Sample } from 'components/Sample';
When I build the app, the app itself works fine (thanks to the
vite-tsconfig-paths
), but all thed.ts
files for.ts
files that are inside a subfolder of src, are generated with invalidimport
paths.The original ts file:
The output d.ts file:
It was working fine in
vite-plugin-dts@3.6.4
. Any version since then (so starting from v3.7.0) has the issue.Possibly there is an issue in this commit that was introduced in 3.7.0:
e8827cb
Reproduction
https://stackblitz.com/edit/vitejs-vite-sg53ed?file=dist%2Ftypes%2Fcomponents%2FSample%2Findex.d.ts
Steps to reproduce
src
, and there create any other folder containing some sample component:where
index.ts
is only reexporting the componentimport the component in App.tsx:
import { Sample } from 'components/Sample';
set the project's configuration:
package.json
vite related libraries:
tsconfig.json
add the following
"paths"
:vite.config.ts
vite build
commanddist/types
folder you will find d.ts files with invalid import pathsSystem Info
Validations
The text was updated successfully, but these errors were encountered: