Skip to content
This repository has been archived by the owner on Oct 12, 2021. It is now read-only.

Ejecting from CRA, removing production minification. #421

Merged
merged 4 commits into from
Jun 27, 2018

Conversation

kenhoff
Copy link
Contributor

@kenhoff kenhoff commented Jun 25, 2018

Sorry for the big one!

  • ejects from create-react-app, removes the react-scripts dependency and adds a whole bunch of config files.
  • all of the standard yarn commands are still the same - see app/package.json
  • apparently the standard UglifyJsPlugin creates invalid sourcemaps, which is why Sentry isn't giving me any line numbers to debug with.
  • Removing the UglifyJsPlugin (below) and just relying on the standard webpack sourcemaps (devtool) creates correctly formatted sourcemaps, but almost doubles the bundle size to ~1mb.
  • Your call if you'd like to merge this and have me focus on bugfixes, or if you'd like me to find a way to get minification correctly working.
new webpack.optimize.UglifyJsPlugin({
  compress: {
    warnings: false,
    // Disabled because of an issue with Uglify breaking seemingly valid code:
    // https:/facebookincubator/create-react-app/issues/2376
    // Pending further investigation:
    // https:/mishoo/UglifyJS2/issues/2011
    comparisons: false,
  },
  mangle: {
    safari10: true,
  },
  output: {
    comments: false,
    // Turned on because emoji and regex is not minified properly using default
    // https:/facebookincubator/create-react-app/issues/2488
    ascii_only: true,
  },
  sourceMap: shouldUseSourceMap,
}),

@kenhoff kenhoff self-assigned this Jun 25, 2018
@tschellenbach
Copy link
Member

UglifyJsPlugin is pretty popular, lets have a look if we can figure out what exactly is going wrong here

@kenhoff
Copy link
Contributor Author

kenhoff commented Jun 25, 2018

Okey doke, closing until I can determine why create-react-app isn't creating valid sourcemaps.

@kenhoff kenhoff closed this Jun 25, 2018
@kenhoff
Copy link
Contributor Author

kenhoff commented Jun 27, 2018

Reopening this after a few days of research, with a couple of issues to reference:

It appears that there's some combination of webpack, babel, and uglifyjs that's causing invalid sourcemaps to be emitted. Chrome is still able to use them (somehow, I'm not sure why - might just be with some slightly wrong mappings?), but sentry isn't picking up on them. The community hasn't been able to fix it yet, and I'm not able to dive deeper into this at this time.

This PR, if merged, will create valid sourcemaps at the expense of minification (~500kb bundle -> ~900kb bundle), and allow me to start cranking through the frontend errors on Sentry.

@kenhoff kenhoff reopened this Jun 27, 2018
@tschellenbach tschellenbach merged commit 753e381 into master Jun 27, 2018
@astrotars astrotars deleted the kenhoff/feat/eject branch July 3, 2018 17:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants