Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions src/content/docs/ja/reference/experimental-flags/rust-compiler.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: 試験的なRustコンパイラー
sidebar:
label: Rustコンパイラー
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>

AstroファイルにRustベースの新しいコンパイラーを使用できるようにします。このコンパイラーはより高速で、エラーメッセージがわかりやすく、モダンなJavaScript・TypeScript・CSSの機能に対して全般的に優れたサポートを提供します。

将来のメジャーバージョンでは、Astroはデフォルトでこの新しいコンパイラーを使用するようになりますが、`experimental.rustCompiler`フラグを使用することで、いち早く将来の動作を試すことができます。

コンパイラーへのフィードバックや開発状況を確認するには、[Astroの新しいコンパイラーに関するRFC](https://github.com/withastro/roadmap/discussions/1306)をご参照ください。

## 使い方

この試験的なフラグは特定の使い方を必要とせず、Astroがプロジェクトに使用するコンパイラーにのみ影響します。

Rustコンパイラーを有効にするには、`astro.config.mjs`に以下を追加します。

```js title="astro.config.mjs" ins={4-6}
import { defineConfig } from "astro/config";

export default defineConfig({
experimental: {
rustCompiler: true
}
});
```

次に、`@astrojs/compiler-rs`パッケージをプロジェクトにインストールします。

<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>

### 動作の違いについて

AstroのGoコンパイラーとは異なり、この試験的なRustコンパイラーは無効なHTML構造を修正しません。たとえば、以下のようなパターンはそのまま出力され、自動修正されなくなります。

- `<p><div>Bad nesting</div></p>`(`p`タグから`div`を除去する代わりに)
- `<p>My paragraph` (閉じタグ`</p>`を補完する代わりに)

そのため、Astroファイルに無効なHTMLが含まれている場合、Rustコンパイラーによる出力が以前のコンパイラーと異なる場合や、ビルド時にエラーが発生する場合があります。

## 制限事項

現時点では、Rustコンパイラーはdevツールバーの監査が正しく機能するために必要なメタデータを出力しません。
Loading