-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
fix(remix-dev/vite, remix-server-runtime): handle criticalCss
in an adapter agnostic way
#8076
Changes from all commits
f7cfe04
76c9af1
6e79c12
74c61db
a0dfa4b
b330177
6dea3a2
c6ca6fb
a8222ef
3141d03
80797d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@remix-run/dev": patch | ||
"@remix-run/server-runtime": patch | ||
--- | ||
|
||
Fix flash of unstyled content for non-Express custom servers in Vite dev |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,22 @@ export async function broadcastDevReady(build: ServerBuild, origin?: string) { | |
export function logDevReady(build: ServerBuild) { | ||
console.log(`[REMIX DEV] ${build.assets.version} ready`); | ||
} | ||
|
||
type DevServerHooks = { | ||
getCriticalCss: ( | ||
build: ServerBuild, | ||
pathname: string | ||
) => Promise<string | undefined>; | ||
}; | ||
|
||
const globalDevServerHooksKey = "__remix_devServerHooks"; | ||
|
||
export function setDevServerHooks(devServerHooks: DevServerHooks) { | ||
// @ts-expect-error | ||
globalThis[globalDevServerHooksKey] = devServerHooks; | ||
} | ||
|
||
export function getDevServerHooks(): DevServerHooks | undefined { | ||
// @ts-expect-error | ||
return globalThis[globalDevServerHooksKey]; | ||
} | ||
Comment on lines
+36
to
+46
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! I didn't think about exposing get/set API. let _devServerHooks: DevServerHooks | undefined;
export function setDevServerHooks(devServerHooks: DevServerHooks) {
_devServerHooks = devServerHooks
}
export function getDevServerHooks(): DevServerHooks | undefined {
return _devServerHooks;
} But this might have issues when dual package hazard like scenario (user-code is esm, but remix library is commonjs)? I was just looking at the sveltekit for how they deal with const { set_fix_stack_trace } = await vite.ssrLoadModule(
`${runtime_base}/shared-server.js`
);
set_fix_stack_trace(fix_stack_trace); export let fix_stack_trace = (error) => error?.stack;
export function set_fix_stack_trace(value) {
fix_stack_trace = value;
} I'm still digesting what's happening with this, but it might be possible to avoid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is such a nice clean up 🎉