-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
chore: Don't duplicate the URL parsing Regexes #34788
Conversation
WalkthroughThis update optimizes the Changes
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
/build-deploy-preview skip-tests=true |
Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9850343078. |
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- app/client/src/ce/utils/serviceWorkerUtils.test.ts (12 hunks)
- app/client/src/ce/utils/serviceWorkerUtils.ts (1 hunks)
Files skipped from review due to trivial changes (2)
- app/client/src/ce/utils/serviceWorkerUtils.test.ts
- app/client/src/ce/utils/serviceWorkerUtils.ts
@sharat87 Can you also create a EE test PR also for these change? Last time when I tried importing the regexes from appRoutes there were some issues in the build. I would like to do a manual test before we merge. |
Deploy-Preview-URL: https://ce-34788.dp.appsmith.com |
@@ -2,13 +2,14 @@ import { Mutex } from "async-mutex"; | |||
import { APP_MODE } from "entities/App"; |
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.
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.
@riodeuno, I suspected that too. I think it's quite likely as well. But from the code, it looks like we're mostly importing constant strings, both into application code and service worker code, so I think this is okay. I'd rather constants are imported from a single source for both. It'll mean they'll effectively be downloaded twice, once for application and once for service worker, but I think this is okay. Especially since we need the constant value in service worker code, so might as well import from a common source.
I don't know enough to be sure about the above though, so I'd invite more opinions on this. 🙏
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.
Agreed.
We can run yarn analyze
and see what it looks like.
Looking at it without analyzing it --
The only thing that comes to mind is that the serviceworker js file is created at build time, once generated there shouldn't be any ramifications on the chunks for our codebase. Based on this, this change is fine.
It could be that service worker utils are chunked along with our main app codebase. We're talking about ~250 LoC. The trade-off here is code structure that allows for better maintainability and fewer side effects vs saving the minified version of ~250 lines of unminified code from being downloaded in the chunk. I'm happy to trade in favour of better code structure.
@dvj1988 I too am looking for your opinion on this.
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.
Actually, scratch that. I'm fairly certain that serviceworkerutils would not get into our main codebase chunks. As we would not be importing this utils file for anything in our codebase. Approving this PR.
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 the constants that are imported are duplicated in both the service worker bundle as well as the main bundle. There is a minor duplication of code in the bundle but as you guys have mentioned it better to have a single source of truth.
This is from https://ce-34788.dp.appsmith.com/pageService.js
This is from https://ce-34788.dp.appsmith.com/static/js/main.46d3445c.js
I believe the reason why we have duplication is because, the two bundles are generated as 2 different entry points in weback and the chunks generated in one entry point is not reused in another.
Also if you check the service worker we can see chunk details of the main bundle being injected into the service worker. So that means the service worker is bundled after the main bundle chunks are created.
Thanks @dvj1988 for the heads-up. Indeed there was a failure, and I fixed it in this EE PR: https://github.com/appsmithorg/appsmith-ee/pull/4565. |
Please give me time to manually test both ce and ee DPs today. |
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.
LGTM.
This code duplication meant that we missed updating the regexes to the ones that support UUIDs, and so the caching functionality broke. This PR removes the duplication and imports the regex constants from a single place. /test sanity <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/9850040595> > Commit: d8261a1 > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9850040595&attempt=1" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Sanity` > Spec: > <hr>Tue, 09 Jul 2024 03:00:41 UTC <!-- end of auto-generated comment: Cypress test results --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Refactor** - Improved maintainability by importing path constants from a centralized location. - Replaced hardcoded `pageId` and `applicationId` with variables for better code clarity and flexibility. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This code duplication meant that we missed updating the regexes to the ones that support UUIDs, and so the caching functionality broke.
This PR removes the duplication and imports the regex constants from a single place.
/test sanity
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9850040595
Commit: d8261a1
Cypress dashboard.
Tags:
@tag.Sanity
Spec:
Tue, 09 Jul 2024 03:00:41 UTC
Summary by CodeRabbit
pageId
andapplicationId
with variables for better code clarity and flexibility.