rosetack 0.1.3 → 0.1.5

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.
@@ -1,29 +1,19 @@
1
1
  /**
2
- * The rosetack Vercel function - the dynamic half of a Vercel deploy.
2
+ * Vercel function entry: the edge adapter, unchanged.
3
3
  *
4
- * Every request that is NOT a static file in dist/ lands here: dynamic
5
- * pages (/sign, anything reading getContext() or $store()), /api routes,
6
- * and POST server actions. Static answers - prerendered documents, the
7
- * bundles, baked API bodies - are served by the CDN straight from dist/
8
- * and never touch this code. That split is the whole rosetack story: the
9
- * static half costs zero function invocations.
4
+ * vercel.json rewrites every unmatched path here and ships dist/ with the
5
+ * bundle (the adapter imports dist/server.js at runtime, so the function
6
+ * cannot start without it). The handler is createEdgeHandler's returned
7
+ * (request) => Response, exposed behind Vercel's Web Standard signature.
10
8
  *
11
- * It reuses the framework's own edge adapter (the same Web-standard fetch
12
- * handler the edge adapter test exercises) over the built server bundle,
13
- * on Vercel's Node.js runtime, whose Web Standard handler is
14
- * `export default { fetch }` - one handler object, every method. The
15
- * Node.js runtime compiles TypeScript entrypoints and their imports, so
16
- * this file and the adapter it pulls in stay .ts.
17
- *
18
- * Install: copy this file to <project>/api/rosetack.ts and deploy/vercel.json
19
- * to <project>/vercel.json, then `vercel --prod`. In a project that depends
20
- * on the published package the import below becomes:
21
- * import { createEdgeHandler } from 'rosetack/edge';
9
+ * The dist path goes through fileURLToPath, NOT URL.pathname: on Windows a
10
+ * pathname carries the drive as `/C:/...` and the leading slash makes the
11
+ * dynamic import resolve against the drive root instead of this directory.
22
12
  */
23
- import { createEdgeHandler } from '../src/cli/edge.ts';
24
13
  import { fileURLToPath } from 'node:url';
14
+ import { createEdgeHandler } from '../src/cli/edge.ts';
25
15
 
26
- // dist/ next to the api/ directory, whatever the working directory is.
27
- const handle = await createEdgeHandler(fileURLToPath(new URL('../dist', import.meta.url)));
16
+ const dist = fileURLToPath(new URL('../dist/', import.meta.url));
17
+ const handle = await createEdgeHandler(dist);
28
18
 
29
19
  export default { fetch: handle };
@@ -0,0 +1,4 @@
1
+ import('./dist/prod.mjs').catch((err) => {
2
+ console.error('[server.cjs] failed to start dist/prod.mjs:', err);
3
+ process.exit(1);
4
+ });