ezfw-core 1.0.66 → 1.0.67
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/islands/ViteIslandsPlugin.js +17 -9
- package/package.json +1 -1
|
@@ -669,7 +669,7 @@ async function renderPageDev(page, server, opts, renderer, islands, root) {
|
|
|
669
669
|
// Render body
|
|
670
670
|
const body = await renderer.renderPage(page.name, definition, ctx);
|
|
671
671
|
// Generate hydration script
|
|
672
|
-
const scripts = generateHydrationScript(ctx.islands, true);
|
|
672
|
+
const scripts = generateHydrationScript(ctx.islands, true, [...ctx.styles]);
|
|
673
673
|
// Generate head meta tags
|
|
674
674
|
const title = page.title || page.name;
|
|
675
675
|
const headTags = page.description
|
|
@@ -758,7 +758,7 @@ async function renderPageBuild(page, opts, renderer, analyzer, root, islands) {
|
|
|
758
758
|
// Render body
|
|
759
759
|
const body = await renderer.renderPage(page.name, definition, ctx);
|
|
760
760
|
// Generate hydration script
|
|
761
|
-
const scripts = generateHydrationScript(ctx.islands, false);
|
|
761
|
+
const scripts = generateHydrationScript(ctx.islands, false, [...ctx.styles]);
|
|
762
762
|
// Generate head meta tags
|
|
763
763
|
const title = page.title || page.name;
|
|
764
764
|
const headTags = page.description
|
|
@@ -773,21 +773,29 @@ async function renderPageBuild(page, opts, renderer, analyzer, root, islands) {
|
|
|
773
773
|
/**
|
|
774
774
|
* Generate hydration script
|
|
775
775
|
*/
|
|
776
|
-
function generateHydrationScript(islands, isDev) {
|
|
777
|
-
if (islands.length === 0) {
|
|
778
|
-
return '';
|
|
779
|
-
}
|
|
776
|
+
function generateHydrationScript(islands, isDev, cssModules = []) {
|
|
780
777
|
const islandsJson = JSON.stringify(islands);
|
|
781
|
-
|
|
782
|
-
|
|
778
|
+
const cssModulesJson = JSON.stringify(cssModules);
|
|
779
|
+
// In dev mode, use local ez/ path (framework is in project, not node_modules)
|
|
780
|
+
const runtimePath = isDev ? '/ez/islands/runtime.ts' : '/assets/islands-runtime.js';
|
|
783
781
|
// Use hydrate.js for SSR - it doesn't import CSS directly, avoiding MIME type issues
|
|
784
782
|
const frameworkPath = isDev ? '/hydrate.js' : '/assets/hydrate.js';
|
|
783
|
+
// Generate CSS loading code - load CSS modules BEFORE rendering
|
|
784
|
+
const cssLoadingCode = cssModules.length > 0 ? `
|
|
785
|
+
// Load CSS modules used by SSR-rendered components
|
|
786
|
+
const cssModules = ${cssModulesJson};
|
|
787
|
+
for (const cssName of cssModules) {
|
|
788
|
+
await ez.resolveStyles(cssName);
|
|
789
|
+
}
|
|
790
|
+
console.log('[Ez SSR] Loaded ${cssModules.length} CSS module(s):', cssModules);` : '';
|
|
785
791
|
return `<script type="module">
|
|
786
792
|
// Ez Islands v2 - Set SSR flag and islands data BEFORE loading runtime
|
|
787
793
|
window.__EZ_SSR_MODE__ = true;
|
|
788
794
|
window.__EZ_ISLANDS__ = ${islandsJson};
|
|
789
|
-
// Load framework first
|
|
795
|
+
// Load framework first
|
|
790
796
|
await import('${frameworkPath}');
|
|
797
|
+
${cssLoadingCode}
|
|
798
|
+
// Then load runtime for island hydration
|
|
791
799
|
await import('${runtimePath}');
|
|
792
800
|
</script>`;
|
|
793
801
|
}
|