@resolid/dev 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -12
- package/dist/index-BMC9vh2X.d.mts +5 -0
- package/dist/{index-BxG71-IE.d.mts → index-BMs3Y706.d.mts} +7 -6
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/routes.d.mts +10 -3
- package/dist/routes.mjs +3 -1
- package/dist/server.d.mts +3 -3
- package/dist/vite.d.mts +1 -1
- package/dist/vite.mjs +1 -1
- package/package.json +4 -6
- package/cli/react-router.js +0 -16
- package/dist/index-Bl4eSdJb.d.mts +0 -5
package/README.md
CHANGED
|
@@ -8,27 +8,25 @@
|
|
|
8
8
|
## Installation
|
|
9
9
|
|
|
10
10
|
```shell
|
|
11
|
-
pnpm add @resolid/dev
|
|
12
|
-
# or
|
|
13
|
-
npm install @resolid/dev
|
|
14
|
-
# or
|
|
15
|
-
yarn add @resolid/dev
|
|
16
|
-
# or
|
|
17
|
-
bun add @resolid/dev
|
|
11
|
+
pnpm add -D @resolid/dev @react-router/dev
|
|
18
12
|
```
|
|
19
13
|
|
|
14
|
+
> If you use npm/yarn/bun, replace with the equivalent command.
|
|
15
|
+
|
|
20
16
|
## What is included
|
|
21
17
|
|
|
22
18
|
- `defineDevConfig` (`@resolid/dev`): generate unified `vitePluginOptions` and `reactRouterConfig`.
|
|
23
|
-
- `resolidVite` (`@resolid/dev/vite`): combine Resolid plugin behavior with React Router Vite
|
|
24
|
-
|
|
19
|
+
- `resolidVite` (`@resolid/dev/vite`): combine Resolid plugin behavior with React Router Vite
|
|
20
|
+
plugin.
|
|
21
|
+
- Route helpers (`@resolid/dev/routes`):`flexRoutes`, `relativeFactory`, `prefix`, `route`,
|
|
22
|
+
`layout`, `index`.
|
|
25
23
|
- Router helpers (`@resolid/dev/router`): `mergeMeta`.
|
|
26
24
|
- Server-side router helpers (`@resolid/dev/router.server`):
|
|
27
25
|
`createRequestIdMiddleware`, `httpNotFound`, `getClientIp`, `getRequestOrigin`.
|
|
28
|
-
- Server adapters (`@resolid/dev/server`): `createServer`, `nodeConfig`, `netlifyConfig`,
|
|
29
|
-
|
|
26
|
+
- Server adapters (`@resolid/dev/server`): `createServer`, `nodeConfig`, `netlifyConfig`,
|
|
27
|
+
`vercelConfig`.
|
|
30
28
|
|
|
31
|
-
## Usage patterns
|
|
29
|
+
## Usage patterns
|
|
32
30
|
|
|
33
31
|
### 1) Central config
|
|
34
32
|
|
|
@@ -93,6 +91,30 @@ export default await createServer((platform) => {
|
|
|
93
91
|
|
|
94
92
|
Visit: https://reactrouter.com/home
|
|
95
93
|
|
|
94
|
+
### 6) Flex routes
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
// src/routes.ts
|
|
98
|
+
import { flexRoutes, type RouteConfig } from "@resolid/dev/routes";
|
|
99
|
+
|
|
100
|
+
export default flexRoutes() satisfies RouteConfig;
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Router Rules
|
|
104
|
+
|
|
105
|
+
- Routes are defined and nested using folders, very similar to how HTML files are laid out on the nginx server
|
|
106
|
+
- The `_layout` file wraps all downstream routes, which require an `<Outlet />` to render sub-routes
|
|
107
|
+
- The `_index` file is the default file for the folder, for example: `/users/_index.tsx` will match `/users`
|
|
108
|
+
- Variables are represented by `$` in the file path, for example: `/users/$id/edit.tsx` will match `/users/123/edit`
|
|
109
|
+
- Enclosing a route segment in parentheses will make the segment optional, for example: `/($lang)/categories.tsx` will
|
|
110
|
+
match `/categories`, `/zh/categories`
|
|
111
|
+
- You can use `[]` to escape special characters in routing conventions, for example: `/make-[$$$]-fast-online.tsx` will
|
|
112
|
+
match `/make-$$$-fast-online`
|
|
113
|
+
- Files and folders prefixed with `_` become invisible, allowing folder organization without affecting routing paths,
|
|
114
|
+
for example: `/_legal-pages/privacy-policy.tsx` will match `/ privacy-policy`
|
|
115
|
+
- `$.tsx` splash route will match the rest of the URL, including slashes, e.g. `/files/$.tsx` will match `/files`,
|
|
116
|
+
`/files/one`, `/files/one/two`
|
|
117
|
+
|
|
96
118
|
## License
|
|
97
119
|
|
|
98
120
|
MIT License (MIT). Please see [LICENSE](./LICENSE) for more information.
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as ServerPlatform, t as NodeVersion } from "./index-BMC9vh2X.mjs";
|
|
2
|
+
import { Simplify } from "@resolid/utils";
|
|
2
3
|
import { Config } from "@react-router/dev/config";
|
|
3
4
|
|
|
4
5
|
//#region src/config/index.d.ts
|
|
5
6
|
interface VitePluginOptions {
|
|
6
|
-
platform:
|
|
7
|
+
platform: ServerPlatform;
|
|
7
8
|
nodeVersion: NodeVersion;
|
|
8
9
|
entryFile: string;
|
|
9
10
|
devExclude?: (string | RegExp)[];
|
|
10
11
|
}
|
|
11
|
-
type ReactRouterConfig = Omit<Config, "appDirectory" | "ssr" | "serverModuleFormat" | "future"> & {
|
|
12
|
+
type ReactRouterConfig = Simplify<Omit<Config, "appDirectory" | "ssr" | "serverModuleFormat" | "future"> & {
|
|
12
13
|
future?: Omit<Config["future"], "v8_middleware" | "v8_splitRouteModules" | "v8_viteEnvironmentApi">;
|
|
13
|
-
}
|
|
14
|
-
type DevConfigOptions = Partial<VitePluginOptions> & {
|
|
14
|
+
}>;
|
|
15
|
+
type DevConfigOptions = Simplify<Partial<VitePluginOptions> & {
|
|
15
16
|
appDirectory?: string;
|
|
16
17
|
includeFiles?: string[];
|
|
17
18
|
reactRouterConfig?: ReactRouterConfig;
|
|
18
|
-
}
|
|
19
|
+
}>;
|
|
19
20
|
interface DevConfig {
|
|
20
21
|
vitePluginOptions: VitePluginOptions;
|
|
21
22
|
reactRouterConfig: Config;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as defineDevConfig, i as VitePluginOptions, n as DevConfigOptions, r as ReactRouterConfig, t as DevConfig } from "./index-
|
|
1
|
+
import { a as defineDevConfig, i as VitePluginOptions, n as DevConfigOptions, r as ReactRouterConfig, t as DevConfig } from "./index-BMs3Y706.mjs";
|
|
2
2
|
export { DevConfig, DevConfigOptions, ReactRouterConfig, VitePluginOptions, defineDevConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cp as e,mkdir as t,readFile as n,readdir as r,realpath as i,rm as a,stat as o,symlink as s,writeFile as c}from"node:fs/promises";import{basename as l,dirname as u,join as d,relative as f}from"node:path";import p from"fast-glob";import{existsSync as m}from"node:fs";import{build as h}from"rolldown";import{esmExternalRequirePlugin as g}from"rolldown/plugins";import{searchForWorkspaceRoot as _}from"vite";var v=`@resolid/dev`,y=`0.
|
|
1
|
+
import{cp as e,mkdir as t,readFile as n,readdir as r,realpath as i,rm as a,stat as o,symlink as s,writeFile as c}from"node:fs/promises";import{basename as l,dirname as u,join as d,relative as f}from"node:path";import p from"fast-glob";import{existsSync as m}from"node:fs";import{build as h}from"rolldown";import{esmExternalRequirePlugin as g}from"rolldown/plugins";import{searchForWorkspaceRoot as _}from"vite";var v=`@resolid/dev`,y=`0.2.0`;async function b({includeFiles:t=[],nodeVersion:r=22,buildManifest:i,reactRouterConfig:o,viteConfig:s,buildStart:c,buildBundleEnd:l}){let m=s.root,_=s.build.assetsDir??`assets`,v=JSON.parse(await n(d(m,`package.json`),`utf8`)),y=x(v.dependencies??{},s.ssr.external),b=d(o.buildDirectory,`server`),C=i?.serverBundles??{site:{id:`site`,file:f(m,d(b,o.serverBuildFile))}},w=t?.length>0?await p(t,{cwd:m}):[],T=await c();await Promise.all(Object.entries(C).map(async([,t])=>{let n=t.id,i=d(m,t.file),o=u(i);await S(d(o,`package.json`),v,y,r),console.log(`Bundle file for ${n}...`);let s=d(o,`server.mjs`);await h({input:i,output:{file:s,codeSplitting:!1,minify:`dce-only`,comments:{legal:!1}},platform:`node`,transform:{define:{"process.env.NODE_ENV":JSON.stringify(`production`),"import.meta.env.NODE_ENV":JSON.stringify(`production`)},target:`node${r}`},external:[`vite`,...Object.keys(y)],plugins:[g({external:[`vite`,...Object.keys(y)],skipDuplicateCheck:!0})]}),await a(d(o,_),{force:!0,recursive:!0}),await a(i,{force:!0}),await Promise.all(w.map(t=>e(t,d(b,t),{recursive:!0}))),await l?.(T,o,n,s,y)}))}function x(e,t){let n=Array.isArray(t)?t.filter(e=>![`react-router`,`react-router-dom`,`@react-router/architect`,`@react-router/cloudflare`,`@react-router/dev`,`@react-router/express`,`@react-router/node`,`@react-router/serve`].includes(e)):t;return Object.keys(e).filter(e=>n===void 0?!1:n===!0?!0:n.includes(e)).reduce((t,n)=>(t[n]=e[n]??``,t),{})}async function S(e,t,n,r){let i={name:t.name,type:t.type,version:t.version,scripts:{postinstall:t.scripts?.postinstall??``},dependencies:n,engines:{node:`${r}.x`}};await c(e,JSON.stringify(i,null,2),`utf8`)}async function C(e,n=!1){let r=d(...e);return n&&await a(r,{recursive:!0,force:!0}),await t(r,{recursive:!0}),r}function w(e){if(e?.routeIdToServerBundleId){let t=Object.values(e.routes).filter(e=>e.id!=`root`).map(t=>{let n=[...T(e.routes,t.parentId),t.path].join(`/`);return{id:t.id,path:`/${n}`}}),n={};for(let[r,i]of Object.entries(e?.routeIdToServerBundleId)){n[i]||(n[i]=[]);for(let e of t)e.id==r&&n[i].push(e.path)}let r={};for(let[e,t]of Object.entries(n)){t.sort((e,t)=>e.length<t.length?-1:1);for(let n of t)!r[n]&&!Object.keys(r).find(t=>r[t].bundleId==e&&n.startsWith(r[t].path))&&(r[n]={path:n,bundleId:e})}let i=Object.values(r).map(e=>({path:e.path.endsWith(`/`)?e.path.slice(0,-1):e.path,bundleId:e.bundleId}));return i.sort((e,t)=>e.path.length>t.path.length?-1:1),i}return[{path:``,bundleId:`site`}]}function T(e,t){if(t==null)return[];let n=[],r=t=>{let i=e[t];i.parentId&&r(i.parentId),i.path&&n.push(i.path)};return r(t),n}async function E(n,a,c){let p=_(n),{nodeFileTrace:h}=await import(`@vercel/nft`),g=await h([n],{base:p,cache:c}),v=Array.from(g.fileList).map(e=>d(p,e)),y=u(v[0]);for(let e of v.slice(1))for(;!e.startsWith(y);)y=u(y);return await Promise.all(v.map(async c=>{let p=d(a,f(y,c)),h=await i(c),g=h!==c,_=(await o(c)).isDirectory();if(await t(u(p),{recursive:!0}),c==n){let t=u(n),i=u(p);await Promise.all((await r(t)).filter(e=>e!==l(n)).map(n=>e(d(t,n),d(i,n),{recursive:!0})))}g?m(p)||await s(f(u(p),d(a,f(y,h))),p,_?`dir`:`file`):_||await e(c,p)})),f(y,n)}const D=e=>{let{nodeVersion:t}=e;return{name:`@resolid/react-router-hono-netlify-preset`,reactRouterConfig:()=>({buildEnd:async({buildManifest:n,reactRouterConfig:r,viteConfig:i})=>{await b({includeFiles:e.includeFiles,nodeVersion:t,buildManifest:n,reactRouterConfig:r,viteConfig:i,buildStart:async()=>{let e=await C([i.root,`.netlify`,`v1`],!0);return await O(i.build.assetsDir??`assets`,d(e,`config.json`)),{netlifyRoot:e,netlifyFunctionDir:await C([e,`functions`]),serverRoutes:w(n),nftCache:{}}},buildBundleEnd:async(e,n,r,i)=>{console.log(`Coping Netlify function files for ${r}...`);let a=await E(i,await C([e.netlifyFunctionDir,r],!0),e.nftCache),o=e.serverRoutes.find(e=>e.bundleId==r)?.path,s=o?[o,`${o}/*`]:`/*`;await c(d(e.netlifyFunctionDir,`${r}.mjs`),`export { default } from "./${d(r,a)}";
|
|
2
2
|
|
|
3
3
|
export const config = {
|
|
4
4
|
path: ${Array.isArray(s)?JSON.stringify(s):`"${s}"`},
|
package/dist/routes.d.mts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { RouteConfigEntry, index, layout, route } from "@react-router/dev/routes";
|
|
2
2
|
|
|
3
|
-
//#region src/routes/index.d.ts
|
|
3
|
+
//#region src/routes/relative/index.d.ts
|
|
4
4
|
declare function relativeFactory(directory: string): {
|
|
5
5
|
route: typeof route;
|
|
6
6
|
index: typeof index;
|
|
7
7
|
layout: typeof layout;
|
|
8
8
|
};
|
|
9
9
|
//#endregion
|
|
10
|
-
|
|
10
|
+
//#region src/routes/flex/index.d.ts
|
|
11
|
+
type FolderRoutesOptions = {
|
|
12
|
+
routesDirectory?: string;
|
|
13
|
+
ignoredRouteFiles?: string[];
|
|
14
|
+
};
|
|
15
|
+
declare function flexRoutes(options?: FolderRoutesOptions): Promise<RouteConfigEntry[]>;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { FolderRoutesOptions, flexRoutes, relativeFactory };
|
package/dist/routes.mjs
CHANGED
|
@@ -1 +1,3 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{readdir as e}from"node:fs/promises";import{extname as t,join as n,relative as r,resolve as i,win32 as a}from"node:path";import{getAppDirectory as o,index as s,layout as c,route as l}from"@react-router/dev/routes";import{makeRe as u}from"minimatch";function d(e){let t=o();return{route:(n,a,...o)=>l(n,r(t,i(e,a)),...o),index:(n,...a)=>s(r(t,i(e,n)),...a),layout:(n,...a)=>c(r(t,i(e,n)),...a)}}async function f(t,i,a=t){for(let o of await e(t,{withFileTypes:!0,encoding:`utf8`})){let e=n(t,o.name);o.isDirectory()?await f(e,i,a):o.isFile()&&i(r(a,e))}}function p(e,t=`root`){let n={};for(let t in e){let r=e[t];n[t]={id:r.id,file:r.file,path:r.path,index:r.index,caseSensitive:r.caseSensitive}}let r=[];for(let i in n){let a=n[i],{parentId:o}=e[a.id];if(o===t)r.push(a);else{let e=o&&n[o];e&&(e.children=e.children||[],e.children.push(a))}}return r}function m(e,r){let i={},a=new Map,o=new Map;for(let i of r){let r=y(n(e,i)),s=r.slice(0,-t(r).length),c=s.slice(-7)==`_layout`?s.slice(0,-8):s,l=a.get(c);if(l){let e=o.get(c)??[l];e.push(r),o.set(c,e);continue}a.set(c,r)}let s=new v,c=Array.from(a).sort(([e],[t])=>t.length-e.length);for(let[t,n]of c){let[r,a]=h(t.slice(e.length+1)),o=t.slice(-6)==`_index`;i[t]={file:n,id:t,path:g(r,a,o)},o&&(i[t].index=!0);let c=s.findAndRemove(t,e=>[`.`,`/`].includes(e.slice(t.length).charAt(0)));if(s.add(t),c.length>0)for(let e of c)i[e].parentId=t}let l=new Map;for(let[e]of c){let t=i[e];if(!t.parentId)continue;let n=l.get(t.parentId)||[];n.push(t),l.set(t.parentId,n)}let u=new Map,d=new Map;for(let[t]of c){let n=i[t],r=n.path||``,a=n.parentId?i[n.parentId]:null,o=n.path;a?.path&&o&&(o=o.slice(a.path.length).replace(/^\//,``).replace(/\/$/,``)),n.parentId||=`root`,n.path=o||void 0;let s=n.id.replace(RegExp(`^${e}/`),``).split(/[./]/).pop();if(s&&s[0]==`_`&&s!==`_index`)continue;let c=r+(n.index?`?index`:``),l=u.get(c);if(u.set(c,n),l&&(r||n.index)){let e=d.get(r);e||=[l],e.push(n),d.set(r,e)}}if(o.size>0)for(let[e,t]of o.entries()){let[n,...r]=t,i=r.map(e=>`⭕ ${e}`).join(`
|
|
2
|
+
`);console.error(`!Route ID 冲突: "${e}"\n\n下列路由都定义了相同的路由 ID,但只有第一个会生效\n\n🟢 ${n}\n${i}\n`)}if(d.size>0)for(let[e,t]of d.entries()){for(let e=1;e<t.length;e++)delete i[t[e].id];let[n,...r]=t.map(e=>e.file),a=e[0]==`/`?e:`/${e}`,o=r.map(e=>`⭕ ${e}`).join(`
|
|
3
|
+
`);console.error(`! Route 路径冲突: "${a}"\n\n下列路由都定义了相同的 URL,但只有第一个会生效\n\n🟢 ${n}\n${o}\n`)}return i}function h(e){let t=[],n=[],r=0,i=``,a=``,o=`NORMAL`,s=(e,r)=>{if(e){if(r.includes(`*`)||r.includes(`:`)||r.includes(`?`))throw Error("路由文件或目录中不能存在 `*` `:` `?` 特殊字符");t.push(e),n.push(r)}};for(;r<e.length;){let t=e[r];switch(r++,o){case`NORMAL`:if(t&&[`.`,`/`].includes(t)){s(i,a),i=``,a=``,o=`NORMAL`;break}if(t===`[`){o=`ESCAPE`,a+=t;break}if(t===`(`){o=`OPTIONAL`,a+=t;break}if(!i&&t==`$`){r===e.length?(i+=`*`,a+=t):(i+=`:`,a+=t);break}i+=t,a+=t;break;case`ESCAPE`:if(t===`]`){o=`NORMAL`,a+=t;break}i+=t,a+=t;break;case`OPTIONAL`:if(t===`)`){i+=`?`,a+=t,o=`NORMAL`;break}if(t===`[`){o=`OPTIONAL_ESCAPE`,a+=t;break}if(!i&&t===`$`){r===e.length?(i+=`*`,a+=t):(i+=`:`,a+=t);break}i+=t,a+=t;break;case`OPTIONAL_ESCAPE`:if(t===`]`){o=`OPTIONAL`,a+=t;break}i+=t,a+=t;break}}return s(i,a),[t,n]}function g(e,t,n){let r=[],i=n?e.slice(0,-1):e;for(let e=0;e<i.length;e++){let n=t[e],a=i[e];a.startsWith(`_`)&&n.startsWith(`_`)||(a.endsWith(`_`)&&n.endsWith(`_`)&&(a=a.slice(0,-1)),r.push(a))}return r.length?r.join(`/`):void 0}const _=Symbol(`PrefixLookupTrieEndSymbol`);var v=class{root={[_]:!1};add(e){if(!e)throw Error(`Cannot add empty string to PrefixLookupTrie`);let t=this.root;for(let n of e)t[n]||(t[n]={[_]:!1}),t=t[n];t[_]=!0}findAndRemove(e,t){let n=this.root;for(let t of e){if(!n[t])return[];n=n[t]}return this.#e([],n,e,t)}#e(e,t,n,r){for(let i of Object.keys(t))this.#e(e,t[i],n+i,r);return t[_]&&r(n)&&(t[_]=!1,e.push(n)),e}};function y(e){return e.split(a.sep).join(`/`)}const b=[`.js`,`.jsx`,`.ts`,`.tsx`,`.md`,`.mdx`];async function x(e={}){let{routesDirectory:r=`routes`,ignoredRouteFiles:i=[]}=e,a=o(),s=i.map(e=>u(e)).filter(e=>!!e),c=[];return await f(n(a,r),e=>{s.some(t=>t.test(e))||b.includes(t(e))&&c.push(e)}),p(m(r,c))}export{x as flexRoutes,d as relativeFactory};
|
package/dist/server.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as
|
|
1
|
+
import { n as ServerPlatform } from "./index-BMC9vh2X.mjs";
|
|
2
2
|
import { AppLoadContext, RouterContextProvider, ServerBuild, UNSAFE_MiddlewareEnabled } from "react-router";
|
|
3
3
|
import { Context, Context as HonoContext, Env, Hono, Hono as Hono$1, MiddlewareHandler } from "hono";
|
|
4
4
|
import { Http2Bindings, HttpBindings } from "@hono/node-server";
|
|
@@ -49,6 +49,6 @@ declare const cacheControl: typeof cache;
|
|
|
49
49
|
declare const nodeConfig: PlatformConfig<HonoNodeServerOptions>;
|
|
50
50
|
declare const netlifyConfig: PlatformConfig<HonoNetlifyServerOptions>;
|
|
51
51
|
declare const vercelConfig: PlatformConfig<HonoVercelServerOptions>;
|
|
52
|
-
declare const createServer: (factory: (platform:
|
|
52
|
+
declare const createServer: (factory: (platform: ServerPlatform) => HonoNodeServerOptions | HonoNetlifyServerOptions | HonoVercelServerOptions | undefined) => Promise<((req: Request, context: NetlifyContext) => Response | Promise<Response>) | ((incoming: IncomingMessage | Http2ServerRequest, outgoing: ServerResponse | Http2ServerResponse) => Promise<void>) | Hono<NodeEnv>>;
|
|
53
53
|
//#endregion
|
|
54
|
-
export { type Hono, type HonoContext, type NetlifyContext, type NodeEnv, type
|
|
54
|
+
export { type Hono, type HonoContext, type NetlifyContext, type NodeEnv, type ServerPlatform, cacheControl, createServer, netlifyConfig, nodeConfig, vercelConfig };
|
package/dist/vite.d.mts
CHANGED
package/dist/vite.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{join as e,relative as t}from"node:path";import{existsSync as n,statSync as r}from"node:fs";import{normalizePath as i}from"vite";import{
|
|
1
|
+
import{join as e,relative as t}from"node:path";import{existsSync as n,statSync as r}from"node:fs";import{normalizePath as i}from"vite";import{makeRe as a}from"minimatch";import{getRequestListener as o}from"@hono/node-server";import{reactRouter as s}from"@react-router/dev/vite";function c(n,r){if(!(`__reactRouterPluginContext`in n))return;let{reactRouterConfig:i,rootDirectory:a,buildManifest:o,environmentBuildContext:s}=n.__reactRouterPluginContext,c=t(a,i.appDirectory);return{entryFile:e(c,r.entryFile),appDir:c,buildDir:t(a,i.buildDirectory),assetsDir:n.build?.assetsDir||`assets`,ssrBuild:s?.name===`ssr`,future:i.future,buildManifest:o}}function l(e,t){let n=i(e),[r]=n.split(`/`),o=[RegExp(`^(?=\\/${n}\\/)((?!.*\\.data(\\?|$)).*\\..*(\\?.*)?$)`),RegExp(`^(?=\\/${n}\\/.*\\/\\..*\\/.*)`)];if(n!=r&&(o.push(RegExp(`^(?=\\/${r}\\/)((?!.*\\.data(\\?|$)).*\\..*(\\?.*)?$)`)),o.push(RegExp(`^(?=\\/${r}\\/.*\\/\\..*\\/.*)`))),t)for(let e of t)if(e instanceof RegExp)o.push(e);else try{o.push(a(e))}catch{}return o}function u(e,t){if(e.includes(`/node_modules/`)||e.startsWith(`/@`)||e.includes(`?import`))return!0;for(let n of t)if(n.test(e))return!0;return!1}function d(t){let i=``,a;return{name:`@resolid/vite-dev-plugin`,enforce:`post`,config(e){if(a=c(e,t),!a)return;let n={define:{"import.meta.env.RESOLID_PLATFORM":JSON.stringify(t.platform),"import.meta.env.RESOLID_BUILD_DIR":JSON.stringify(a.buildDir),"import.meta.env.RESOLID_ASSETS_DIR":JSON.stringify(a.assetsDir)},ssr:{noExternal:[`@resolid/dev`]}};if(!a.future?.v8_viteEnvironmentApi&&!a.ssrBuild)return n;let r={build:{target:`node${t.nodeVersion}`,rollupOptions:{input:a.entryFile}}};return a.future?.v8_viteEnvironmentApi?{...n,environments:{ssr:r}}:{...n,...r}},configResolved(e){if(i=e.publicDir,a?.buildManifest?.serverBundles)for(let t of Object.keys(a.buildManifest.serverBundles))e.environments[`ssrBundle_${t}`]&&(e.environments[`ssrBundle_${t}`].build.rollupOptions.input=a.entryFile)},async configureServer(s){if(!a)return;let c=l(a.appDir,t?.devExclude);s.middlewares.use(await(async t=>async(s,l,d)=>{if(s.url){let t=e(i,s.url);try{if(n(t)&&r(t).isFile())return d()}catch{}}if(s.url&&u(s.url,c))return d();let f=a.entryFile,p=a.future?.v8_viteEnvironmentApi?(await t.environments.ssr.runner.import(f)).default:(await t.ssrLoadModule(f)).default;if(!p)return d(Error(`Failed to find default export from ${f}`));await o(async e=>{let t=await p.fetch(e,{incoming:s,outgoing:l});if(!(t instanceof Response))throw t;return t},{overrideGlobalObjects:!1,errorHandler:e=>{let n;e instanceof Error?(n=e,t.ssrFixStacktrace(n)):n=typeof e==`string`?Error(`The response is not an instance of "Response", but: ${e}`):Error(`Unknown error: ${e}`),d(n)}})(s,l)})(s))},handleHotUpdate({server:e,modules:t}){if(t.some(e=>e._ssrModule))return e.hot.send({type:`full-reload`}),[]}}}function f(e){return[d(e),...s()]}export{f as resolidVite};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@resolid/dev",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Development utils for Resolid applications",
|
|
6
6
|
"keywords": [
|
|
@@ -22,11 +22,7 @@
|
|
|
22
22
|
"url": "git+https://github.com/resolid/framework.git",
|
|
23
23
|
"directory": "packages/dev"
|
|
24
24
|
},
|
|
25
|
-
"bin": {
|
|
26
|
-
"react-router": "cli/react-router.js"
|
|
27
|
-
},
|
|
28
25
|
"files": [
|
|
29
|
-
"cli",
|
|
30
26
|
"dist",
|
|
31
27
|
"env.d.ts"
|
|
32
28
|
],
|
|
@@ -69,7 +65,6 @@
|
|
|
69
65
|
},
|
|
70
66
|
"dependencies": {
|
|
71
67
|
"@hono/node-server": "^1.19.9",
|
|
72
|
-
"@react-router/dev": "^7.13.1",
|
|
73
68
|
"@resolid/utils": "^1.2.7",
|
|
74
69
|
"@vercel/nft": "^1.3.2",
|
|
75
70
|
"fast-glob": "^3.3.3",
|
|
@@ -78,10 +73,12 @@
|
|
|
78
73
|
"rolldown": "latest"
|
|
79
74
|
},
|
|
80
75
|
"devDependencies": {
|
|
76
|
+
"@react-router/dev": "^7.13.1",
|
|
81
77
|
"tsdown": "^0.20.3"
|
|
82
78
|
},
|
|
83
79
|
"peerDependencies": {
|
|
84
80
|
"@netlify/types": "^2.3.0",
|
|
81
|
+
"@react-router/dev": "^7.13.1",
|
|
85
82
|
"@react-router/node": "^7.13.1",
|
|
86
83
|
"isbot": "^5.1.35",
|
|
87
84
|
"react-router": "^7.13.1",
|
|
@@ -93,6 +90,7 @@
|
|
|
93
90
|
"scripts": {
|
|
94
91
|
"build": "tsdown",
|
|
95
92
|
"lint": "oxlint",
|
|
93
|
+
"test": "vitest run",
|
|
96
94
|
"typecheck": "tsc --noEmit"
|
|
97
95
|
}
|
|
98
96
|
}
|
package/cli/react-router.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { spawn } from "node:child_process";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { argv, exit } from "node:process";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
|
|
7
|
-
const binPath = resolve(
|
|
8
|
-
dirname(fileURLToPath(import.meta.url)),
|
|
9
|
-
"../node_modules/.bin/react-router",
|
|
10
|
-
);
|
|
11
|
-
|
|
12
|
-
const child = spawn(binPath, argv.slice(2), { stdio: "inherit" });
|
|
13
|
-
|
|
14
|
-
child.on("exit", (code) => {
|
|
15
|
-
exit(code ?? 0);
|
|
16
|
-
});
|