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

Switch to Vite from Create React App #1152

Merged
merged 55 commits into from
Mar 15, 2024
Merged

Switch to Vite from Create React App #1152

merged 55 commits into from
Mar 15, 2024

Conversation

microbit-matt-hillsdon
Copy link
Collaborator

@microbit-matt-hillsdon microbit-matt-hillsdon commented Mar 11, 2024

  • CRA -> Vite + Vitest + eslint
  • TypeScript 4->5

npm audit issues are now at 0 🎉

Notable changes:

  • Use a worker per language to workaround Vite/Safari 14 limitations
    • I also renamed the main worker-side file to make it clearer what was what as I found it confusing to come back to.
  • Fixed a dev-only API tab initialisation issue found by e2e tests
  • Adding updated eslint config caught a missing await in storage.ts. Should only have been significant when deleting files that don't exist which we never intend to do but please review.

Tasks:

  • Review bundle size change
  • Reinstate eslint, unifying config with other micro:bit apps
  • Check browser support
    • I also tried more intentional target browsers list for esbuild, but they're not meaningfully different from Vite's defaults (for module support) in terms of code generation.

So long as you don't look too closely...
Need to evaluate module vs classic
index.html Outdated Show resolved Hide resolved
index.html Outdated Show resolved Hide resolved
@microbit-matt-hillsdon
Copy link
Collaborator Author

The Vite way seems to be to commit defaults in .env and use .env.local for uncommitted changes. It's already committed.
@microbit-matt-hillsdon microbit-matt-hillsdon marked this pull request as ready for review March 14, 2024 13:33
Copy link
Contributor

@microbit-grace microbit-grace left a comment

Choose a reason for hiding this comment

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

Mostly LGTM, left a few comments. Will leave for Rob to review

src/fs/host.ts Outdated Show resolved Hide resolved
src/fs/migration.test.ts Outdated Show resolved Hide resolved
@microbit-robert
Copy link
Collaborator

I've seen a couple of these errors on switching language that I would guess we expect:
image

We also get some shift in the sidebar with reference panel showing on changing language. Not a big issue, but a difference from production. Just after language change we lose spacing:
image

Then the spacing returns to normal:
image

@microbit-robert
Copy link
Collaborator

A few comments, but otherwise, the code changes look good and the app behaves as expected.

Co-authored-by: Robert Knight <[email protected]>
Co-authored-by: Grace <[email protected]>
@microbit-matt-hillsdon
Copy link
Collaborator Author

I've seen a couple of these errors on switching language that I would guess we expect

I didn't expect these... will try to understand.

We also get some shift in the sidebar with reference panel showing on changing language. Not a big issue, but a difference from production.

That's very odd. We do have some media-query-dependent styling in DocumentationTopLevelItem.

@microbit-matt-hillsdon
Copy link
Collaborator Author

We also get some shift in the sidebar with reference panel showing on changing language. Not a big issue, but a difference from production.

That's very odd. We do have some media-query-dependent styling in DocumentationTopLevelItem.

This isn't language-change specific. It happens on load too.

Otherwise we needlessly render assuming false which causes rerenders
with visual change at start-up and on language change.

Not Vite related, we need to rescue this if we abandon the PR.
@microbit-matt-hillsdon
Copy link
Collaborator Author

We also get some shift in the sidebar with reference panel showing on changing language. Not a big issue, but a difference from production.

That's very odd. We do have some media-query-dependent styling in DocumentationTopLevelItem.

This isn't language-change specific. It happens on load too.

Fixed in d4313dd. I think this was a Chakra UI upgrade issue rather than a Vite one.

@microbit-matt-hillsdon
Copy link
Collaborator Author

I've so far failed to reproduce the error in @microbit-robert's screenshot. I do see this though, for example when starting in Dutch and switching to English (but not the other way around).

lunr.multi.js:50 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'wordCharacters')
    at t.multiLanguage (lunr.multi.js:50:58)
    at be (search.worker.ts:285:31)
    at Be.index (search.worker.ts:358:25)
    at Be.ctx.onmessage (search.worker.ts:344:21)

Previously we pulled the language off what we indexed which could cause
an issue when the search index was updated for a new language but the
content had not been reloaded. Instead an index now knows its language.

Additionally, ensure we wait for the languages of all content to match
before indexing.
@microbit-matt-hillsdon
Copy link
Collaborator Author

microbit-matt-hillsdon commented Mar 14, 2024

I've so far failed to reproduce the error in @microbit-robert's screenshot. I do see this though, for example when starting in Dutch and switching to English (but not the other way around).

lunr.multi.js:50 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'wordCharacters')
    at t.multiLanguage (lunr.multi.js:50:58)
    at be (search.worker.ts:285:31)
    at Be.index (search.worker.ts:358:25)
    at Be.ctx.onmessage (search.worker.ts:344:21)

Fixed in 994c4a7. Whether you could reproduce this depended on timing but was pretty easy.

Copy link
Collaborator

@microbit-robert microbit-robert left a comment

Choose a reason for hiding this comment

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

LGTM.

@microbit-matt-hillsdon microbit-matt-hillsdon merged commit 4425d16 into main Mar 15, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants