@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
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
|
+
|
|
3
9
|
## 0.3.3
|
|
4
10
|
|
|
5
11
|
### 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,
|
|
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 = "
|
|
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/
|
|
423
|
+
name: "@quilted/hono",
|
|
424
424
|
sideEffects: true,
|
|
425
425
|
module: MAGIC_MODULE_ENTRY,
|
|
426
426
|
source() {
|
|
427
|
-
|
|
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 = "
|
|
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 === "
|
|
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
|
-
|
|
680
|
-
const { baseURL } = assets;
|
|
677
|
+
hono() {
|
|
681
678
|
return multiline`
|
|
682
|
-
|
|
683
|
-
|
|
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
|
-
|
|
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,13 +712,13 @@ function magicModuleAppRequestRouter({
|
|
|
736
712
|
root = process.cwd()
|
|
737
713
|
} = {}) {
|
|
738
714
|
return createMagicModulePlugin({
|
|
739
|
-
name: "@quilted/magic-module/app-
|
|
740
|
-
module:
|
|
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`
|
|
720
|
+
import {Hono} from 'hono';
|
|
744
721
|
import {jsx} from 'preact/jsx-runtime';
|
|
745
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
746
722
|
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
747
723
|
|
|
748
724
|
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
@@ -750,11 +726,11 @@ function magicModuleAppRequestRouter({
|
|
|
750
726
|
MAGIC_MODULE_BROWSER_ASSETS
|
|
751
727
|
)};
|
|
752
728
|
|
|
753
|
-
const
|
|
729
|
+
const app = new Hono();
|
|
754
730
|
const assets = new BrowserAssets();
|
|
755
731
|
|
|
756
|
-
|
|
757
|
-
|
|
732
|
+
app.get(async (c) => {
|
|
733
|
+
const request = c.req.raw;
|
|
758
734
|
const response = await renderAppToHTMLResponse(jsx(App), {
|
|
759
735
|
request,
|
|
760
736
|
assets,
|
|
@@ -763,7 +739,7 @@ function magicModuleAppRequestRouter({
|
|
|
763
739
|
return response;
|
|
764
740
|
});
|
|
765
741
|
|
|
766
|
-
export default
|
|
742
|
+
export default app;
|
|
767
743
|
`;
|
|
768
744
|
}
|
|
769
745
|
});
|
|
@@ -1070,4 +1046,4 @@ function getSourceFromCustomEntry(entry) {
|
|
|
1070
1046
|
return typeof entry === "object" ? entry.source : entry;
|
|
1071
1047
|
}
|
|
1072
1048
|
|
|
1073
|
-
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY,
|
|
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 };
|
package/build/esm/constants.mjs
CHANGED
|
@@ -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
|
|
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,
|
|
7
|
+
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_HONO };
|
package/build/esm/index.mjs
CHANGED
|
@@ -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,
|
|
6
|
+
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY, MAGIC_MODULE_ENV, MAGIC_MODULE_HONO } from './constants.mjs';
|
package/build/esm/server.mjs
CHANGED
|
@@ -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,
|
|
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 = "
|
|
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 === "
|
|
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 === "
|
|
68
|
+
if (format === "hono") {
|
|
69
69
|
plugins.push(
|
|
70
70
|
createMagicModulePlugin({
|
|
71
|
-
name: "@quilted/magic-module/server-
|
|
72
|
-
module:
|
|
71
|
+
name: "@quilted/magic-module/server-hono",
|
|
72
|
+
module: MAGIC_MODULE_HONO,
|
|
73
73
|
alias: serverEntry
|
|
74
74
|
}),
|
|
75
75
|
createMagicModulePlugin({
|
|
76
|
-
name: "@quilted/
|
|
76
|
+
name: "@quilted/hono",
|
|
77
77
|
sideEffects: true,
|
|
78
78
|
module: MAGIC_MODULE_ENTRY,
|
|
79
79
|
source() {
|
|
80
|
-
return runtime.
|
|
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
|
-
|
|
130
|
+
hono() {
|
|
131
131
|
return multiline`
|
|
132
|
-
import
|
|
133
|
-
MAGIC_MODULE_REQUEST_ROUTER
|
|
134
|
-
)};
|
|
132
|
+
import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
|
|
135
133
|
|
|
136
|
-
import {
|
|
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
|
-
|
|
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,
|
|
175
|
+
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO, nodeServerRuntime, quiltServer };
|