Skip to content

FileSizeReporter reports with wrong (hardcoded) path. #2357

Closed
@fezhengjin

Description

@fezhengjin

Can you reproduce the problem with latest npm?

yes

Description

When i changed the value of appBuild property to dist in "react-scripts/config/paths.js" and run npm run build, the printFileSizesAfterBuild function logged wrong paths.

Expected behavior

Log in the console should be like:

File sizes after gzip:

  16.13 KB  dist/static/js/main.3a5b25c4.js
  5.72 KB   dist/static/css/main.dc21d15c.css

Actual behavior

But it still reported with "build" in paths:

File sizes after gzip:

  16.13 KB  build/static/js/main.3a5b25c4.js
  5.72 KB   build/static/css/main.dc21d15c.css

Environment

Run these commands in the project folder and fill in their results:

  1. npm ls react-scripts (if you haven’t ejected):
  2. node -v: v7.4.0
  3. npm -v: 4.0.5

Then, specify:

  1. Operating system: macOS Sierra 10.12.4
  2. Browser and version:

Hardcode

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-dev-utils/FileSizeReporter.js#L33

Activity

gaearon

gaearon commented on May 25, 2017

@gaearon
Contributor

Good catch. Want to send a PR that passes appBuild folder into that function?

fezhengjin

fezhengjin commented on May 25, 2017

@fezhengjin
ContributorAuthor

@gaearon It's my pleasure.

noseglid

noseglid commented on May 30, 2017

@noseglid

This never made it into the documentation, which still incorrectly states

printFileSizesAfterBuild(webpackStats: WebpackStats, previousFileSizes: OpaqueFileSizes)

when in fact it should be

printFileSizesAfterBuild(webpackStats: WebpackStats, previousFileSizes: OpaqueFileSizes, buildFolder: string)

or this happens

Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

/Users/noseglid/devel/content-admin/scripts/build.js:10
  throw err;
  ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.basename (path.js:1355:5)
    at webpackStats.toJson.assets.filter.map.asset (/Users/noseglid/devel/content-admin/node_modules/react-dev-utils/FileSizeReporter.js:34:32)
    at Array.map (native)
    at printFileSizesAfterBuild (/Users/noseglid/devel/content-admin/node_modules/react-dev-utils/FileSizeReporter.js:27:6)
    at measureFileSizesBeforeBuild.then.then (/Users/noseglid/devel/content-admin/scripts/build.js:68:7)
gaearon

gaearon commented on May 30, 2017

@gaearon
Contributor

Good point. Want to send a PR?

gaearon

gaearon commented on May 30, 2017

@gaearon
Contributor

Reopened for docs.

1 remaining item

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @gaearon@noseglid@fezhengjin

        Issue actions

          FileSizeReporter reports with wrong (hardcoded) path. · Issue #2357 · facebook/create-react-app