@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 CHANGED
@@ -1,5 +1,21 @@
1
1
  # @quilted/rollup
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#872](https://github.com/lemonmade/quilt/pull/872) [`8bf65e7`](https://github.com/lemonmade/quilt/commit/8bf65e797f929ee95730323426c229409e65c9a4) Thanks [@lemonmade](https://github.com/lemonmade)! - Replace @quilted/request-router with Hono
8
+
9
+ ## 0.3.3
10
+
11
+ ### Patch Changes
12
+
13
+ - [#871](https://github.com/lemonmade/quilt/pull/871) [`c16b322`](https://github.com/lemonmade/quilt/commit/c16b3224d3c86bc3a3b6f6af44267650d1e8dc1d) Thanks [@lemonmade](https://github.com/lemonmade)! - Remove @quilt/quilt/globals module
14
+
15
+ - Updated dependencies [[`c16b322`](https://github.com/lemonmade/quilt/commit/c16b3224d3c86bc3a3b6f6af44267650d1e8dc1d)]:
16
+ - @quilted/babel@0.2.4
17
+ - @quilted/graphql@3.3.9
18
+
3
19
  ## 0.3.2
4
20
 
5
21
  ### Patch Changes
package/build/esm/app.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as path from 'node:path';
2
2
  import * as fs from 'node:fs/promises';
3
3
  import { createRequire } from 'node:module';
4
- import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS } from './constants.mjs';
4
+ import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO, MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS } from './constants.mjs';
5
5
  import { resolveEnvOption } from './features/env.mjs';
6
6
  import { multiline } from './shared/strings.mjs';
7
7
  import { getNodePlugins, removeBuildFiles, normalizeRollupInput } from './shared/rollup.mjs';
@@ -363,7 +363,7 @@ async function quiltAppServerPlugins({
363
363
  app,
364
364
  env,
365
365
  entry,
366
- format = "request-router",
366
+ format = "hono",
367
367
  graphql = true,
368
368
  assets,
369
369
  output,
@@ -420,12 +420,11 @@ async function quiltAppServerPlugins({
420
420
  }),
421
421
  magicModuleAppComponent({ entry: app, root: project.root }),
422
422
  createMagicModulePlugin({
423
- name: "@quilted/request-router",
423
+ name: "@quilted/hono",
424
424
  sideEffects: true,
425
425
  module: MAGIC_MODULE_ENTRY,
426
426
  source() {
427
- const options = { assets: { baseURL } };
428
- return runtime.requestRouter?.(options) ?? nodeAppServerRuntime().requestRouter(options);
427
+ return runtime.hono?.() ?? nodeAppServerRuntime().hono();
429
428
  }
430
429
  }),
431
430
  magicModuleAppRequestRouter({ entry, root: project.root }),
@@ -490,13 +489,13 @@ async function quiltAppServerPlugins({
490
489
  function quiltAppServerInput({
491
490
  root = process.cwd(),
492
491
  entry,
493
- format = "request-router"
492
+ format = "hono"
494
493
  } = {}) {
495
494
  return {
496
495
  name: "@quilted/app-server/input",
497
496
  async options(options) {
498
497
  const serverEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppServer({ entry, root });
499
- const finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
498
+ const finalEntry = format === "hono" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
500
499
  const finalEntryName = typeof serverEntry === "string" ? path.basename(serverEntry).split(".").slice(0, -1).join(".") : "server";
501
500
  return {
502
501
  ...options,
@@ -665,8 +664,7 @@ function quiltAppServiceWorkerInput({
665
664
  function nodeAppServerRuntime({
666
665
  host,
667
666
  port,
668
- format = "module",
669
- assets: serveAssets = true
667
+ format = "module"
670
668
  } = {}) {
671
669
  const rollupFormat = format === "commonjs" || format === "cjs" ? "cjs" : "esm";
672
670
  return {
@@ -676,37 +674,15 @@ function nodeAppServerRuntime({
676
674
  format: rollupFormat
677
675
  }
678
676
  },
679
- requestRouter({ assets }) {
680
- const { baseURL } = assets;
677
+ hono() {
681
678
  return multiline`
682
- ${serveAssets ? `import * as path from 'path';` : ""}
683
- ${rollupFormat === "cjs" ? "" : `import {fileURLToPath} from 'url';`}
684
- import {createServer} from 'http';
685
-
686
- import requestRouter from ${JSON.stringify(
687
- MAGIC_MODULE_REQUEST_ROUTER
688
- )};
689
-
690
- import {createHttpRequestListener${serveAssets ? ", serveStatic" : ""}} from '@quilted/quilt/request-router/node';
679
+ import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
680
+ import {serve} from '@quilted/hono/node';
691
681
 
692
682
  const port = ${port ?? "Number.parseInt(process.env.PORT, 10)"};
693
683
  const host = ${host ? JSON.stringify(host) : "process.env.HOST"};
694
684
 
695
- ${serveAssets ? multiline`
696
- const dirname = ${rollupFormat === "cjs" ? `__dirname` : `path.dirname(fileURLToPath(import.meta.url))`};
697
- const serve = serveStatic(path.resolve(dirname, '../assets'), {
698
- baseUrl: ${JSON.stringify(baseURL)},
699
- });
700
- ` : ""}
701
- const listener = createHttpRequestListener(requestRouter);
702
-
703
- createServer(async (request, response) => {
704
- ${serveAssets ? `if (request.url.startsWith(${JSON.stringify(
705
- baseURL
706
- )})) return serve(request, response);` : ""}
707
-
708
- await listener(request, response);
709
- }).listen(port, host);
685
+ serve({fetch: app.fetch, port, hostname: host});
710
686
  `;
711
687
  }
712
688
  };
@@ -736,15 +712,13 @@ function magicModuleAppRequestRouter({
736
712
  root = process.cwd()
737
713
  } = {}) {
738
714
  return createMagicModulePlugin({
739
- name: "@quilted/magic-module/app-request-router",
740
- module: MAGIC_MODULE_REQUEST_ROUTER,
715
+ name: "@quilted/magic-module/app-hono",
716
+ module: MAGIC_MODULE_HONO,
741
717
  alias: () => sourceEntryForAppServer({ entry, root }),
742
718
  async source() {
743
719
  return multiline`
744
- import '@quilted/quilt/globals';
745
-
720
+ import {Hono} from 'hono';
746
721
  import {jsx} from 'preact/jsx-runtime';
747
- import {RequestRouter} from '@quilted/quilt/request-router';
748
722
  import {renderAppToHTMLResponse} from '@quilted/quilt/server';
749
723
 
750
724
  import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
@@ -752,11 +726,11 @@ function magicModuleAppRequestRouter({
752
726
  MAGIC_MODULE_BROWSER_ASSETS
753
727
  )};
754
728
 
755
- const router = new RequestRouter();
729
+ const app = new Hono();
756
730
  const assets = new BrowserAssets();
757
731
 
758
- // For all GET requests, render our React application.
759
- router.get(async (request) => {
732
+ app.get(async (c) => {
733
+ const request = c.req.raw;
760
734
  const response = await renderAppToHTMLResponse(jsx(App), {
761
735
  request,
762
736
  assets,
@@ -765,7 +739,7 @@ function magicModuleAppRequestRouter({
765
739
  return response;
766
740
  });
767
741
 
768
- export default router;
742
+ export default app;
769
743
  `;
770
744
  }
771
745
  });
@@ -781,8 +755,6 @@ function magicModuleAppBrowserEntry({
781
755
  async source() {
782
756
  const reactRootFunction = hydrate ? "hydrate" : "render";
783
757
  return multiline`
784
- import '@quilted/quilt/globals';
785
-
786
758
  import {jsx} from 'preact/jsx-runtime';
787
759
  import {${reactRootFunction}} from 'preact';
788
760
 
@@ -1074,4 +1046,4 @@ function getSourceFromCustomEntry(entry) {
1074
1046
  return typeof entry === "object" ? entry.source : entry;
1075
1047
  }
1076
1048
 
1077
- export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, additionalEntriesForAppBrowser, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, nodeAppServerRuntime, quiltApp, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserPlugins, quiltAppServer, quiltAppServerInput, quiltAppServerPlugins, quiltAppServiceWorker, quiltAppServiceWorkerInput, quiltAppServiceWorkerPlugins, sourceEntryForAppBrowser, sourceEntryForAppServer, sourceEntryForAppServiceWorker };
1049
+ export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO, additionalEntriesForAppBrowser, magicModuleAppAssetManifests, magicModuleAppBrowserEntry, magicModuleAppComponent, magicModuleAppRequestRouter, nodeAppServerRuntime, quiltApp, quiltAppBrowser, quiltAppBrowserInput, quiltAppBrowserPlugins, quiltAppServer, quiltAppServerInput, quiltAppServerPlugins, quiltAppServiceWorker, quiltAppServiceWorkerInput, quiltAppServiceWorkerPlugins, sourceEntryForAppBrowser, sourceEntryForAppServer, sourceEntryForAppServiceWorker };
@@ -2,6 +2,6 @@ const MAGIC_MODULE_ENV = "quilt:module/env";
2
2
  const MAGIC_MODULE_ENTRY = "quilt:module/entry";
3
3
  const MAGIC_MODULE_APP_COMPONENT = "quilt:module/app";
4
4
  const MAGIC_MODULE_BROWSER_ASSETS = "quilt:module/assets";
5
- const MAGIC_MODULE_REQUEST_ROUTER = "quilt:module/request-router";
5
+ const MAGIC_MODULE_HONO = "quilt:module/hono";
6
6
 
7
- export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_REQUEST_ROUTER };
7
+ export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_HONO };
@@ -3,7 +3,6 @@ import { multiline } from '../shared/strings.mjs';
3
3
  import MagicString from 'magic-string';
4
4
 
5
5
  const MODULE_PREFIX = "quilt-async-module:";
6
- const IMPORT_PREFIX = "quilt-async-import:";
7
6
  function asyncModules({
8
7
  preload = true,
9
8
  baseURL = "/assets/",
@@ -13,9 +12,7 @@ function asyncModules({
13
12
  name: "@quilted/async",
14
13
  async resolveId(id, importer) {
15
14
  let prefix;
16
- if (id.startsWith(IMPORT_PREFIX)) {
17
- prefix = IMPORT_PREFIX;
18
- } else if (id.startsWith(MODULE_PREFIX)) {
15
+ if (id.startsWith(MODULE_PREFIX)) {
19
16
  prefix = MODULE_PREFIX;
20
17
  } else {
21
18
  return null;
@@ -36,20 +33,6 @@ function asyncModules({
36
33
  return {id: ${JSON.stringify(moduleID)}, import: load};
37
34
  }
38
35
  `;
39
- return code;
40
- }
41
- if (id.startsWith(`\0${IMPORT_PREFIX}`)) {
42
- const imported = id.replace(`\0${IMPORT_PREFIX}`, "");
43
- const moduleID = getModuleID({ imported });
44
- const code = multiline`
45
- import * as AsyncModule from ${JSON.stringify(imported)};
46
-
47
- ((globalThis[Symbol.for('quilt')] ||= {}).asyncModules ||= new Map).set(${JSON.stringify(
48
- moduleID
49
- )}, AsyncModule);
50
-
51
- export default AsyncModule;
52
- `;
53
36
  return {
54
37
  code,
55
38
  meta: {
@@ -59,16 +42,15 @@ function asyncModules({
59
42
  }
60
43
  return null;
61
44
  },
62
- transform: baseURL ? (code) => code.replace(/__QUILT_ASSETS_BASE_URL__/g, JSON.stringify(baseURL)) : void 0,
63
45
  async generateBundle(options, bundle) {
64
46
  if (preload) {
65
47
  switch (options.format) {
66
48
  case "es": {
67
- await preloadAsyncAssetsInESMBundle(bundle);
49
+ await preloadAsyncAssetsInESMBundle(bundle, { baseURL });
68
50
  break;
69
51
  }
70
52
  case "system": {
71
- await preloadAsyncAssetsInSystemJSBundle(bundle);
53
+ await preloadAsyncAssetsInSystemJSBundle(bundle, { baseURL });
72
54
  break;
73
55
  }
74
56
  }
@@ -79,7 +61,7 @@ function asyncModules({
79
61
  function defaultModuleID({ imported }) {
80
62
  return path.relative(process.cwd(), imported).replace(/[\\/]/g, "-");
81
63
  }
82
- async function preloadAsyncAssetsInESMBundle(bundle) {
64
+ async function preloadAsyncAssetsInESMBundle(bundle, { baseURL = "/" } = {}) {
83
65
  const { parse: parseImports } = await import('es-module-lexer');
84
66
  for (const chunk of Object.values(bundle)) {
85
67
  if (chunk.type !== "chunk") continue;
@@ -87,6 +69,7 @@ async function preloadAsyncAssetsInESMBundle(bundle) {
87
69
  const { code } = chunk;
88
70
  const newCode = new MagicString(code);
89
71
  const imports = (await parseImports(code))[0];
72
+ let hasReplacements = false;
90
73
  for (const imported of imports) {
91
74
  const { s: start, e: end, ss: importStart, d: dynamicStart } = imported;
92
75
  if (dynamicStart < 0) continue;
@@ -94,9 +77,11 @@ async function preloadAsyncAssetsInESMBundle(bundle) {
94
77
  const dependencies = getDependenciesForImport(
95
78
  importSource,
96
79
  chunk,
97
- bundle
80
+ bundle,
81
+ { baseURL }
98
82
  );
99
83
  if (dependencies.size === 1) continue;
84
+ hasReplacements = true;
100
85
  const originalImport = code.slice(importStart, end + 1);
101
86
  newCode.overwrite(
102
87
  importStart,
@@ -104,10 +89,13 @@ async function preloadAsyncAssetsInESMBundle(bundle) {
104
89
  preloadContentForDependencies(dependencies, originalImport)
105
90
  );
106
91
  }
92
+ if (hasReplacements) {
93
+ newCode.prepend(getPreloadHelperFunction() + "\n");
94
+ }
107
95
  chunk.code = newCode.toString();
108
96
  }
109
97
  }
110
- async function preloadAsyncAssetsInSystemJSBundle(bundle) {
98
+ async function preloadAsyncAssetsInSystemJSBundle(bundle, { baseURL = "/" } = {}) {
111
99
  for (const chunk of Object.values(bundle)) {
112
100
  if (chunk.type !== "chunk") continue;
113
101
  if (chunk.dynamicImports.length === 0) continue;
@@ -115,30 +103,34 @@ async function preloadAsyncAssetsInSystemJSBundle(bundle) {
115
103
  const newCode = new MagicString(code);
116
104
  const systemDynamicImportRegex = /\bmodule\.import\(([^)]*)\)/g;
117
105
  let match;
106
+ let hasReplacements = false;
118
107
  while (match = systemDynamicImportRegex.exec(code)) {
119
108
  const [originalImport, imported] = match;
120
109
  const importSource = imported.trim().slice(1, imported.length - 1);
121
110
  const dependencies = getDependenciesForImport(
122
111
  importSource,
123
112
  chunk,
124
- bundle
113
+ bundle,
114
+ { baseURL }
125
115
  );
126
116
  if (dependencies.size === 1) continue;
117
+ hasReplacements = true;
127
118
  newCode.overwrite(
128
119
  match.index,
129
120
  match.index + originalImport.length,
130
121
  preloadContentForDependencies(dependencies, originalImport)
131
122
  );
132
123
  }
124
+ if (hasReplacements) {
125
+ newCode.prepend(getPreloadHelperFunction() + "\n");
126
+ }
133
127
  chunk.code = newCode.toString();
134
128
  }
135
129
  }
136
130
  function preloadContentForDependencies(dependencies, originalExpression) {
137
- return `Promise.resolve().then(() => globalThis[Symbol.for('quilt')]?.asyncModules?.preload?.(${Array.from(
138
- dependencies
139
- ).map((dependency) => JSON.stringify(dependency)).join(",")})).then(function(){return ${originalExpression}})`;
131
+ return `__quilt_preload(${JSON.stringify(Array.from(dependencies))}).then(() => {return ${originalExpression}})`;
140
132
  }
141
- function getDependenciesForImport(imported, chunk, bundle) {
133
+ function getDependenciesForImport(imported, chunk, bundle, { baseURL = "/" } = {}) {
142
134
  const originalFilename = chunk.fileName;
143
135
  const dependencies = /* @__PURE__ */ new Set();
144
136
  const analyzed = /* @__PURE__ */ new Set();
@@ -152,7 +144,8 @@ function getDependenciesForImport(imported, chunk, bundle) {
152
144
  analyzed.add(filename);
153
145
  const chunk2 = bundle[filename];
154
146
  if (chunk2 == null) return;
155
- dependencies.add(chunk2.fileName);
147
+ const url = `${baseURL}${baseURL.endsWith("/") ? "" : "/"}${chunk2.fileName}`;
148
+ dependencies.add(url);
156
149
  if (chunk2.type !== "chunk") return;
157
150
  for (const imported2 of chunk2.imports) {
158
151
  addDependencies(imported2);
@@ -161,5 +154,15 @@ function getDependenciesForImport(imported, chunk, bundle) {
161
154
  addDependencies(normalizedFile);
162
155
  return dependencies;
163
156
  }
157
+ function getPreloadHelperFunction({
158
+ type = "module"
159
+ } = {}) {
160
+ const scriptRel = JSON.stringify(
161
+ type === "module" ? "modulepreload" : "preload"
162
+ );
163
+ return multiline`
164
+ const __quilt_preload=(()=>{const o=new Map,f=${scriptRel};class QuiltPreloadError extends Error{constructor(e,{cause:l}={}){super(\`Unable to preload \${e}\`,{cause:l}),this.source=e}}class QuiltPreloadErrorEvent extends Event{constructor(e){super("quilt:preload-error",{cancelable:!0}),this.error=e}}return function __quilt_preload(e){return e.length===0?Promise.resolve():Promise.all(e.map(s=>{const r=s.startsWith("/")?s:"/"+s;if(o.has(r))return;o.set(r,!0);const i=r.endsWith(".css");if(document.querySelector(\`link[href="\${r}"]\`)!=null)return;const t=document.createElement("link");if(i?t.rel="stylesheet":(t.as="script",t.rel=f),t.crossOrigin="",t.href=r,document.head.appendChild(t),i)return new Promise(a=>{t.addEventListener("load",()=>a()),t.addEventListener("error",h=>a(new QuiltPreloadError(r,{cause:h})))})})).then(s=>{for(const r of s)r!=null&&d(r)})};function d(n){const e=new QuiltPreloadErrorEvent(n);if(window.dispatchEvent(e),!e.defaultPrevented)throw n}})();
165
+ `;
166
+ }
164
167
 
165
- export { IMPORT_PREFIX, asyncModules };
168
+ export { asyncModules };
@@ -3,4 +3,4 @@ export { quiltModule } from './module.mjs';
3
3
  export { quiltPackage, quiltPackageESModules, quiltPackageESNext } from './package.mjs';
4
4
  export { quiltServer } from './server.mjs';
5
5
  export { multiline } from './shared/strings.mjs';
6
- export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_REQUEST_ROUTER } from './constants.mjs';
6
+ export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_HONO } from './constants.mjs';
@@ -3,13 +3,13 @@ import { Project } from './shared/project.mjs';
3
3
  import { getNodePlugins, removeBuildFiles } from './shared/rollup.mjs';
4
4
  import { multiline } from './shared/strings.mjs';
5
5
  import { resolveEnvOption } from './features/env.mjs';
6
- import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER } from './constants.mjs';
6
+ import { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO } from './constants.mjs';
7
7
  import { createMagicModulePlugin } from './shared/magic-module.mjs';
8
8
 
9
9
  async function quiltServer({
10
10
  root: rootPath = process.cwd(),
11
11
  entry,
12
- format = "request-router",
12
+ format = "hono",
13
13
  env,
14
14
  graphql = true,
15
15
  output,
@@ -47,7 +47,7 @@ async function quiltServer({
47
47
  })
48
48
  ]);
49
49
  const serverEntry = entry ? project.resolve(entry) : await sourceForServer(project);
50
- const finalEntry = format === "request-router" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
50
+ const finalEntry = format === "hono" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
51
51
  const finalEntryName = serverEntry ? path.basename(serverEntry).split(".").slice(0, -1).join(".") : "server";
52
52
  const plugins = [
53
53
  ...nodePlugins,
@@ -65,19 +65,19 @@ async function quiltServer({
65
65
  esnext({ mode, targets: ["current node"] }),
66
66
  removeBuildFiles([outputDirectory, reportDirectory], { root: project.root })
67
67
  ];
68
- if (format === "request-router") {
68
+ if (format === "hono") {
69
69
  plugins.push(
70
70
  createMagicModulePlugin({
71
- name: "@quilted/magic-module/server-request-router",
72
- module: MAGIC_MODULE_REQUEST_ROUTER,
71
+ name: "@quilted/magic-module/server-hono",
72
+ module: MAGIC_MODULE_HONO,
73
73
  alias: serverEntry
74
74
  }),
75
75
  createMagicModulePlugin({
76
- name: "@quilted/request-router",
76
+ name: "@quilted/hono",
77
77
  sideEffects: true,
78
78
  module: MAGIC_MODULE_ENTRY,
79
79
  source() {
80
- return runtime.requestRouter?.() ?? nodeServerRuntime().requestRouter();
80
+ return runtime.hono?.() ?? nodeServerRuntime().hono();
81
81
  }
82
82
  })
83
83
  );
@@ -127,18 +127,31 @@ function nodeServerRuntime({
127
127
  resolve: {
128
128
  exportConditions: ["node"]
129
129
  },
130
- requestRouter() {
130
+ hono() {
131
131
  return multiline`
132
- import requestRouter from ${JSON.stringify(
133
- MAGIC_MODULE_REQUEST_ROUTER
134
- )};
132
+ import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
135
133
 
136
- import {createHttpServer} from '@quilted/quilt/request-router/node';
134
+ import {serve} from '@quilted/quilt/hono/node';
137
135
 
138
136
  const port = ${port ?? "Number.parseInt(process.env.PORT, 10)"};
139
137
  const host = ${host ? JSON.stringify(host) : "process.env.HOST"};
140
-
141
- createHttpServer(requestRouter).listen(port, host);
138
+
139
+ const server = serve(app);
140
+
141
+ process.on('SIGINT', () => {
142
+ server.close();
143
+ process.exit(0);
144
+ });
145
+
146
+ process.on('SIGTERM', () => {
147
+ server.close((err) => {
148
+ if (err) {
149
+ console.error(err);
150
+ process.exit(1);
151
+ }
152
+ process.exit(0);
153
+ });
154
+ });
142
155
  `;
143
156
  }
144
157
  };
@@ -159,4 +172,4 @@ async function sourceForServer(project) {
159
172
  return possibleSourceFiles[0];
160
173
  }
161
174
 
162
- export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_REQUEST_ROUTER, nodeServerRuntime, quiltServer };
175
+ export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO, nodeServerRuntime, quiltServer };