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

refactor(website): Upgrade dependencies and use StarlightPage component #1854

Merged
merged 9 commits into from
Feb 18, 2024

Conversation

yanthomasdev
Copy link
Contributor

@yanthomasdev yanthomasdev commented Feb 18, 2024

Summary

This PR uses the new <StarlightPage> component instead of the custom <StarlightSplashLayout> one, which was making it impossible for us to upgrade Starlight, Astro and its dependencies.

I've added per-file comments explaining a few changes necessary due to the breaking changes from upgrading.

Test Plan

Visually expecting the website and seeing everything is working as usual

@github-actions github-actions bot added the A-Website Area: website label Feb 18, 2024
Copy link

netlify bot commented Feb 18, 2024

Deploy Preview for biomejs ready!

Name Link
🔨 Latest commit 744f683
🔍 Latest deploy log https://app.netlify.com/sites/biomejs/deploys/65d2484cc1b4d000089fa8e1
😎 Deploy Preview https://deploy-preview-1854--biomejs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 100 (no change from production)
Accessibility: 97 (no change from production)
Best Practices: 100 (no change from production)
SEO: 93 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@@ -1,40 +1,9 @@
import { netlifyStatic } from "@astrojs/netlify";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The static Netlify adapter will be deprecated, so I've removed it. Note that we technically don't even need this one, so we should feel safe to remove it as well.

Copy link
Member

Choose a reason for hiding this comment

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

We don't??? 😯🤯

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, both Vercel and Netlify let you deploy just fine without an adapter, we do mention it in the docs: https://docs.astro.build/en/guides/integrations-guide/netlify/

It might enable some host-specific features but for the most part, the adapters aren't focused on the static use case.

import rehypeSlug from "rehype-slug";
import remarkToc from "remark-toc";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looks like we weren't using "remark-toc" anywhere, so I've removed it. Also, did the same for @astrojs/vercel, which isn't being used anymore.

@@ -397,11 +362,10 @@ export default defineConfig({

markdown: {
syntaxHighlight: "prism",
remarkPlugins: [remarkToc],
rehypePlugins: [rehypeSlug, [rehypeAutolinkHeadings, autolinkConfig]],
rehypePlugins: [rehypeSlug, ...rehypeAutolink()],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the unified project had breaking changes, we now have some weird behavior clashing issue when trying to apply the remarkAutolink plugin, had to move it to an external file to make it work properly.

}

const { src } = Astro.props as Props;

const files = await import.meta.glob<string>("/src/assets/svg/**/*.svg", {
as: "raw",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

as: "raw" was deprecated in Vite, so I've replaced it for the recommended query: "?raw"

@@ -343,7 +343,7 @@ function initState(
searchParams.get("bracketSpacing") === "true" ||
defaultPlaygroundState.settings.bracketSpacing,
bracketSameLine:
searchParams.get("bracketSameLine") === "true" ??
searchParams.get("bracketSameLine") === "true" ||
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Vite was complaining and throwing an warning about this line where the left operand would always be used, might be a false alarm from it, so that's something we can change back, probably.

Copy link
Member

Choose a reason for hiding this comment

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

We should revert this change, it previously caused some issue

},

adapter: netlifyStatic(),
adapter: netlify(),

vite: {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason Vite is complaining about some imported code by Astro's DevToolbar. Supposedly vite.server.fs.allow the path used should fix it, but didn't work for me.

Copy link
Member

Choose a reason for hiding this comment

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

We have to disable their remote image service, because they don't support multiple remote image domains from the config file. Their alternative is to use another configuration file

Copy link
Contributor Author

@yanthomasdev yanthomasdev Feb 18, 2024

Choose a reason for hiding this comment

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

There we go, the vite.server.fs.allow issue should be fixed, Vite now has a utility to allow workspace packages to be served, which fixes the issue with serving files from dependencies.

Comment on lines +50 to +51
"react": "^18.2.0",
"react-dom": "^18.2.0",
Copy link
Member

Choose a reason for hiding this comment

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

Seems like the playground doesn't work anymore. Unless you want to spend time understanding the issue, maybe we can revert the change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue doesn't seem related to updating the React dependencies, reverting them doesn't fix, nor does loading the Playground without <StarlightPage> - my best guess it might be Vite-related? But hard to know without context on how the Playground was built.

},

adapter: netlifyStatic(),
adapter: netlify(),

vite: {
Copy link
Member

Choose a reason for hiding this comment

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

We have to disable their remote image service, because they don't support multiple remote image domains from the config file. Their alternative is to use another configuration file

@@ -343,7 +343,7 @@ function initState(
searchParams.get("bracketSpacing") === "true" ||
defaultPlaygroundState.settings.bracketSpacing,
bracketSameLine:
searchParams.get("bracketSameLine") === "true" ??
searchParams.get("bracketSameLine") === "true" ||
Copy link
Member

Choose a reason for hiding this comment

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

We should revert this change, it previously caused some issue

@@ -1,40 +1,9 @@
import { netlifyStatic } from "@astrojs/netlify";
Copy link
Member

Choose a reason for hiding this comment

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

We don't??? 😯🤯

@@ -34,25 +33,25 @@
"@types/node": "^18.18.0",
"@types/react": "^18.2.23",
"@types/react-dom": "^18.2.8",
"@uiw/react-codemirror": "4.20.2",
"@uiw/react-codemirror": "4.21.21",
Copy link
Member

@Sec-ant Sec-ant Feb 18, 2024

Choose a reason for hiding this comment

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

The playground not working anymore is caused by this bump.

This version of @uiw/react-codemirror indirectly requires the version of @codemirror/state to be in range ^0.6.4 because of its dependencies: @codemirror/view and @codemirror/commands.

However @codemirror/[email protected] is explicitly pinned in the devDependencies, so two versions of @codemirror/state are installed and hence the error occurs which you can find in the console, and it breaks the playground.

A simple fix is to bump the @codemirror/state in devDepedencies to 0.6.4.

And IMHO a future-proof fix is to try not pinning these low-level dependencies (including other codemirror tools) but use semver ranges instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, thanks @Sec-ant - hadn't noticed the dependencies were pinned, I've moved them to ranges instead and seem to be working fine locally!

@ematipico ematipico merged commit 5394928 into biomejs:main Feb 18, 2024
7 checks passed
@ysm-dev
Copy link

ysm-dev commented Feb 19, 2024

RSS link broken after this PR: https://biomejs.dev/feed.xml

@yanthomasdev
Copy link
Contributor Author

RSS link broken after this PR: biomejs.dev/feed.xml

I'll give it a look, thanks for noticing @ysm-dev!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Website Area: website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants