scripts: Don’t make empty subfolders for ignored files in build folder #7001
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
I noticed empty
build/__tests__
folder in the installed[email protected]
package.Although I didn’t find where that problem was fixed between 23.4.0 and 23.4.1, I did find change in assumption as reason for many empty subfolders in
build
folder.Comment in
scripts/build.js
file:For a long while, files in folders matching
IGNORE_PATTERN
are not copied, sobuildFile
function can return early beforemkdirp
call.The diff after code is moved with a change takes a second look to understand what happened :(
Test plan
yarn build-clean
andyarn build
andyarn jest
yarn build
__tests__
or__mocks__
folders or subfoldersThe improved number of folder 56 = 189 - 133
The baseline number of empty folders 83 < 133 because some intermediate level subfolder do contain subfolders (even though they don’t contain files)
Here are the commands for rows in preceding table:
find packages/*/build -type f -print | wc
find packages/*/build -type d -print | wc
find packages/*/build -type d -print | grep -e __tests__ -e __mocks__ | wc
find packages/*/build -type d -empty -print | wc