Skip to content

Conversation

@chmelevskij
Copy link
Member

@chmelevskij chmelevskij commented Mar 1, 2021

Moving more parts to esm. Jus realised that main.js works with all the global stuff. So idea is to move it first and then move on tab basis

@chmelevskij chmelevskij changed the title chore: move injecte_methods to modules Move main.js to modules and help tab Mar 1, 2021
break;
case 'help':
TABS.help.initialize(content_ready);
import('./tabs/help').then(({ help }) => help.initialize(content_ready));
Copy link
Member Author

Choose a reason for hiding this comment

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

Idea is to move the rest of the tabs to this usage. This way every tab and it's dependencies will be migrated one by one. Eventually leaving single main.js as entry point and removing the global variables.

Copy link
Member

Choose a reason for hiding this comment

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

Ok. It seems a little strange to me but I don't have experience enough to know if this is the best way or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tried few different approaches. All of them are hard, because there was no clear separation on how to do it incrementally. This approach with TABS being the separation point is the most straightforwards.

we could definitely change the way tabs are exported and handled. That will be the next step. Didn't wan't to change a that because there are so many tabs already, and testing/reviewing a lot of changes will be hard enough already, there are a lot of other small things which have to be resolved. Like circular dependencies and random global variables.

Copy link
Member

Choose a reason for hiding this comment

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

The approach to do the conversion step-by-step in this way seems reasonable.

What is the reason you chose to import the tabs here, instead of importing all of them at the top of the file, and just initialising them here?

@chmelevskij chmelevskij mentioned this pull request Mar 2, 2021
5 tasks
Copy link
Member

@McGiverGim McGiverGim left a comment

Choose a reason for hiding this comment

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

It seems a correct approach to me. Only one suggestion to discuss about moving to the end of the file the window declarations.

break;
case 'help':
TABS.help.initialize(content_ready);
import('./tabs/help').then(({ help }) => help.initialize(content_ready));
Copy link
Member

Choose a reason for hiding this comment

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

Ok. It seems a little strange to me but I don't have experience enough to know if this is the best way or not.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@chmelevskij chmelevskij requested a review from McGiverGim March 13, 2021 05:49
Copy link
Member

@McGiverGim McGiverGim left a comment

Choose a reason for hiding this comment

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

Seems ok to me!

break;
case 'help':
TABS.help.initialize(content_ready);
import('./tabs/help').then(({ help }) => help.initialize(content_ready));
Copy link
Member

Choose a reason for hiding this comment

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

The approach to do the conversion step-by-step in this way seems reasonable.

What is the reason you chose to import the tabs here, instead of importing all of them at the top of the file, and just initialising them here?

@chmelevskij
Copy link
Member Author

What is the reason you chose to import the tabs here, instead of importing all of them at the top of the file, and just initialising them here?

Could probably go that route as well tbh. Usually this would improve the performance a bit, since we wouldn't load all the js, but it's a desktop app. But even for desktop app, I think it would make more sense to initialize and load them dynamically. rather than loading all of the code all at once.

@mikeller
Copy link
Member

Fair enough, we are trading off maintainability for loading time here.

@mikeller mikeller merged commit e84666e into betaflight:master Mar 16, 2021
@mikeller mikeller added this to the 10.8.0 milestone Mar 16, 2021
@chmelevskij
Copy link
Member Author

we are trading off maintainability for loading time here.

It's not like it got worse 😆

@mikeller
Copy link
Member

@chmelevskij:

It's not like it got worse 

That's exactly how you end up with codebases that are rubbish in the first place...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants