-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Cache busting for icons & language files #8710
Conversation
otherwise react-sdk can't build anymore with riot-web in a specific location
…the unit tests in ci, where riot-web is a subdirectory of react-sdk
900e603
to
c2d1439
Compare
unit tests on react sdk are currently broken... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall, this looks great! 😁 I am excited to see this merge.
webpack.config.js
Outdated
// riot-web/webapp/i18n during build by copy-res.js | ||
test: /\.*languages.json$/, | ||
type: "javascript/auto", | ||
use: [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there's only one loader for this test, you should be able to remove the use: [ ]
part and fold the loader
and options
keys into the main object (see .wasm
as an example).
scripts/copy-res.js
Outdated
fs.writeFileSync(dest + lang + '.json', JSON.stringify(translations, null, 4)); | ||
const json = JSON.stringify(translations, null, 4); | ||
const jsonBuffer = Buffer.from(json); | ||
const digest = loaderUtils.getHashDigest(jsonBuffer, "sha512", "base64", 7); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think base64
includes /
, which could get weird for things in file paths. Also, I'm not sure how much it actually impacts build time, but sha512
seems like overkill for this problem... We really only need the simplest thing that gives a different value when the file changes. (Also we're only keeping 7 bytes of it, so powerful hashes like sha512
are mostly doing work that is thrown out.)
For images via Webpack we're currently using [hash:7]
, which seems to equate to getHashDigest(buffer, null, null, 7)
, which will then default to md5
and hex
, which seems fast, safe, and sufficient for the problem here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, this looks ready to go! Thanks for working on this. It should be quite helpful! 😁
Can this/should this be applied to config.json as well? #7241 |
Hmm, I don't think we can use the same approach for config.json, as it's not part of Riot's build process. I don't think we would want to entangle it in the build process either, as people might use other configuration management systems (Ansible, etc.) to produce and manage the file. |
React-SDK PR: matrix-org/matrix-react-sdk#2658
For i18n, I changed the copy-res.js script to generate content-hashed filenames and include those in languages.json, which then gets a content-hashed filename with file-loader.
Fixes #4136