Dev: a stylesheet shared by the entry and a lazy component moves after the lazy component's styles
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 62/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- css, javascript, typescript
- 領域
- build-system, frontend
調査の方向性
The dedupe logic is in devStylePatch in src/dev-manifest.ts, on the line that picks ssr from o and el by data-asset. Reproduce with the issue's App/Button/Page files and check the link tags in the hydrated head. Done means .corner resolves to absolute in dev, the stylesheet order matches vite build, and editing button.css still hot-updates while the page is open.
索引モデルが issue の本文から書いたものです。
説明
In start-mode dev, a stylesheet that both the entry graph and a lazy component import ends up after the lazy component's own stylesheets. Production keeps it before them. Rules of equal specificity then resolve the other way in dev: a lazy page's override of a shared component's style loses.
Versions: @solidjs/[email protected], [email protected], @solidjs/[email protected], [email protected].
Reproduction
// vite.config.ts
import { defineConfig } from 'vite';
import solid from '@solidjs/vite-plugin';
export default defineConfig({
plugins: [solid({ start: { app: 'src/App.tsx' }, ssr: true })],
});
// src/App.tsx
import { lazy, Loading } from 'solid-js';
import { Button } from './Button';
const Page = lazy(() => import('./Page'));
export default function App() {
return (
<main>
<Button>Header button</Button>
<Loading>
<Page />
</Loading>
</main>
);
}
// src/Button.tsx
import type { JSX } from 'solid-js';
import './button.css';
export function Button(props: { class?: string; children: JSX.Element }) {
return <button class={`button ${props.class ?? ''}`}>{props.children}</button>;
}
// src/Page.tsx
import { Button } from './Button';
import './page.css';
export default function Page() {
return (
<div class="panel">
<Button class="corner">Copy</Button>
</div>
);
}
/* src/button.css */
.button {
position: relative;
}
/* src/page.css */
.panel {
position: relative;
height: 200px;
border: 1px solid;
}
/* Same specificity as .button, so it wins only when page.css comes after button.css. */
.corner {
position: absolute;
top: 8px;
right: 8px;
}
Run vite, open the page, and wait for hydration. "Copy" stays in the normal flow instead of the panel's top right corner. vite build + vite preview renders it in the corner.
| style tags in the server HTML | style tags after hydration | .corner |
|
|---|---|---|---|
| dev | button.css, page.css, button.css |
page.css, button.css |
position: relative |
| build | Button-*.css, Page-*.css |
Button-*.css, Page-*.css |
position: absolute |
Cause
The dev shell carries button.css twice, both marked data-asset. The SSR runtime renders the lazy component's styles (button.css, page.css), and the handler then injects the entry graph's styles (button.css again) before </head>.
devStylePatch (src/dev-manifest.ts) dedupes the two by data-vite-dev-id. It removes o, the tag found by querySelectorAll, whenever o is data-asset:
var ssr=o.hasAttribute("data-asset")?o:el.hasAttribute("data-asset")?el:null;
When both twins are SSR'd, the observer handles the later tag as el, so o is the earlier one and it is removed. The copy that survives sits after page.css.
Suggested fix
When both twins are SSR'd, drop the later one, so the stylesheet keeps the first position the shell gave it:
var ssr=o.hasAttribute("data-asset")&&el.hasAttribute("data-asset")?(o.compareDocumentPosition(el)&4?el:o):o.hasAttribute("data-asset")?o:el.hasAttribute("data-asset")?el:null;
With that line patched into the repro's copy of the plugin, the hydrated order is button.css, page.css and .corner is absolute, as in the build. Editing button.css with the page open still hot-updates it.
Not emitting entry styles that the shell already carries would fix it as well. Moving the entry styles ahead of the lazy ones does not: in the larger app where I first saw this, the shared stylesheets still ended up after the lazy ones.
- 主要言語
- TypeScript
- スター
- 522
- フォーク
- 73
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 35
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solidjs/solid-vite-plugin のほかの issue
-
Test environment detection doesn't consider Vitest workspaces対応中かも @carloitaben が 55 日前に担当しました。 オープン1.x
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
solidjs/solid-vite-plugin#205 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[3.0.0-next.50 / next] SSR build: the $$moduleUrl export added to a Worker main module stops workerd from starting対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 半日 初心者へのやさしさ 55/100
solidjs/solid-vite-plugin#420 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
solidjs/solid-vite-plugin#419 ·
メンテナーはふだん 1 日以内に返信
-
start.node: node.js imports node:http before start.instrument runs, so HTTP instrumentation misses the server対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 4/5 1〜2日 初心者へのやさしさ 30/100
solidjs/solid-vite-plugin#418 ·
メンテナーはふだん 1 日以内に返信
-
Dev manifest bridge keeps stale CSS after an edit対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 4/5 3〜5日 初心者へのやさしさ 34/100
solidjs/solid-vite-plugin#415 ·
メンテナーはふだん 1 日以内に返信
solidjs/solid-vite-plugin の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
agilepathway/label-checker#739 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
CopilotKit/OpenBot#800 ·
メンテナーはふだん 1 日以内に返信
-
Endpoint links in the tag operations list are below the 24px target size対応中かも @AdzerKI が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
ehmpathy/rhachet-roles-bhuild#471 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信