Skip to content
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 refresh pragma #1348

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .changeset/neat-avocados-teach.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solidjs/start": patch
---

Fix refresh pragma
1 change: 0 additions & 1 deletion examples/bare/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { createSignal } from "solid-js";
import "./app.css";

Expand Down
1 change: 1 addition & 0 deletions examples/bare/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/bare/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/basic/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { MetaProvider, Title } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
Expand Down
1 change: 1 addition & 0 deletions examples/basic/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/basic/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/experiments/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { MetaProvider, Title } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
Expand Down
1 change: 1 addition & 0 deletions examples/experiments/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/experiments/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { StartServer, createHandler } from "@solidjs/start/server";

declare module "@solidjs/start/server" {
Expand Down
1 change: 0 additions & 1 deletion examples/hackernews/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/hackernews/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
Expand Down
1 change: 1 addition & 0 deletions examples/hackernews/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/notes/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/notes/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/notes/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/todomvc/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/todomvc/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/todomvc/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 1 addition & 0 deletions examples/with-auth/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-auth/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-mdx/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/with-mdx/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-mdx/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-prisma/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/with-prisma/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-prisma/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-solid-styled/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { MetaProvider } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
Expand Down
1 change: 1 addition & 0 deletions examples/with-solid-styled/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-solid-styled/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-tailwindcss/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/with-tailwindcss/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-tailwindcss/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-trpc/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { MetaProvider, Title } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
Expand Down
1 change: 1 addition & 0 deletions examples/with-trpc/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-trpc/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
3 changes: 1 addition & 2 deletions examples/with-unocss/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import "virtual:uno.css";
import "@unocss/reset/tailwind.css";
import "virtual:uno.css";

// @refresh reload
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
import { Suspense } from "solid-js";
Expand Down
1 change: 1 addition & 0 deletions examples/with-unocss/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-unocss/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 0 additions & 1 deletion examples/with-vitest/src/app.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @refresh reload
import { MetaProvider, Title } from "@solidjs/meta";
import { Router } from "@solidjs/router";
import { FileRoutes } from "@solidjs/start";
Expand Down
1 change: 1 addition & 0 deletions examples/with-vitest/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { mount, StartClient } from "@solidjs/start/client";

mount(() => <StartClient />, document.getElementById("app")!);
1 change: 1 addition & 0 deletions examples/with-vitest/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh reload
import { createHandler, StartServer } from "@solidjs/start/server";

export default createHandler(() => (
Expand Down
1 change: 1 addition & 0 deletions packages/start/client/StartClient.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
// @ts-ignore
import App from "#start/app";
import type { JSX } from "solid-js";
Expand Down
3 changes: 3 additions & 0 deletions packages/start/client/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// @refresh skip
// TODO rename to index.tsx?
import "vinxi/client";
export { StartClient } from "./StartClient";
export { mount } from "./mount";

1 change: 1 addition & 0 deletions packages/start/client/islands.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
import "vinxi/client";
export function StartClient() {
return null;
Expand Down
1 change: 1 addition & 0 deletions packages/start/client/spa/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
import type { JSX } from "solid-js";
import { render, type MountableElement } from "solid-js/web";
import "vinxi/client";
Expand Down
2 changes: 2 additions & 0 deletions packages/start/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
// @refresh skip
// TODO rename to index.ts?
export * from "./shared/index";
1 change: 1 addition & 0 deletions packages/start/server/StartServer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
// @ts-ignore
import App from "#start/app";
import type { Component, JSX } from "solid-js";
Expand Down
2 changes: 2 additions & 0 deletions packages/start/server/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @refresh skip
// TODO rename to index.ts?
export { StartServer } from "./StartServer";
export { createHandler } from "./handler";
export * from "./types";
Expand Down
5 changes: 3 additions & 2 deletions packages/start/server/islands/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { type Component, type ComponentProps, lazy, sharedConfig } from "solid-js";
import { getRequestEvent, Hydration, NoHydration } from "solid-js/web";
// @refresh skip
import { lazy, sharedConfig, type Component, type ComponentProps } from "solid-js";
import { Hydration, NoHydration, getRequestEvent } from "solid-js/web";
// import { IslandManifest } from "./types";
import { splitProps } from "./utils";

Expand Down
2 changes: 2 additions & 0 deletions packages/start/server/islands/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @refresh skip
// TODO rename to utils.ts?
// @ts-nocheck
import { $PROXY } from "solid-js";

Expand Down
2 changes: 2 additions & 0 deletions packages/start/server/renderAsset.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @refresh skip
// TODO rename to renderAsset.ts?
import type { JSX } from "solid-js";
import type { Asset } from "./types";

Expand Down
1 change: 1 addition & 0 deletions packages/start/server/spa/StartServer.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
// @ts-ignore
import type { Component } from "solid-js";
import { NoHydration, getRequestEvent, ssr } from "solid-js/web";
Expand Down
2 changes: 2 additions & 0 deletions packages/start/server/spa/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// @refresh skip
// TODO rename to index.ts?
export * from "../types";
export { StartServer } from "./StartServer";
export { createHandler } from "./handler";
Expand Down
36 changes: 18 additions & 18 deletions packages/start/shared/ErrorBoundary.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
// @refresh skip
import { ErrorBoundary as DefaultErrorBoundary, type ParentProps } from "solid-js";
import { isServer } from "solid-js/web";
import { HttpStatusCode } from "./HttpStatusCode";
import { DevOverlay } from "./dev-overlay";

export function ErrorBoundary(props: ParentProps) {
if (import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY) {
return <DevOverlay>{props.children}</DevOverlay>;
}
const message = isServer ? "500 | Internal Server Error" : "Error | Uncaught Client Exception";
return (
<DefaultErrorBoundary
fallback={
<>
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">{message}</span>
<HttpStatusCode code={500} />
</>
}
>
{props.children}
</DefaultErrorBoundary>
);
}
export const ErrorBoundary = import.meta.env.DEV && import.meta.env.START_DEV_OVERLAY
? (props: ParentProps) => <DevOverlay>{props.children}</DevOverlay>
: (props: ParentProps) => {
const message = isServer ? "500 | Internal Server Error" : "Error | Uncaught Client Exception";
return (
<DefaultErrorBoundary
fallback={
<>
<span style="font-size:1.5em;text-align:center;position:fixed;left:0px;bottom:55%;width:100%;">{message}</span>
<HttpStatusCode code={500} />
</>
}
>
{props.children}
</DefaultErrorBoundary>
)
};
6 changes: 3 additions & 3 deletions packages/start/shared/FileRoutes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ export function createRoutes() {
}

let routes: any[];
export const FileRoutes = () => {
return isServer ? (getRequestEvent() as PageEvent).routes : routes || (routes = createRoutes());
};
export const FileRoutes = isServer
? () => (getRequestEvent() as PageEvent).routes
: () => routes || (routes = createRoutes());
16 changes: 11 additions & 5 deletions packages/start/shared/HttpHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
// @refresh skip
import { onCleanup } from "solid-js";
import { getRequestEvent, isServer } from "solid-js/web";
import type { PageEvent } from "../server/types";

export function HttpHeader(props: { name: string; value: string; append?: boolean }) {
if (isServer) {
export interface HttpHeaderProps {
name: string;
value: string;
append?: boolean;
}

export const HttpHeader = isServer
? (props: HttpHeaderProps) => {
const event = getRequestEvent() as PageEvent;

if (props.append) event.response.headers.append(props.name, props.value);
Expand All @@ -23,7 +30,6 @@ export function HttpHeader(props: { name: string; value: string; append?: boolea
if (values.length) event.response.headers.set(props.name, values.join(","));
else event.response.headers.delete(props.name);
});
return null;
}

return null;
}
: (_props: HttpHeaderProps) => null;
14 changes: 10 additions & 4 deletions packages/start/shared/HttpStatusCode.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// @refresh skip
import { onCleanup } from "solid-js";
import { getRequestEvent, isServer } from "solid-js/web";
import type { PageEvent } from "../server/types";

export function HttpStatusCode(props: { code: number, text?: string }) {
if (isServer) {
export interface HttpStatusCodeProps {
code: number;
text?: string;
}

export const HttpStatusCode = isServer
? (props: HttpStatusCodeProps) => {
const event = getRequestEvent() as PageEvent;
event.response.status = props.code;
event.response.statusText = props.text;
onCleanup(() => !event.nativeEvent.handled && (event.response.status = 200));
return null;
}
return null;
}
: (_props: HttpStatusCodeProps) => null;
1 change: 1 addition & 0 deletions packages/start/shared/clientOnly.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
import type { Component, ComponentProps, JSX } from "solid-js";
import { createMemo, createSignal, onMount, sharedConfig, splitProps, untrack } from "solid-js";
import { isServer } from "solid-js/web";
Expand Down
1 change: 1 addition & 0 deletions packages/start/shared/dev-overlay/CodeView.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @refresh skip
import type { BuiltinLanguage, Highlighter } from 'shikiji';
import { getHighlighterCore, loadWasm } from 'shikiji/core';
import { createEffect, createResource, type JSX } from 'solid-js';
Expand Down
Loading
Loading