-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat: add page about experimental Rust compiler #13303
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
Open
Princesseuh
wants to merge
8
commits into
v6
Choose a base branch
from
feat/rust-compiler
base: v6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+72
−0
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
58752a1
feat: add page about experimental Rust compiler
Princesseuh 0ea8f27
Merge branch 'v6' into feat/rust-compiler
yanthomasdev a8bf3d0
fix: everything
Princesseuh b44fd72
Apply suggestions from code review
Princesseuh ee6ed12
fix: add rfc
Princesseuh 42a981a
Apply suggestions from code review
Princesseuh bfaf934
Update src/content/docs/en/reference/experimental-flags/rust-compiler…
Princesseuh a7751ff
Merge branch 'v6' into feat/rust-compiler
sarah11918 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/content/docs/en/reference/experimental-flags/rust-compiler.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| --- | ||
| title: Experimental Rust compiler | ||
| sidebar: | ||
| label: Rust compiler | ||
| i18nReady: true | ||
| --- | ||
|
|
||
| import Since from '~/components/Since.astro' | ||
| import PackageManagerTabs from '~/components/tabs/PackageManagerTabs.astro' | ||
|
|
||
| <p> | ||
|
|
||
| **Type:** `boolean`<br /> | ||
| **Default:** `false`<br /> | ||
| <Since v="6.0.0" /> | ||
| </p> | ||
|
|
||
| Enables using the new Rust-based compiler for Astro files. This compiler is faster, provides better error messages, and generally has better support for modern JavaScript, TypeScript, and CSS features. | ||
|
|
||
| In a future major version, Astro will use this new compiler by default, but you can opt in to the future behavior early using the `experimental.rustCompiler` flag. | ||
|
|
||
| To give feedback on the compiler, or to keep up with its development, see the [RFC for a new compiler for Astro](https://github.com/withastro/roadmap/discussions/1306) for more information and discussion. | ||
|
|
||
| ## Usage | ||
|
|
||
| This experimental flag requires no specific usage and only affects which compiler Astro uses for your project. | ||
|
|
||
| To enable the Rust compiler, add the following to your `astro.config.mjs`: | ||
|
|
||
| ```js title="astro.config.mjs" ins={4-6} | ||
| import { defineConfig } from "astro/config"; | ||
|
|
||
| export default defineConfig({ | ||
| experimental: { | ||
| rustCompiler: true | ||
| } | ||
| }); | ||
| ``` | ||
|
|
||
| and then install the `@astrojs/compiler-rs` package into your project: | ||
|
|
||
| <PackageManagerTabs> | ||
| <Fragment slot="npm"> | ||
| ```shell | ||
| npm install @astrojs/compiler-rs | ||
| ``` | ||
| </Fragment> | ||
| <Fragment slot="pnpm"> | ||
| ```shell | ||
| pnpm add @astrojs/compiler-rs | ||
| ``` | ||
| </Fragment> | ||
| <Fragment slot="yarn"> | ||
| ```shell | ||
| yarn add @astrojs/compiler-rs | ||
| ``` | ||
| </Fragment> | ||
| </PackageManagerTabs> | ||
|
|
||
| ### Expected differences | ||
|
|
||
| Unlike Astro's current Go compiler, this experimental Rust compiler will not correct invalid HTML structure. For example, the following notable patterns will be left as written, and no longer corrected: | ||
|
|
||
| - `<p><div>Bad nesting</div></p>` (instead of removing the `div` from of the `p`) | ||
| - `<p>My paragraph` (instead of adding the missing closing `</p>` tag) | ||
|
|
||
| This means that if your Astro files contain invalid HTML, you may see a different output from the Rust compiler than you did with the previous compiler, or may encounter errors while building. | ||
|
|
||
| ## Limitations | ||
|
|
||
| At this time, the Rust compiler does not support HTML minification (the `compressHTML` option in `astro.config.mjs`) and does not currently output the required metadata for the dev toolbar audits to work correctly. | ||
Princesseuh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.