dspace-angular
dspace-angular copied to clipboard
Shrink size of Klaro & ban wildcard imports.
References
This PR continues to try to decrease the size of main.js.
- This PR includes the changes in #1903 (so it is smaller than it appears)
This PR decreases the GZipped size of main.js by an additional ~15KB. (on top of the ~66KB decrease of #1903, totaling a ~81KB decrease). This measurement was determined by running the following on main vs this PR:
yarn build:statswebpack-bundle-analyzer .\dist\browser\stats.json
Description
This PR updates the following:
- Bans usage of wildcard imports (except where required). This ensures these wildcard imports don't accidentally import an entire library when all we need is a few features of the library. (This change doesn't appear to have shrunk
main.jsmuch, but it's a safety measure to avoid future growth ofmain.js)- For example, this is not allowed:
import * as fs from 'fs'; - Instead, you should do something like:
import { existsSync, writeFileSync } from 'fs';
- For example, this is not allowed:
- Replaced wildcard imports where possible to do so. (For some mini-libraries this is not possible. But they are exceptions to the new rule.)
- Upgrade to latest Klaro
- Switch to importing
klaro-no-translations, which excludes the built in translations in Klaro & decreases the size of Klaro. This is because we are already translating much of Klaro in our existingsrc/assets/i18n/*.json5files. Added a few more keys to ensure all of Klaro is translated in DSpace.
Instructions for Reviewers
- Test Klaro cookie popup. Use Incognito mode to verify the Klaro popup is fully translated. Switch to a different language and verify it is still mostly translated (there may be a few English words still if the
*.json5translation pack you select is missing a few keys). - Review code changes.
@artlowel : Assigning to you for review as you volunteered to look at shrinking main.js. Please feel free to delegate if you wish.
@ybnd : I've addressed your prior feedback. If you could give this a quick rereview, I'd appreciate it!