Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't strip stack traces of evaluated webpack bundles #1050

Merged
merged 4 commits into from
Dec 5, 2016

Conversation

jameslnewell
Copy link
Contributor

formatWebpackMessages is neat! I'm using it outside of create-react-app. However, it's a little too eager in stripping stack traces from messages.

I'm using the static-react-render-webpack-plugin which evaluates the outputted webpack bundle. When evaluating the outputted webpack bundle throws (in the user's code), the user needs the stack trace to debug what went wrong. formatWebpackMessages is stripping all stack traces making that difficult.

This PR excludes stack traces where the source path contains webpack:. I've created a demo of the regexp working which shows stack traces being stripped for babel-loader but not static-react-render-webpack-plugin.

Example stack trace
static-react-render-webpack-plugin: Error rendering page "scripts/components/compare/couples.js": ReferenceError: Foobar is not defined
    at Couples (webpack:///./components/compare/couples/index.jsx?:37:5)
    at eval (webpack:///../~/react/lib/ReactCompositeComponent.js?:305:16)
    at measureLifeCyclePerf (webpack:///../~/react/lib/ReactCompositeComponent.js?:74:12)
    at ReactCompositeComponentMixin._constructComponentWithoutOwner (webpack:///../~/react/lib/ReactCompositeComponent.js?:304:14)
    at ReactCompositeComponentMixin._constructComponent (webpack:///../~/react/lib/ReactCompositeComponent.js?:279:21)
    at ReactCompositeComponentMixin.mountComponent (webpack:///../~/react/lib/ReactCompositeComponent.js?:187:21)
    at Object.ReactReconciler.mountComponent (webpack:///../~/react/lib/ReactReconciler.js?:47:35)
    at ReactDOMComponent.ReactMultiChild.Mixin.mountChildren (webpack:///../~/react/lib/ReactMultiChild.js?:240:44)
    at ReactDOMComponent.Mixin._createContentMarkup (webpack:///../~/react/lib/ReactDOMComponent.js?:661:32)
    at ReactDOMComponent.Mixin.mountComponent (webpack:///../~/react/lib/ReactDOMComponent.js?:528:29)

@facebook-github-bot
Copy link

Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks!

If you are contributing on behalf of someone else (eg your employer): the individual CLA is not sufficient - use https://developers.facebook.com/opensource/cla?type=company instead. Contact cla@fb.com if you have any questions.

@jameslnewell jameslnewell changed the title Don't strip stack traces of evaluated webpack code Don't strip stack traces of evaluated webpack bundles Nov 17, 2016
@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

because the last line doesn't always have a `\n` and `create-react-app` is leaving the last line of the stack traces present in the error messages
@jameslnewell
Copy link
Contributor Author

Also fixed an issue where the last line of the stack trace is left in the message because it doesn't end with \n.

@gaearon
Copy link
Contributor

gaearon commented Nov 17, 2016

Can you add a comment explaining the exception to future readers?

@jameslnewell
Copy link
Contributor Author

Sure. How's that look?

@gaearon gaearon added this to the 0.8.2 milestone Dec 5, 2016
@gaearon gaearon merged commit f7d9cd8 into facebook:master Dec 5, 2016
@gaearon
Copy link
Contributor

gaearon commented Dec 5, 2016

Looks great.

mofelee added a commit to xiaohu-developer/create-react-app that referenced this pull request Dec 7, 2016
* master: (30 commits)
  Relax peerDependencies for ESLint preset (facebook#1191)
  Update Webpack to fix source map issues (facebook#1188)
  Update webpack prod config (facebook#1181)
  Chrome 'open tab' reuse an empty tab when possible (facebook#1165)
  Use file-loader for svgs (facebook#1180)
  Fix Babel issues in tests by applying the right transforms (facebook#1179)
  [babel-preset-react-app] Temporary fix missing babel plugins (facebook#1177)
  Add Subresource Integrity support (facebook#1176)
  Remove path module from webpack config on eject. (facebook#1175)
  Don't strip stack traces of evaluated webpack bundles (facebook#1050)
  Add deploy to Firebase CDN on template's README (Closes facebook#374) (facebook#1143)
  Update e2e.sh (facebook#1167)
  Document what npm build does and pushState (facebook#933)
  Fix minor typo/grammar (facebook#1099)
  Add "npm run build silently fails" to Troubleshooting (facebook#1168)
  Add testURL to jest config (facebook#1120)
  Make jsx-no-undef rule an error (facebook#1159)
  Update CHANGELOG.md
  Publish
  Update changelog for 0.8.1
  ...
alexdriaguine pushed a commit to alexdriaguine/create-react-app that referenced this pull request Jan 23, 2017
* Don't strip stack traces of evaluated webpack code

* Strip stack traces at the end of a string

because the last line doesn't always have a `\n` and `create-react-app` is leaving the last line of the stack traces present in the error messages

* code comment

* code comment
randycoulman pushed a commit to CodingZeal/create-react-app that referenced this pull request May 8, 2017
* Don't strip stack traces of evaluated webpack code

* Strip stack traces at the end of a string

because the last line doesn't always have a `\n` and `create-react-app` is leaving the last line of the stack traces present in the error messages

* code comment

* code comment
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants