@quilted/rollup 0.3.2 → 0.4.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/CHANGELOG.md +16 -0
- package/build/esm/app.mjs +19 -47
- package/build/esm/constants.mjs +2 -2
- package/build/esm/features/async.mjs +34 -31
- package/build/esm/index.mjs +1 -1
- package/build/esm/server.mjs +29 -16
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +13 -25
- package/build/typescript/app.d.ts.map +1 -1
- package/build/typescript/constants.d.ts +1 -1
- package/build/typescript/constants.d.ts.map +1 -1
- package/build/typescript/features/async.d.ts +0 -1
- package/build/typescript/features/async.d.ts.map +1 -1
- package/build/typescript/server.d.ts +15 -16
- package/build/typescript/server.d.ts.map +1 -1
- package/package.json +3 -3
- package/source/app.ts +28 -86
- package/source/constants.ts +1 -1
- package/source/features/async.ts +124 -37
- package/source/server.ts +41 -31
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RollupOptions, InputPluginOption, GetManualChunk } from 'rollup';
|
|
2
|
-
import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS,
|
|
2
|
+
import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_HONO } from './constants.ts';
|
|
3
3
|
import { type MagicModuleEnvOptions } from './features/env.ts';
|
|
4
4
|
import { type RollupNodePluginOptions } from './shared/rollup.ts';
|
|
5
5
|
import { type BrowserGroupTargetSelection } from './shared/browserslist.ts';
|
|
@@ -198,17 +198,15 @@ export interface AppServerOptions extends AppBaseOptions {
|
|
|
198
198
|
*/
|
|
199
199
|
entry?: string;
|
|
200
200
|
/**
|
|
201
|
-
* Whether this server code uses
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
* the
|
|
205
|
-
*
|
|
206
|
-
* as a basic server-side JavaScript project, without the special
|
|
207
|
-
* `request-router` adaptor.
|
|
201
|
+
* Whether this server code uses `hono` to define itself in a generic way, which can
|
|
202
|
+
* be adapted to a variety of environments. By default, this is `'hono'`, and when `'hono'`,
|
|
203
|
+
* the `entry` you specified must export an `Hono` object as its default export. When set to `'custom'`,
|
|
204
|
+
* the app server will be built as a basic server-side JavaScript project, without the special
|
|
205
|
+
* `hono` adaptor.
|
|
208
206
|
*
|
|
209
|
-
* @default '
|
|
207
|
+
* @default 'hono'
|
|
210
208
|
*/
|
|
211
|
-
format?: '
|
|
209
|
+
format?: 'hono' | 'custom';
|
|
212
210
|
/**
|
|
213
211
|
* Customizes the assets created for your application.
|
|
214
212
|
*/
|
|
@@ -303,12 +301,10 @@ export interface AppRuntime {
|
|
|
303
301
|
*/
|
|
304
302
|
server?: AppServerRuntime;
|
|
305
303
|
}
|
|
306
|
-
export interface AppServerRuntime extends Omit<ServerRuntime, '
|
|
307
|
-
|
|
308
|
-
assets: Required<Pick<AppBrowserAssetsOptions, 'baseURL'>>;
|
|
309
|
-
}): string;
|
|
304
|
+
export interface AppServerRuntime extends Omit<ServerRuntime, 'hono'> {
|
|
305
|
+
hono?(): string;
|
|
310
306
|
}
|
|
311
|
-
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS,
|
|
307
|
+
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_HONO, };
|
|
312
308
|
export declare function quiltApp({ root, app, env, graphql, assets, browser: browserOptions, server: serverOptions, serviceWorker: serviceWorkerOptions, runtime, }?: AppOptions): Promise<RollupOptions[]>;
|
|
313
309
|
export declare function quiltAppBrowser(options?: AppBrowserOptions): Promise<{
|
|
314
310
|
plugins: InputPluginOption[];
|
|
@@ -500,23 +496,15 @@ export declare function quiltAppServiceWorkerInput({ root, entry, }?: Pick<AppSe
|
|
|
500
496
|
}>;
|
|
501
497
|
};
|
|
502
498
|
export interface NodeAppServerRuntimeOptions extends NodeServerRuntimeOptions {
|
|
503
|
-
/**
|
|
504
|
-
* Whether the server should serve assets from the asset output directory.
|
|
505
|
-
*
|
|
506
|
-
* @default true
|
|
507
|
-
*/
|
|
508
|
-
assets?: boolean;
|
|
509
499
|
}
|
|
510
|
-
export declare function nodeAppServerRuntime({ host, port, format,
|
|
500
|
+
export declare function nodeAppServerRuntime({ host, port, format, }?: NodeAppServerRuntimeOptions): {
|
|
511
501
|
env: string;
|
|
512
502
|
output: {
|
|
513
503
|
options: {
|
|
514
504
|
format: "esm" | "cjs";
|
|
515
505
|
};
|
|
516
506
|
};
|
|
517
|
-
|
|
518
|
-
assets: Required<Pick<AppBrowserAssetsOptions, "baseURL">>;
|
|
519
|
-
}): string;
|
|
507
|
+
hono(): string;
|
|
520
508
|
};
|
|
521
509
|
export declare function magicModuleAppComponent({ entry, root, }: {
|
|
522
510
|
entry?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../source/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../source/app.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAEV,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,QAAQ,CAAC;AAGhB,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,2BAA2B,EAC3B,iBAAiB,EAClB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAmB,KAAK,qBAAqB,EAAC,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAIL,KAAK,uBAAuB,EAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAOL,KAAK,2BAA2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5 +2,5 @@ export declare const MAGIC_MODULE_ENV = "quilt:module/env";
|
|
|
2
2
|
export declare const MAGIC_MODULE_ENTRY = "quilt:module/entry";
|
|
3
3
|
export declare const MAGIC_MODULE_APP_COMPONENT = "quilt:module/app";
|
|
4
4
|
export declare const MAGIC_MODULE_BROWSER_ASSETS = "quilt:module/assets";
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const MAGIC_MODULE_HONO = "quilt:module/hono";
|
|
6
6
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../source/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAC7D,eAAO,MAAM,2BAA2B,wBAAwB,CAAC;AACjE,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../source/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,0BAA0B,qBAAqB,CAAC;AAC7D,eAAO,MAAM,2BAA2B,wBAAwB,CAAC;AACjE,eAAO,MAAM,iBAAiB,sBAAsB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../source/features/async.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAA4B,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../source/features/async.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAA4B,MAAM,QAAQ,CAAC;AAM9D,MAAM,WAAW,OAAO;IACtB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,CAAC,OAAO,EAAE;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,GAAG,MAAM,CAAC;CAChD;AAED,wBAAgB,YAAY,CAAC,EAC3B,OAAc,EACd,OAAoB,EACpB,QAAQ,EAAE,WAA6B,GACxC,GAAE,OAAY,GAAG,MAAM,CA0DvB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type InputPluginOption } from 'rollup';
|
|
2
2
|
import { RollupNodePluginOptions } from './shared/rollup.ts';
|
|
3
3
|
import { type MagicModuleEnvOptions } from './features/env.ts';
|
|
4
|
-
import { MAGIC_MODULE_ENTRY,
|
|
4
|
+
import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO } from './constants.ts';
|
|
5
5
|
import type { ModuleRuntime } from './module.ts';
|
|
6
6
|
export interface ServerOptions {
|
|
7
7
|
/**
|
|
@@ -19,17 +19,16 @@ export interface ServerOptions {
|
|
|
19
19
|
*/
|
|
20
20
|
entry?: string;
|
|
21
21
|
/**
|
|
22
|
-
* Whether this server code uses
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* `request-router` adaptor.
|
|
22
|
+
* Whether this server code uses `hono` to define itself in a generic way,
|
|
23
|
+
* which can be adapted to a variety of environments. By default, this is
|
|
24
|
+
* `'hono'`, and when `'hono'`, the `entry` you specified must export an
|
|
25
|
+
* `Hono` object as its default export. When set to `'custom'`, the app
|
|
26
|
+
* server will be built as a basic server-side JavaScript project, without
|
|
27
|
+
* the special `hono` adaptor.
|
|
29
28
|
*
|
|
30
|
-
* @default '
|
|
29
|
+
* @default 'hono'
|
|
31
30
|
*/
|
|
32
|
-
format?: '
|
|
31
|
+
format?: 'hono' | 'custom';
|
|
33
32
|
/**
|
|
34
33
|
* Whether to include GraphQL-related code transformations.
|
|
35
34
|
*
|
|
@@ -56,12 +55,12 @@ export interface ServerRuntime extends ModuleRuntime {
|
|
|
56
55
|
*/
|
|
57
56
|
env?: string;
|
|
58
57
|
/**
|
|
59
|
-
* The content to use as the entry point when the server uses the `
|
|
60
|
-
* format for their server. This file should import the
|
|
61
|
-
* this app from 'quilt:module/
|
|
58
|
+
* The content to use as the entry point when the server uses the `hono`
|
|
59
|
+
* format for their server. This file should import the hono instance for
|
|
60
|
+
* this app from 'quilt:module/hono', and create a server that is appropriate
|
|
62
61
|
* for this runtime.
|
|
63
62
|
*/
|
|
64
|
-
|
|
63
|
+
hono?(): string;
|
|
65
64
|
}
|
|
66
65
|
export interface ServerOutputOptions extends Pick<RollupNodePluginOptions, 'bundle'> {
|
|
67
66
|
/**
|
|
@@ -87,7 +86,7 @@ export interface ServerOutputOptions extends Pick<RollupNodePluginOptions, 'bund
|
|
|
87
86
|
*/
|
|
88
87
|
hash?: boolean | 'async-only';
|
|
89
88
|
}
|
|
90
|
-
export { MAGIC_MODULE_ENTRY,
|
|
89
|
+
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO };
|
|
91
90
|
export declare function quiltServer({ root: rootPath, entry, format, env, graphql, output, runtime, }?: ServerOptions): Promise<{
|
|
92
91
|
input: {
|
|
93
92
|
[x: string]: string;
|
|
@@ -176,6 +175,6 @@ export declare function nodeServerRuntime({ host, port, format, }?: NodeServerRu
|
|
|
176
175
|
resolve: {
|
|
177
176
|
exportConditions: string[];
|
|
178
177
|
};
|
|
179
|
-
|
|
178
|
+
hono(): string;
|
|
180
179
|
};
|
|
181
180
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../source/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,iBAAiB,EAAqB,MAAM,QAAQ,CAAC;AAGlE,OAAO,EACL,uBAAuB,EAGxB,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAmB,KAAK,qBAAqB,EAAC,MAA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AAE,OAAO,GAAG,YAAY,CAAC;CAC/B;AAED,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,CAAC;AAE/C,wBAAsB,WAAW,CAAC,EAChC,IAAI,EAAE,QAAwB,EAC9B,KAAK,EACL,MAAe,EACf,GAAG,EACH,OAAc,EACd,MAAM,EACN,OAA6B,GAC9B,GAAE,aAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsHpB;AAED,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAEvB;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,MAAM,CAAC,EACH,QAAQ,GACR,SAAS,GACT,WAAW,GACX,KAAK,GACL,IAAI,GACJ,UAAU,GACV,KAAK,CAAC;CACX;AAED,wBAAgB,iBAAiB,CAAC,EAChC,IAAI,EACJ,IAAI,EACJ,MAAiB,GAClB,GAAE,wBAA6B;;;;;;;;;;;EAuC/B"}
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"access": "public",
|
|
7
7
|
"@quilted/registry": "https://registry.npmjs.org"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.4.0",
|
|
10
10
|
"engines": {
|
|
11
11
|
"node": ">=20.10.0"
|
|
12
12
|
},
|
|
@@ -138,8 +138,8 @@
|
|
|
138
138
|
"@babel/preset-typescript": "^7.26.0",
|
|
139
139
|
"@mdn/browser-compat-data": "^5.6.0",
|
|
140
140
|
"@quilted/assets": "^0.1.9",
|
|
141
|
-
"@quilted/babel": "^0.2.
|
|
142
|
-
"@quilted/graphql": "^3.3.
|
|
141
|
+
"@quilted/babel": "^0.2.4",
|
|
142
|
+
"@quilted/graphql": "^3.3.9",
|
|
143
143
|
"@rollup/plugin-alias": "^5.1.0",
|
|
144
144
|
"@rollup/plugin-babel": "^6.0.4",
|
|
145
145
|
"@rollup/plugin-commonjs": "^28.0.0",
|
package/source/app.ts
CHANGED
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
MAGIC_MODULE_ENTRY,
|
|
15
15
|
MAGIC_MODULE_APP_COMPONENT,
|
|
16
16
|
MAGIC_MODULE_BROWSER_ASSETS,
|
|
17
|
-
|
|
17
|
+
MAGIC_MODULE_HONO,
|
|
18
18
|
} from './constants.ts';
|
|
19
19
|
import {resolveEnvOption, type MagicModuleEnvOptions} from './features/env.ts';
|
|
20
20
|
|
|
@@ -265,17 +265,15 @@ export interface AppServerOptions extends AppBaseOptions {
|
|
|
265
265
|
entry?: string;
|
|
266
266
|
|
|
267
267
|
/**
|
|
268
|
-
* Whether this server code uses
|
|
269
|
-
*
|
|
270
|
-
*
|
|
271
|
-
* the
|
|
272
|
-
*
|
|
273
|
-
* as a basic server-side JavaScript project, without the special
|
|
274
|
-
* `request-router` adaptor.
|
|
268
|
+
* Whether this server code uses `hono` to define itself in a generic way, which can
|
|
269
|
+
* be adapted to a variety of environments. By default, this is `'hono'`, and when `'hono'`,
|
|
270
|
+
* the `entry` you specified must export an `Hono` object as its default export. When set to `'custom'`,
|
|
271
|
+
* the app server will be built as a basic server-side JavaScript project, without the special
|
|
272
|
+
* `hono` adaptor.
|
|
275
273
|
*
|
|
276
|
-
* @default '
|
|
274
|
+
* @default 'hono'
|
|
277
275
|
*/
|
|
278
|
-
format?: '
|
|
276
|
+
format?: 'hono' | 'custom';
|
|
279
277
|
|
|
280
278
|
/**
|
|
281
279
|
* Customizes the assets created for your application.
|
|
@@ -387,17 +385,15 @@ export interface AppRuntime {
|
|
|
387
385
|
server?: AppServerRuntime;
|
|
388
386
|
}
|
|
389
387
|
|
|
390
|
-
export interface AppServerRuntime extends Omit<ServerRuntime, '
|
|
391
|
-
|
|
392
|
-
assets: Required<Pick<AppBrowserAssetsOptions, 'baseURL'>>;
|
|
393
|
-
}): string;
|
|
388
|
+
export interface AppServerRuntime extends Omit<ServerRuntime, 'hono'> {
|
|
389
|
+
hono?(): string;
|
|
394
390
|
}
|
|
395
391
|
|
|
396
392
|
export {
|
|
397
393
|
MAGIC_MODULE_ENTRY,
|
|
398
394
|
MAGIC_MODULE_APP_COMPONENT,
|
|
399
395
|
MAGIC_MODULE_BROWSER_ASSETS,
|
|
400
|
-
|
|
396
|
+
MAGIC_MODULE_HONO,
|
|
401
397
|
};
|
|
402
398
|
|
|
403
399
|
const require = createRequire(import.meta.url);
|
|
@@ -826,7 +822,7 @@ export async function quiltAppServerPlugins({
|
|
|
826
822
|
app,
|
|
827
823
|
env,
|
|
828
824
|
entry,
|
|
829
|
-
format = '
|
|
825
|
+
format = 'hono',
|
|
830
826
|
graphql = true,
|
|
831
827
|
assets,
|
|
832
828
|
output,
|
|
@@ -888,16 +884,11 @@ export async function quiltAppServerPlugins({
|
|
|
888
884
|
}),
|
|
889
885
|
magicModuleAppComponent({entry: app, root: project.root}),
|
|
890
886
|
createMagicModulePlugin({
|
|
891
|
-
name: '@quilted/
|
|
887
|
+
name: '@quilted/hono',
|
|
892
888
|
sideEffects: true,
|
|
893
889
|
module: MAGIC_MODULE_ENTRY,
|
|
894
890
|
source() {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return (
|
|
898
|
-
runtime.requestRouter?.(options) ??
|
|
899
|
-
nodeAppServerRuntime().requestRouter(options)
|
|
900
|
-
);
|
|
891
|
+
return runtime.hono?.() ?? nodeAppServerRuntime().hono();
|
|
901
892
|
},
|
|
902
893
|
}),
|
|
903
894
|
magicModuleAppRequestRouter({entry, root: project.root}),
|
|
@@ -972,7 +963,7 @@ export async function quiltAppServerPlugins({
|
|
|
972
963
|
export function quiltAppServerInput({
|
|
973
964
|
root = process.cwd(),
|
|
974
965
|
entry,
|
|
975
|
-
format = '
|
|
966
|
+
format = 'hono',
|
|
976
967
|
}: Pick<AppServerOptions, 'root' | 'entry' | 'format'> = {}) {
|
|
977
968
|
return {
|
|
978
969
|
name: '@quilted/app-server/input',
|
|
@@ -981,7 +972,7 @@ export function quiltAppServerInput({
|
|
|
981
972
|
normalizeRollupInput(options.input) ??
|
|
982
973
|
(await sourceEntryForAppServer({entry, root}));
|
|
983
974
|
const finalEntry =
|
|
984
|
-
format === '
|
|
975
|
+
format === 'hono'
|
|
985
976
|
? MAGIC_MODULE_ENTRY
|
|
986
977
|
: (serverEntry ?? MAGIC_MODULE_ENTRY);
|
|
987
978
|
const finalEntryName =
|
|
@@ -1191,20 +1182,12 @@ export function quiltAppServiceWorkerInput({
|
|
|
1191
1182
|
} satisfies Plugin;
|
|
1192
1183
|
}
|
|
1193
1184
|
|
|
1194
|
-
export interface NodeAppServerRuntimeOptions extends NodeServerRuntimeOptions {
|
|
1195
|
-
/**
|
|
1196
|
-
* Whether the server should serve assets from the asset output directory.
|
|
1197
|
-
*
|
|
1198
|
-
* @default true
|
|
1199
|
-
*/
|
|
1200
|
-
assets?: boolean;
|
|
1201
|
-
}
|
|
1185
|
+
export interface NodeAppServerRuntimeOptions extends NodeServerRuntimeOptions {}
|
|
1202
1186
|
|
|
1203
1187
|
export function nodeAppServerRuntime({
|
|
1204
1188
|
host,
|
|
1205
1189
|
port,
|
|
1206
1190
|
format = 'module',
|
|
1207
|
-
assets: serveAssets = true,
|
|
1208
1191
|
}: NodeAppServerRuntimeOptions = {}) {
|
|
1209
1192
|
const rollupFormat =
|
|
1210
1193
|
format === 'commonjs' || format === 'cjs' ? 'cjs' : 'esm';
|
|
@@ -1216,52 +1199,15 @@ export function nodeAppServerRuntime({
|
|
|
1216
1199
|
format: rollupFormat,
|
|
1217
1200
|
},
|
|
1218
1201
|
},
|
|
1219
|
-
|
|
1220
|
-
const {baseURL} = assets;
|
|
1221
|
-
|
|
1202
|
+
hono() {
|
|
1222
1203
|
return multiline`
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
import {createServer} from 'http';
|
|
1226
|
-
|
|
1227
|
-
import requestRouter from ${JSON.stringify(
|
|
1228
|
-
MAGIC_MODULE_REQUEST_ROUTER,
|
|
1229
|
-
)};
|
|
1230
|
-
|
|
1231
|
-
import {createHttpRequestListener${
|
|
1232
|
-
serveAssets ? ', serveStatic' : ''
|
|
1233
|
-
}} from '@quilted/quilt/request-router/node';
|
|
1204
|
+
import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
|
|
1205
|
+
import {serve} from '@quilted/hono/node';
|
|
1234
1206
|
|
|
1235
1207
|
const port = ${port ?? 'Number.parseInt(process.env.PORT, 10)'};
|
|
1236
1208
|
const host = ${host ? JSON.stringify(host) : 'process.env.HOST'};
|
|
1237
1209
|
|
|
1238
|
-
|
|
1239
|
-
serveAssets
|
|
1240
|
-
? multiline`
|
|
1241
|
-
const dirname = ${
|
|
1242
|
-
rollupFormat === 'cjs'
|
|
1243
|
-
? `__dirname`
|
|
1244
|
-
: `path.dirname(fileURLToPath(import.meta.url))`
|
|
1245
|
-
};
|
|
1246
|
-
const serve = serveStatic(path.resolve(dirname, '../assets'), {
|
|
1247
|
-
baseUrl: ${JSON.stringify(baseURL)},
|
|
1248
|
-
});
|
|
1249
|
-
`
|
|
1250
|
-
: ''
|
|
1251
|
-
}
|
|
1252
|
-
const listener = createHttpRequestListener(requestRouter);
|
|
1253
|
-
|
|
1254
|
-
createServer(async (request, response) => {
|
|
1255
|
-
${
|
|
1256
|
-
serveAssets
|
|
1257
|
-
? `if (request.url.startsWith(${JSON.stringify(
|
|
1258
|
-
baseURL,
|
|
1259
|
-
)})) return serve(request, response);`
|
|
1260
|
-
: ''
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
await listener(request, response);
|
|
1264
|
-
}).listen(port, host);
|
|
1210
|
+
serve({fetch: app.fetch, port, hostname: host});
|
|
1265
1211
|
`;
|
|
1266
1212
|
},
|
|
1267
1213
|
} satisfies AppServerRuntime;
|
|
@@ -1300,15 +1246,13 @@ export function magicModuleAppRequestRouter({
|
|
|
1300
1246
|
root = process.cwd(),
|
|
1301
1247
|
}: Pick<AppServerOptions, 'entry' | 'root'> = {}) {
|
|
1302
1248
|
return createMagicModulePlugin({
|
|
1303
|
-
name: '@quilted/magic-module/app-
|
|
1304
|
-
module:
|
|
1249
|
+
name: '@quilted/magic-module/app-hono',
|
|
1250
|
+
module: MAGIC_MODULE_HONO,
|
|
1305
1251
|
alias: () => sourceEntryForAppServer({entry, root}) as Promise<string>,
|
|
1306
1252
|
async source() {
|
|
1307
1253
|
return multiline`
|
|
1308
|
-
import '
|
|
1309
|
-
|
|
1254
|
+
import {Hono} from 'hono';
|
|
1310
1255
|
import {jsx} from 'preact/jsx-runtime';
|
|
1311
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
1312
1256
|
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
1313
1257
|
|
|
1314
1258
|
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
@@ -1316,11 +1260,11 @@ export function magicModuleAppRequestRouter({
|
|
|
1316
1260
|
MAGIC_MODULE_BROWSER_ASSETS,
|
|
1317
1261
|
)};
|
|
1318
1262
|
|
|
1319
|
-
const
|
|
1263
|
+
const app = new Hono();
|
|
1320
1264
|
const assets = new BrowserAssets();
|
|
1321
1265
|
|
|
1322
|
-
|
|
1323
|
-
|
|
1266
|
+
app.get(async (c) => {
|
|
1267
|
+
const request = c.req.raw;
|
|
1324
1268
|
const response = await renderAppToHTMLResponse(jsx(App), {
|
|
1325
1269
|
request,
|
|
1326
1270
|
assets,
|
|
@@ -1329,7 +1273,7 @@ export function magicModuleAppRequestRouter({
|
|
|
1329
1273
|
return response;
|
|
1330
1274
|
});
|
|
1331
1275
|
|
|
1332
|
-
export default
|
|
1276
|
+
export default app;
|
|
1333
1277
|
`;
|
|
1334
1278
|
},
|
|
1335
1279
|
});
|
|
@@ -1347,8 +1291,6 @@ export function magicModuleAppBrowserEntry({
|
|
|
1347
1291
|
const reactRootFunction = hydrate ? 'hydrate' : 'render';
|
|
1348
1292
|
|
|
1349
1293
|
return multiline`
|
|
1350
|
-
import '@quilted/quilt/globals';
|
|
1351
|
-
|
|
1352
1294
|
import {jsx} from 'preact/jsx-runtime';
|
|
1353
1295
|
import {${reactRootFunction}} from 'preact';
|
|
1354
1296
|
|
package/source/constants.ts
CHANGED
|
@@ -2,4 +2,4 @@ export const MAGIC_MODULE_ENV = 'quilt:module/env';
|
|
|
2
2
|
export const MAGIC_MODULE_ENTRY = 'quilt:module/entry';
|
|
3
3
|
export const MAGIC_MODULE_APP_COMPONENT = 'quilt:module/app';
|
|
4
4
|
export const MAGIC_MODULE_BROWSER_ASSETS = 'quilt:module/assets';
|
|
5
|
-
export const
|
|
5
|
+
export const MAGIC_MODULE_HONO = 'quilt:module/hono';
|