[FOLIO-943] Add --sourcemap setting to stripes build in blackbox builds Created: 20/Nov/17  Updated: 12/Nov/18  Resolved: 22/Nov/17

Status: Closed
Project: FOLIO
Components: Continuous Integration
Affects versions: None
Fix versions: None

Type: Task Priority: P2
Reporter: Wayne Schneider Assignee: Wayne Schneider
Resolution: Done Votes: 0
Labels: ci, sprint27
Remaining Estimate: Not Specified
Time Spent: 1 hour, 30 minutes
Original estimate: Not Specified

Issue links:
Relates
relates to STCOR-64 Source map option for static builds Closed
Sprint:

 Comments   
Comment by Matthew Jones [ 21/Nov/17 ]

While updating the build command to include --sourcemap, we may also want to set the environment variable NODE_ENV=production if we're not doing so already.

NODE_ENV=production stripes build stripes.config.js output --sourcemap

This will keep React from running in development mode.

Comment by Mike Taylor [ 21/Nov/17 ]

What is the effect of that, Matt?

Comment by Matthew Jones [ 21/Nov/17 ]

React will do things a bit differently when running in "production" mode, supposedly making the UI render faster. Since re-enabling minification ( STRIPES-102 Closed ) along with the STCOR-64 Closed sourcemap PR, React now logs a warning about not being in production mode while minified.

"Warning: It looks like you're using a minified copy of the development build of React. When deploying React apps to production, make sure to use the production build which skips development warnings and is faster. See https://fb.me/react-minification for more details."

Redux has similar behavior and warning:

"You are currently using minified code outside of NODE_ENV === 'production'. This means that you are running a slower development build of Redux. You can use loose-envify (https://github.com/zertosh/loose-envify) for browserify or DefinePlugin for webpack (http://stackoverflow.com/questions/30030031) to ensure you have the correct code for your production build."

I updated stripes-core in the same PR to include Webpack's EnvironmentPlugin. This enables us to tell React and Redux to operate in production mode. This is done by setting the NODE_ENV environment variable to "production". Webpack will also trim out unused code as a result, making the build slightly smaller.

As a trade-off, we also lose some of React's development logging while in production mode. Therefore, I suppose it really comes down to the target audience for a given build if we want to maintain the React dev logging or better performance.

Comment by Mike Taylor [ 21/Nov/17 ]

My take is that, at present at least, folio-testing is essentially part of the development process – at least, lots of bugs first manifest there (sometimes in ways that can't be reproduced on development boxes) and need to be tracked down. So I think minification and suchlike would not be appropriate. (For folio-demo they would be, of course.)

Comment by Matthew Jones [ 21/Nov/17 ]

With source maps available, minification should be okay. There could be issues resulting from minification and it would be good to catch them early. I agree the added logging in folio-testing would be helpful to keep. Then we only need to add --sourcemap as originally requested.

Comment by Wayne Schneider [ 21/Nov/17 ]

OK, this has been added to the Ansible role for building Stripes. It should appear in folio-testing tomorrow. Thanks, Matthew Jones!

Comment by Wayne Schneider [ 22/Nov/17 ]

Source maps are now available on the Vagrant boxes folio/testing and folio/snapshot, but for some reason not on folio-testing.aws.indexdata.com.

Comment by Matthew Jones [ 22/Nov/17 ]

Wayne Schneider I am seeing the sourcemaps on folio-testing.aws.indexdata.com. Any chance you have a cached copy in your browser?

Comment by Mike Taylor [ 22/Nov/17 ]

Working perfectly for me! Many thanks, Wayne. (I'm just sorry you don't seem to be getting the benefit of your own work!)

Comment by Wayne Schneider [ 22/Nov/17 ]

Turns out it was a yarn version issue on folio-testing, now resolved.

Generated at Thu Feb 08 23:09:27 UTC 2024 using Jira 1001.0.0-SNAPSHOT#100246-sha1:7a5c50119eb0633d306e14180817ddef5e80c75d.