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

bundle solid-start/entry-client #1034

Closed
Closed
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
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: 🔨 Build
run: pnpm --filter solid-start build:entry-client

- name: Use Deno
if: matrix.adapter == 'solid-start-deno'
uses: denoland/setup-deno@v1
Expand Down
7 changes: 7 additions & 0 deletions packages/start/entry-client/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "solid-start/entry-client",
"module": "./dist/index.jsx",
"types": "./dist/index.d.ts",
"type": "module",
"sideEffects": false
}
Comment on lines +1 to +7
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf. https://github.com/solidjs/solid/blob/main/packages/solid/html/package.json

I'm not including main because I believe we require Node18.... I don't know nearly enough about Node to know if that's good enough justification but we're not using a "real" bundler like Rollup. Maybe later?

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { MetaProvider } from "@solidjs/meta";
import { Router, RouterProps } from "@solidjs/router";
// @ts-ignore
import Root from "~start/root";
import { ServerContext } from "../server/ServerContext";
import { FETCH_EVENT, PageEvent } from "../server/types";
import { ServerContext } from "solid-start/server/ServerContext";
import { FETCH_EVENT, PageEvent } from "solid-start/server/types";

const rootData: { default: <T>() => Promise<T> } = Object.values(
import.meta.glob("/src/root.data.(js|ts)", { eager: true })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { JSX } from "solid-js";
import { hydrate, render } from "solid-js/web";

import { hydrateServerRouter } from "../islands/mount";
import mountRouter from "../islands/router";
import { hydrateServerRouter } from "solid-start/islands/mount";
import mountRouter from "solid-start/islands/router";

declare global {
interface Window {
Expand Down
15 changes: 15 additions & 0 deletions packages/start/entry-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"noEmit": false,
"emitDeclarationOnly": false,
"outDir": "./dist",
"types": ["../env", "solid-start/vite/plugin", "solid-start/router"],
"paths": {
"solid-start/islands": ["../islands"],
"solid-start/server": ["../server"]
}
},
"include": ["./src"],
"exclude": []
}
2 changes: 1 addition & 1 deletion packages/start/islands/entry-client.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import StartClient from "../entry-client/StartClient";
import StartClient from "../entry-client/src/StartClient";

StartClient();
13 changes: 9 additions & 4 deletions packages/start/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@
"./api": "./api/index.ts",
"./api/*": "./api/*",
"./durable-object": "./durable-object/index.ts",
"./entry-client": "./entry-client/index.tsx",
"./entry-client/*": "./entry-client/*",
"./entry-client": {
"types": "./entry-client/dist/index.d.ts",
"import": "./entry-client/dist/index.jsx"
},
"./entry-client/dist/*": "./entry-client/dist/*",
"./entry-server": "./entry-server/index.ts",
"./entry-server/*": "./entry-server/*",
"./error-boundary": "./error-boundary/index.tsx",
Expand Down Expand Up @@ -62,7 +65,8 @@
"data",
"dev",
"durable-object",
"entry-client",
"entry-client/dist",
"entry-client/package.json",
"entry-server",
"error-boundary",
"fs-router",
Expand All @@ -82,7 +86,8 @@
"types.ts"
],
"scripts": {
"typecheck": "tsc --noEmit --checkJs false --skipLibCheck"
"build:entry-client": "tsc --project ./entry-client/tsconfig.json",
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@babel/core": "^7.22.9",
Expand Down
39 changes: 39 additions & 0 deletions packages/start/router.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { A as BaseA, Location, NavigateOptions, Navigator, RouteDataFunc } from "@solidjs/router";
import { JSX } from "solid-js";
import { LocationEntry, useSearchParams as useIslandsSearchParams } from "./islands/router";
export type RouteParams<T extends string> = Record<T, string>;
export type RouteDataArgs<T extends keyof StartRoutes = "$"> = {
data: StartRoutes[T]["data"];
params: RouteParams<StartRoutes[T]["params"]>;
location: Location;
navigate: Navigator;
};
declare const A: typeof BaseA;
declare const Routes: (props: import("@solidjs/router").RoutesProps) => JSX.Element;
declare const Outlet: () => JSX.Element;
declare const useNavigate: () => Navigator;
declare const useSearchParams: typeof useIslandsSearchParams | (<T extends import("@solidjs/router").Params>() => [T, (params: import("@solidjs/router").SetParams, options?: Partial<NavigateOptions<unknown>> | undefined) => void]);
declare global {
interface Window {
router: {
navigate: (to: string, options?: Partial<NavigateOptions>) => Promise<boolean>;
push: (to: string | URL, options: Partial<NavigateOptions>) => void;
update: (body: string) => Promise<boolean>;
router: EventTarget;
location: () => LocationEntry;
};
}
interface StartRoutes {
$: {
params: any;
data: any;
};
}
interface Route {
"/notes/[note]": "/notes/[note]";
}
}
Comment on lines +16 to +35
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file was generated from Router.tsx. It's used by the tsconfig via "types": [ ..., "solid-start/router", which afaik only accepts .d.ts files (or whole projects).

In actuality all entry-client needs is this here declare global, but I'm leaving it in Router.tsx for now for easy review. Could easily move it elsewhere if requested!

export declare function useRouteData<T extends keyof StartRoutes>(): ReturnType<StartRoutes[T]["data"]>;
export declare function useRouteData<T extends (...args: any[]) => any>(): T extends RouteDataFunc<infer _, infer R> ? R : ReturnType<T>;
export { useLocation } from "./islands/useLocation";
export { A, Outlet, Routes, useNavigate, useSearchParams };
6 changes: 4 additions & 2 deletions packages/start/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,21 @@
"target": "ESNext",
"allowJs": true,
"noEmit": true,
"checkJs": true,
"declaration": true,
"checkJs": false,
"module": "ESNext",
"moduleResolution": "node",
"jsxImportSource": "solid-js",
"jsx": "preserve",
"types": ["./env"],
"strict": true,
"skipLibCheck": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"paths": {
"vite": ["./node_modules/vite"]
},
"baseUrl": "./"
},
"include": ["./**/*.ts", "./**/*.tsx", "./**/*.js", "./**/*.jsx"],
"exclude": ["node_modules", "**/node_modules/*"]
"exclude": ["node_modules", "**/node_modules/*", "entry-client"]
}
2 changes: 1 addition & 1 deletion packages/start/virtual/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import { mount, StartClient } from "../entry-client";
import { mount, StartClient } from "../entry-client/src";

mount(() => <StartClient />, document);
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.