-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: better CSS parsing #21978
feat: better CSS parsing #21978
Conversation
--- /dev/null | ||
+++ b/es/rrweb/packages/rrweb-snapshot/es/css.js | ||
@@ -0,0 +1,87 @@ | ||
+import postcss from '../../../../../../../../../postcss/lib/postcss.js' |
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.
Directory is after the patch is applied e.g. node_modules/.pnpm/rrweb@2.0.0-alpha.13_patch_hash=6bgnomayryopibyfydha2z5wbi/node_modules/rrweb/es/rrweb/packages/rrweb-snapshot/es
patches/rrweb@2.0.0-alpha.13.patch
Outdated
- whitespace(); | ||
- while (css[0] == '}') { | ||
- error('extra closing bracket'); | ||
- css = css.slice(1); | ||
- whitespace(); | ||
- } | ||
- const m = match(/^(("(?:\\"|[^"])*"|'(?:\\'|[^'])*'|[^{])+)/); | ||
+ const m = match(/^([^{]+)/); |
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.
Diff gets a little funky here because we are removing a previously applied patch
patches/rrweb@2.0.0-alpha.13.patch
Outdated
} | ||
|
||
-const commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; | ||
-function parse(css, options = {}) { |
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.
Removes all the old ast generation code because of a naming clash
This is huge, hopefully its a smooth patch 😅 |
87a5c0b
to
a756743
Compare
@marandaneto I got scared 🙈 added a try / catch with the existing code that it should fall back to in production. Going to ship once 🍏 |
Very clever 🚀 |
Change is live and everything works as expected 🙌 |
Problem
Towards #18520
Changes
postcss
node module inposthog
and reference code from within a patch applied to therrweb
packageDoes this work well for both Cloud and self-hosted?
Yes
How did you test this code?
postcss
is tree shaken in production and cannot be accessed 🤔