-
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
Fix issue with nested imports #376
Conversation
…ptions, add more cases
Fixes #330 |
Thanks for your PR, but there are some errors occured from CI. Could you slove them? |
Updated with new solution. Thanks! |
Hey 👋 v4.1.0 is released which should fix this. I tried to add some test cases to cover the cases mentioned here. If any of you could update and test if you're still having the issue? If not, can you post your full |
Thank you for this fix! It seems to work using |
…ugin-dts#376 Signed-off-by: Lachlan Heywood <[email protected]>
…ugin-dts#376 Signed-off-by: Lachlan Heywood <[email protected]>
…ugin-dts#376 Signed-off-by: Lachlan Heywood <[email protected]>
…ugin-dts#376 Signed-off-by: Lachlan Heywood <[email protected]>
…ugin-dts#376 Signed-off-by: Lachlan Heywood <[email protected]>
Context
With a path alias like
@/*
pointing tosrc/*
, an import like this:an import statement like
import { foo } from '@/foo'
transforms to
import { foo } from './src/foo'
Problem
There is an issue, however, with nested imports being ignored:
an import like
import { foo } from '@/nested/foo'
should transformed to
import { foo } from './src/nested/foo'
but actually just stays as
import { foo } from '@/nested/foo'
Solution
The fix was to update the regex pattern to look for anything in place of the asterisk (
(.+)
) rather than just 'any non forward slash' (([^\\/]+)
).vite-plugin-dts/src/utils.ts
Lines 444 to 446 in 8a0c140
Details
The commit log tells the story best and that's probably the easiest way to review the PR as well:
test(transform): add failing integration test for transformCode
This test covers the issue.
fix(utils): correct issue with failing integration test
This is the fix mentioned above.
test(utils): add tests for parseTsAliases
This test just covers the new regex pattern and a couple of extra cases I found from some recent open issues.
test(transform): refactor process aliases test with helper and descriptions, add more cases
This wasn't strictly necessary, but I wanted to make the test more readable and add a few more cases.
test: adds test cases from issue and fixes Invalid imports in generated d.ts for project with tsconfig path alias defined for any module #330
This is an additional test case to cover the issues mentioned in Invalid imports in generated d.ts for project with tsconfig path alias defined for any module #330