Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

CSS Modules classes are compiled as dynamic/reactive variables rather than static strings (Optimization)

オープン
#223 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
typescript, vite

調査の方向性

まず Solid Babel plugin と Vite CSS Modules の処理順序を追跡します。issue では比較対象として custom Vite plugin が提供されています。処理順序の変更をこのリポジトリと Vite のどちらに実装すべきかを判断し、CSS Module class strings が workaround なしで静的かつ非リアクティブな DOM テキストとしてコンパイルされることを完了条件とします。

索引モデルが issue の本文から書いたものです。

説明

@ryansolid Just following up on the issue we discussed during your Friday stream.

CSS Module classes are substituted for static strings by Vite AFTER the Solid babel plugin runs, so the CSS class strings are not compiled into static text directly in the DOM strings. This has a considerable performance effect because it breaks up long strings that would otherwise be inserted into the DOM at once statically.

This can be alleviated slightly with a custom Vite plugin like this one, which adds @once to at least compile these without reactivity:

{
  name: 'vite-plugin-optimize-solid-css-modules',
  enforce: 'pre',
  transform: {
    handler: code => ({
      code: code.replace(/class=\{([a-zA-Z '"`[\].-]+|(?:`(?:\$\{[a-zA-Z '"`[\].-]+\}\s*)+)`)\}/g, 'class={/*@once*/$1}'),
      map: null,
    }),
    filter: { id: /\.[mc]?[jt]sx$/ },
  },
}

But without a modification to the order that CSS modules are processed, getting CSS modules to match the performance of plain CSS won’t be possible. I’ve taken a stab at fixing it myself, but the fix may need to be contributed to Vite. Needs some further investigation.

主要言語
TypeScript
スター
522
フォーク
72
平均マージ
20時間 1分
マージ済み PR(30日)
31

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/solid-vite-plugin のほかの issue

solidjs/solid-vite-plugin の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。