@quilted/rollup 0.3.3 → 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 +6 -0
- package/build/esm/app.mjs +19 -43
- package/build/esm/constants.mjs +2 -2
- 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 +14 -26
- 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/module.d.ts +1 -1
- package/build/typescript/package.d.ts +2 -2
- package/build/typescript/server.d.ts +16 -17
- package/build/typescript/server.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/app.ts +28 -82
- package/source/constants.ts +1 -1
- 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
|
-
format: "
|
|
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,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAGlC,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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"}
|
|
@@ -84,7 +84,7 @@ export interface ModuleAssetsOptions extends Pick<RollupNodePluginOptions, 'bund
|
|
|
84
84
|
}
|
|
85
85
|
export declare function quiltModule({ root, entry, env, assets, graphql, runtime, }?: ModuleOptions): Promise<{
|
|
86
86
|
input: {
|
|
87
|
-
[
|
|
87
|
+
[x: string]: string;
|
|
88
88
|
};
|
|
89
89
|
plugins: InputPluginOption[];
|
|
90
90
|
output: {
|
|
@@ -122,7 +122,7 @@ export declare function quiltPackage({ root, commonjs, esnext: explicitESNext, e
|
|
|
122
122
|
generatedCode: "es2015";
|
|
123
123
|
};
|
|
124
124
|
} | {
|
|
125
|
-
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | import("rollup").NullValue |
|
|
125
|
+
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | Plugin<any> | import("rollup").NullValue | import("rollup").InputPluginOption[]> | null)[];
|
|
126
126
|
output: OutputOptions | OutputOptions[] | {
|
|
127
127
|
preserveModules: true;
|
|
128
128
|
preserveModulesRoot: string;
|
|
@@ -192,7 +192,7 @@ export declare function quiltPackageESNext({ root, react: useReact, graphql, ent
|
|
|
192
192
|
generatedCode: "es2015";
|
|
193
193
|
};
|
|
194
194
|
} | {
|
|
195
|
-
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | import("rollup").NullValue |
|
|
195
|
+
plugins: (false | void | Plugin<any> | import("rollup").InputPluginOption[] | Promise<false | Plugin<any> | import("rollup").NullValue | import("rollup").InputPluginOption[]> | null)[];
|
|
196
196
|
output: OutputOptions | OutputOptions[] | {
|
|
197
197
|
preserveModules: true;
|
|
198
198
|
preserveModulesRoot: string;
|
|
@@ -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;
|
|
@@ -170,12 +169,12 @@ export declare function nodeServerRuntime({ host, port, format, }?: NodeServerRu
|
|
|
170
169
|
env: string;
|
|
171
170
|
output: {
|
|
172
171
|
options: {
|
|
173
|
-
format: "
|
|
172
|
+
format: "esm" | "cjs";
|
|
174
173
|
};
|
|
175
174
|
};
|
|
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,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAC,kBAAkB,EAAE,
|
|
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,MAAM,mBAAmB,CAAC;AAC/E,OAAO,EAAC,kBAAkB,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAErE,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,aAAa,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IAEpB;;;;;;;;OAQG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAAC;IAE3B;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;OAEG;I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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,13 +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`
|
|
1254
|
+
import {Hono} from 'hono';
|
|
1308
1255
|
import {jsx} from 'preact/jsx-runtime';
|
|
1309
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
1310
1256
|
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
1311
1257
|
|
|
1312
1258
|
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
@@ -1314,11 +1260,11 @@ export function magicModuleAppRequestRouter({
|
|
|
1314
1260
|
MAGIC_MODULE_BROWSER_ASSETS,
|
|
1315
1261
|
)};
|
|
1316
1262
|
|
|
1317
|
-
const
|
|
1263
|
+
const app = new Hono();
|
|
1318
1264
|
const assets = new BrowserAssets();
|
|
1319
1265
|
|
|
1320
|
-
|
|
1321
|
-
|
|
1266
|
+
app.get(async (c) => {
|
|
1267
|
+
const request = c.req.raw;
|
|
1322
1268
|
const response = await renderAppToHTMLResponse(jsx(App), {
|
|
1323
1269
|
request,
|
|
1324
1270
|
assets,
|
|
@@ -1327,7 +1273,7 @@ export function magicModuleAppRequestRouter({
|
|
|
1327
1273
|
return response;
|
|
1328
1274
|
});
|
|
1329
1275
|
|
|
1330
|
-
export default
|
|
1276
|
+
export default app;
|
|
1331
1277
|
`;
|
|
1332
1278
|
},
|
|
1333
1279
|
});
|
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';
|
package/source/server.ts
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import {multiline} from './shared/strings.ts';
|
|
13
13
|
import {resolveEnvOption, type MagicModuleEnvOptions} from './features/env.ts';
|
|
14
|
-
import {MAGIC_MODULE_ENTRY,
|
|
14
|
+
import {MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO} from './constants.ts';
|
|
15
15
|
import {createMagicModulePlugin} from './shared/magic-module.ts';
|
|
16
16
|
import type {ModuleRuntime} from './module.ts';
|
|
17
17
|
|
|
@@ -33,17 +33,16 @@ export interface ServerOptions {
|
|
|
33
33
|
entry?: string;
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Whether this server code uses
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
* `request-router` adaptor.
|
|
36
|
+
* Whether this server code uses `hono` to define itself in a generic way,
|
|
37
|
+
* which can be adapted to a variety of environments. By default, this is
|
|
38
|
+
* `'hono'`, and when `'hono'`, the `entry` you specified must export an
|
|
39
|
+
* `Hono` object as its default export. When set to `'custom'`, the app
|
|
40
|
+
* server will be built as a basic server-side JavaScript project, without
|
|
41
|
+
* the special `hono` adaptor.
|
|
43
42
|
*
|
|
44
|
-
* @default '
|
|
43
|
+
* @default 'hono'
|
|
45
44
|
*/
|
|
46
|
-
format?: '
|
|
45
|
+
format?: 'hono' | 'custom';
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
48
|
* Whether to include GraphQL-related code transformations.
|
|
@@ -76,12 +75,12 @@ export interface ServerRuntime extends ModuleRuntime {
|
|
|
76
75
|
env?: string;
|
|
77
76
|
|
|
78
77
|
/**
|
|
79
|
-
* The content to use as the entry point when the server uses the `
|
|
80
|
-
* format for their server. This file should import the
|
|
81
|
-
* this app from 'quilt:module/
|
|
78
|
+
* The content to use as the entry point when the server uses the `hono`
|
|
79
|
+
* format for their server. This file should import the hono instance for
|
|
80
|
+
* this app from 'quilt:module/hono', and create a server that is appropriate
|
|
82
81
|
* for this runtime.
|
|
83
82
|
*/
|
|
84
|
-
|
|
83
|
+
hono?(): string;
|
|
85
84
|
}
|
|
86
85
|
|
|
87
86
|
export interface ServerOutputOptions
|
|
@@ -112,12 +111,12 @@ export interface ServerOutputOptions
|
|
|
112
111
|
hash?: boolean | 'async-only';
|
|
113
112
|
}
|
|
114
113
|
|
|
115
|
-
export {MAGIC_MODULE_ENTRY,
|
|
114
|
+
export {MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO};
|
|
116
115
|
|
|
117
116
|
export async function quiltServer({
|
|
118
117
|
root: rootPath = process.cwd(),
|
|
119
118
|
entry,
|
|
120
|
-
format = '
|
|
119
|
+
format = 'hono',
|
|
121
120
|
env,
|
|
122
121
|
graphql = true,
|
|
123
122
|
output,
|
|
@@ -163,7 +162,7 @@ export async function quiltServer({
|
|
|
163
162
|
: await sourceForServer(project);
|
|
164
163
|
|
|
165
164
|
const finalEntry =
|
|
166
|
-
format === '
|
|
165
|
+
format === 'hono'
|
|
167
166
|
? MAGIC_MODULE_ENTRY
|
|
168
167
|
: (serverEntry ?? MAGIC_MODULE_ENTRY);
|
|
169
168
|
|
|
@@ -188,21 +187,19 @@ export async function quiltServer({
|
|
|
188
187
|
removeBuildFiles([outputDirectory, reportDirectory], {root: project.root}),
|
|
189
188
|
];
|
|
190
189
|
|
|
191
|
-
if (format === '
|
|
190
|
+
if (format === 'hono') {
|
|
192
191
|
plugins.push(
|
|
193
192
|
createMagicModulePlugin({
|
|
194
|
-
name: '@quilted/magic-module/server-
|
|
195
|
-
module:
|
|
193
|
+
name: '@quilted/magic-module/server-hono',
|
|
194
|
+
module: MAGIC_MODULE_HONO,
|
|
196
195
|
alias: serverEntry,
|
|
197
196
|
}),
|
|
198
197
|
createMagicModulePlugin({
|
|
199
|
-
name: '@quilted/
|
|
198
|
+
name: '@quilted/hono',
|
|
200
199
|
sideEffects: true,
|
|
201
200
|
module: MAGIC_MODULE_ENTRY,
|
|
202
201
|
source() {
|
|
203
|
-
return (
|
|
204
|
-
runtime.requestRouter?.() ?? nodeServerRuntime().requestRouter()
|
|
205
|
-
);
|
|
202
|
+
return runtime.hono?.() ?? nodeServerRuntime().hono();
|
|
206
203
|
},
|
|
207
204
|
}),
|
|
208
205
|
);
|
|
@@ -288,18 +285,31 @@ export function nodeServerRuntime({
|
|
|
288
285
|
resolve: {
|
|
289
286
|
exportConditions: ['node'],
|
|
290
287
|
},
|
|
291
|
-
|
|
288
|
+
hono() {
|
|
292
289
|
return multiline`
|
|
293
|
-
import
|
|
294
|
-
MAGIC_MODULE_REQUEST_ROUTER,
|
|
295
|
-
)};
|
|
290
|
+
import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
|
|
296
291
|
|
|
297
|
-
import {
|
|
292
|
+
import {serve} from '@quilted/quilt/hono/node';
|
|
298
293
|
|
|
299
294
|
const port = ${port ?? 'Number.parseInt(process.env.PORT, 10)'};
|
|
300
295
|
const host = ${host ? JSON.stringify(host) : 'process.env.HOST'};
|
|
301
|
-
|
|
302
|
-
|
|
296
|
+
|
|
297
|
+
const server = serve(app);
|
|
298
|
+
|
|
299
|
+
process.on('SIGINT', () => {
|
|
300
|
+
server.close();
|
|
301
|
+
process.exit(0);
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
process.on('SIGTERM', () => {
|
|
305
|
+
server.close((err) => {
|
|
306
|
+
if (err) {
|
|
307
|
+
console.error(err);
|
|
308
|
+
process.exit(1);
|
|
309
|
+
}
|
|
310
|
+
process.exit(0);
|
|
311
|
+
});
|
|
312
|
+
});
|
|
303
313
|
`;
|
|
304
314
|
},
|
|
305
315
|
} satisfies ServerRuntime;
|