Skip to content

Commit 2606826

Browse files
authored
refactor: Fix fast refresh invalidations (#1150)
Fixes #727 as best we can w/o requiring major changes. HMR works best w/ functional components and that's too big of a change to switch everything to functional components just for HMR. Added an eslint rule which will warn about things that will almost certainly invalidate HMR. Fixed the warnings it emitted. Tested locally by changing some displayed text values in some panels and seeing if the page triggered a full reload. I didn't have any specific files/cases that triggered full reloads previously and it seems Vite 4 has made it better on its own. If we start running into cases. Saving `GridRenderer` doesn't trigger a full page reload (didn't before either), but massively slows the page (also had this behavior prior to this change). The change eventually propagates and refreshes We should keep an eye on vitejs/vite#12062 which will likely also fix the slow HMR issues on some components. There seems to be duplication of modules in the update list and it can explode at times (like GridRenderer triggers 14 unique modules, but 20k updates consisting of just those 14) BREAKING CHANGE: Renamed `renderFileListItem` to `FileListItem`. Renamed `RenderFileListItemProps` to `FileListItemProps`. Removed exports for `ConsolePlugin.assertIsConsolePluginProps`, `GridPlugin.SUPPORTED_TYPES`, `FileList.getPathFromItem`, `FileList.DRAG_HOVER_TIMEOUT`, `FileList.getItemIcon`, `Grid.directionForKey`, `GotoRow.isIrisGridProxyModel`, and `Aggregations.SELECTABLE_OPTIONS`. These were all only being consumed within their own file and are not consumed in enterprise
1 parent 362928f commit 2606826

53 files changed

Lines changed: 392 additions & 304 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package-lock.json

Lines changed: 18 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/code-studio/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import logInit from './log/LogInit';
88

99
logInit();
1010

11+
// eslint-disable-next-line react-refresh/only-export-components
1112
const AppRoot = React.lazy(() => import('./AppRoot'));
1213

1314
ReactDOM.render(

packages/code-studio/src/main/AppInit.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ const mapStateToProps = (state: RootState) => ({
377377
workspaceStorage: getWorkspaceStorage(state),
378378
});
379379

380-
export default connect(mapStateToProps, {
380+
const ConnectedAppInit = connect(mapStateToProps, {
381381
setActiveTool: setActiveToolAction,
382382
setCommandHistoryStorage: setCommandHistoryStorageAction,
383383
setDashboardData: setDashboardDataAction,
@@ -391,3 +391,5 @@ export default connect(mapStateToProps, {
391391
setWorkspaceStorage: setWorkspaceStorageAction,
392392
setServerConfigValues: setServerConfigValuesAction,
393393
})(AppInit);
394+
395+
export default ConnectedAppInit;

packages/code-studio/src/main/AppMainContainer.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,8 +904,10 @@ const mapStateToProps = (state: RootState) => ({
904904
serverConfigValues: getServerConfigValues(state),
905905
});
906906

907-
export default connect(mapStateToProps, {
907+
const ConnectedAppMainContainer = connect(mapStateToProps, {
908908
setActiveTool: setActiveToolAction,
909909
updateDashboardData: updateDashboardDataAction,
910910
updateWorkspaceData: updateWorkspaceDataAction,
911911
})(withRouter(AppMainContainer));
912+
913+
export default ConnectedAppMainContainer;

packages/code-studio/src/settings/ColumnSpecificSectionContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,8 @@ const mapStateToProps = (state: RootState) => ({
644644
settings: getSettings(state),
645645
});
646646

647-
export default connect(mapStateToProps, { saveSettings: saveSettingsAction })(
648-
ColumnSpecificSectionContent
649-
);
647+
const ConnectedColumnSpecificSectionContent = connect(mapStateToProps, {
648+
saveSettings: saveSettingsAction,
649+
})(ColumnSpecificSectionContent);
650+
651+
export default ConnectedColumnSpecificSectionContent;

packages/code-studio/src/settings/FormattingSectionContent.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,8 @@ const mapStateToProps = (state: RootState) => ({
631631
settings: getSettings(state),
632632
});
633633

634-
export default connect(mapStateToProps, { saveSettings: saveSettingsAction })(
635-
FormattingSectionContent
636-
);
634+
const ConnectedFormattingSectionContent = connect(mapStateToProps, {
635+
saveSettings: saveSettingsAction,
636+
})(FormattingSectionContent);
637+
638+
export default ConnectedFormattingSectionContent;

packages/code-studio/src/settings/ShortcutsSectionContent.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,9 @@ const mapStateToProps = (state: RootState) => ({
143143

144144
const mapDispatchToProps = { saveSettings: saveSettingsAction };
145145

146-
export default connect(
146+
const ConnectedShortcutSectionContent = connect(
147147
mapStateToProps,
148148
mapDispatchToProps
149149
)(ShortcutSectionContent);
150+
151+
export default ConnectedShortcutSectionContent;

packages/code-studio/src/styleguide/StyleGuideInit.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ const mapStateToProps = (state: RootState) => ({
4444
workspace: getWorkspace(state),
4545
});
4646

47-
export default connect(mapStateToProps, {
47+
const ConnectedStyleGuideInit = connect(mapStateToProps, {
4848
setWorkspace: setWorkspaceAction,
4949
})(StyleGuideInit);
50+
51+
export default ConnectedStyleGuideInit;

packages/code-studio/src/styleguide/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import logInit from '../log/LogInit';
88

99
logInit();
1010

11+
// eslint-disable-next-line react-refresh/only-export-components
1112
const StyleGuideRoot = React.lazy(() => import('./StyleGuideRoot'));
1213

1314
ReactDOM.render(

packages/components/src/DateTimeInput.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
33
import userEvent from '@testing-library/user-event';
4-
import DateTimeInput, { addSeparators } from './DateTimeInput';
4+
import DateTimeInput from './DateTimeInput';
5+
import { addSeparators } from './DateTimeInputUtils';
56

67
const DEFAULT_DATE_TIME = '2022-02-22 00:00:00.000000000';
78
// Zero width space

0 commit comments

Comments
 (0)