-
Notifications
You must be signed in to change notification settings - Fork 45
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't Resolve Module with explicit .ts #2055
Comments
Wallaby for webpack never supported file imports with explicit You can add a preprocessor to rename compiled files back to |
It's a large repo and a few developers like adding explicit extensions to differentiate between directories. I'm the only one using Wallaby at the moment and would rather not clean up after them every time an import with .ts is used. Any idea what the preprocessor would look like? |
If I'm not wrong, this approach is only complicating things. Even TypeScript compiler by default is unhappy about imports with file extensions.
I would highly recommend against it (haven't seen any of our users doing it, so can't guarantee the solidness of the approach), and would rather recommend fixing the code, but if you really can not do, here is the way: compilers: {
'**/*.js?(x)': wallaby.compilers.babel(),
'**/*.ts?(x)': wallaby.compilers.babel()
},
+ preprocessors: {
+ '**/*.js': file => require('fs').existsSync(path.join(wallaby.projectCacheDir, file.path.replace('.js', '.ts')))
+ ? file.changeExt('ts').content : file.content
+ },
|
Do you have any references on how adding the extensions causes issues for the Typescript compiler? |
I was referring to this default behaviour of Typescript compiler: |
I'm having issues with wallaby and webpack where certain modules are not resolved. If we add an explicit .ts to the module import path, wallaby can't seem to find it. This seems to have just started. There errors look like
The wallaby config looks like
The babel config looks like
And we currently have this for our Webpack resolve section
The text was updated successfully, but these errors were encountered: