Skip to content
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

Devbuild on esbuild #8774

Merged
merged 6 commits into from
Feb 1, 2022
Merged

Devbuild on esbuild #8774

merged 6 commits into from
Feb 1, 2022

Conversation

mbrzakovic
Copy link
Collaborator

Switched devbuild from rollup to esbuild.

  • Reasoning: Faster dev build (now: 0.3s, was: 12s)

Added start:watch command.
Minor change to start command (now runs only build:dev). start:extended now runs build.

This should speed up development process.

I thought about switching build:legacy to esbuild too, however esbuild does not support lowering to es5 which is needed to support IE users (~1.3% of desktop browser users use IE according to statcounter).

@mbrzakovic mbrzakovic added this to the 2.21.0 milestone Oct 28, 2021
@bhousel
Copy link
Member

bhousel commented Oct 28, 2021

We already have this working in the RapiD repo, even using the esbuild-plugin-babel to generate a legacy build for the tests and IE11.

I'd prefer to just send you a PR with the build tooling that we have to keep the projects more closely in sync.

@mbrzakovic
Copy link
Collaborator Author

We already have this working in the RapiD repo, even using the esbuild-plugin-babel to generate a legacy build for the tests and IE11.

I'd prefer to just send you a PR with the build tooling that we have to keep the projects more closely in sync.

That sounds great,
Please double check if the legacy build is working - Currently I am unable to https://mapwith.ai/rapid via IE11.
I'd prefer to keep the projects in sync as well, so lets work towards a correct common solution.

@bhousel
Copy link
Member

bhousel commented Oct 29, 2021

OK, so I spent some time on this today and the IE11 story is not great. Here's a brain dump of what I learned today.

  • @babel/polyfill has been deprecated a while ago in favor of just importing core-js at the main entry point of the application.

  • I did try this, but had no luck getting Babel / esbuild to actually create a bundle that would work in IE11. I did try a lot of different options with @babel/preset-env useBuiltIns, also updated all our dependencies.

  • The PhantomJS tests do continue to work (I consider this even more important than IE11), but that's because I've been including a core-js-bundle in a script tag in the test runner page.
    https://github.com/facebookincubator/RapiD/blob/08aead986ab7f1a39af3405ed5d9a50f1aa7b53e/test/index.html#L24

  • I can also remove core-js from the iD bundle and use this same script tag trick early in the index.html page (before iD gets loaded), in this case IE11 will actually work:

    <script src='https://cdn.jsdelivr.net/npm/core-js-bundle@3.19/index.min.js'></script>
  • But as you can see - nobody has looked at this in a while and there are all kinds of bugs in styling. Pointer Events like zoom and pan are not really working right anymore either. I guess it works, but really people shouldn't be using this.

ie11

I really can't spend any more time fighting with babel / core-js / esbuild to make iD work in IE11, let alone fixing all those other bugs once we get it working, so I'm going to just drop support on the RapiD side. It's probably been broken for a while and nobody noticed until you mentioned it on this PR yesterday. 😅

cc @Bonkles

@mbrzakovic
Copy link
Collaborator Author

@bhousel thanks for going this far on the IE11 story, your information is a great learning!
I've just double checked the current dev mirror via IE11 and I am confirming that map editting is possible however the user experience is bad - inconsistent ui elements, unexpected pointer events etc.
It seems to me that by continuing to support IE there is additional maintanence burden (mostly with build/bundle infrastructure and unit testing).
It is unfortunate that iD does not have usage telemetry that would provide more insight into the browser % usage statistics.

I think similarly as you did on rapiD side, decision should be made if iD should continue to support IE11.
I encourage everyone to please raise their opinions in the comments.

For this PR, based on the decision there are essentially two ways to processed:

  1. Switch dev to esbuild, keep rollup for legacy
  2. Switch to esbuild, drop legacy

In any case, as mentioned, I would prefer to reduce the code difference between the projects (iD, rapiD) which is why it is a good idea to merge all reasonable changes which we discussed in #8776

@mbrzakovic mbrzakovic added help wanted For intermediate contributors, requires investigation or knowledge of iD code waitfor-consensus Waiting for OpenStreetMap consensus labels Nov 4, 2021
@kymckay
Copy link
Collaborator

kymckay commented Nov 4, 2021

I vote to drop IE11, have had my suspicions for a while that it is relevant to very very few (double digit at most) users of iD and the fact that nobody has complained seems to confirm that. A shame we don't have hard proof via telemetry like you say.

Edit: Even Microsoft are dropping support for it. Office 365 already doesn't since August, and the browser itself will be retired next year.

@bhousel
Copy link
Member

bhousel commented Nov 4, 2021

For this PR, based on the decision there are essentially two ways to processed:

  1. Switch dev to esbuild, keep rollup for legacy
  2. Switch to esbuild, drop legacy

I think a third option, which takes things as far as I got last Friday, is worth considering as it cost no extra time to set up:

  • in id.js and elsewhere - remove core-js (because this polyfill pack is the thing that is hard for esbuild/babel to deal with)
  • in index.html - inject a core-js-bundle script if IE11 detected (prior to injecting iD.legacy.js)
  • then we really can just use esbuild and drop rollup (it really is about 100x faster, and I do think this is worth doing).

But, this is really for - if people think supporting IE11 in some form is worth it, and knowing that there are more bugs to squash once we actually get it working. (my concern is more time than anything)

@tyrasd
Copy link
Member

tyrasd commented Nov 5, 2021

A shame we don't have hard proof via telemetry

Maybe @tomhughes has some means (by looking into the server logs) to see approximately how large the fraction of requests is which open the iD editor on osm.org?

@tomhughes
Copy link
Member

There were 5904 editor start events yesterday (that's anybody using the edit button on the site but most will be iD) and 7 of them were using IE by the looks of it.

@tomhughes
Copy link
Member

Top 25 browsers starting an editor yesterday:
image

@mbrzakovic mbrzakovic mentioned this pull request Nov 16, 2021
7 tasks
@tyrasd
Copy link
Member

tyrasd commented Dec 7, 2021

I think similarly as you did on rapiD side, decision should be made if iD should continue to support IE11.

Sorry for delaying the decision on this for so long. My opinion is that we should drop support IE11. This is because of the relatively large to be expected amount of dev work needed to get it into an actually acceptably usable state, and the benefit of a more streamlined dev setup.

Switch to esbuild, drop legacy

This is the way I would go forward.

@mbrzakovic would you be able to finish up this pr (with #8776)? Before that, I would merge #8764, which was also kind of blocked on the decision of dropping IE11 support or not. For any further follow-up tasks: see #8811

@tyrasd tyrasd mentioned this pull request Dec 7, 2021
@tyrasd tyrasd added chore-build Improvements to the iD build scripts / CI environment and removed waitfor-consensus Waiting for OpenStreetMap consensus labels Dec 7, 2021
@mbrzakovic
Copy link
Collaborator Author

@mbrzakovic would you be able to finish up this pr (with #8776)? After that, I would immediately merge #8764, which was also kind of blocked on the decision of dropping IE11 support or not.

Yea I can wrap it up, although please note that my dev bandwidth is very limited this and next week so I might not be super responsive on this topic during the time. Sounds like a good plan.

The idea was to first merge #8776 here, iron out few small items and then finally merge this PR.

Currently #8776 has few additional changes that support .legacy build which should be reverted now to be inline with the above-mentioned decision.
@bhousel do you have time to polish #8776?

@tyrasd
Copy link
Member

tyrasd commented Dec 7, 2021

Perfect, thanks 👍 And no worries. If we can land this sometime before mid January, it would be just fine for the 2.21 release.

bhousel and others added 3 commits January 17, 2022 14:18
* Sync up RapiD and iD esbuild config scripts

* Remove uglify too

* Remove babel/preset-react

* Just have `npm run start` start a modern build, remove `quickstart`

* Better setup for modern/legacy build
- much simpler babel config
- separate entry points for modern and legacy (ie11/phantom)
- explicitly import 'core-js' and 'regenerator-runtime' instead of using deprecated 'babel/polyfill' plugin
- still need 'core-js-bundle' for the test/index.html, so Mocha/PhantomJS combo will work.

* Revert "Better setup for modern/legacy build"

This reverts commit 4ce17de.

Co-authored-by: Milos Brzakovic (E-Search) <mbrzakovic@microsoft.com>
@tyrasd tyrasd merged commit 5f40eea into develop Feb 1, 2022
@tyrasd tyrasd deleted the devbuild_on_esbuild branch February 1, 2022 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore-build Improvements to the iD build scripts / CI environment help wanted For intermediate contributors, requires investigation or knowledge of iD code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants