Skip to content

Commit

Permalink
Fix file size report after build (facebook#5335)
Browse files Browse the repository at this point in the history
Fixes facebook#5333

printFileSizesAfterBuild calls canReadAsset with an object containing
the file name while measureFileSizesBeforeBuild calls it with just the
name. When canReadAsset only receives the name it returns false since
accessing the `name` property results in undefined.

This commit fixes that by having canReadAssset instead expect only the
file name and making printFileSizesAfterBuild just like
measureFileSizesBeforeBuild only provide the name as argument.
  • Loading branch information
OskarPersson authored and Timer committed Oct 6, 2018
1 parent 99a6c37 commit 40fd435
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/react-dev-utils/FileSizeReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ var gzipSize = require('gzip-size').sync;

function canReadAsset(asset) {
return (
/\.(js|css)$/.test(asset.name) &&
!/service-worker\.js/.test(asset.name) &&
!/precache-manifest\.[0-9a-f]+\.js/.test(asset.name)
/\.(js|css)$/.test(asset) &&
!/service-worker\.js/.test(asset) &&
!/precache-manifest\.[0-9a-f]+\.js/.test(asset)
);
}

Expand All @@ -37,7 +37,7 @@ function printFileSizesAfterBuild(
.map(stats =>
stats
.toJson({ all: false, assets: true })
.assets.filter(canReadAsset)
.assets.filter(asset => canReadAsset(asset.name))
.map(asset => {
var fileContents = fs.readFileSync(path.join(root, asset.name));
var size = gzipSize(fileContents);
Expand Down

0 comments on commit 40fd435

Please sign in to comment.