@reckona/mreact-router 0.0.100 → 0.0.102
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/build.d.ts.map +1 -1
- package/dist/build.js +378 -50
- package/dist/build.js.map +1 -1
- package/package.json +11 -11
- package/src/build.ts +517 -53
package/dist/build.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AAwCA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAI5C,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAG1B,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,OAAO,EAAqC,KAAK,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AA2BnG,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAarD,MAAM,WAAW,eAAgB,SAAQ,uBAAuB;IAC9D,kBAAkB,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACzE,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,SAAS,oBAAoB,EAAE,GAAG,SAAS,CAAC;IACtD,UAAU,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,SAAS,CAAC,GAAG,SAAS,CAAC;CACtD;AAED,MAAM,MAAM,aAAa,GACrB,MAAM,GACN,cAAc,GACd,gBAAgB,GAChB,UAAU,GACV,eAAe,GACf,cAAc,GACd,sBAAsB,GACtB,eAAe,GACf,cAAc,GACd,uBAAuB,GACvB,eAAe,GACf,mBAAmB,GACnB,WAAW,GACX,YAAY,GACZ,gBAAgB,GAChB,kBA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AE,QAAQ,GAAG,UAAU,CAAC;CAC9B;AA8rCD,wBAAsB,+CAA+C,CAAC,OAAO,EAAE;IAC7E,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;IACzD,WAAW,CAAC,EAAE,SAAS,YAAY,EAAE,GAAG,SAAS,CAAC;CACnD,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAWlC;AA83BD,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,+BAA+B,GACvC,OAAO,CAAC,yBAAyB,CAAC,CA4CpC;AA2DD,wBAAsB,8BAA8B,CAClD,OAAO,EAAE,qCAAqC,GAC7C,OAAO,CAAC,+BAA+B,CAAC,CAqD1C"}
|
package/dist/build.js
CHANGED
|
@@ -1577,9 +1577,41 @@ async function writeCloudflareRouteModules(options) {
|
|
|
1577
1577
|
root: options.projectRoot,
|
|
1578
1578
|
vitePlugins: options.vitePlugins,
|
|
1579
1579
|
});
|
|
1580
|
+
const directComponentRoutes = await collectCloudflareDirectComponentRoutes({
|
|
1581
|
+
requiredRoutes,
|
|
1582
|
+
routesDir: options.routesDir,
|
|
1583
|
+
serverModules: options.serverModules,
|
|
1584
|
+
sourceAnalysis: options.sourceAnalysis,
|
|
1585
|
+
});
|
|
1586
|
+
const stringShellComponentRoutes = await collectCloudflareStringShellComponentRoutes({
|
|
1587
|
+
requiredRoutes,
|
|
1588
|
+
routesDir: options.routesDir,
|
|
1589
|
+
serverModules: options.serverModules,
|
|
1590
|
+
sourceAnalysis: options.sourceAnalysis,
|
|
1591
|
+
});
|
|
1592
|
+
const directComponentRouteIds = new Set(directComponentRoutes.map((route) => route.routeId));
|
|
1593
|
+
const stringShellComponentRouteIds = new Set(stringShellComponentRoutes.map((route) => route.routeId));
|
|
1594
|
+
const directComponentModules = await buildCloudflareServerComponentModuleBatch({
|
|
1595
|
+
cacheDir: options.cacheDir,
|
|
1596
|
+
projectRoot: options.projectRoot,
|
|
1597
|
+
routes: directComponentRoutes,
|
|
1598
|
+
serverModules: options.serverModules,
|
|
1599
|
+
sourceAnalysis: options.sourceAnalysis,
|
|
1600
|
+
vitePlugins: options.vitePlugins,
|
|
1601
|
+
});
|
|
1602
|
+
const stringShellComponentModules = await buildCloudflareStringRouteComponentModuleBatch({
|
|
1603
|
+
cacheDir: options.cacheDir,
|
|
1604
|
+
projectRoot: options.projectRoot,
|
|
1605
|
+
routes: stringShellComponentRoutes,
|
|
1606
|
+
serverModules: options.serverModules,
|
|
1607
|
+
sourceAnalysis: options.sourceAnalysis,
|
|
1608
|
+
vitePlugins: options.vitePlugins,
|
|
1609
|
+
});
|
|
1580
1610
|
await Promise.all([
|
|
1581
1611
|
writeCloudflareBatchedRouteModuleChunks(options.cloudflareDir, serverRouteModules),
|
|
1582
1612
|
writeCloudflareBatchedRouteModuleChunks(options.cloudflareDir, loaderRouteModules),
|
|
1613
|
+
writeCloudflareBatchedRouteModuleChunks(options.cloudflareDir, directComponentModules),
|
|
1614
|
+
writeCloudflareBatchedRouteModuleChunks(options.cloudflareDir, stringShellComponentModules),
|
|
1583
1615
|
]);
|
|
1584
1616
|
const registryEntries = await mapWithBuildConcurrency(requiredRoutes, async ({ route, routeFile, routeId }) => {
|
|
1585
1617
|
const routeModuleFile = `routes/${routeId}.mjs`;
|
|
@@ -1610,27 +1642,38 @@ async function writeCloudflareRouteModules(options) {
|
|
|
1610
1642
|
? "stream"
|
|
1611
1643
|
: "string";
|
|
1612
1644
|
try {
|
|
1613
|
-
const
|
|
1614
|
-
?
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1645
|
+
const batchedComponent = stringShellComponentRouteIds.has(routeId)
|
|
1646
|
+
? stringShellComponentModules.entries.get(routeId)
|
|
1647
|
+
: directComponentRouteIds.has(routeId)
|
|
1648
|
+
? directComponentModules.entries.get(routeId)
|
|
1649
|
+
: undefined;
|
|
1650
|
+
let componentFile = batchedComponent?.fileName;
|
|
1651
|
+
if (batchedComponent === undefined) {
|
|
1652
|
+
const componentOutput = serverOutput === "stream"
|
|
1653
|
+
? await buildCloudflareStreamRouteComponentModule({
|
|
1654
|
+
cacheDir: options.cacheDir,
|
|
1655
|
+
filename: route.file,
|
|
1656
|
+
projectRoot: options.projectRoot,
|
|
1657
|
+
routesDir: options.routesDir,
|
|
1658
|
+
serverModules: options.serverModules,
|
|
1659
|
+
sourceAnalysis: options.sourceAnalysis,
|
|
1660
|
+
vitePlugins: options.vitePlugins,
|
|
1661
|
+
})
|
|
1662
|
+
: await buildCloudflareStringRouteComponentModule({
|
|
1663
|
+
cacheDir: options.cacheDir,
|
|
1664
|
+
filename: route.file,
|
|
1665
|
+
projectRoot: options.projectRoot,
|
|
1666
|
+
routesDir: options.routesDir,
|
|
1667
|
+
serverModules: options.serverModules,
|
|
1668
|
+
sourceAnalysis: options.sourceAnalysis,
|
|
1669
|
+
vitePlugins: options.vitePlugins,
|
|
1670
|
+
});
|
|
1671
|
+
componentFile = `routes/${routeId}.${hashText(componentOutput).slice(0, 8)}.component.mjs`;
|
|
1672
|
+
await writeFile(join(options.cloudflareDir, componentFile), componentOutput);
|
|
1673
|
+
}
|
|
1674
|
+
if (componentFile === undefined) {
|
|
1675
|
+
throw new Error("Missing bundled Cloudflare component module.");
|
|
1676
|
+
}
|
|
1634
1677
|
const componentImport = `./${componentFile.split("/").pop() ?? componentFile}`;
|
|
1635
1678
|
routeModuleExports = [
|
|
1636
1679
|
`export { default, App, slots } from ${JSON.stringify(componentImport)};`,
|
|
@@ -1666,6 +1709,282 @@ async function writeCloudflareRouteModules(options) {
|
|
|
1666
1709
|
await writeFile(join(options.cloudflareDir, "route-modules.mjs"), registrySource);
|
|
1667
1710
|
return { registryFile: "route-modules.mjs" };
|
|
1668
1711
|
}
|
|
1712
|
+
async function collectCloudflareDirectComponentRoutes(options) {
|
|
1713
|
+
const routes = await Promise.all(options.requiredRoutes.map(async ({ route, routeFile, routeId }) => {
|
|
1714
|
+
if (route.kind !== "page") {
|
|
1715
|
+
return undefined;
|
|
1716
|
+
}
|
|
1717
|
+
const serverOutput = options.serverModules[routeFile]?.analysis?.streamRoute === true ||
|
|
1718
|
+
options.sourceAnalysis.byRouteFile.get(routeFile)?.streamRoute === true
|
|
1719
|
+
? "stream"
|
|
1720
|
+
: "string";
|
|
1721
|
+
if (serverOutput !== "string") {
|
|
1722
|
+
return undefined;
|
|
1723
|
+
}
|
|
1724
|
+
const shellFiles = await cloudflareShellFilesForPage(options.routesDir, route.file);
|
|
1725
|
+
if (shellFiles.length > 0) {
|
|
1726
|
+
return undefined;
|
|
1727
|
+
}
|
|
1728
|
+
return {
|
|
1729
|
+
filename: route.file,
|
|
1730
|
+
routeId,
|
|
1731
|
+
};
|
|
1732
|
+
}));
|
|
1733
|
+
return routes.filter((route) => route !== undefined);
|
|
1734
|
+
}
|
|
1735
|
+
async function collectCloudflareStringShellComponentRoutes(options) {
|
|
1736
|
+
const routes = await Promise.all(options.requiredRoutes.map(async ({ route, routeFile, routeId }) => {
|
|
1737
|
+
if (route.kind !== "page") {
|
|
1738
|
+
return undefined;
|
|
1739
|
+
}
|
|
1740
|
+
const serverOutput = options.serverModules[routeFile]?.analysis?.streamRoute === true ||
|
|
1741
|
+
options.sourceAnalysis.byRouteFile.get(routeFile)?.streamRoute === true
|
|
1742
|
+
? "stream"
|
|
1743
|
+
: "string";
|
|
1744
|
+
if (serverOutput !== "string") {
|
|
1745
|
+
return undefined;
|
|
1746
|
+
}
|
|
1747
|
+
const shellFiles = await cloudflareShellFilesForPage(options.routesDir, route.file);
|
|
1748
|
+
if (shellFiles.length === 0) {
|
|
1749
|
+
return undefined;
|
|
1750
|
+
}
|
|
1751
|
+
return {
|
|
1752
|
+
filename: route.file,
|
|
1753
|
+
routeId,
|
|
1754
|
+
shellFiles,
|
|
1755
|
+
};
|
|
1756
|
+
}));
|
|
1757
|
+
return routes.filter((route) => route !== undefined);
|
|
1758
|
+
}
|
|
1759
|
+
async function buildCloudflareServerComponentModuleBatch(options) {
|
|
1760
|
+
if (options.routes.length === 0) {
|
|
1761
|
+
return { chunks: [], entries: new Map() };
|
|
1762
|
+
}
|
|
1763
|
+
const virtualModules = new Map();
|
|
1764
|
+
const bundleEntries = await Promise.all(options.routes.map(async (route) => {
|
|
1765
|
+
const metadataModule = await buildCloudflareRouteMetadataExportModule({
|
|
1766
|
+
cacheDir: options.cacheDir,
|
|
1767
|
+
filename: route.filename,
|
|
1768
|
+
hasMetadata: buildSourceAnalysisForFile(options.sourceAnalysis, options.projectRoot, route.filename)?.hasMetadata,
|
|
1769
|
+
root: options.projectRoot,
|
|
1770
|
+
vitePlugins: options.vitePlugins,
|
|
1771
|
+
});
|
|
1772
|
+
const metadataId = `mreact:metadata:${route.routeId}`;
|
|
1773
|
+
if (metadataModule !== undefined) {
|
|
1774
|
+
virtualModules.set(metadataId, {
|
|
1775
|
+
contents: metadataModule,
|
|
1776
|
+
resolveDir: dirname(route.filename),
|
|
1777
|
+
});
|
|
1778
|
+
}
|
|
1779
|
+
return {
|
|
1780
|
+
code: cloudflareServerComponentModuleEntry(route.filename, metadataModule === undefined ? undefined : metadataId),
|
|
1781
|
+
filename: `${route.filename}.mreact-cloudflare-component.js`,
|
|
1782
|
+
name: `${route.routeId}.component`,
|
|
1783
|
+
routeId: route.routeId,
|
|
1784
|
+
};
|
|
1785
|
+
}));
|
|
1786
|
+
const output = await bundleRouterModules({
|
|
1787
|
+
cacheDir: options.cacheDir,
|
|
1788
|
+
chunkFileNames: "routes/chunks/[name].[hash].mjs",
|
|
1789
|
+
entries: bundleEntries,
|
|
1790
|
+
entryFileNames: "routes/[name].[hash].mjs",
|
|
1791
|
+
minify: true,
|
|
1792
|
+
platform: "node",
|
|
1793
|
+
plugins: [
|
|
1794
|
+
cloudflareVirtualModulesPlugin(virtualModules),
|
|
1795
|
+
cloudflareServerSourceTransformPlugin({
|
|
1796
|
+
projectRoot: options.projectRoot,
|
|
1797
|
+
serverOutput: "string",
|
|
1798
|
+
serverModules: options.serverModules,
|
|
1799
|
+
vitePlugins: options.vitePlugins,
|
|
1800
|
+
}),
|
|
1801
|
+
cloudflareWorkspaceRuntimePlugin(),
|
|
1802
|
+
],
|
|
1803
|
+
root: options.projectRoot,
|
|
1804
|
+
target: "es2022",
|
|
1805
|
+
vitePlugins: options.vitePlugins,
|
|
1806
|
+
});
|
|
1807
|
+
const entriesByName = new Map(bundleEntries.map((entry) => [entry.name, entry]));
|
|
1808
|
+
const entries = new Map();
|
|
1809
|
+
for (const chunk of output.chunks) {
|
|
1810
|
+
if (!chunk.isEntry) {
|
|
1811
|
+
continue;
|
|
1812
|
+
}
|
|
1813
|
+
const entry = entriesByName.get(chunk.name);
|
|
1814
|
+
if (entry === undefined) {
|
|
1815
|
+
continue;
|
|
1816
|
+
}
|
|
1817
|
+
entries.set(entry.routeId, {
|
|
1818
|
+
code: chunk.code,
|
|
1819
|
+
fileName: chunk.fileName,
|
|
1820
|
+
});
|
|
1821
|
+
}
|
|
1822
|
+
return { chunks: output.chunks, entries };
|
|
1823
|
+
}
|
|
1824
|
+
async function buildCloudflareStringRouteComponentModuleBatch(options) {
|
|
1825
|
+
if (options.routes.length === 0) {
|
|
1826
|
+
return { chunks: [], entries: new Map() };
|
|
1827
|
+
}
|
|
1828
|
+
const virtualModules = new Map();
|
|
1829
|
+
const bundleEntries = await Promise.all(options.routes.map(async (route) => {
|
|
1830
|
+
const metadataImports = [];
|
|
1831
|
+
const pageMetadataId = `mreact:metadata:${route.routeId}:page`;
|
|
1832
|
+
const pageMetadataModule = await buildCloudflareRouteMetadataExportModule({
|
|
1833
|
+
cacheDir: options.cacheDir,
|
|
1834
|
+
filename: route.filename,
|
|
1835
|
+
hasMetadata: buildSourceAnalysisForFile(options.sourceAnalysis, options.projectRoot, route.filename)?.hasMetadata,
|
|
1836
|
+
root: options.projectRoot,
|
|
1837
|
+
vitePlugins: options.vitePlugins,
|
|
1838
|
+
});
|
|
1839
|
+
if (pageMetadataModule === undefined) {
|
|
1840
|
+
metadataImports.push("const pageMetadataModule = {};");
|
|
1841
|
+
}
|
|
1842
|
+
else {
|
|
1843
|
+
virtualModules.set(pageMetadataId, {
|
|
1844
|
+
contents: pageMetadataModule,
|
|
1845
|
+
resolveDir: dirname(route.filename),
|
|
1846
|
+
});
|
|
1847
|
+
metadataImports.push(`import * as pageMetadataModule from ${JSON.stringify(pageMetadataId)};`);
|
|
1848
|
+
}
|
|
1849
|
+
const shellMetadataImports = await Promise.all(route.shellFiles.map(async (shell, index) => {
|
|
1850
|
+
const shellMetadataId = `mreact:metadata:${route.routeId}:shell:${index}`;
|
|
1851
|
+
const shellMetadataModule = await buildCloudflareRouteMetadataExportModule({
|
|
1852
|
+
cacheDir: options.cacheDir,
|
|
1853
|
+
filename: shell.file,
|
|
1854
|
+
hasMetadata: buildSourceAnalysisForFile(options.sourceAnalysis, options.projectRoot, shell.file)?.hasMetadata,
|
|
1855
|
+
root: options.projectRoot,
|
|
1856
|
+
vitePlugins: options.vitePlugins,
|
|
1857
|
+
});
|
|
1858
|
+
if (shellMetadataModule === undefined) {
|
|
1859
|
+
return `const shellMetadataModule${index} = {};`;
|
|
1860
|
+
}
|
|
1861
|
+
virtualModules.set(shellMetadataId, {
|
|
1862
|
+
contents: shellMetadataModule,
|
|
1863
|
+
resolveDir: dirname(shell.file),
|
|
1864
|
+
});
|
|
1865
|
+
return `import * as shellMetadataModule${index} from ${JSON.stringify(shellMetadataId)};`;
|
|
1866
|
+
}));
|
|
1867
|
+
metadataImports.push(...shellMetadataImports);
|
|
1868
|
+
return {
|
|
1869
|
+
code: cloudflareStringRouteComponentModuleEntry({
|
|
1870
|
+
filename: route.filename,
|
|
1871
|
+
metadataImports,
|
|
1872
|
+
pageMetadataModuleName: "pageMetadataModule",
|
|
1873
|
+
shellFiles: route.shellFiles,
|
|
1874
|
+
shellMetadataModuleName: (index) => `shellMetadataModule${index}`,
|
|
1875
|
+
}),
|
|
1876
|
+
filename: `${route.filename}.mreact-cloudflare-string-route.js`,
|
|
1877
|
+
name: `${route.routeId}.string`,
|
|
1878
|
+
routeId: route.routeId,
|
|
1879
|
+
};
|
|
1880
|
+
}));
|
|
1881
|
+
const output = await bundleRouterModules({
|
|
1882
|
+
cacheDir: options.cacheDir,
|
|
1883
|
+
chunkFileNames: "routes/chunks/[name].[hash].mjs",
|
|
1884
|
+
entries: bundleEntries,
|
|
1885
|
+
entryFileNames: "routes/[name].[hash].mjs",
|
|
1886
|
+
minify: true,
|
|
1887
|
+
platform: "node",
|
|
1888
|
+
plugins: [
|
|
1889
|
+
cloudflareVirtualModulesPlugin(virtualModules),
|
|
1890
|
+
cloudflareServerSourceTransformPlugin({
|
|
1891
|
+
projectRoot: options.projectRoot,
|
|
1892
|
+
serverOutput: "string",
|
|
1893
|
+
serverModules: options.serverModules,
|
|
1894
|
+
vitePlugins: options.vitePlugins,
|
|
1895
|
+
}),
|
|
1896
|
+
cloudflareWorkspaceRuntimePlugin(),
|
|
1897
|
+
],
|
|
1898
|
+
root: options.projectRoot,
|
|
1899
|
+
target: "es2022",
|
|
1900
|
+
vitePlugins: options.vitePlugins,
|
|
1901
|
+
});
|
|
1902
|
+
const entriesByName = new Map(bundleEntries.map((entry) => [entry.name, entry]));
|
|
1903
|
+
const entries = new Map();
|
|
1904
|
+
for (const chunk of output.chunks) {
|
|
1905
|
+
if (!chunk.isEntry) {
|
|
1906
|
+
continue;
|
|
1907
|
+
}
|
|
1908
|
+
const entry = entriesByName.get(chunk.name);
|
|
1909
|
+
if (entry === undefined) {
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
entries.set(entry.routeId, {
|
|
1913
|
+
code: chunk.code,
|
|
1914
|
+
fileName: chunk.fileName,
|
|
1915
|
+
});
|
|
1916
|
+
}
|
|
1917
|
+
return { chunks: output.chunks, entries };
|
|
1918
|
+
}
|
|
1919
|
+
function cloudflareStringRouteComponentModuleEntry(options) {
|
|
1920
|
+
const shellImports = options.shellFiles.map((shell, index) => `import * as shellRouteModule${index} from ${JSON.stringify(shell.file)};`);
|
|
1921
|
+
const shellDefinitions = options.shellFiles.map((shell, index) => `{ component: selectComponent(shell${index}, ${JSON.stringify(shell.file)}), id: ${JSON.stringify(shell.id)}, kind: ${JSON.stringify(shell.kind)}, module: shell${index} }`);
|
|
1922
|
+
const shellModules = options.shellFiles.map((_, index) => `const shell${index} = routeComponentModule(shellRouteModule${index}, ${options.shellMetadataModuleName(index)});`);
|
|
1923
|
+
return `import * as pageRouteModule from ${JSON.stringify(options.filename)};
|
|
1924
|
+
${shellImports.join("\n")}
|
|
1925
|
+
${options.metadataImports.join("\n")}
|
|
1926
|
+
|
|
1927
|
+
const pageModule = routeComponentModule(pageRouteModule, ${options.pageMetadataModuleName});
|
|
1928
|
+
${shellModules.join("\n")}
|
|
1929
|
+
const pageComponent = selectComponent(pageModule, ${JSON.stringify(options.filename)});
|
|
1930
|
+
const shells = [${shellDefinitions.join(", ")}];
|
|
1931
|
+
export const slots = pageModule.slots;
|
|
1932
|
+
export const App = renderCloudflareStringRoute;
|
|
1933
|
+
export default renderCloudflareStringRoute;
|
|
1934
|
+
|
|
1935
|
+
async function renderCloudflareStringRoute(props) {
|
|
1936
|
+
const slotHtml = await renderRouteSlots(pageModule.slots, props);
|
|
1937
|
+
const layoutShells = await renderLayoutShells(shells, props, slotHtml);
|
|
1938
|
+
const metadata = await resolveRouteMetadata([...shells.map((shell) => shell.module), pageModule], props);
|
|
1939
|
+
let html = "<!DOCTYPE html>";
|
|
1940
|
+
for (const shell of layoutShells) {
|
|
1941
|
+
html += shell.prefix;
|
|
1942
|
+
}
|
|
1943
|
+
html += String(await pageComponent(props) ?? "");
|
|
1944
|
+
for (const shell of [...layoutShells].reverse()) {
|
|
1945
|
+
html += shell.suffix;
|
|
1946
|
+
}
|
|
1947
|
+
html = injectCloudflareHead(html, metadata, cloudflareRouteHeadTags(props.clientManifest, props.route.path));
|
|
1948
|
+
return new Response(html, {
|
|
1949
|
+
headers: {
|
|
1950
|
+
"content-type": "text/html; charset=utf-8"
|
|
1951
|
+
}
|
|
1952
|
+
});
|
|
1953
|
+
}
|
|
1954
|
+
|
|
1955
|
+
function routeComponentModule(routeModule, metadataModule) {
|
|
1956
|
+
const component = routeModule.default ?? routeModule.App ?? Object.values(routeModule).find((value) => typeof value === "function");
|
|
1957
|
+
return {
|
|
1958
|
+
...routeModule,
|
|
1959
|
+
App: component,
|
|
1960
|
+
default: component,
|
|
1961
|
+
generateMetadata: metadataModule.generateMetadata,
|
|
1962
|
+
metadata: metadataModule.metadata,
|
|
1963
|
+
slots: routeModule.slots,
|
|
1964
|
+
};
|
|
1965
|
+
}
|
|
1966
|
+
|
|
1967
|
+
function selectComponent(module, label) {
|
|
1968
|
+
const component = module.default ?? module.App ?? Object.values(module).find((value) => typeof value === "function");
|
|
1969
|
+
if (typeof component !== "function") {
|
|
1970
|
+
throw new Error(\`No Cloudflare component export was found for \${label}.\`);
|
|
1971
|
+
}
|
|
1972
|
+
return component;
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1975
|
+
async function renderRouteSlots(slots, props) {
|
|
1976
|
+
if (slots === undefined) {
|
|
1977
|
+
return {};
|
|
1978
|
+
}
|
|
1979
|
+
const rendered = {};
|
|
1980
|
+
for (const [name, value] of Object.entries(slots)) {
|
|
1981
|
+
rendered[name] = typeof value === "function" ? String(await value(props) ?? "") : String(value ?? "");
|
|
1982
|
+
}
|
|
1983
|
+
return rendered;
|
|
1984
|
+
}
|
|
1985
|
+
|
|
1986
|
+
${cloudflareShellRuntimeSource()}`;
|
|
1987
|
+
}
|
|
1669
1988
|
async function buildCloudflareServerComponentModule(options) {
|
|
1670
1989
|
const metadataModule = await buildCloudflareRouteMetadataExportModule({
|
|
1671
1990
|
cacheDir: options.cacheDir,
|
|
@@ -1674,15 +1993,7 @@ async function buildCloudflareServerComponentModule(options) {
|
|
|
1674
1993
|
root: options.projectRoot,
|
|
1675
1994
|
vitePlugins: options.vitePlugins,
|
|
1676
1995
|
});
|
|
1677
|
-
const entry =
|
|
1678
|
-
${metadataModule === undefined ? "const metadataModule = {};" : 'import * as metadataModule from "mreact:metadata";'}
|
|
1679
|
-
|
|
1680
|
-
const component = routeModule.default ?? routeModule.App ?? Object.values(routeModule).find((value) => typeof value === "function");
|
|
1681
|
-
export const App = component;
|
|
1682
|
-
export default component;
|
|
1683
|
-
export const generateMetadata = metadataModule.generateMetadata;
|
|
1684
|
-
export const metadata = metadataModule.metadata;
|
|
1685
|
-
export const slots = routeModule.slots;`;
|
|
1996
|
+
const entry = cloudflareServerComponentModuleEntry(options.filename, metadataModule === undefined ? undefined : "mreact:metadata");
|
|
1686
1997
|
return bundleCloudflareVirtualModule({
|
|
1687
1998
|
entry,
|
|
1688
1999
|
filename: `${options.filename}.mreact-cloudflare-component.js`,
|
|
@@ -1704,6 +2015,17 @@ export const slots = routeModule.slots;`;
|
|
|
1704
2015
|
vitePlugins: options.vitePlugins,
|
|
1705
2016
|
});
|
|
1706
2017
|
}
|
|
2018
|
+
function cloudflareServerComponentModuleEntry(filename, metadataModuleId) {
|
|
2019
|
+
return `import * as routeModule from ${JSON.stringify(filename)};
|
|
2020
|
+
${metadataModuleId === undefined ? "const metadataModule = {};" : `import * as metadataModule from ${JSON.stringify(metadataModuleId)};`}
|
|
2021
|
+
|
|
2022
|
+
const component = routeModule.default ?? routeModule.App ?? Object.values(routeModule).find((value) => typeof value === "function");
|
|
2023
|
+
export const App = component;
|
|
2024
|
+
export default component;
|
|
2025
|
+
export const generateMetadata = metadataModule.generateMetadata;
|
|
2026
|
+
export const metadata = metadataModule.metadata;
|
|
2027
|
+
export const slots = routeModule.slots;`;
|
|
2028
|
+
}
|
|
1707
2029
|
async function buildCloudflareStringRouteComponentModule(options) {
|
|
1708
2030
|
const shellFiles = await cloudflareShellFilesForPage(options.routesDir, options.filename);
|
|
1709
2031
|
if (shellFiles.length === 0) {
|
|
@@ -2319,26 +2641,10 @@ async function bundleCloudflareVirtualModule(options) {
|
|
|
2319
2641
|
entry: options.entry,
|
|
2320
2642
|
filename: options.filename,
|
|
2321
2643
|
plugins: [
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
namespace: "mreact-cloudflare-virtual",
|
|
2327
|
-
path: args.path,
|
|
2328
|
-
}));
|
|
2329
|
-
buildApi.onLoad({ filter: /.*/, namespace: "mreact-cloudflare-virtual" }, (args) => {
|
|
2330
|
-
const contents = options.modules.get(args.path);
|
|
2331
|
-
if (contents === undefined) {
|
|
2332
|
-
throw new Error(`Missing virtual Cloudflare module ${args.path}.`);
|
|
2333
|
-
}
|
|
2334
|
-
return {
|
|
2335
|
-
contents,
|
|
2336
|
-
loader: "js",
|
|
2337
|
-
resolveDir: options.resolveDir,
|
|
2338
|
-
};
|
|
2339
|
-
});
|
|
2340
|
-
},
|
|
2341
|
-
},
|
|
2644
|
+
cloudflareVirtualModulesPlugin(new Map(Array.from(options.modules, ([id, contents]) => [
|
|
2645
|
+
id,
|
|
2646
|
+
{ contents, resolveDir: options.resolveDir },
|
|
2647
|
+
]))),
|
|
2342
2648
|
...options.plugins,
|
|
2343
2649
|
],
|
|
2344
2650
|
resolveDir: options.resolveDir,
|
|
@@ -2346,6 +2652,28 @@ async function bundleCloudflareVirtualModule(options) {
|
|
|
2346
2652
|
vitePlugins: options.vitePlugins,
|
|
2347
2653
|
});
|
|
2348
2654
|
}
|
|
2655
|
+
function cloudflareVirtualModulesPlugin(modules) {
|
|
2656
|
+
return {
|
|
2657
|
+
name: "mreact-cloudflare-virtual-modules",
|
|
2658
|
+
setup(buildApi) {
|
|
2659
|
+
buildApi.onResolve({ filter: /^mreact:/ }, (args) => ({
|
|
2660
|
+
namespace: "mreact-cloudflare-virtual",
|
|
2661
|
+
path: args.path,
|
|
2662
|
+
}));
|
|
2663
|
+
buildApi.onLoad({ filter: /.*/, namespace: "mreact-cloudflare-virtual" }, (args) => {
|
|
2664
|
+
const module = modules.get(args.path);
|
|
2665
|
+
if (module === undefined) {
|
|
2666
|
+
throw new Error(`Missing virtual Cloudflare module ${args.path}.`);
|
|
2667
|
+
}
|
|
2668
|
+
return {
|
|
2669
|
+
contents: module.contents,
|
|
2670
|
+
loader: "js",
|
|
2671
|
+
resolveDir: module.resolveDir,
|
|
2672
|
+
};
|
|
2673
|
+
});
|
|
2674
|
+
},
|
|
2675
|
+
};
|
|
2676
|
+
}
|
|
2349
2677
|
async function cloudflareShellFilesForPage(routesDir, pageFile) {
|
|
2350
2678
|
const shells = await existingRouteShellCandidates(routesDir, pageFile, async (file) => {
|
|
2351
2679
|
try {
|