Remove regex-based JS/HTML rewriting, switch to AST-based rewriting
See original GitHub issueAST-based JS/HTML rewriting is available as an experimental feature with https://github.com/cypress-io/cypress/pull/5273
Here are the remaining tasks before it can fully replace the existing regex-based rewriting:
- Validation with users - is it solving the issues we set out to fix?
- (2) Rewrite all traffic (currently, only AUT’s current origin is intercepted)
- may require inlining
resolvers.ts
- may require inlining
- (3) Do https://github.com/cypress-io/cypress/issues/7268 or have it be fixed by inlining
resolvers.ts
- or else rewriting will break if a user visits an http:// url that redirects to https://
- (4) Inject HTML via
parse5
instead of regex. - (4) Resolve issue where proxy will no longer work for normal web browsing outside of Cypress frame. Possible solution: inject a stub
window.Cypress.resolveWindowReference
into every html page here: https://github.com/cypress-io/cypress/blob/2ed56949cb14b4630ca11ec8c4cda715aa9bfa26/packages/server/lib/util/inject.js#L1-L28 - (4) Performance measurements:
- difference between rewriting with sourcemap and without
- comparison to regex-based rewriting
- (4) Performance improvements:
- improve speed: add streaming parsing/rewriting of JS (parse5 handles rewriting HTML as a stream)
- mem usage: explore caching js in deferred-sourcemap-cache on filesystem
- understand how sourcemaps are cached in browser and how we can reduce unnecessary regeneration/not store old sourcemaps in RAM
- (4) Add comments around injected code to help users understand - potentially include original code in a comment
- (1) Need a real fix for Electron worker_threads https://github.com/electron/electron/issues/23366
- (4) Fix all code TODOs from original PR: https://github.com/cypress-io/cypress/pull/5273
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Experiments | Cypress Documentation
Enables AST-based JS/HTML rewriting. This may fix issues caused by the existing regex-based JS/HTML replacement algorithm. See #5273 for details.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
4.8.0 looking good 👍
@drumbeg yeah, just merged that PR; it may fix the issue for you once released