pywb
pywb copied to clipboard
Add JS module detection rewriting
Description
This PR modifies pywb to detect and rewrite JS modules. Global overrides are imported in modules via a new _wb_module_decl.js static file.
This also bumps wombat to 3.4.2.
Motivation and Context
JavaScript modules were previously not detected, which caused errors in replay for sites that use them.
Types of changes
- [X] Replay fix (fixes a replay specific issue)
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
Checklist:
- [ ] My change requires a change to the documentation.
- [ ] I have updated the documentation accordingly.
- [ ] I have added or updated tests to cover my changes.
- [X] All new and existing tests passed.
I tested this on a site we've been handling trouble with (https://www.aucyberexplorer.com.au/). Unfortunately this site uses JavaScript modules that don't start with import or export so the is_module check doesn't trigger. It looks like wabac.js handles this problem by introducing a new esm_ modifier so the detection is based on the context in the referencing page rather than the contents of the script file alone.