-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Consolidate webasset bundle to single chunks #38706
Conversation
1a4899b
to
c6317dc
Compare
Updated with some loom videos showing it work/not-work Please help me break this! |
I did toy with the idea of keeping the hashing for |
|
web/packages/build/vite/config.ts
Outdated
// This removes code splitting. | ||
inlineDynamicImports: true, |
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.
Can we remove React.lazy
and all the default exports instead? Otherwise we're wrapping the loading of all route components in a promise for no reason
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.
Removed react lazy on everything except access graph/assist. Was getting really weird "React Markdown" errors unless it was lazy loaded. like 40+ of them during testing. I'll keep inspecting but for now, every other lazy is removed
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.
We could something like with manualChunks
to programmatically choose which chunks are split and remove hashing that way for those specifically, or we can keep this line to handle the assist/access graph and call it a day. I dont know much about assist's internals I think to know what to chunk out
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.
e update if we stick with these changes https://github.com/gravitational/teleport.e/pull/3566
Another loom of a "upgrade in process" with multiple sessions. There was an error that showed up but its because my second proxy couldn't reach the auth server (which is running with my first proxy) during an upgrade but thats not related to my webassets https://www.loom.com/share/1cd8dd618b054b63ac2462387ba32b07 |
ff4b1ee
to
5fc46ed
Compare
Another way to help review this is to build the UI and just poke around to make sure everything works still. I made large changes to imports of features and while I tried to check most it'd be nice to have another set of eyes to check for regressions |
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.
The linked-to RFD is still open, and this change appears to be talked about as an aside at the end. Was it decided somewhere that this is the approach that we're going with? If yes, have we characterized the performance impact?
web/packages/build/vite/config.ts
Outdated
@@ -69,6 +69,18 @@ export function createViteConfig( | |||
outDir: outputDirectory, | |||
assetsDir: 'app', | |||
emptyOutDir: true, | |||
rollupOptions: { | |||
output: { | |||
// This removes code splitting. |
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.
// This removes code splitting. | |
// This prevents code splitting. |
web/packages/build/vite/config.ts
Outdated
// this will remove hashing from asset (non-js) files. We will keep the javascript file | ||
// hashed in order to avoid a cache issue between versions. `no-cache` headers are set | ||
// for our html file |
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.
We will keep the javascript file hashed
doesn't this contradict the previous comment of
removes hashing from our entry point file
?
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.
sorry, an older version and I left the comments in. thanks
@@ -16,5 +16,4 @@ | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
|
|||
// export as default for use with React.lazy | |||
export { AwsOidc as default } from './AwsOidc'; |
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.
Why are we keeping this one?
@@ -16,5 +16,4 @@ | |||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
*/ | |||
|
|||
// export as default for use with React.lazy | |||
export { LockCheckout as default } from './LockCheckout'; |
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.
And this one?
import LoginFailed from './Login/LoginFailed'; | ||
import LoginSuccess from './Login/LoginSuccess'; | ||
import Login from './Login'; | ||
import Welcome from './Welcome'; | ||
|
||
import type { History } from 'history'; | ||
import Console from './Console'; | ||
import Player from './Player'; | ||
import DesktopSession from './DesktopSession'; |
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.
These are all default exports
import TrustedClusters from './TrustedClusters'; | ||
export default TrustedClusters; | ||
export { TrustedClusters }; |
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.
Can we use this PR to clean these up all the way through to the component?
That way we can have a consistent
export { TrustedClusters } from './TrustedClusters';
I know it's slightly increasing the scope of this PR, but we'd never get round to the cleanup otherwise
Feel free to ignore
import Account from './Account'; | ||
import Support from './Support'; |
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.
Still default
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.
Approving as it LGTM, pending the last default export changes
10bf931
to
0159477
Compare
This will prevent the react bundle from being code split. This means that our entire javascript bundle will be a single file as well as our css file. It also removes hashing from the included webassets. The reason for this change is to allow different versioned proxies to coexist behind a load balancer. If we remove code splitting, then the only time our bundle will load is on initial hit, and the web client will then have the entire bundle. This also removes React.lazy. React.lazy wrapped components in a promise to allow for dynamic imports during runtime. This is no longer needed. Lastly, to clean up the default exports used by react lazy, this removes (most) default exports for feature components. Assist and telemetry-boot are not included in the javascript bundle
0159477
to
82d1a4e
Compare
This will prevent the react bundle from being code split. This means that our entire javascript bundle will be a single file as well as our css file. It also removes hashing from the included webassets. The reason for this change is to allow different versioned proxies to coexist behind a load balancer. If we remove code splitting, then the only time our bundle will load is on initial hit, and the web client will then have the entire bundle. This also removes React.lazy. React.lazy wrapped components in a promise to allow for dynamic imports during runtime. This is no longer needed. Lastly, to clean up the default exports used by react lazy, this removes (most) default exports for feature components. Assist and telemetry-boot are not included in the javascript bundle
* Prevent code splitting (#38706) This will prevent the react bundle from being code split. This means that our entire javascript bundle will be a single file as well as our css file. It also removes hashing from the included webassets. The reason for this change is to allow different versioned proxies to coexist behind a load balancer. If we remove code splitting, then the only time our bundle will load is on initial hit, and the web client will then have the entire bundle. This also removes React.lazy. React.lazy wrapped components in a promise to allow for dynamic imports during runtime. This is no longer needed. Lastly, to clean up the default exports used by react lazy, this removes (most) default exports for feature components. Assist and telemetry-boot are not included in the javascript bundle * Fix the import on the account settings page (#39015) * Fix auth connector imports (#39019) * Init discover resources inside the discover component (#39166) * Use ETag headers for served javascript files (#39251) --------- Co-authored-by: Bartosz Leper <[email protected]>
Refer to the "Why" section of this RFD for info on the issue solved with this PR.
This PR will configure vite to pipe all code chunks together. So techincally, this isn't removing code splitting, but in reality just not splitting the code. The benefits of this way are
This ignores fonts/images/wasm, and only affects javascript and css files. We will now have a single javascript and css file load on initial page load. This will increase latency slightly as there is a larger file to download but it will remove any other network requests for javascript files after (since it has the entire bundle) and usually the javascript file and css file will be cached by the browser anyway so this initial latency increase should only happen once per version (or however their browser may be set up).
Quick loom videos showing the error and fix
https://www.loom.com/share/bcae5d79b14a4e6e8df8e0603ace0f04
https://www.loom.com/share/2ce5386941c849dca6a142089d927aa3