Skip to content

Commit 9fd9844

Browse files
OskarPerssonTimer
authored andcommitted
Fix file size report after build (#5335)
Fixes #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.
1 parent b201aee commit 9fd9844

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/react-dev-utils/FileSizeReporter.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ var gzipSize = require('gzip-size').sync;
1717

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

@@ -37,7 +37,7 @@ function printFileSizesAfterBuild(
3737
.map(stats =>
3838
stats
3939
.toJson({ all: false, assets: true })
40-
.assets.filter(canReadAsset)
40+
.assets.filter(asset => canReadAsset(asset.name))
4141
.map(asset => {
4242
var fileContents = fs.readFileSync(path.join(root, asset.name));
4343
var size = gzipSize(fileContents);

0 commit comments

Comments
 (0)