Skip to content
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

refactor(app-shell): add more code split entry points #2997

Merged
merged 5 commits into from
Mar 17, 2023
Merged

Conversation

emmenko
Copy link
Member

@emmenko emmenko commented Mar 10, 2023

Branched off #2995

Extracted from #2821

Main goal is to reduce the size of the main bundle by code splitting more components within the App Shell.

Webpack (Starter template with code splitted routes)
image

Vite (Playground with code splitted routes)
image

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2023

🦋 Changeset detected

Latest commit: bf8f0eb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 35 packages
Name Type
@commercetools-frontend/application-shell Patch
@commercetools-local/playground Patch
@commercetools-frontend/cypress Patch
@commercetools-applications/merchant-center-template-starter-typescript Patch
@commercetools-applications/merchant-center-template-starter Patch
@commercetools-backend/eslint-config-node Patch
@commercetools-backend/express Patch
@commercetools-backend/loggers Patch
@commercetools-frontend/actions-global Patch
@commercetools-frontend/application-components Patch
@commercetools-frontend/application-config Patch
@commercetools-frontend/application-shell-connectors Patch
@commercetools-frontend/assets Patch
@commercetools-frontend/babel-preset-mc-app Patch
@commercetools-frontend/browser-history Patch
@commercetools-frontend/codemod Patch
@commercetools-frontend/constants Patch
@commercetools-frontend/create-mc-app Patch
@commercetools-frontend/eslint-config-mc-app Patch
@commercetools-frontend/i18n Patch
@commercetools-frontend/jest-preset-mc-app Patch
@commercetools-frontend/jest-stylelint-runner Patch
@commercetools-frontend/l10n Patch
@commercetools-frontend/mc-dev-authentication Patch
@commercetools-frontend/mc-html-template Patch
@commercetools-frontend/mc-scripts Patch
@commercetools-frontend/notifications Patch
@commercetools-frontend/permissions Patch
@commercetools-frontend/react-notifications Patch
@commercetools-frontend/sdk Patch
@commercetools-frontend/sentry Patch
@commercetools-frontend/url-utils Patch
@commercetools-local/visual-testing-app Patch
@commercetools-website/custom-applications Patch
@commercetools-website/components-playground Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2023

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-72lgnalum-commercetools.vercel.app
https://appkit-sha-77d2134693657bbcf8fcdb178239786b0d709ef2.commercetools.vercel.app
https://appkit-pr-2997.commercetools.vercel.app

Built with commit bf8f0eb.
This pull request is being automatically deployed with vercel-action

@emmenko emmenko force-pushed the nm-props-cleanup branch 2 times, most recently from 9325e29 to 461f7ac Compare March 13, 2023 11:43
Base automatically changed from nm-props-cleanup to main March 15, 2023 10:30
@emmenko emmenko marked this pull request as ready for review March 15, 2023 10:51
@emmenko emmenko requested a review from a team March 15, 2023 10:58
@emmenko emmenko marked this pull request as draft March 15, 2023 13:19
@emmenko emmenko removed the request for review from a team March 15, 2023 13:19
Copy link
Contributor

@kark kark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙌

Comment on lines +2 to +3
'@commercetools-frontend/application-shell': patch
'@commercetools-local/playground': patch
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think our template packages are missing

Copy link
Contributor

@Rhotimee Rhotimee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏽👏🏽

<RestrictedApplication
</SuspendedRoute>
<SuspendedRoute>
<ApplicationShellAuthenticated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I think this is a great idea.

However, I would also share some thoughts about lazy loading component with a very high chance of been rendered as this ApplicationShellAuthenticated, or project and locale switchers. By moving them out from the initial bundle, we are introducing a delay in the user experience since now they will need to be fetched when React detects it needs them.

Maybe the latency for a backoffice application is not such a high requirement because most users will have a wired internet connection, but just wanted to share some concerns I had in the past when using lazy loading too much.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Yes some parts might have a slight delay now. The <ApplicationShellAuthenticated> is only rendered if the user is authenticated so I think we can try code splitting it.

In general we can observe the loading behavior / performance and make further adjustments along the way.

Regarding the switcher components, you're right they probably don't need to be code splitted. Let me revert that part.

Copy link
Contributor

@ddouglasz ddouglasz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

@emmenko emmenko merged commit 4e79621 into main Mar 17, 2023
@emmenko emmenko deleted the nm-more-code-split branch March 17, 2023 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants