@quilted/rollup 0.3.3 → 0.4.1
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 +12 -0
- package/build/esm/app.mjs +24 -44
- package/build/esm/constants.mjs +2 -2
- package/build/esm/index.mjs +1 -1
- package/build/esm/server.mjs +34 -17
- package/build/tsconfig.tsbuildinfo +1 -1
- package/build/typescript/app.d.ts +24 -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/module.d.ts +1 -1
- package/build/typescript/package.d.ts +2 -2
- package/build/typescript/server.d.ts +22 -17
- package/build/typescript/server.d.ts.map +1 -1
- package/package.json +1 -1
- package/source/app.ts +47 -83
- package/source/constants.ts +1 -1
- package/source/server.ts +55 -32
|
@@ -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
|
*/
|
|
@@ -302,13 +300,22 @@ export interface AppRuntime {
|
|
|
302
300
|
* Customizations to the server for this runtime.
|
|
303
301
|
*/
|
|
304
302
|
server?: AppServerRuntime;
|
|
303
|
+
/**
|
|
304
|
+
* Customizations to the browser build for this runtime.
|
|
305
|
+
*/
|
|
306
|
+
browser?: {
|
|
307
|
+
/**
|
|
308
|
+
* Provides additional Rollup options to customize the server build.
|
|
309
|
+
* This function receives the current Rollup options and can return
|
|
310
|
+
* modified options or a partial override.
|
|
311
|
+
*/
|
|
312
|
+
rollup?(options: RollupOptions): InputPluginOption;
|
|
313
|
+
};
|
|
305
314
|
}
|
|
306
|
-
export interface AppServerRuntime extends Omit<ServerRuntime, '
|
|
307
|
-
|
|
308
|
-
assets: Required<Pick<AppBrowserAssetsOptions, 'baseURL'>>;
|
|
309
|
-
}): string;
|
|
315
|
+
export interface AppServerRuntime extends Omit<ServerRuntime, 'hono'> {
|
|
316
|
+
hono?(): string;
|
|
310
317
|
}
|
|
311
|
-
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS,
|
|
318
|
+
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_HONO, };
|
|
312
319
|
export declare function quiltApp({ root, app, env, graphql, assets, browser: browserOptions, server: serverOptions, serviceWorker: serviceWorkerOptions, runtime, }?: AppOptions): Promise<RollupOptions[]>;
|
|
313
320
|
export declare function quiltAppBrowser(options?: AppBrowserOptions): Promise<{
|
|
314
321
|
plugins: InputPluginOption[];
|
|
@@ -500,23 +507,15 @@ export declare function quiltAppServiceWorkerInput({ root, entry, }?: Pick<AppSe
|
|
|
500
507
|
}>;
|
|
501
508
|
};
|
|
502
509
|
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
510
|
}
|
|
510
|
-
export declare function nodeAppServerRuntime({ host, port, format,
|
|
511
|
+
export declare function nodeAppServerRuntime({ host, port, format, }?: NodeAppServerRuntimeOptions): {
|
|
511
512
|
env: string;
|
|
512
513
|
output: {
|
|
513
514
|
options: {
|
|
514
515
|
format: "cjs" | "esm";
|
|
515
516
|
};
|
|
516
517
|
};
|
|
517
|
-
|
|
518
|
-
assets: Required<Pick<AppBrowserAssetsOptions, "baseURL">>;
|
|
519
|
-
}): string;
|
|
518
|
+
hono(): string;
|
|
520
519
|
};
|
|
521
520
|
export declare function magicModuleAppComponent({ entry, root, }: {
|
|
522
521
|
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,E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,CAAC;CACrB,mCAyCA;AAsBD,wBAAsB,uBAAuB,CAAC,EAC5C,KAAK,EACL,IAAoB,GACrB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,+BA8BA;AAED,wBAAsB,8BAA8B,CAAC,EACnD,KAAK,EACL,IAAoB,GACrB,EAAE;IACD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;CACrB,+BAgBA"}
|
|
@@ -2,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"}
|
|
@@ -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
|
-
import { type InputPluginOption } from 'rollup';
|
|
1
|
+
import { type InputPluginOption, type RollupOptions } 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,18 @@ 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;
|
|
64
|
+
/**
|
|
65
|
+
* Provides additional Rollup options to customize the server build.
|
|
66
|
+
* This function receives the current Rollup options and can return
|
|
67
|
+
* modified options or a partial override.
|
|
68
|
+
*/
|
|
69
|
+
rollup?(options: RollupOptions): InputPluginOption;
|
|
65
70
|
}
|
|
66
71
|
export interface ServerOutputOptions extends Pick<RollupNodePluginOptions, 'bundle'> {
|
|
67
72
|
/**
|
|
@@ -87,7 +92,7 @@ export interface ServerOutputOptions extends Pick<RollupNodePluginOptions, 'bund
|
|
|
87
92
|
*/
|
|
88
93
|
hash?: boolean | 'async-only';
|
|
89
94
|
}
|
|
90
|
-
export { MAGIC_MODULE_ENTRY,
|
|
95
|
+
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO };
|
|
91
96
|
export declare function quiltServer({ root: rootPath, entry, format, env, graphql, output, runtime, }?: ServerOptions): Promise<{
|
|
92
97
|
input: {
|
|
93
98
|
[x: string]: string;
|
|
@@ -176,6 +181,6 @@ export declare function nodeServerRuntime({ host, port, format, }?: NodeServerRu
|
|
|
176
181
|
resolve: {
|
|
177
182
|
exportConditions: string[];
|
|
178
183
|
};
|
|
179
|
-
|
|
184
|
+
hono(): string;
|
|
180
185
|
};
|
|
181
186
|
//# 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,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../source/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,iBAAiB,EAAE,KAAK,aAAa,EAAC,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,K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pB;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
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.
|
|
@@ -385,19 +383,29 @@ export interface AppRuntime {
|
|
|
385
383
|
* Customizations to the server for this runtime.
|
|
386
384
|
*/
|
|
387
385
|
server?: AppServerRuntime;
|
|
386
|
+
|
|
387
|
+
/**
|
|
388
|
+
* Customizations to the browser build for this runtime.
|
|
389
|
+
*/
|
|
390
|
+
browser?: {
|
|
391
|
+
/**
|
|
392
|
+
* Provides additional Rollup options to customize the server build.
|
|
393
|
+
* This function receives the current Rollup options and can return
|
|
394
|
+
* modified options or a partial override.
|
|
395
|
+
*/
|
|
396
|
+
rollup?(options: RollupOptions): InputPluginOption;
|
|
397
|
+
};
|
|
388
398
|
}
|
|
389
399
|
|
|
390
|
-
export interface AppServerRuntime extends Omit<ServerRuntime, '
|
|
391
|
-
|
|
392
|
-
assets: Required<Pick<AppBrowserAssetsOptions, 'baseURL'>>;
|
|
393
|
-
}): string;
|
|
400
|
+
export interface AppServerRuntime extends Omit<ServerRuntime, 'hono'> {
|
|
401
|
+
hono?(): string;
|
|
394
402
|
}
|
|
395
403
|
|
|
396
404
|
export {
|
|
397
405
|
MAGIC_MODULE_ENTRY,
|
|
398
406
|
MAGIC_MODULE_APP_COMPONENT,
|
|
399
407
|
MAGIC_MODULE_BROWSER_ASSETS,
|
|
400
|
-
|
|
408
|
+
MAGIC_MODULE_HONO,
|
|
401
409
|
};
|
|
402
410
|
|
|
403
411
|
const require = createRequire(import.meta.url);
|
|
@@ -505,7 +513,7 @@ export async function quiltAppBrowser(options: AppBrowserOptions = {}) {
|
|
|
505
513
|
rollupGenerateOptionsForBrowsers(browserGroup.browsers),
|
|
506
514
|
]);
|
|
507
515
|
|
|
508
|
-
|
|
516
|
+
const rollupOptions = {
|
|
509
517
|
plugins,
|
|
510
518
|
output: {
|
|
511
519
|
format: isESM ? 'esm' : 'systemjs',
|
|
@@ -523,6 +531,12 @@ export async function quiltAppBrowser(options: AppBrowserOptions = {}) {
|
|
|
523
531
|
},
|
|
524
532
|
preserveEntrySignatures: false,
|
|
525
533
|
} satisfies RollupOptions;
|
|
534
|
+
|
|
535
|
+
if (runtime?.browser?.rollup) {
|
|
536
|
+
rollupOptions.plugins.push(runtime.browser.rollup(rollupOptions));
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return rollupOptions;
|
|
526
540
|
}
|
|
527
541
|
|
|
528
542
|
export async function quiltAppBrowserPlugins({
|
|
@@ -826,7 +840,7 @@ export async function quiltAppServerPlugins({
|
|
|
826
840
|
app,
|
|
827
841
|
env,
|
|
828
842
|
entry,
|
|
829
|
-
format = '
|
|
843
|
+
format = 'hono',
|
|
830
844
|
graphql = true,
|
|
831
845
|
assets,
|
|
832
846
|
output,
|
|
@@ -888,16 +902,11 @@ export async function quiltAppServerPlugins({
|
|
|
888
902
|
}),
|
|
889
903
|
magicModuleAppComponent({entry: app, root: project.root}),
|
|
890
904
|
createMagicModulePlugin({
|
|
891
|
-
name: '@quilted/
|
|
905
|
+
name: '@quilted/hono',
|
|
892
906
|
sideEffects: true,
|
|
893
907
|
module: MAGIC_MODULE_ENTRY,
|
|
894
908
|
source() {
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
return (
|
|
898
|
-
runtime.requestRouter?.(options) ??
|
|
899
|
-
nodeAppServerRuntime().requestRouter(options)
|
|
900
|
-
);
|
|
909
|
+
return runtime.hono?.() ?? nodeAppServerRuntime().hono();
|
|
901
910
|
},
|
|
902
911
|
}),
|
|
903
912
|
magicModuleAppRequestRouter({entry, root: project.root}),
|
|
@@ -972,7 +981,7 @@ export async function quiltAppServerPlugins({
|
|
|
972
981
|
export function quiltAppServerInput({
|
|
973
982
|
root = process.cwd(),
|
|
974
983
|
entry,
|
|
975
|
-
format = '
|
|
984
|
+
format = 'hono',
|
|
976
985
|
}: Pick<AppServerOptions, 'root' | 'entry' | 'format'> = {}) {
|
|
977
986
|
return {
|
|
978
987
|
name: '@quilted/app-server/input',
|
|
@@ -981,7 +990,7 @@ export function quiltAppServerInput({
|
|
|
981
990
|
normalizeRollupInput(options.input) ??
|
|
982
991
|
(await sourceEntryForAppServer({entry, root}));
|
|
983
992
|
const finalEntry =
|
|
984
|
-
format === '
|
|
993
|
+
format === 'hono'
|
|
985
994
|
? MAGIC_MODULE_ENTRY
|
|
986
995
|
: (serverEntry ?? MAGIC_MODULE_ENTRY);
|
|
987
996
|
const finalEntryName =
|
|
@@ -1191,20 +1200,12 @@ export function quiltAppServiceWorkerInput({
|
|
|
1191
1200
|
} satisfies Plugin;
|
|
1192
1201
|
}
|
|
1193
1202
|
|
|
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
|
-
}
|
|
1203
|
+
export interface NodeAppServerRuntimeOptions extends NodeServerRuntimeOptions {}
|
|
1202
1204
|
|
|
1203
1205
|
export function nodeAppServerRuntime({
|
|
1204
1206
|
host,
|
|
1205
1207
|
port,
|
|
1206
1208
|
format = 'module',
|
|
1207
|
-
assets: serveAssets = true,
|
|
1208
1209
|
}: NodeAppServerRuntimeOptions = {}) {
|
|
1209
1210
|
const rollupFormat =
|
|
1210
1211
|
format === 'commonjs' || format === 'cjs' ? 'cjs' : 'esm';
|
|
@@ -1216,52 +1217,15 @@ export function nodeAppServerRuntime({
|
|
|
1216
1217
|
format: rollupFormat,
|
|
1217
1218
|
},
|
|
1218
1219
|
},
|
|
1219
|
-
|
|
1220
|
-
const {baseURL} = assets;
|
|
1221
|
-
|
|
1220
|
+
hono() {
|
|
1222
1221
|
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';
|
|
1222
|
+
import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
|
|
1223
|
+
import {serve} from '@quilted/hono/node';
|
|
1234
1224
|
|
|
1235
1225
|
const port = ${port ?? 'Number.parseInt(process.env.PORT, 10)'};
|
|
1236
1226
|
const host = ${host ? JSON.stringify(host) : 'process.env.HOST'};
|
|
1237
1227
|
|
|
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);
|
|
1228
|
+
serve({fetch: app.fetch, port, hostname: host});
|
|
1265
1229
|
`;
|
|
1266
1230
|
},
|
|
1267
1231
|
} satisfies AppServerRuntime;
|
|
@@ -1300,13 +1264,13 @@ export function magicModuleAppRequestRouter({
|
|
|
1300
1264
|
root = process.cwd(),
|
|
1301
1265
|
}: Pick<AppServerOptions, 'entry' | 'root'> = {}) {
|
|
1302
1266
|
return createMagicModulePlugin({
|
|
1303
|
-
name: '@quilted/magic-module/app-
|
|
1304
|
-
module:
|
|
1267
|
+
name: '@quilted/magic-module/app-hono',
|
|
1268
|
+
module: MAGIC_MODULE_HONO,
|
|
1305
1269
|
alias: () => sourceEntryForAppServer({entry, root}) as Promise<string>,
|
|
1306
1270
|
async source() {
|
|
1307
1271
|
return multiline`
|
|
1272
|
+
import {Hono} from 'hono';
|
|
1308
1273
|
import {jsx} from 'preact/jsx-runtime';
|
|
1309
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
1310
1274
|
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
1311
1275
|
|
|
1312
1276
|
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
@@ -1314,11 +1278,11 @@ export function magicModuleAppRequestRouter({
|
|
|
1314
1278
|
MAGIC_MODULE_BROWSER_ASSETS,
|
|
1315
1279
|
)};
|
|
1316
1280
|
|
|
1317
|
-
const
|
|
1281
|
+
const app = new Hono();
|
|
1318
1282
|
const assets = new BrowserAssets();
|
|
1319
1283
|
|
|
1320
|
-
|
|
1321
|
-
|
|
1284
|
+
app.get(async (c) => {
|
|
1285
|
+
const request = c.req.raw;
|
|
1322
1286
|
const response = await renderAppToHTMLResponse(jsx(App), {
|
|
1323
1287
|
request,
|
|
1324
1288
|
assets,
|
|
@@ -1327,7 +1291,7 @@ export function magicModuleAppRequestRouter({
|
|
|
1327
1291
|
return response;
|
|
1328
1292
|
});
|
|
1329
1293
|
|
|
1330
|
-
export default
|
|
1294
|
+
export default app;
|
|
1331
1295
|
`;
|
|
1332
1296
|
},
|
|
1333
1297
|
});
|
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';
|