@constela/start 1.2.4 → 1.2.6
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.
|
@@ -1546,17 +1546,53 @@ async function loadPageData(baseDir, dataSources, context) {
|
|
|
1546
1546
|
}
|
|
1547
1547
|
return result;
|
|
1548
1548
|
}
|
|
1549
|
-
|
|
1549
|
+
function resolveSourceData(source, loadedData, resolvedImports) {
|
|
1550
|
+
if (typeof source === "string") {
|
|
1551
|
+
return loadedData[source];
|
|
1552
|
+
}
|
|
1553
|
+
if (source && typeof source === "object" && "expr" in source) {
|
|
1554
|
+
const expr = source;
|
|
1555
|
+
if (expr.expr === "import" && "name" in expr) {
|
|
1556
|
+
const importName = expr.name;
|
|
1557
|
+
const importPath = expr.path;
|
|
1558
|
+
const importData = resolvedImports?.[importName];
|
|
1559
|
+
if (importData === void 0) {
|
|
1560
|
+
throw new Error(`Import "${importName}" not found for getStaticPaths source`);
|
|
1561
|
+
}
|
|
1562
|
+
if (importPath) {
|
|
1563
|
+
const pathParts = importPath.split(".");
|
|
1564
|
+
let result = importData;
|
|
1565
|
+
for (const part of pathParts) {
|
|
1566
|
+
if (result && typeof result === "object" && part in result) {
|
|
1567
|
+
result = result[part];
|
|
1568
|
+
} else {
|
|
1569
|
+
throw new Error(`Path "${importPath}" not found in import "${importName}"`);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return result;
|
|
1573
|
+
}
|
|
1574
|
+
return importData;
|
|
1575
|
+
}
|
|
1576
|
+
if (expr.expr === "var" && "name" in expr) {
|
|
1577
|
+
const varName = expr.name;
|
|
1578
|
+
return loadedData[varName];
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
throw new Error(`Invalid getStaticPaths source: ${JSON.stringify(source)}`);
|
|
1582
|
+
}
|
|
1583
|
+
async function generateStaticPathsFromPage(pageConfig, loadedData, resolvedImports) {
|
|
1550
1584
|
if (!pageConfig.getStaticPaths) {
|
|
1551
1585
|
return [];
|
|
1552
1586
|
}
|
|
1553
1587
|
const { source, params } = pageConfig.getStaticPaths;
|
|
1554
|
-
const sourceData = loadedData
|
|
1588
|
+
const sourceData = resolveSourceData(source, loadedData, resolvedImports);
|
|
1555
1589
|
if (sourceData === void 0) {
|
|
1556
|
-
|
|
1590
|
+
const sourceStr = typeof source === "string" ? source : JSON.stringify(source);
|
|
1591
|
+
throw new Error(`Data source "${sourceStr}" not found for getStaticPaths`);
|
|
1557
1592
|
}
|
|
1558
1593
|
if (!Array.isArray(sourceData)) {
|
|
1559
|
-
|
|
1594
|
+
const sourceStr = typeof source === "string" ? source : JSON.stringify(source);
|
|
1595
|
+
throw new Error(`Data source "${sourceStr}" must be an array for getStaticPaths`);
|
|
1560
1596
|
}
|
|
1561
1597
|
const paths = [];
|
|
1562
1598
|
for (const item of sourceData) {
|
|
@@ -1856,7 +1892,7 @@ var JsonPageLoader = class {
|
|
|
1856
1892
|
*/
|
|
1857
1893
|
async getStaticPaths(pagePath) {
|
|
1858
1894
|
const pageInfo = await this.loadPage(pagePath);
|
|
1859
|
-
return generateStaticPathsFromPage(pageInfo.page, pageInfo.loadedData);
|
|
1895
|
+
return generateStaticPathsFromPage(pageInfo.page, pageInfo.loadedData, pageInfo.resolvedImports);
|
|
1860
1896
|
}
|
|
1861
1897
|
/**
|
|
1862
1898
|
* Compile a page to CompiledProgram
|
|
@@ -2228,7 +2264,8 @@ async function bundleCSS(options) {
|
|
|
2228
2264
|
bundle: true,
|
|
2229
2265
|
outfile: outFile,
|
|
2230
2266
|
minify: options.minify ?? true,
|
|
2231
|
-
loader: { ".css": "css" }
|
|
2267
|
+
loader: { ".css": "css" },
|
|
2268
|
+
conditions: ["style"]
|
|
2232
2269
|
});
|
|
2233
2270
|
} else {
|
|
2234
2271
|
const virtualEntry = resolvedCssFiles.map((f) => `@import "${f}";`).join("\n");
|
|
@@ -2240,7 +2277,8 @@ async function bundleCSS(options) {
|
|
|
2240
2277
|
},
|
|
2241
2278
|
bundle: true,
|
|
2242
2279
|
outfile: outFile,
|
|
2243
|
-
minify: options.minify ?? true
|
|
2280
|
+
minify: options.minify ?? true,
|
|
2281
|
+
conditions: ["style"]
|
|
2244
2282
|
});
|
|
2245
2283
|
}
|
|
2246
2284
|
} catch (error) {
|
|
@@ -2537,7 +2575,8 @@ async function build2(options) {
|
|
|
2537
2575
|
if (pageInfo.page.getStaticPaths) {
|
|
2538
2576
|
staticPathsResult = await generateStaticPathsFromPage(
|
|
2539
2577
|
pageInfo.page,
|
|
2540
|
-
pageInfo.loadedData
|
|
2578
|
+
pageInfo.loadedData,
|
|
2579
|
+
pageInfo.resolvedImports
|
|
2541
2580
|
);
|
|
2542
2581
|
} else {
|
|
2543
2582
|
const externalPaths = await loadGetStaticPaths(route.file);
|
package/dist/cli/index.js
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constela/start",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.6",
|
|
4
4
|
"description": "Meta-framework for Constela applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -41,10 +41,10 @@
|
|
|
41
41
|
"unified": "^11.0.0",
|
|
42
42
|
"vite": "^6.0.0",
|
|
43
43
|
"@constela/compiler": "0.7.0",
|
|
44
|
-
"@constela/core": "0.7.0",
|
|
45
|
-
"@constela/runtime": "0.10.1",
|
|
46
44
|
"@constela/router": "8.0.0",
|
|
47
|
-
"@constela/
|
|
45
|
+
"@constela/core": "0.7.0",
|
|
46
|
+
"@constela/server": "3.0.0",
|
|
47
|
+
"@constela/runtime": "0.10.1"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@types/mdast": "^4.0.4",
|