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

special/webpack improvements #449

Merged
merged 3 commits into from Nov 1, 2019
Merged

special/webpack improvements #449

merged 3 commits into from Nov 1, 2019

Conversation

sveyret
Copy link
Contributor

@sveyret sveyret commented Nov 1, 2019

Correcting some issues about webpack special parser.
Tests included.
This is correcting issues #246, #446 and #448.

Copy link
Member

@rumpl rumpl left a comment

Choose a reason for hiding this comment

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

LGTM just fix the linting issues please 👍

}

export default function parseWebpack(content, filepath, deps) {
const filename = path.basename(filepath);
if (webpackConfigRegex.test(filename)) {
const module = require(filepath).module || {}; // eslint-disable-line global-require
const wpConfig = require(filepath); // eslint-disable-line global-require
Copy link
Member

Choose a reason for hiding this comment

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

You changed the regex to include .ts config files, wouldn't this fail for a ts file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am working with TypeScript, and it's working like a charm… 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I've got a doubt. It's working with my project but I'm calling depcheck from a TypeScript file using ts-node. Maybe it'd be a requirement in order to use this feature.

Copy link
Member

Choose a reason for hiding this comment

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

Ok so yeah it works for you because of ts-node.

I think we should revert the ts loading until we find a good way of dealing with this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll do some more tests directly using the command line.
But anyway, will it hurt to keep this commit? I mean, at worst, if people is not using it with the same requisites as I do, it will fail while reading the config file, and therefore, work as before. So it should be improved, but already can be a useful feature…

Copy link
Member

Choose a reason for hiding this comment

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

The cli could fail for users where it didn't fail before. At least could you make a PR and make it so that it uses the tryRequire?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So, after my tests, I can confirm that:

  • when using ts-node, it works well, even with command line (I tested with npx ts-node ~/depcheck/bin/depcheck.js --specials=bin,tslint,webpack);
  • when executing depcheck with node, the webpack configuration file is ignored, but the rest of the process is working correctly.

Copy link
Member

Choose a reason for hiding this comment

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

Great then, nothing broke :)

@codecov
Copy link

codecov bot commented Nov 1, 2019

Codecov Report

Merging #449 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #449      +/-   ##
==========================================
+ Coverage   99.13%   99.15%   +0.02%     
==========================================
  Files          36       36              
  Lines         697      714      +17     
==========================================
+ Hits          691      708      +17     
  Misses          6        6
Impacted Files Coverage Δ
src/special/webpack.js 100% <100%> (ø) ⬆️

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 335a847...052b49c. Read the comment docs.

@rumpl rumpl merged commit 40fa69c into depcheck:master Nov 1, 2019
@rumpl
Copy link
Member

rumpl commented Nov 1, 2019

Beautiful, 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.

None yet

2 participants