@taujs/create-taujs 0.1.3 → 0.1.5
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/dist/index.js +11 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -160,7 +160,7 @@ async function generateFiles(targetDir, config) {
|
|
|
160
160
|
);
|
|
161
161
|
await fs.writeFile(
|
|
162
162
|
path.join(targetDir, "src/client/index.html"),
|
|
163
|
-
generateIndexHtml(
|
|
163
|
+
generateIndexHtml()
|
|
164
164
|
);
|
|
165
165
|
await fs.writeFile(
|
|
166
166
|
path.join(targetDir, "src/client/App.tsx"),
|
|
@@ -214,7 +214,7 @@ function generatePackageJson(projectName, packageManager) {
|
|
|
214
214
|
"build:client": "tsx build.ts",
|
|
215
215
|
"build:entry-server": "BUILD_MODE=ssr tsx build.ts",
|
|
216
216
|
"build:server": "esbuild src/server/index.ts --bundle --platform=node --format=esm --outfile=dist/server/index.js --external:fastify --external:@taujs/server --external:@taujs/react",
|
|
217
|
-
build: "
|
|
217
|
+
build: "tsx build.ts && BUILD_MODE=ssr tsx build.ts && esbuild src/server/index.ts --bundle --platform=node --format=esm --outfile=dist/server/index.js --external:fastify --external:@taujs/server --external:@taujs/react",
|
|
218
218
|
start: "NODE_ENV=production node dist/server/index.js",
|
|
219
219
|
lint: "tsc --noEmit"
|
|
220
220
|
},
|
|
@@ -238,19 +238,13 @@ function generatePackageJson(projectName, packageManager) {
|
|
|
238
238
|
}
|
|
239
239
|
function generateBuildTs() {
|
|
240
240
|
return `import path from "node:path";
|
|
241
|
-
import { fileURLToPath } from "node:url";
|
|
242
|
-
|
|
243
241
|
import { taujsBuild } from "@taujs/server";
|
|
244
|
-
|
|
245
242
|
import config from "./taujs.config.ts";
|
|
246
243
|
|
|
247
|
-
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
248
|
-
|
|
249
244
|
await taujsBuild({
|
|
250
|
-
clientBaseDir: path.resolve(
|
|
245
|
+
clientBaseDir: path.resolve(process.cwd(), "src/client"),
|
|
251
246
|
config,
|
|
252
|
-
projectRoot:
|
|
253
|
-
mode: process.env.BUILD_MODE === 'ssr' ? 'ssr' : 'client',
|
|
247
|
+
projectRoot: process.cwd(),
|
|
254
248
|
});
|
|
255
249
|
`;
|
|
256
250
|
}
|
|
@@ -448,16 +442,13 @@ ${projectName}/
|
|
|
448
442
|
MIT
|
|
449
443
|
`;
|
|
450
444
|
}
|
|
451
|
-
function generateIndexHtml(
|
|
445
|
+
function generateIndexHtml() {
|
|
452
446
|
return `<!DOCTYPE html>
|
|
453
447
|
<html lang="en">
|
|
454
448
|
<head>
|
|
455
449
|
<meta charset="UTF-8" />
|
|
456
450
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
457
|
-
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
458
|
-
<link rel="stylesheet" href="/styles.css" />
|
|
459
451
|
<!--ssr-head-->
|
|
460
|
-
<title>${title}</title>
|
|
461
452
|
</head>
|
|
462
453
|
<body>
|
|
463
454
|
<main id="root"><!--ssr-html--></main>
|
|
@@ -469,6 +460,8 @@ function generateAppComponent() {
|
|
|
469
460
|
return `import { Suspense } from 'react';
|
|
470
461
|
import { useSSRStore } from '@taujs/react';
|
|
471
462
|
|
|
463
|
+
import "./styles.css";
|
|
464
|
+
|
|
472
465
|
type GreetingData = {
|
|
473
466
|
message: string;
|
|
474
467
|
timestamp: string;
|
|
@@ -652,7 +645,7 @@ code {
|
|
|
652
645
|
}
|
|
653
646
|
|
|
654
647
|
.app-title::before {
|
|
655
|
-
background: url("favicon.svg") no-repeat;
|
|
648
|
+
background: url("/favicon.svg") no-repeat;
|
|
656
649
|
background-size: 50px 50px;
|
|
657
650
|
content: "";
|
|
658
651
|
border-radius: 4px;
|
|
@@ -791,32 +784,22 @@ import { App } from './App';
|
|
|
791
784
|
export const { renderSSR, renderStream } = createRenderer({
|
|
792
785
|
appComponent: () => <App />,
|
|
793
786
|
headContent: ({ data }) => \`
|
|
794
|
-
<meta
|
|
795
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
796
|
-
<meta name="description" content="A \u03C4js template application">
|
|
797
|
-
<title>\${data?.message || "\u03C4js - Composing systems, not just apps"}</title>
|
|
798
|
-
<link rel="icon" href="/favicon.svg" type="image/svg+xml"/>
|
|
787
|
+
<meta name="description" content="\${data?.message || "\u03C4js - Composing systems, not just apps"}">
|
|
799
788
|
\`,
|
|
800
789
|
enableDebug: process.env.NODE_ENV === "development",
|
|
801
790
|
});
|
|
802
791
|
`;
|
|
803
792
|
}
|
|
804
793
|
function generateServerIndex() {
|
|
805
|
-
return `import
|
|
806
|
-
import { createServer } from '@taujs/server';
|
|
794
|
+
return `import { createServer } from '@taujs/server';
|
|
807
795
|
import config from '../../taujs.config.ts';
|
|
808
796
|
import { serviceRegistry } from './services/registry.ts';
|
|
809
797
|
|
|
810
|
-
const isDev = process.env.NODE_ENV !==
|
|
811
|
-
|
|
812
|
-
const clientRoot = isDev
|
|
813
|
-
? path.resolve(process.cwd(), 'src/client') // source for dev + Vite
|
|
814
|
-
: path.resolve(process.cwd(), 'dist/client'); // built assets for prod
|
|
798
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
815
799
|
|
|
816
800
|
const { app, net } = await createServer({
|
|
817
801
|
config,
|
|
818
802
|
serviceRegistry,
|
|
819
|
-
clientRoot,
|
|
820
803
|
debug: isDev ? { ssr: true } : false,
|
|
821
804
|
});
|
|
822
805
|
|