@absolutejs/absolute 0.19.0-beta.930 → 0.19.0-beta.931

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.
@@ -2698,100 +2698,6 @@ var init_svelteServerModule = __esm(() => {
2698
2698
  });
2699
2699
  });
2700
2700
 
2701
- // src/core/vueServerModule.ts
2702
- import { mkdir as mkdir2 } from "fs/promises";
2703
- import { dirname as dirname3, join as join5, relative as relative3, resolve as resolve5 } from "path";
2704
- var {Transpiler } = globalThis.Bun;
2705
- var ISLAND_COMPONENT_ID_LENGTH = 8, serverCacheRoot2, compiledModuleCache2, transpiler2, ensureRelativeImportPath2 = (from, target) => {
2706
- const importPath = relative3(dirname3(from), target).replace(/\\/g, "/");
2707
- return importPath.startsWith(".") ? importPath : `./${importPath}`;
2708
- }, getCachedModulePath2 = (sourcePath) => {
2709
- const relativeSourcePath = relative3(process.cwd(), sourcePath).replace(/\\/g, "/");
2710
- const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
2711
- return join5(serverCacheRoot2, `${normalizedSourcePath}.server.js`);
2712
- }, writeIfChanged2 = async (path, content) => {
2713
- const targetFile = Bun.file(path);
2714
- if (await targetFile.exists()) {
2715
- const currentContent = await targetFile.text();
2716
- if (currentContent === content)
2717
- return;
2718
- }
2719
- await Bun.write(path, content);
2720
- }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
2721
- const lines = code.split(`
2722
- `);
2723
- const specifierSet = new Set;
2724
- const vueImportRegex = /^import\s+{([^}]+)}\s+from\s+['"]vue['"];?$/;
2725
- lines.forEach((line) => {
2726
- const match = line.match(vueImportRegex);
2727
- if (match?.[1])
2728
- match[1].split(",").forEach((importSpecifier) => specifierSet.add(importSpecifier.trim()));
2729
- });
2730
- const nonVueLines = lines.filter((line) => !vueImportRegex.test(line));
2731
- return specifierSet.size ? [
2732
- `import { ${[...specifierSet].join(", ")} } from "vue";`,
2733
- ...nonVueLines
2734
- ].join(`
2735
- `) : nonVueLines.join(`
2736
- `);
2737
- }, extractRelativeVueImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => typeof importPath === "string" && importPath.startsWith(".") && importPath.endsWith(".vue")), compileVueServerModule = async (sourcePath) => {
2738
- const cachedModulePath = compiledModuleCache2.get(sourcePath);
2739
- if (cachedModulePath)
2740
- return cachedModulePath;
2741
- const compiler = await import("@vue/compiler-sfc");
2742
- const source = await Bun.file(sourcePath).text();
2743
- const { descriptor } = compiler.parse(source, { filename: sourcePath });
2744
- const componentId = Bun.hash(sourcePath).toString(BASE_36_RADIX).slice(0, ISLAND_COMPONENT_ID_LENGTH);
2745
- const hasScript = descriptor.script || descriptor.scriptSetup;
2746
- const compiledScript = hasScript ? compiler.compileScript(descriptor, {
2747
- id: componentId,
2748
- inlineTemplate: false
2749
- }) : { bindings: {}, content: "export default {};" };
2750
- const renderCode = descriptor.template ? compiler.compileTemplate({
2751
- compilerOptions: {
2752
- bindingMetadata: compiledScript.bindings,
2753
- expressionPlugins: ["typescript"],
2754
- prefixIdentifiers: true,
2755
- isCustomElement: (tag) => tag === "absolute-island"
2756
- },
2757
- filename: sourcePath,
2758
- id: componentId,
2759
- scoped: descriptor.styles.some((styleBlock) => styleBlock.scoped),
2760
- source: descriptor.template.content,
2761
- ssr: true,
2762
- ssrCssVars: descriptor.cssVars
2763
- }).code : "const ssrRender = () => {};";
2764
- const childImportPaths = extractRelativeVueImports(compiledScript.content);
2765
- const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
2766
- compiledPath: await compileVueServerModule(resolve5(dirname3(sourcePath), relativeImport)),
2767
- spec: relativeImport
2768
- })));
2769
- const strippedScript = stripExports(compiledScript.content);
2770
- const transpiledScript = transpiler2.transformSync(strippedScript);
2771
- const assembled = mergeVueImports([
2772
- transpiledScript,
2773
- renderCode,
2774
- "script.ssrRender = ssrRender;",
2775
- "export default script;"
2776
- ].join(`
2777
- `));
2778
- const compiledModulePath = getCachedModulePath2(sourcePath);
2779
- let rewritten = assembled;
2780
- for (const child of compiledChildren) {
2781
- rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
2782
- }
2783
- await mkdir2(dirname3(compiledModulePath), { recursive: true });
2784
- await writeIfChanged2(compiledModulePath, rewritten);
2785
- compiledModuleCache2.set(sourcePath, compiledModulePath);
2786
- return compiledModulePath;
2787
- };
2788
- var init_vueServerModule = __esm(() => {
2789
- init_constants();
2790
- serverCacheRoot2 = join5(process.cwd(), ".absolutejs", "islands", "vue");
2791
- compiledModuleCache2 = new Map;
2792
- transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
2793
- });
2794
-
2795
2701
  // src/core/renderIslandMarkup.ts
2796
2702
  var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildComponentCache, nextIslandId = () => {
2797
2703
  islandSequence += 1;
@@ -2814,17 +2720,9 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2814
2720
  const loadPromise = loadAndCompileServerBuildComponent(buildReferencePath);
2815
2721
  resolvedServerBuildComponentCache.set(buildReferencePath, loadPromise);
2816
2722
  return loadPromise;
2817
- }, resolveRuntimeImportTarget = async (resolvedModulePath) => {
2818
- if (resolvedModulePath.endsWith(".svelte")) {
2819
- return compileSvelteServerModule(resolvedModulePath);
2820
- }
2821
- if (resolvedModulePath.endsWith(".vue")) {
2822
- return compileVueServerModule(resolvedModulePath);
2823
- }
2824
- return resolvedModulePath;
2825
2723
  }, loadServerImportComponent = async (resolvedComponent, exportName) => {
2826
2724
  const resolvedModulePath = resolvedComponent.startsWith(".") ? new URL(resolvedComponent, import.meta.url).pathname : resolvedComponent;
2827
- const importTarget = await resolveRuntimeImportTarget(resolvedModulePath);
2725
+ const importTarget = resolvedModulePath.endsWith(".svelte") ? await compileSvelteServerModule(resolvedModulePath) : resolvedModulePath;
2828
2726
  const loadedModule = await import(importTarget);
2829
2727
  if (exportName && exportName !== "default" && exportName in loadedModule) {
2830
2728
  return loadedModule[exportName];
@@ -2928,7 +2826,6 @@ var islandSequence = 0, resolvedServerComponentCache, resolvedServerBuildCompone
2928
2826
  var init_renderIslandMarkup = __esm(() => {
2929
2827
  init_islandSsr();
2930
2828
  init_svelteServerModule();
2931
- init_vueServerModule();
2932
2829
  init_islandMarkupAttributes();
2933
2830
  init_islands();
2934
2831
  resolvedServerComponentCache = new Map;
@@ -3886,5 +3783,5 @@ export {
3886
3783
  Island
3887
3784
  };
3888
3785
 
3889
- //# debugId=FFD15DAC4462A68964756E2164756E21
3786
+ //# debugId=80AC5EFAD2AD7A5B64756E2164756E21
3890
3787
  //# sourceMappingURL=index.js.map