commcare-hq icon indicating copy to clipboard operation
commcare-hq copied to clipboard

Remove hqdefine and use_js_bundler

Open orangejenny opened this issue 11 months ago • 6 comments

Technical Summary

https://dimagi.atlassian.net/browse/SAAS-17490 and https://dimagi.atlassian.net/browse/SAAS-17489

Safety Assurance

Safety story

This touches a lot of files, but it's small, systematic changes. The main risks are js in hqwebapp (which admittedly is used on virtually all pages), app manager, and web apps. I've smoke tested app manager and web apps and will put this on staging.

Marking don't merge because I'd like to let https://github.com/dimagi/commcare-hq/pull/36419 be live for a little bit before merging this (which will make it hard to roll back that PR).

Automated test coverage

No.

QA Plan

No.

Rollback instructions

  • [x] This PR can be reverted after deploy with no further considerations

Labels & Review

  • [x] Risk label is set correctly
  • [x] The set of people pinged as reviewers is appropriate for the level of risk of the change

orangejenny avatar May 22 '25 12:05 orangejenny

Not linting.

orangejenny avatar May 22 '25 12:05 orangejenny

@biyeun Can you say more about what kind of testing you'd have QA do for this? I don't think it justifies regression testing everything. The bulk of it is renames that webpack is already doing.

orangejenny avatar May 22 '25 14:05 orangejenny

Added commits to remove use_js_bundler, which I was going to do as a separate piece of cleanup, but it conflicts with the hqDefine removal so that would get annoying.

orangejenny avatar May 22 '25 17:05 orangejenny

@orangejenny who will be in charge of getting this over the finish line?

MartinRiese avatar May 23 '25 14:05 MartinRiese

@MartinRiese I can take it, assuming it goes smoothly. I'm planning to merge it the week after next (I'm offline next week, and at that point webpack on form builder, which I'm still a little nervous about, will have been live for a little bit). If any issues come up that mean it takes more time, then I might seek out someone to wrap it up.

orangejenny avatar May 23 '25 15:05 orangejenny

Added a few AMD to ESM conversions.

orangejenny avatar May 24 '25 00:05 orangejenny

Hi Jenny, I saw in some cases, hqDefine is changed to import, in other cases, hqDefine is changed to define. Wondering what is making the difference? I'm thinking if I should do the same thing for those define files: https://github.com/dimagi/commcare-hq/pull/36502

jingcheng16 avatar Jun 02 '25 14:06 jingcheng16

@jingcheng16 Good question. hqDefine is changed to a series of import statements for files that can be converted to ES6. hqDefine is converted to define for files that are not yet converted to ES6. Converting them to define just means that they're now using standard AMD syntax, and I'm removing HQ's custom hqDefine function. If you check out the diff in this PR for webpack/webpack.common.js, you'll see that in webpack files, we were already replacing any hqDefine calls with a define call.

Why didn't I just convert everything to ES6? I haven't converted cloudcare because there's some complexity there, so those files are still using AMD, and then any files that cloudcare depends on are also still on AMD.

I believe that all of the files you touched in https://github.com/dimagi/commcare-hq/pull/36502/ are being converted to ES6 in this PR.

orangejenny avatar Jun 02 '25 15:06 orangejenny

Not sure if change hqDefine to define in main.js requires us import textchange plugin explicitly. But I think we can always address it in another PR. I'll go verify it locally, later this afternoon.

jingcheng16 avatar Jun 02 '25 15:06 jingcheng16

@jingcheng16 I think textchange should be imported in whatever files use it. I'm going to merge this PR because it's enormous, but after that I can take a look at textchange.

orangejenny avatar Jun 02 '25 15:06 orangejenny