Skip to content

Provide stacktrace for react-scripts/build.js build function #8436

Description

@Dergash

Is your proposal related to a problem?

I've encountered a problem that I think could've been diagnosed more easily if build script were more verbose and provided a stack trace aside of error message.

My scenario was pretty simple - I've used CRA, eject, then played a bit with entry record:
https://github.com/facebook/create-react-app/blob/687c4ebf211ad30238f2d59e063b8171e015bfc7/packages/react-scripts/config/webpack.config.js#L151
by replacing an array configuration with an object configuration (which is valid webpack option)

After that I couldn't build my app (which is fine) and I coundn't easily find a problem, see attached image:
original
As you can see, the error message didn't tell me where the problem occured or what the context was, so if I've played a lot around my configuration then I have to either revert my changes line by line to find which exactly broke the build or debug build script itself.

Describe the solution you'd like

Error message was formed here:
https://github.com/facebook/create-react-app/blob/687c4ebf211ad30238f2d59e063b8171e015bfc7/packages/react-scripts/scripts/build.js#L196

If there would've been an additional stacktrace added to that array:

if (err) {
    messages.errors.push(err.stack);
}
return reject(new Error(messages.errors.join('\n\n'), ));

then I would have a more precise description of a problem that shows me that 'filter of undefined' situation occured exactly at 583 line of my webpack config which I should further work with:
suggestion

Describe alternatives you've considered

There is an obvious concern that stacktraces might not have a place in defined policy of user-friendly error messages, but they probably could be enabled by additional --verbose flag.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions