@useavalon/avalon 0.1.64 → 0.1.65

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.
@@ -1,4 +1,4 @@
1
- import{readFileSync as e,existsSync as t,readdirSync as n,statSync as r}from"node:fs";import{resolve as i,dirname as a,relative as o}from"node:path";export function islandClientBundlerPlugin(e,t){let n=process.cwd(),r=new Map,i=!1,a=c(e,n);for(let e of a)d(e,n,r);let o=`\0avalon-island-entry:`,s=!1;return{name:`avalon:island-client-bundler`,enforce:`pre`,configResolved(e){s=e.command===`serve`,i=e.command===`build`},resolveId(e){return e.startsWith(o)?e:null},load(e){if(!e.startsWith(o))return null;let t=e.slice(21),n=JSON.stringify(t);if(t.includes(`.qwik.`))return i?[`export * from ${n};`,`export { _hW } from "@builder.io/qwik";`].join(`
1
+ import{readFileSync as e,existsSync as t,readdirSync as n,statSync as r}from"node:fs";import{resolve as i,dirname as a,relative as o}from"node:path";export function islandClientBundlerPlugin(e,t){let n=process.cwd(),r=new Map,i=!1,a=c(e,n);for(let e of a)d(e,n,r);let o=`\0avalon-island-entry:`,s=!1,l=[],u={},f=`dist`;return{name:`avalon:island-client-bundler`,enforce:`pre`,configResolved(e){s=e.command===`serve`,i=e.command===`build`,l=e.resolve?.alias??[],u=e.define??{},f=e.build?.outDir??`dist`},resolveId(e){return e.startsWith(o)?e:null},load(e){if(!e.startsWith(o))return null;let t=e.slice(21),n=JSON.stringify(t);if(t.includes(`.qwik.`))return i?[`export * from ${n};`,`export { _hW } from "@builder.io/qwik";`].join(`
2
2
  `):[`export * from ${n};`,`export { _hW } from "@builder.io/qwik";`,`import __C from ${n};`,`export default __C;`,`if(typeof globalThis<"u")globalThis.__avalonIsland=__C;`].join(`
3
- `);let r=t.includes(`.lit.`),a=[];return r&&i&&a.push(`import "@useavalon/lit/client";`),a.push(`import __C from ${n};`,`var Component = __C;`,`export { Component as default, Component };`,`if(typeof globalThis<"u")globalThis.__avalonIsland=Component;`),i&&a.push(`export { loadIntegrationModule } from "virtual:avalon/integration-loader";`),a.join(`
4
- `)},async buildStart(){if(s)return;let t=this.environment;if(!(t&&t.name!==`client`)&&r.size>0){for(let[,e]of r)this.emitFile({type:`chunk`,id:o+e.filePath,fileName:`islands/${e.bundleKey}.js`,preserveSignature:`exports-only`});e.verbose&&console.log(`🏝️ Emitting ${r.size} island client bundles`)}}}}function c(e,r){let a=[];if(e.pagesDir){let n=i(r,e.pagesDir);t(n)&&a.push(n)}if(e.layoutsDir){let n=i(r,e.layoutsDir);t(n)&&a.push(n)}if(e.modules){let o=i(r,e.modules.dir);if(t(o))try{for(let e of n(o,{withFileTypes:!0}))if(e.isDirectory())for(let n of[`pages`,`layouts`,`components`]){let r=i(o,e.name,n);t(r)&&a.push(r)}}catch{}}return a}const l=[`.qwik.`];function u(e){return l.some(t=>e.includes(t))}function d(t,r,a){let o;try{o=n(t,{withFileTypes:!0})}catch{return}for(let n of o){let o=i(t,n.name);if(n.isDirectory()){d(o,r,a);continue}if(/\.(tsx?|jsx?|mdx?)$/.test(n.name))try{let t=e(o,`utf-8`),n=t.includes(`island=`)||t.includes(`island `),i=/import\s+\w+\s+from\s+['"][^'"]*\.qwik\.[^'"]*['"]/m.test(t);if(!n&&!i)continue;f(t,o,r,a)}catch{}}}function f(e,t,n,r){let i=/<([A-Z]\w*)\s+[^>]*\bisland\b/g,a=new Set,s;for(;(s=i.exec(e))!==null;)a.add(s[1]);let c=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,l=new Set,d=[];for(;(s=c.exec(e))!==null;)d.push([s[1],s[2]]),u(s[2])&&RegExp(`<`+s[1]+`[\\s/>]`).test(e)&&l.add(s[1]);if(!(a.size===0&&l.size===0))for(let[e,i]of d){if(!a.has(e)&&!l.has(e))continue;let s=p(i,t,n);if(!s)continue;let c=o(n,s).replaceAll(`\\`,`/`).replace(/\.(tsx?|jsx?)$/,``);r.has(s)||r.set(s,{filePath:s,bundleKey:c})}}function p(e,n,o){let s;if(e.startsWith(`@shared/`))s=i(o,`app/shared`,e.slice(8));else if(e.startsWith(`@modules/`))s=i(o,`app/modules`,e.slice(9));else if(e.startsWith(`@/`))s=i(o,`app`,e.slice(2));else if(e.startsWith(`.`))s=i(a(n),e);else return null;if(t(s)&&r(s).isFile())return s;for(let e of[`.tsx`,`.ts`,`.jsx`,`.js`,`.vue`,`.svelte`])if(t(s+e))return s+e;return null}
3
+ `);let r=t.includes(`.lit.`),a=t.includes(`.solid.`),s=t.includes(`.preact.`),c=t.includes(`.react.`),l=t.includes(`.vue.`),u=t.includes(`.svelte.`),d=[];if(r&&i&&d.push(`import "@useavalon/lit/client";`),d.push(`import __C from ${n};`,`var Component = __C;`,`export { Component as default, Component };`,`if(typeof globalThis<"u")globalThis.__avalonIsland=Component;`),i){let e={solid:`@useavalon/solid/client`,preact:`@useavalon/preact/client`,react:`@useavalon/react/client`,vue:`@useavalon/vue/client`,svelte:`@useavalon/svelte/client`,lit:`@useavalon/lit/client`},t=a?`solid`:s?`preact`:c?`react`:l?`vue`:u?`svelte`:r?`lit`:null;t&&e[t]?d.push(`export { hydrate as __hydrateIsland } from ${JSON.stringify(e[t])};`):d.push(`export { loadIntegrationModule } from "virtual:avalon/integration-loader";`)}return d.join(`
4
+ `)},async buildStart(){if(s)return;let t=this.environment;if(!(t&&t.name!==`client`)&&r.size>0){for(let[,e]of r)this.emitFile({type:`chunk`,id:o+e.filePath,fileName:`islands/${e.bundleKey}.js`,preserveSignature:`exports-only`});e.verbose&&console.log(`🏝️ Emitting ${r.size} island client bundles`)}},async closeBundle(){if(s||!i||r.size===0||globalThis.__avalonIslandsRebuilt)return;globalThis.__avalonIslandsRebuilt=!0;let{buildIsolatedIslands:e}=await import(`../post-build/isolated-island-builder.js`),t=new Map;for(let[e,n]of r){let r=n.filePath.includes(`.solid.`)?`solid`:n.filePath.includes(`.preact.`)?`preact`:n.filePath.includes(`.react.`)?`react`:n.filePath.includes(`.vue.`)||n.filePath.endsWith(`.vue`)?`vue`:n.filePath.includes(`.svelte.`)||n.filePath.endsWith(`.svelte`)?`svelte`:n.filePath.includes(`.lit.`)?`lit`:n.filePath.includes(`.qwik.`)?`qwik`:`preact`;t.set(e,{...n,framework:r})}await e(n,f,t,l,u)}}}function c(e,r){let a=[];if(e.pagesDir){let n=i(r,e.pagesDir);t(n)&&a.push(n)}if(e.layoutsDir){let n=i(r,e.layoutsDir);t(n)&&a.push(n)}if(e.modules){let o=i(r,e.modules.dir);if(t(o))try{for(let e of n(o,{withFileTypes:!0}))if(e.isDirectory())for(let n of[`pages`,`layouts`,`components`]){let r=i(o,e.name,n);t(r)&&a.push(r)}}catch{}}return a}const l=[`.qwik.`];function u(e){return l.some(t=>e.includes(t))}function d(t,r,a){let o;try{o=n(t,{withFileTypes:!0})}catch{return}for(let n of o){let o=i(t,n.name);if(n.isDirectory()){d(o,r,a);continue}if(/\.(tsx?|jsx?|mdx?)$/.test(n.name))try{let t=e(o,`utf-8`),n=t.includes(`island=`)||t.includes(`island `),i=/import\s+\w+\s+from\s+['"][^'"]*\.qwik\.[^'"]*['"]/m.test(t);if(!n&&!i)continue;f(t,o,r,a)}catch{}}}function f(e,t,n,r){let i=/<([A-Z]\w*)\s+[^>]*\bisland\b/g,a=new Set,s;for(;(s=i.exec(e))!==null;)a.add(s[1]);let c=/import\s+(\w+)\s+from\s+['"]([^'"]+)['"]/g,l=new Set,d=[];for(;(s=c.exec(e))!==null;)d.push([s[1],s[2]]),u(s[2])&&RegExp(`<`+s[1]+`[\\s/>]`).test(e)&&l.add(s[1]);if(!(a.size===0&&l.size===0))for(let[e,i]of d){if(!a.has(e)&&!l.has(e))continue;let s=p(i,t,n);if(!s)continue;let c=o(n,s).replaceAll(`\\`,`/`).replace(/\.(tsx?|jsx?)$/,``);r.has(s)||r.set(s,{filePath:s,bundleKey:c})}}function p(e,n,o){let s;if(e.startsWith(`@shared/`))s=i(o,`app/shared`,e.slice(8));else if(e.startsWith(`@modules/`))s=i(o,`app/modules`,e.slice(9));else if(e.startsWith(`@/`))s=i(o,`app`,e.slice(2));else if(e.startsWith(`.`))s=i(a(n),e);else return null;if(t(s)&&r(s).isFile())return s;for(let e of[`.tsx`,`.ts`,`.jsx`,`.js`,`.vue`,`.svelte`])if(t(s+e))return s+e;return null}
@@ -1 +1 @@
1
- export function generatePerIslandScript(e){let{islandId:r,componentSrc:i,framework:a,condition:o,conditionArg:s,propsJson:c,isCustomDirective:l,directiveScript:u}=e;return`<script type="module">${n(r,o,t(r,i,a,c),s,l,u)}<\/script>`}function t(e,t,n,r){return[`async function h(){`,`var e=document.getElementById(${JSON.stringify(e)});`,`if(!e||e.dataset.hydrated)return;`,`try{`,`var p=${r};`,`var m=await import(${JSON.stringify(t)});`,`var C=m.default||Object.values(m).find(function(v){return typeof v==="function"&&v.prototype})||m;`,`var i=await m.loadIntegrationModule(${JSON.stringify(n)});`,`if(i.hydrate)await i.hydrate(e,C,p);`,`e.dataset.hydrated="true";`,`}catch(err){console.error("Hydration error:",err)}`,`}`].join(``)}function n(e,t,n,r,i,a){if(t===`on:client`)return`${n}(window.requestIdleCallback||requestAnimationFrame)(function(){h()});`;if(t===`on:visible`)return[n,`var e=document.getElementById(${JSON.stringify(e)});`,`if(e){try{var o=new IntersectionObserver(function(n){`,`if(n[0].isIntersecting){h();o.disconnect()}`,`},{rootMargin:"50px",threshold:0});o.observe(e)}catch(_){h()}}`].join(``);if(t===`on:idle`)return[n,`if("requestIdleCallback" in globalThis){`,`globalThis.requestIdleCallback(function(){h()},{timeout:5000})`,`}else if(document.readyState==="complete"){`,`setTimeout(function(){h()},200)`,`}else{globalThis.addEventListener("load",function(){setTimeout(function(){h()},200)},{once:true})}`].join(``);if(t===`on:interaction`)return[n,`var e=document.getElementById(${JSON.stringify(e)});`,`if(e){var d=false;var ev=["click","touchstart","mouseenter","focusin"];`,`var fn=function(){if(d)return;d=true;ev.forEach(function(n){e.removeEventListener(n,fn)});h()};`,`ev.forEach(function(n){e.addEventListener(n,fn,{once:true,passive:true})})}`].join(``);if(t.startsWith(`media:`)){let e=t.slice(6);return[n,`try{var mq=globalThis.matchMedia(${JSON.stringify(e)});`,`if(mq.matches){h()}else{mq.addEventListener("change",function x(ev){`,`if(ev.matches){h();mq.removeEventListener("change",x)}},{once:true})}}catch(_){h()}`].join(``)}return i&&a?[n,`var e=document.getElementById(${JSON.stringify(e)});`,`if(e){var dir=(${a});`,`dir(e,function(){h()}${r?`,${JSON.stringify(r)}`:``})}`].join(``):`${n}h();`}
1
+ export function generatePerIslandScript(e){let{islandId:r,componentSrc:i,framework:a,condition:o,conditionArg:s,propsJson:c,isCustomDirective:l,directiveScript:u}=e;return`<script type="module">${n(r,o,t(r,i,a,c),s,l,u)}<\/script>`}function t(e,t,n,r){return[`async function h(){`,`var e=document.getElementById(${JSON.stringify(e)});`,`if(!e||e.dataset.hydrated)return;`,`try{`,`var p=${r};`,`var m=await import(${JSON.stringify(t)});`,`var C=m.default||Object.values(m).find(function(v){return typeof v==="function"&&v.prototype})||m;`,`if(m.__hydrateIsland){await m.__hydrateIsland(e,C,p)}`,`else if(m.loadIntegrationModule){var i=await m.loadIntegrationModule(${JSON.stringify(n)});if(i.hydrate)await i.hydrate(e,C,p)}`,`e.dataset.hydrated="true";`,`}catch(err){console.error("Hydration error:",err)}`,`}`].join(``)}function n(e,t,n,r,i,a){if(t===`on:client`)return`${n}(window.requestIdleCallback||requestAnimationFrame)(function(){h()});`;if(t===`on:visible`)return[n,`var e=document.getElementById(${JSON.stringify(e)});`,`if(e){try{var o=new IntersectionObserver(function(n){`,`if(n[0].isIntersecting){h();o.disconnect()}`,`},{rootMargin:"50px",threshold:0});o.observe(e)}catch(_){h()}}`].join(``);if(t===`on:idle`)return[n,`if("requestIdleCallback" in globalThis){`,`globalThis.requestIdleCallback(function(){h()},{timeout:5000})`,`}else if(document.readyState==="complete"){`,`setTimeout(function(){h()},200)`,`}else{globalThis.addEventListener("load",function(){setTimeout(function(){h()},200)},{once:true})}`].join(``);if(t===`on:interaction`)return[n,`var e=document.getElementById(${JSON.stringify(e)});`,`if(e){var d=false;var ev=["click","touchstart","mouseenter","focusin"];`,`var fn=function(){if(d)return;d=true;ev.forEach(function(n){e.removeEventListener(n,fn)});h()};`,`ev.forEach(function(n){e.addEventListener(n,fn,{once:true,passive:true})})}`].join(``);if(t.startsWith(`media:`)){let e=t.slice(6);return[n,`try{var mq=globalThis.matchMedia(${JSON.stringify(e)});`,`if(mq.matches){h()}else{mq.addEventListener("change",function x(ev){`,`if(ev.matches){h();mq.removeEventListener("change",x)}},{once:true})}}catch(_){h()}`].join(``)}return i&&a?[n,`var e=document.getElementById(${JSON.stringify(e)});`,`if(e){var dir=(${a});`,`dir(e,function(){h()}${r?`,${JSON.stringify(r)}`:``})}`].join(``):`${n}h();`}
@@ -1,18 +1,21 @@
1
1
  /**
2
2
  * Post-build Island Inlining
3
3
  *
4
- * Re-bundles each island chunk with esbuild to inline shared dependencies
4
+ * Re-bundles island chunks with esbuild to inline shared dependencies
5
5
  * (framework runtimes) into a single self-contained file per island.
6
- * This eliminates the separate shared chunks, matching Astro's approach.
7
6
  *
8
- * Runs AFTER the main Vite build, operating on the compiled JS output.
9
- * No framework plugins needed .vue/.svelte/.solid are already compiled to JS.
7
+ * Safe for all frameworks because each island wrapper exports __hydrateIsland
8
+ * directly from the framework adapterthe component and hydrate function
9
+ * share the same module graph, so no duplicate framework singletons are created.
10
+ *
11
+ * Runs AFTER the main Vite build, operating on compiled JS output.
10
12
  */
11
13
  interface InlineResult {
12
14
  island: string;
13
15
  beforeSize: number;
14
16
  afterSize: number;
15
17
  success: boolean;
18
+ skipped?: boolean;
16
19
  error?: string;
17
20
  }
18
21
  /**
@@ -1,2 +1,2 @@
1
- import{readdir as e,readFile as t}from"node:fs/promises";import{resolve as n,join as r}from"node:path";export async function inlineIslandChunks(e,r={}){let{verbose:i=!1,skipQwik:o=!0}=r,s=await a(n(e,`islands`));if(s.length===0)return i&&console.log(`🏝️ No island files found, skipping inlining`),[];let c=null,l;if(globalThis.Bun!==void 0)c=`bun`;else try{l=await import(`esbuild`),c=`esbuild`}catch{}if(!c)return console.warn(`🏝️ No bundler available (Bun or esbuild), skipping island inlining`),[];let u=[];for(let r of s){let a=r.replace(e+`/`,``);if(o&&a.includes(`.qwik.`)){u.push({island:a,beforeSize:0,afterSize:0,success:!0});continue}try{let e=await t(r,`utf-8`),o=Buffer.byteLength(e,`utf-8`);if(!e.includes(`from"../`)&&!e.includes(`from'../`)){u.push({island:a,beforeSize:o,afterSize:o,success:!0});continue}if(c===`bun`){let e={entrypoints:[r],outdir:n(r,`..`),naming:`[name].[ext]`,minify:!0,target:`browser`,format:`esm`,treeshaking:!0,external:[`*integration-loader*`]},t=await Bun.build(e);if(!t.success)throw Error(t.logs.map(e=>e.message).join(`
1
+ import{readdir as e,readFile as t}from"node:fs/promises";import{resolve as n,join as r}from"node:path";export async function inlineIslandChunks(e,r={}){let{verbose:i=!1,skipQwik:o=!0}=r,s=await a(n(e,`islands`));if(s.length===0)return i&&console.log(`🏝️ No island files found, skipping inlining`),[];let c=null,l;if(globalThis.Bun!==void 0)c=`bun`;else try{l=await import(`esbuild`),c=`esbuild`}catch{}if(!c)return console.warn(`🏝️ No bundler available (Bun or esbuild), skipping island inlining`),[];console.log(`🏝️ Inlining shared chunks into ${s.length} islands...`);let u=[];for(let r of s){let a=r.replace(`${e}/`,``);if(a.includes(`.qwik.`)){u.push({island:a,beforeSize:0,afterSize:0,success:!0,skipped:!0});continue}try{let e=await t(r,`utf-8`),o=Buffer.byteLength(e,`utf-8`);if(!e.includes(`from"../`)&&!e.includes(`from'../`)){u.push({island:a,beforeSize:o,afterSize:o,success:!0});continue}if(c===`bun`){let e={entrypoints:[r],outdir:n(r,`..`),naming:`[name].[ext]`,minify:!0,target:`browser`,format:`esm`,treeshaking:!0,external:[`*integration-loader*`]},t=await Bun.build(e);if(!t.success)throw Error(t.logs.map(e=>e.message).join(`
2
2
  `))}else await l.build({entryPoints:[r],outfile:r,bundle:!0,format:`esm`,minify:!0,treeShaking:!0,target:`es2020`,allowOverwrite:!0,plugins:[{name:`externalize-integration-loader`,setup(e){e.onResolve({filter:/integration-loader|rolldown-runtime/},e=>({path:e.path,external:!0}))}}]});let s=await t(r,`utf-8`),d=Buffer.byteLength(s,`utf-8`);if(u.push({island:a,beforeSize:o,afterSize:d,success:!0}),i){let e=(o/1024).toFixed(1),t=(d/1024).toFixed(1);console.log(` ✅ ${a}: ${e} KiB → ${t} KiB`)}}catch(e){let t=e instanceof Error?e.message:String(e);console.error(` ❌ ${a}: ${t}`),u.push({island:a,beforeSize:0,afterSize:0,success:!1,error:t})}}let d=u.filter(e=>e.success).length,f=u.filter(e=>!e.success).length;return console.log(`🏝️ Done: ${d} inlined${f?`, ${f} failed`:``}`),u}async function a(t,n=[]){try{let i=await e(t,{withFileTypes:!0});for(let e of i){let i=r(t,e.name);e.isDirectory()?await a(i,n):e.name.endsWith(`.js`)&&!e.name.endsWith(`.map`)&&n.push(i)}}catch{}return n}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Isolated Island Builder
3
+ *
4
+ * Builds each island as a separate Vite build with fresh framework plugins.
5
+ * This produces self-contained island files with the framework runtime inlined
6
+ * and tree-shaken — matching Astro's approach.
7
+ *
8
+ * Each build:
9
+ * 1. Loads framework plugins fresh (vite-plugin-solid, @vitejs/plugin-vue, etc.)
10
+ * 2. Compiles from source (.tsx/.vue/.svelte)
11
+ * 3. Outputs a single file with codeSplitting: false
12
+ * 4. Tree-shakes aggressively — only used runtime functions remain
13
+ *
14
+ * Runs as a post-build step after the main Vite build.
15
+ */
16
+ interface IslandBuildResult {
17
+ island: string;
18
+ success: boolean;
19
+ size?: number;
20
+ error?: string;
21
+ }
22
+ interface IslandSource {
23
+ filePath: string;
24
+ bundleKey: string;
25
+ framework: string;
26
+ }
27
+ /**
28
+ * Build all islands in isolation.
29
+ *
30
+ * @param cwd - Project root directory
31
+ * @param distDir - Build output directory (e.g., "dist")
32
+ * @param islands - Map of discovered islands (filePath → bundleKey)
33
+ * @param resolveAliases - Resolve aliases from the main Vite config
34
+ * @param defineValues - Define replacements from the main Vite config
35
+ */
36
+ export declare function buildIsolatedIslands(cwd: string, distDir: string, islands: Map<string, IslandSource>, resolveAliases: any[], defineValues: Record<string, unknown>): Promise<IslandBuildResult[]>;
37
+ export {};
@@ -0,0 +1,4 @@
1
+ import{existsSync as e,statSync as t}from"node:fs";import{resolve as n}from"node:path";function r(e,t){let n=JSON.stringify(e);if(t===`qwik`)return[`export * from ${n};`,`export { _hW } from "@builder.io/qwik";`].join(`
2
+ `);let r=[];t===`lit`&&r.push(`import "@useavalon/lit/client";`),r.push(`import __C from ${n};`,`var Component = __C;`,`export { Component as default, Component };`,`if(typeof globalThis<"u")globalThis.__avalonIsland=Component;`);let i={solid:`@useavalon/solid/client`,preact:`@useavalon/preact/client`,react:`@useavalon/react/client`,vue:`@useavalon/vue/client`,svelte:`@useavalon/svelte/client`,lit:`@useavalon/lit/client`};return i[t]&&r.push(`export { hydrate as __hydrateIsland } from ${JSON.stringify(i[t])};`),r.join(`
3
+ `)}async function i(e,t){let n=[],{resolve:r}=await import(`node:path`),i={solid:{pkg:`vite-plugin-solid`,integration:`packages/integrations/solid`,esmEntry:`dist/esm/index.mjs`},vue:{pkg:`@vitejs/plugin-vue`,integration:`packages/integrations/vue`,esmEntry:`dist/index.mjs`},svelte:{pkg:`@sveltejs/vite-plugin-svelte`,integration:`packages/integrations/svelte`,esmEntry:`src/index.js`}}[e];if(!i)return n;try{let a=r(r(t,`..`,i.integration),`node_modules`,i.pkg),o=i.esmEntry?r(a,i.esmEntry):a,{pathToFileURL:s}=await import(`node:url`),c=await import(s(o).href);switch(e){case`solid`:{let e=c.default??c;n.push(e({ssr:!1,hot:!1}));break}case`vue`:{let e=c.default??c;n.push(e());break}case`svelte`:{let e=c.svelte??c.default;n.push(e({compilerOptions:{hydratable:!0}}));break}}}catch(t){console.warn(` ⚠ Could not load ${e} plugin: ${t instanceof Error?t.message:t}`)}return n}function a(e){let t={solid:`@useavalon/solid/client`,preact:`@useavalon/preact/client`,react:`@useavalon/react/client`,vue:`@useavalon/vue/client`,svelte:`@useavalon/svelte/client`,lit:`@useavalon/lit/client`}[e];return t?[`import { hydrate } from ${JSON.stringify(t)};`,`export async function loadIntegrationModule() { return { hydrate }; }`].join(`
4
+ `):`export async function loadIntegrationModule() { return {}; }`}async function o(e){let{createRequire:t}=await import(`node:module`),n=t(`${e}/package.json`),r=e=>{try{return n.resolve(e).replace(/\.js$/,`.mjs`)}catch{return null}},i={preact:r(`preact`),"preact/hooks":r(`preact/hooks`),"preact/compat":r(`preact/compat`),"preact/compat/client":r(`preact/compat/client`),"preact/compat/server":r(`preact/compat/server`),"preact/jsx-runtime":r(`preact/jsx-runtime`),react:r(`preact/compat`),"react/jsx-runtime":r(`preact/jsx-runtime`),"react/jsx-dev-runtime":r(`preact/jsx-runtime`),"react-dom":r(`preact/compat`),"react-dom/client":r(`preact/compat/client`),"react-dom/server":r(`preact/compat/server`)};return{name:`avalon:isolated-preact-compat`,enforce:`pre`,resolveId(e){return i[e]||null}}}export async function buildIsolatedIslands(s,c,l,u,d){if(l.size===0)return[];let{build:f}=await import(`vite`);console.log(`🏝️ Building ${l.size} islands in isolation...`);let p=performance.now(),m=[];for(let[,p]of l){let{filePath:l,bundleKey:h,framework:g}=p,_=`islands/${h}.js`;if(g===`qwik`||g===`lit`){m.push({island:_,success:!0});continue}let v=r(l,g),y=`\0isolated-island-entry`,b=`\0virtual:avalon/integration-loader`;try{let r=await i(g,s);await f({configFile:!1,root:s,logLevel:`silent`,plugins:[{name:`avalon:isolated-island-virtual`,resolveId(e){return e===y?e:e===`virtual:avalon/integration-loader`||e===b?b:null},load(e){return e===y?v:e===b?a(g):null}},await o(s),...r],build:{write:!0,outDir:n(s,c),emptyOutDir:!1,minify:`esbuild`,target:`es2020`,rollupOptions:{input:y,output:{format:`es`,entryFileNames:_},preserveEntrySignatures:`exports-only`}},resolve:{alias:u},define:{...d,__DEV__:`false`,__PROD__:`true`,"process.env.NODE_ENV":`"production"`}});let l=n(s,c,_),p=e(l)?t(l).size:0;m.push({island:_,success:!0,size:p}),console.log(` ✅ ${h} (${g}): ${(p/1024).toFixed(1)} KiB`)}catch(e){let t=e instanceof Error?e.message:String(e);console.error(` ❌ ${h} (${g}): ${t}`),m.push({island:_,success:!1,error:t})}}let h=((performance.now()-p)/1e3).toFixed(1),g=m.filter(e=>e.success).length,_=m.filter(e=>!e.success).length;return console.log(`🏝️ Done in ${h}s: ${g} built${_?`, ${_} failed`:``}`),m}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useavalon/avalon",
3
- "version": "0.1.64",
3
+ "version": "0.1.65",
4
4
  "description": "Multi-framework islands architecture for the modern web",
5
5
  "license": "MIT",
6
6
  "type": "module",