@emberkit/cli 0.6.9 → 0.7.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/dist/commands/build.js
CHANGED
|
@@ -59,7 +59,7 @@ export async function build(_args) {
|
|
|
59
59
|
log("info", "Building client bundle...");
|
|
60
60
|
await buildClient(root, outDir, viteConfig, customLogger);
|
|
61
61
|
log("info", "Building SSR bundle...");
|
|
62
|
-
await buildSSR(root, outDir, viteConfig, customLogger);
|
|
62
|
+
await buildSSR(root, outDir, viteConfig, customLogger, emberkitConfig);
|
|
63
63
|
log("info", "Generating SSR manifest...");
|
|
64
64
|
await generateManifest(root, outDir, mode);
|
|
65
65
|
if (mode === "hybrid") {
|
|
@@ -72,7 +72,7 @@ export async function build(_args) {
|
|
|
72
72
|
log("info", "Building static site...");
|
|
73
73
|
await buildClient(root, outDir, viteConfig, customLogger);
|
|
74
74
|
log("info", "Building SSR bundle for pre-rendering...");
|
|
75
|
-
await buildSSR(root, outDir, viteConfig, customLogger);
|
|
75
|
+
await buildSSR(root, outDir, viteConfig, customLogger, emberkitConfig);
|
|
76
76
|
log("info", "Generating manifest...");
|
|
77
77
|
await generateManifest(root, outDir, mode);
|
|
78
78
|
log("info", "Pre-rendering all routes...");
|
|
@@ -113,9 +113,26 @@ async function buildClient(root, outDir, viteConfig, customLogger) {
|
|
|
113
113
|
};
|
|
114
114
|
await viteBuild(clientConfig);
|
|
115
115
|
}
|
|
116
|
-
function
|
|
116
|
+
function siteConfigToHeadOptions(site) {
|
|
117
|
+
const config = site;
|
|
118
|
+
if (!config?.url) {
|
|
119
|
+
return "null";
|
|
120
|
+
}
|
|
121
|
+
return JSON.stringify({
|
|
122
|
+
siteUrl: config.url,
|
|
123
|
+
siteName: config.name,
|
|
124
|
+
titleSuffix: config.titleSuffix,
|
|
125
|
+
defaultDescription: config.description,
|
|
126
|
+
defaultOgImage: config.ogImage,
|
|
127
|
+
twitterSite: config.twitterSite,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
function getServerEntryShim(site) {
|
|
131
|
+
const siteHeadOptions = siteConfigToHeadOptions(site);
|
|
117
132
|
return `import { routes, notFoundRoute, errorRoute } from 'virtual:emberkit-routes';
|
|
118
|
-
import { createElement } from '@emberkit/core';
|
|
133
|
+
import { createElement, buildRouteHeadFromMetadata } from '@emberkit/core';
|
|
134
|
+
|
|
135
|
+
const siteHeadOptions = ${siteHeadOptions};
|
|
119
136
|
import { readFileSync } from 'node:fs';
|
|
120
137
|
import { join, dirname } from 'node:path';
|
|
121
138
|
import { fileURLToPath } from 'node:url';
|
|
@@ -250,12 +267,7 @@ export async function render(url) {
|
|
|
250
267
|
const Component = mod.default || mod;
|
|
251
268
|
|
|
252
269
|
if (mod.metadata) {
|
|
253
|
-
|
|
254
|
-
headContent += '<title>' + escapeHtml(mod.metadata.title) + '</title>\\n';
|
|
255
|
-
}
|
|
256
|
-
if (mod.metadata.description) {
|
|
257
|
-
headContent += '<meta name="description" content="' + escapeHtml(mod.metadata.description) + '">\\n';
|
|
258
|
-
}
|
|
270
|
+
headContent += buildRouteHeadFromMetadata(mod.metadata, pathname, siteHeadOptions ?? undefined) + '\\n';
|
|
259
271
|
}
|
|
260
272
|
|
|
261
273
|
const element = createElement(Component, { params: match.params });
|
|
@@ -319,7 +331,7 @@ export async function render(url) {
|
|
|
319
331
|
}
|
|
320
332
|
`;
|
|
321
333
|
}
|
|
322
|
-
async function resolveSSREntry(root) {
|
|
334
|
+
async function resolveSSREntry(root, emberkitConfig) {
|
|
323
335
|
const userEntryTs = join(root, "src", "entry-server.ts");
|
|
324
336
|
const userEntryTsx = join(root, "src", "entry-server.tsx");
|
|
325
337
|
if (existsSync(userEntryTs)) {
|
|
@@ -331,11 +343,12 @@ async function resolveSSREntry(root) {
|
|
|
331
343
|
const cacheDir = join(root, "node_modules", ".cache", "emberkit");
|
|
332
344
|
mkdirSync(cacheDir, { recursive: true });
|
|
333
345
|
const shimPath = join(cacheDir, "server-entry.js");
|
|
334
|
-
|
|
346
|
+
const site = emberkitConfig?.site;
|
|
347
|
+
writeFileSync(shimPath, getServerEntryShim(site), "utf-8");
|
|
335
348
|
return shimPath;
|
|
336
349
|
}
|
|
337
|
-
async function buildSSR(root, outDir, viteConfig, customLogger) {
|
|
338
|
-
const ssrEntry = await resolveSSREntry(root);
|
|
350
|
+
async function buildSSR(root, outDir, viteConfig, customLogger, emberkitConfig) {
|
|
351
|
+
const ssrEntry = await resolveSSREntry(root, emberkitConfig);
|
|
339
352
|
const ssrConfig = {
|
|
340
353
|
...viteConfig,
|
|
341
354
|
root,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// Semver ranges for @emberkit/* packages written into generated projects.
|
|
2
2
|
// When releasing libraries, bump these to match packages/*/package.json "version".
|
|
3
3
|
export const EMBERKIT_PACKAGE_VERSIONS = {
|
|
4
|
-
core: "^0.
|
|
5
|
-
ui: "^
|
|
6
|
-
icons: "^
|
|
7
|
-
cli: "^0.
|
|
4
|
+
core: "^0.6.0",
|
|
5
|
+
ui: "^4.0.0",
|
|
6
|
+
icons: "^4.0.0",
|
|
7
|
+
cli: "^0.7.0",
|
|
8
8
|
edge: "^0.2.4",
|
|
9
9
|
tsconfig: "^0.2.1",
|
|
10
10
|
};
|