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 excludeNodeDevDependencies method: dev modules not excluded on invalid package #7368

Merged
merged 4 commits into from
Feb 24, 2020
Merged

Conversation

darko1979
Copy link
Contributor

What did you implement

This PR fixes the problem dev dependencies not excluded which produces large zip packages.
We had deployment issues with out project that prevented us from deploying a package to aws lambda because of the zip package size. After a few days of debugging I narrowed it to a problematic node_modules package that had it's own dependencies and one of them had an empty folder without package.json. This caused excludeNodeDevDependencies method to fail when trying to read package.json file because there was no catch on readFileAsync which caused this method to stop and return empty array so no modules were excluded.

Probably the cause of the issue #5396

Is this ready for review?: YES
Is it a breaking change?: NO

@darko1979 darko1979 changed the title fix excludeNodeDevDependencies method: dev modules not excluded on valid package fix excludeNodeDevDependencies method: dev modules not excluded on invalid package Feb 20, 2020
Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

@darko1979 makes sense. Great thanks for that fix. I've just proposed one improvement, to avoid eventual side effects.


return globs.concat(baseGlobs);
})
.catch(() => globs);
Copy link
Contributor

Choose a reason for hiding this comment

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

To reflect properly if/else, let's pass this catch callback as second argument to previous then (otherwise it also handles errors which may happen in first then callback and that can impose nasty, difficult to debug issues)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@medikoo Not really sure if I understood you correctly. If I'm not mistaken, the catch block I added only handles the error from readFileAsync it does not handle errors of any previous then blocks.

Copy link
Contributor

@medikoo medikoo Feb 22, 2020

Choose a reason for hiding this comment

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

it does not handle errors of any previous then blocks.

@darko1979 it handles. To ensure it'll only handle error from readFileAsync it needs to be attached directly to promise returned by readFileAsync (and not to result of then() in which we process it's result)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@medikoo I understand now, I corrected it by your suggestion

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

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

Great thanks @darko1979 !

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

Successfully merging this pull request may close these issues.

None yet

2 participants