@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
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @quilted/rollup
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`3a59596`](https://github.com/lemonmade/quilt/commit/3a59596ce09e373cb48da20fa55f360fe815351a) Thanks [@lemonmade](https://github.com/lemonmade)! - Add support for additional Rollup plugins in runtimes
|
|
8
|
+
|
|
9
|
+
## 0.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- [#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
|
|
14
|
+
|
|
3
15
|
## 0.3.3
|
|
4
16
|
|
|
5
17
|
### 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';
|
|
@@ -99,7 +99,7 @@ async function quiltAppBrowser(options = {}) {
|
|
|
99
99
|
targetsSupportModules(browserGroup.browsers),
|
|
100
100
|
rollupGenerateOptionsForBrowsers(browserGroup.browsers)
|
|
101
101
|
]);
|
|
102
|
-
|
|
102
|
+
const rollupOptions = {
|
|
103
103
|
plugins,
|
|
104
104
|
output: {
|
|
105
105
|
format: isESM ? "esm" : "systemjs",
|
|
@@ -117,6 +117,10 @@ async function quiltAppBrowser(options = {}) {
|
|
|
117
117
|
},
|
|
118
118
|
preserveEntrySignatures: false
|
|
119
119
|
};
|
|
120
|
+
if (runtime?.browser?.rollup) {
|
|
121
|
+
rollupOptions.plugins.push(runtime.browser.rollup(rollupOptions));
|
|
122
|
+
}
|
|
123
|
+
return rollupOptions;
|
|
120
124
|
}
|
|
121
125
|
async function quiltAppBrowserPlugins({
|
|
122
126
|
root = process.cwd(),
|
|
@@ -363,7 +367,7 @@ async function quiltAppServerPlugins({
|
|
|
363
367
|
app,
|
|
364
368
|
env,
|
|
365
369
|
entry,
|
|
366
|
-
format = "
|
|
370
|
+
format = "hono",
|
|
367
371
|
graphql = true,
|
|
368
372
|
assets,
|
|
369
373
|
output,
|
|
@@ -420,12 +424,11 @@ async function quiltAppServerPlugins({
|
|
|
420
424
|
}),
|
|
421
425
|
magicModuleAppComponent({ entry: app, root: project.root }),
|
|
422
426
|
createMagicModulePlugin({
|
|
423
|
-
name: "@quilted/
|
|
427
|
+
name: "@quilted/hono",
|
|
424
428
|
sideEffects: true,
|
|
425
429
|
module: MAGIC_MODULE_ENTRY,
|
|
426
430
|
source() {
|
|
427
|
-
|
|
428
|
-
return runtime.requestRouter?.(options) ?? nodeAppServerRuntime().requestRouter(options);
|
|
431
|
+
return runtime.hono?.() ?? nodeAppServerRuntime().hono();
|
|
429
432
|
}
|
|
430
433
|
}),
|
|
431
434
|
magicModuleAppRequestRouter({ entry, root: project.root }),
|
|
@@ -490,13 +493,13 @@ async function quiltAppServerPlugins({
|
|
|
490
493
|
function quiltAppServerInput({
|
|
491
494
|
root = process.cwd(),
|
|
492
495
|
entry,
|
|
493
|
-
format = "
|
|
496
|
+
format = "hono"
|
|
494
497
|
} = {}) {
|
|
495
498
|
return {
|
|
496
499
|
name: "@quilted/app-server/input",
|
|
497
500
|
async options(options) {
|
|
498
501
|
const serverEntry = normalizeRollupInput(options.input) ?? await sourceEntryForAppServer({ entry, root });
|
|
499
|
-
const finalEntry = format === "
|
|
502
|
+
const finalEntry = format === "hono" ? MAGIC_MODULE_ENTRY : serverEntry ?? MAGIC_MODULE_ENTRY;
|
|
500
503
|
const finalEntryName = typeof serverEntry === "string" ? path.basename(serverEntry).split(".").slice(0, -1).join(".") : "server";
|
|
501
504
|
return {
|
|
502
505
|
...options,
|
|
@@ -665,8 +668,7 @@ function quiltAppServiceWorkerInput({
|
|
|
665
668
|
function nodeAppServerRuntime({
|
|
666
669
|
host,
|
|
667
670
|
port,
|
|
668
|
-
format = "module"
|
|
669
|
-
assets: serveAssets = true
|
|
671
|
+
format = "module"
|
|
670
672
|
} = {}) {
|
|
671
673
|
const rollupFormat = format === "commonjs" || format === "cjs" ? "cjs" : "esm";
|
|
672
674
|
return {
|
|
@@ -676,37 +678,15 @@ function nodeAppServerRuntime({
|
|
|
676
678
|
format: rollupFormat
|
|
677
679
|
}
|
|
678
680
|
},
|
|
679
|
-
|
|
680
|
-
const { baseURL } = assets;
|
|
681
|
+
hono() {
|
|
681
682
|
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';
|
|
683
|
+
import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
|
|
684
|
+
import {serve} from '@quilted/hono/node';
|
|
691
685
|
|
|
692
686
|
const port = ${port ?? "Number.parseInt(process.env.PORT, 10)"};
|
|
693
687
|
const host = ${host ? JSON.stringify(host) : "process.env.HOST"};
|
|
694
688
|
|
|
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);
|
|
689
|
+
serve({fetch: app.fetch, port, hostname: host});
|
|
710
690
|
`;
|
|
711
691
|
}
|
|
712
692
|
};
|
|
@@ -736,13 +716,13 @@ function magicModuleAppRequestRouter({
|
|
|
736
716
|
root = process.cwd()
|
|
737
717
|
} = {}) {
|
|
738
718
|
return createMagicModulePlugin({
|
|
739
|
-
name: "@quilted/magic-module/app-
|
|
740
|
-
module:
|
|
719
|
+
name: "@quilted/magic-module/app-hono",
|
|
720
|
+
module: MAGIC_MODULE_HONO,
|
|
741
721
|
alias: () => sourceEntryForAppServer({ entry, root }),
|
|
742
722
|
async source() {
|
|
743
723
|
return multiline`
|
|
724
|
+
import {Hono} from 'hono';
|
|
744
725
|
import {jsx} from 'preact/jsx-runtime';
|
|
745
|
-
import {RequestRouter} from '@quilted/quilt/request-router';
|
|
746
726
|
import {renderAppToHTMLResponse} from '@quilted/quilt/server';
|
|
747
727
|
|
|
748
728
|
import App from ${JSON.stringify(MAGIC_MODULE_APP_COMPONENT)};
|
|
@@ -750,11 +730,11 @@ function magicModuleAppRequestRouter({
|
|
|
750
730
|
MAGIC_MODULE_BROWSER_ASSETS
|
|
751
731
|
)};
|
|
752
732
|
|
|
753
|
-
const
|
|
733
|
+
const app = new Hono();
|
|
754
734
|
const assets = new BrowserAssets();
|
|
755
735
|
|
|
756
|
-
|
|
757
|
-
|
|
736
|
+
app.get(async (c) => {
|
|
737
|
+
const request = c.req.raw;
|
|
758
738
|
const response = await renderAppToHTMLResponse(jsx(App), {
|
|
759
739
|
request,
|
|
760
740
|
assets,
|
|
@@ -763,7 +743,7 @@ function magicModuleAppRequestRouter({
|
|
|
763
743
|
return response;
|
|
764
744
|
});
|
|
765
745
|
|
|
766
|
-
export default
|
|
746
|
+
export default app;
|
|
767
747
|
`;
|
|
768
748
|
}
|
|
769
749
|
});
|
|
@@ -1070,4 +1050,4 @@ function getSourceFromCustomEntry(entry) {
|
|
|
1070
1050
|
return typeof entry === "object" ? entry.source : entry;
|
|
1071
1051
|
}
|
|
1072
1052
|
|
|
1073
|
-
export { MAGIC_MODULE_APP_COMPONENT, MAGIC_MODULE_BROWSER_ASSETS, MAGIC_MODULE_ENTRY,
|
|
1053
|
+
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
|
);
|
|
@@ -98,7 +98,7 @@ async function quiltServer({
|
|
|
98
98
|
filename: path.join(reportDirectory, "bundle-visualizer.html")
|
|
99
99
|
})
|
|
100
100
|
);
|
|
101
|
-
|
|
101
|
+
const options = {
|
|
102
102
|
input: { [finalEntryName]: finalEntry },
|
|
103
103
|
plugins,
|
|
104
104
|
output: {
|
|
@@ -111,6 +111,10 @@ async function quiltServer({
|
|
|
111
111
|
...runtime.output?.options
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
+
if (runtime.rollup) {
|
|
115
|
+
plugins.push(runtime.rollup(options));
|
|
116
|
+
}
|
|
117
|
+
return options;
|
|
114
118
|
}
|
|
115
119
|
function nodeServerRuntime({
|
|
116
120
|
host,
|
|
@@ -127,18 +131,31 @@ function nodeServerRuntime({
|
|
|
127
131
|
resolve: {
|
|
128
132
|
exportConditions: ["node"]
|
|
129
133
|
},
|
|
130
|
-
|
|
134
|
+
hono() {
|
|
131
135
|
return multiline`
|
|
132
|
-
import
|
|
133
|
-
MAGIC_MODULE_REQUEST_ROUTER
|
|
134
|
-
)};
|
|
136
|
+
import app from ${JSON.stringify(MAGIC_MODULE_HONO)};
|
|
135
137
|
|
|
136
|
-
import {
|
|
138
|
+
import {serve} from '@quilted/quilt/hono/node';
|
|
137
139
|
|
|
138
140
|
const port = ${port ?? "Number.parseInt(process.env.PORT, 10)"};
|
|
139
141
|
const host = ${host ? JSON.stringify(host) : "process.env.HOST"};
|
|
140
|
-
|
|
141
|
-
|
|
142
|
+
|
|
143
|
+
const server = serve(app);
|
|
144
|
+
|
|
145
|
+
process.on('SIGINT', () => {
|
|
146
|
+
server.close();
|
|
147
|
+
process.exit(0);
|
|
148
|
+
});
|
|
149
|
+
|
|
150
|
+
process.on('SIGTERM', () => {
|
|
151
|
+
server.close((err) => {
|
|
152
|
+
if (err) {
|
|
153
|
+
console.error(err);
|
|
154
|
+
process.exit(1);
|
|
155
|
+
}
|
|
156
|
+
process.exit(0);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
142
159
|
`;
|
|
143
160
|
}
|
|
144
161
|
};
|
|
@@ -159,4 +176,4 @@ async function sourceForServer(project) {
|
|
|
159
176
|
return possibleSourceFiles[0];
|
|
160
177
|
}
|
|
161
178
|
|
|
162
|
-
export { MAGIC_MODULE_ENTRY,
|
|
179
|
+
export { MAGIC_MODULE_ENTRY, MAGIC_MODULE_HONO, nodeServerRuntime, quiltServer };
|