Skip to content
This repository has been archived by the owner. It is now read-only.

fix(build): Ensure revs/filenames are correctly created. #4210

Merged
merged 2 commits into from Sep 30, 2016

Conversation

@shane-tomlinson
Copy link
Member

@shane-tomlinson shane-tomlinson commented Sep 29, 2016

Also contains #4186.

The main CSS and JS bundle reference URLs to other static resources that
are themselves revved. We erroneously revved the main CSS and JS bundle
before updating the referenced URLs with the revved variants and
updating the JS bundle with SRI hashes. This led to files across two
trains having different content but the same filename.

Instead, we do a two phase approach to revving/SRI hash generation:

  1. rev all the leaf node resources. Update references in the main JS and
    CSS bundle. Generate SRI hashes for revved JS. Insert SRI values into
    main JS bundle.
  2. rev the resources with dependencies. Generate SRI hash for the main
    JS bundle. Update URL references in the HTML. Update SRI values in
    the HTML.

fixes #4189

@shane-tomlinson
Copy link
Member Author

@shane-tomlinson shane-tomlinson commented Sep 29, 2016

@jrgm, @jbuck - I think this'll make you both happy:

➜  scripts git:(issue-4189-fix-the-md5s) md5 4367e7e8.main.js
MD5 (4367e7e8.main.js) = 4367e7e80eb4ac144f82ed9dda86312f
➜  scripts git:(issue-4189-fix-the-md5s) md5 bb8c4e04.head.js
MD5 (bb8c4e04.head.js) = bb8c4e04a4d7bd12925aad4f21624cea
➜  scripts git:(issue-4189-fix-the-md5s) cd ../styles
➜  styles git:(issue-4189-fix-the-md5s) md5 8ed64f83.ar.css
MD5 (8ed64f83.ar.css) = 8ed64f83cfda717bf93cc4368d1cac63
➜  styles git:(issue-4189-fix-the-md5s) md5 abdc5d6d.de.css
MD5 (abdc5d6d.de.css) = abdc5d6d63149a9d4a6f000613897ed9
➜  styles git:(issue-4189-fix-the-md5s) md5 b74c6b69.az.css
MD5 (b74c6b69.az.css) = b74c6b69bd2d38e6b81cdaf7a1d59bb2
@shane-tomlinson shane-tomlinson force-pushed the issue-4189-fix-the-md5s branch from 243b392 to 585f8f3 Sep 29, 2016
Shane Tomlinson added 2 commits Sep 23, 2016
No need to copy over jquery-ui, fxa-checkbox, and styles/fonts to dist.

These JS resources are included into the built bundle and not loaded
dynamically. There is no need to copy these over.

Remove jquery-ui from the rev task.

issue #4177
The main CSS and JS bundle reference URLs to other static resources that
are themselves revved. We erroneously revved the main CSS and JS bundle
before updating the referenced URLs with the revved variants and
updating the JS bundle with SRI hashes. This led to files across two
trains having different content but the same filename.

Instead, we do a two phase approach to revving/SRI hash generation:

1) rev all the leaf node resources. Update references in the main JS and
   CSS bundle. Generate SRI hashes for revved JS. Insert SRI values into
   main JS bundle.
2) rev the resources with dependencies. Generate SRI hash for the main
   JS bundle. Update URL references in the HTML. Update SRI values in
   the HTML.

fixes #4189
@shane-tomlinson shane-tomlinson force-pushed the issue-4189-fix-the-md5s branch from 585f8f3 to f5aa7bc Sep 29, 2016
@shane-tomlinson
Copy link
Member Author

@shane-tomlinson shane-tomlinson commented Sep 29, 2016

@jbuck
jbuck approved these changes Sep 29, 2016
Copy link
Member

@jbuck jbuck left a comment

I compared train-69-dist currently on prod with this patch and got the following results:

  • The 5xx.html files would be overwritten, but that's alright because they're not used on the CDN
  • The i18n json files would be overwritten, but that's alright because they tend to be additive in nature. We're going to look at making them unique in #4113
  • The Google Play Store buttons would be overwritten, but they're not SRI-hashed and I think the worst-case scenario is that they looked stretched until the CDN is cleared
  • main.js and main.js.map would be overwritten, but only sentry accesses these so it's fine. But we should stop shipping these to dist eventually.

🎉 🎉

// different revs of the file with different contents
// can have the same name because the rev was created before
// internal URLs were updated.
with_children: { //eslint-disable-line camelcase

This comment has been minimized.

@vladikoff

vladikoff Sep 30, 2016
Contributor

👍

@vladikoff vladikoff merged commit 6338a82 into master Sep 30, 2016
4 checks passed
4 checks passed
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 94.956%
Details
@vladikoff vladikoff deleted the issue-4189-fix-the-md5s branch Sep 30, 2016
@rfk rfk added this to the FxA-0: quality milestone Oct 10, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

5 participants