@constela/start 1.2.18 → 1.2.19
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.
|
@@ -82,6 +82,13 @@ function wrapHtml(content, hydrationScript, head, options) {
|
|
|
82
82
|
/from\s+['"]@constela\/runtime['"]/g,
|
|
83
83
|
`from '${options.runtimePath}'`
|
|
84
84
|
);
|
|
85
|
+
if (options?.importMap && Object.keys(options.importMap).length > 0) {
|
|
86
|
+
const importMapJson = JSON.stringify({ imports: options.importMap }, null, 2);
|
|
87
|
+
importMapScript = `<script type="importmap">
|
|
88
|
+
${importMapJson}
|
|
89
|
+
</script>
|
|
90
|
+
`;
|
|
91
|
+
}
|
|
85
92
|
} else if (options?.importMap && Object.keys(options.importMap).length > 0) {
|
|
86
93
|
const importMapJson = JSON.stringify({ imports: options.importMap }, null, 2);
|
|
87
94
|
importMapScript = `<script type="importmap">
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
generateHydrationScript,
|
|
3
3
|
renderPage,
|
|
4
4
|
wrapHtml
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-7YAQ4TPR.js";
|
|
6
6
|
|
|
7
7
|
// src/router/file-router.ts
|
|
8
8
|
import fg from "fast-glob";
|
|
@@ -2782,7 +2782,7 @@ async function processLayouts(pageInfo, layoutsDir, routeParams = {}) {
|
|
|
2782
2782
|
};
|
|
2783
2783
|
return updatedPageInfo;
|
|
2784
2784
|
}
|
|
2785
|
-
async function renderPageToHtml(program, params, runtimePath, cssPath) {
|
|
2785
|
+
async function renderPageToHtml(program, params, runtimePath, cssPath, externalImports) {
|
|
2786
2786
|
const normalizedProgram = {
|
|
2787
2787
|
...program,
|
|
2788
2788
|
view: normalizeViewNode(structuredClone(program.view))
|
|
@@ -2800,7 +2800,19 @@ async function renderPageToHtml(program, params, runtimePath, cssPath) {
|
|
|
2800
2800
|
};
|
|
2801
2801
|
const cssLinkTag = cssPath ? `<link rel="stylesheet" href="${cssPath}">` : void 0;
|
|
2802
2802
|
const hydrationScript = generateHydrationScript(normalizedProgram, void 0, routeContext);
|
|
2803
|
-
|
|
2803
|
+
const wrapOptions = {};
|
|
2804
|
+
if (runtimePath) {
|
|
2805
|
+
wrapOptions.runtimePath = runtimePath;
|
|
2806
|
+
}
|
|
2807
|
+
if (externalImports && Object.keys(externalImports).length > 0) {
|
|
2808
|
+
wrapOptions.importMap = externalImports;
|
|
2809
|
+
}
|
|
2810
|
+
return wrapHtml(
|
|
2811
|
+
content,
|
|
2812
|
+
hydrationScript,
|
|
2813
|
+
cssLinkTag,
|
|
2814
|
+
Object.keys(wrapOptions).length > 0 ? wrapOptions : void 0
|
|
2815
|
+
);
|
|
2804
2816
|
}
|
|
2805
2817
|
async function copyPublicDir(publicDir, outDir, generatedFiles) {
|
|
2806
2818
|
if (!existsSync8(publicDir)) {
|
|
@@ -2928,10 +2940,19 @@ async function build2(options) {
|
|
|
2928
2940
|
processedPageInfo = await processLayouts(boundPageInfo, layoutsDir, params);
|
|
2929
2941
|
}
|
|
2930
2942
|
const program = await convertToCompiledProgram(processedPageInfo);
|
|
2931
|
-
const html = await renderPageToHtml(program, params, runtimePath, cssPath);
|
|
2943
|
+
const html = await renderPageToHtml(program, params, runtimePath, cssPath, processedPageInfo.page.externalImports);
|
|
2932
2944
|
await mkdir2(dirname5(outputPath), { recursive: true });
|
|
2933
2945
|
await writeFile(outputPath, html, "utf-8");
|
|
2934
2946
|
generatedFiles.push(outputPath);
|
|
2947
|
+
const slugValue = params["slug"];
|
|
2948
|
+
if (slugValue && (slugValue === "index" || slugValue.endsWith("/index"))) {
|
|
2949
|
+
const parentOutputPath = join9(dirname5(dirname5(outputPath)), "index.html");
|
|
2950
|
+
if (!generatedFiles.includes(parentOutputPath)) {
|
|
2951
|
+
await mkdir2(dirname5(parentOutputPath), { recursive: true });
|
|
2952
|
+
await writeFile(parentOutputPath, html, "utf-8");
|
|
2953
|
+
generatedFiles.push(parentOutputPath);
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2935
2956
|
let routePath = route.pattern;
|
|
2936
2957
|
for (const [key, value] of Object.entries(params)) {
|
|
2937
2958
|
routePath = routePath.replace(`:${key}`, value);
|
|
@@ -2958,7 +2979,7 @@ async function build2(options) {
|
|
|
2958
2979
|
pageInfo = await processLayouts(pageInfo, layoutsDir, {});
|
|
2959
2980
|
}
|
|
2960
2981
|
const program = await convertToCompiledProgram(pageInfo);
|
|
2961
|
-
const html = await renderPageToHtml(program, {}, runtimePath, cssPath);
|
|
2982
|
+
const html = await renderPageToHtml(program, {}, runtimePath, cssPath, pageInfo.page.externalImports);
|
|
2962
2983
|
await mkdir2(dirname5(outputPath), { recursive: true });
|
|
2963
2984
|
await writeFile(outputPath, html, "utf-8");
|
|
2964
2985
|
generatedFiles.push(outputPath);
|
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -23,12 +23,12 @@ import {
|
|
|
23
23
|
transformCsv,
|
|
24
24
|
transformMdx,
|
|
25
25
|
transformYaml
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JOQOX3XZ.js";
|
|
27
27
|
import {
|
|
28
28
|
generateHydrationScript,
|
|
29
29
|
renderPage,
|
|
30
30
|
wrapHtml
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-7YAQ4TPR.js";
|
|
32
32
|
|
|
33
33
|
// src/build/ssg.ts
|
|
34
34
|
import { mkdir, writeFile } from "fs/promises";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/start",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.19",
|
|
4
4
|
"description": "Meta-framework for Constela applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -43,11 +43,11 @@
|
|
|
43
43
|
"postcss": "^8.5.0",
|
|
44
44
|
"@tailwindcss/postcss": "^4.0.0",
|
|
45
45
|
"tailwindcss": "^4.0.0",
|
|
46
|
-
"@constela/router": "8.0.0",
|
|
47
|
-
"@constela/core": "0.7.0",
|
|
48
|
-
"@constela/runtime": "0.10.2",
|
|
49
46
|
"@constela/compiler": "0.7.1",
|
|
50
|
-
"@constela/
|
|
47
|
+
"@constela/core": "0.7.0",
|
|
48
|
+
"@constela/router": "8.0.0",
|
|
49
|
+
"@constela/server": "3.0.1",
|
|
50
|
+
"@constela/runtime": "0.10.2"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@types/mdast": "^4.0.4",
|