hyperspan 1.0.0-alpha.2 → 1.0.0-alpha.3
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/package.json +3 -2
- package/src/server.ts +7 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperspan",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.3",
|
|
4
4
|
"description": "Hyperspan CLI - for @hyperspan/framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"public": true,
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@types/bun": "^1.3.2",
|
|
41
41
|
"@types/degit": "^2.8.6",
|
|
42
|
-
"@types/node": "^24.10.0"
|
|
42
|
+
"@types/node": "^24.10.0",
|
|
43
|
+
"bun-plugin-tailwind": "^0.1.2"
|
|
43
44
|
}
|
|
44
45
|
}
|
package/src/server.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Glob } from 'bun';
|
|
|
2
2
|
import { createServer, getRunnableRoute, IS_PROD, isValidRoutePath, parsePath } from '@hyperspan/framework';
|
|
3
3
|
import { CSS_PUBLIC_PATH, CSS_ROUTE_MAP } from '@hyperspan/framework/client/css';
|
|
4
4
|
import { join } from 'node:path';
|
|
5
|
+
import tailwind from "bun-plugin-tailwind"
|
|
5
6
|
|
|
6
7
|
import type { Hyperspan as HS } from '@hyperspan/framework';
|
|
7
8
|
type startConfig = {
|
|
@@ -62,7 +63,7 @@ export async function addRoutes(server: HS.Server, startConfig: startConfig) {
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
const routeMap: { route: string; file: string }[] = [];
|
|
65
|
-
const routes: HS.Route[] = await Promise.all(
|
|
66
|
+
const routes: HS.Route[] = (await Promise.all(
|
|
66
67
|
routeFiles
|
|
67
68
|
.map(async (filePath) => {
|
|
68
69
|
const relativePath = filePath.split('app/routes/').pop();
|
|
@@ -74,16 +75,17 @@ export async function addRoutes(server: HS.Server, startConfig: startConfig) {
|
|
|
74
75
|
|
|
75
76
|
let cssFiles: string[] = [];
|
|
76
77
|
|
|
77
|
-
// Build the route just for the CSS files
|
|
78
|
-
//
|
|
78
|
+
// Build the route just for the CSS files (expensive, but easiest way to do CSS compilation by route)
|
|
79
|
+
// @TODO: Optimize this at some later date... This is O(n) for each route and doesn't scale well for large projects.
|
|
80
|
+
// @TODO: This will also currently re-compile the same CSS file(s) that are included in multiple routes, which is dumb.
|
|
79
81
|
const buildResult = await Bun.build({
|
|
82
|
+
plugins: [tailwind],
|
|
80
83
|
entrypoints: [filePath],
|
|
81
84
|
outdir: buildDir,
|
|
82
85
|
naming: `app/routes/${path.endsWith('/') ? path + 'index' : path}-[hash].[ext]`,
|
|
83
86
|
minify: IS_PROD,
|
|
84
87
|
format: 'esm',
|
|
85
88
|
target: 'node',
|
|
86
|
-
env: 'APP_PUBLIC_*',
|
|
87
89
|
});
|
|
88
90
|
|
|
89
91
|
// Move CSS files to the public directory
|
|
@@ -110,8 +112,7 @@ export async function addRoutes(server: HS.Server, startConfig: startConfig) {
|
|
|
110
112
|
|
|
111
113
|
return route;
|
|
112
114
|
})
|
|
113
|
-
|
|
114
|
-
);
|
|
115
|
+
)).filter((route) => route !== null);
|
|
115
116
|
|
|
116
117
|
if (startConfig.development) {
|
|
117
118
|
console.log('[Hyperspan] Loaded routes:');
|