betaflight-configurator icon indicating copy to clipboard operation
betaflight-configurator copied to clipboard

RFC: Moving to ESM modules

Open chmelevskij opened this issue 3 years ago • 3 comments

Current configurator setup relies heavily on globally defined classes, functions, helpers etc. Currently it's all dependant on the order of script tags, which can be brittle and is hard to just jump in. But it runs in an environment which supports native esm modules. With minimal bundling needed. Also the build step involves copying and re-installing packages, which takes time.

My proposal is to move the whole application to ESM modules, enabling for better modularity and eventually improving build speeds. Even moving to tools like vitejs to have instantaneous development experience.

There was small PRs with this change, but general idea is to do what has been done in #2430 with the help tab. Where main.js will be module, and every tab will be migrated one by one, to use import() and have exported required variables.

Any global variable, function or other code, which should be part of the module, will be bolted on to window.<export> at the end of the file, but only if it doesn't make sense to just convert whole file/part to module.

Some high level tasks:

  • [ ] move main.js to modules
  • [ ] move every tab to modules, keeping the old globals attached to window where necessary.
  • [ ] resolve all the circular dependencies.
  • [ ] rethink tab cleanup logic, currently which relies on global TABS
  • [ ] fix reliance on global values, make everything imported.

chmelevskij avatar Mar 02 '21 05:03 chmelevskij

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs within a week.

github-actions[bot] avatar Apr 13 '21 04:04 github-actions[bot]

Go away bot 😄 I'm working on it

chmelevskij avatar Apr 13 '21 06:04 chmelevskij

Pinned! ;)

McGiverGim avatar Apr 13 '21 07:04 McGiverGim

@chmelevskij is this done already :stuck_out_tongue:

haslinghuis avatar May 15 '24 17:05 haslinghuis