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

Fix issue with TypeScript paths with allowJs #470

Merged
merged 4 commits into from
Sep 9, 2019

Conversation

novascreen
Copy link
Contributor

Closes #469

I noticed something when I added the test, when you run the existing output.js of tsconfig-paths you also get "Cannot find module", not sure if the output there is intended to be different from output-coverage.js, but thought i'd point it out.

The tsconfig-paths-allowjs/output-coverage.js shows the difference between adding js to the extensions of TsconfigPathsPlugin and not having it.

@novascreen
Copy link
Contributor Author

Another thing, I wasn't sure whether i should only add js or make extensions be SUPPORTED_EXTENSIONS, let me know if i should change that.

@codecov-io
Copy link

codecov-io commented Aug 31, 2019

Codecov Report

Merging #470 into master will increase coverage by 0.25%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #470      +/-   ##
==========================================
+ Coverage   74.68%   74.93%   +0.25%     
==========================================
  Files          13       13              
  Lines         395      399       +4     
==========================================
+ Hits          295      299       +4     
  Misses        100      100
Impacted Files Coverage Δ
src/index.js 83.92% <100%> (+0.39%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2081579...9cd8306. Read the comment docs.

src/index.js Outdated
@@ -71,7 +71,7 @@ module.exports = (
// we need to catch here because the plugin will
// error if there's no tsconfig in the working directory
try {
resolvePlugins.push(new TsconfigPathsPlugin({ silent: true }));
resolvePlugins.push(new TsconfigPathsPlugin({ silent: true, extensions: [".ts", ".tsx", ".js"] }));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
resolvePlugins.push(new TsconfigPathsPlugin({ silent: true, extensions: [".ts", ".tsx", ".js"] }));
resolvePlugins.push(new TsconfigPathsPlugin({ silent: true, extensions: SUPPORTED_EXTENSIONS }));

The docs mention that these should be the same.

Perhaps this should look for allowJs option before assigning the extensions.

If you're using allowJs in tsconfig.json, or allow other non-TS extensions in webpack, make sure you set extensions option in sync with your webpack config.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@styfle I believe I addressed both your suggestions, I did it in two steps, let me know if you want to keep the check against the tsconfig.json

@styfle styfle changed the title Fix issue with TypeScript paths and allowjs Fix issue with TypeScript paths with allowJs Sep 9, 2019
Copy link
Member

@styfle styfle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TypeScript with allowJS and absolute imports fails at runtime
3 participants