-
Notifications
You must be signed in to change notification settings - Fork 109
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
Weird import / bundling issue when using date-fns
#398
Comments
If this helps, I've managed to find the source of the issue. Within the The cause of this issue is that the regex ends up getting applied on LE: The real question is why is the filename resolving the |
Are you using compiler paths? |
@erikbarke No, this happens with out of the box configuration. LE: if you want I can create a simple repro repository. |
@erikbarke Here's a repo that should reproduce the issue: https://github.com/vladjerca/karma-typescript-import-bug |
If I import a specific method from
date-fns
the module is incorrectly resolved.eg:
import addDays from 'date-fns/addDays'
File.ts:
File.spec.ts:
The test fails with the following error:
Here comes the juicy part, running the test with the debugger attached renders this:
This does not hold up when running the application in production, it can only be reproduced via
karma-typescript
😱Basically from what I can tell is that the bundler is somehow loading the entire
date-fns
library instead of targetingdate-fns/addDays
specifically.LE:
karma-typescript
: 5.1.0 (latest as of when this issue was opened)The only workaround I've found for this ATM is to do a really gross hack in my
test configuration script
Let me know if there's any more information I can provide 👍
The text was updated successfully, but these errors were encountered: