@absolutejs/absolute 0.20.0-beta.178 → 0.20.0-beta.179

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.
@@ -4480,7 +4480,7 @@ import { basename as basename3, dirname as dirname4, extname as extname2, join a
4480
4480
  var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandGeneration, transpiler, ensureRelativeImportPath = (from, target) => {
4481
4481
  const importPath = relative3(dirname4(from), target).replace(/\\/g, "/");
4482
4482
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
4483
- }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
4483
+ }, escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), replaceQuotedSpecifier = (code, spec, target) => code.replace(new RegExp(`(['"])${escapeRegExp(spec)}\\1`, "g"), (_match, quote) => `${quote}${target}${quote}`), processDirectoryEntries = (entries, dir, targetFileName, stack) => {
4484
4484
  for (const entry of entries) {
4485
4485
  const entryPath = join7(dir, entry.name);
4486
4486
  if (entry.isDirectory())
@@ -4525,18 +4525,21 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
4525
4525
  return null;
4526
4526
  }
4527
4527
  const basePath = resolve4(dirname4(from), spec);
4528
+ const extensions = [
4529
+ ".ts",
4530
+ ".tsx",
4531
+ ".mts",
4532
+ ".cts",
4533
+ ".js",
4534
+ ".jsx",
4535
+ ".mjs",
4536
+ ".cjs",
4537
+ ".json"
4538
+ ];
4528
4539
  const candidates = [
4529
4540
  basePath,
4530
- `${basePath}.ts`,
4531
- `${basePath}.js`,
4532
- `${basePath}.mjs`,
4533
- `${basePath}.cjs`,
4534
- `${basePath}.json`,
4535
- join7(basePath, "index.ts"),
4536
- join7(basePath, "index.js"),
4537
- join7(basePath, "index.mjs"),
4538
- join7(basePath, "index.cjs"),
4539
- join7(basePath, "index.json")
4541
+ ...extensions.map((extension) => `${basePath}${extension}`),
4542
+ ...extensions.map((extension) => join7(basePath, `index${extension}`))
4540
4543
  ];
4541
4544
  const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
4542
4545
  const foundIndex = existResults.indexOf(true);
@@ -4621,7 +4624,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
4621
4624
  rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
4622
4625
  }
4623
4626
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
4624
- transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
4627
+ transpiled = replaceQuotedSpecifier(transpiled, spec, resolvedModuleImport);
4625
4628
  }
4626
4629
  let compiledCode = compile(transpiled, {
4627
4630
  css: "injected",
@@ -4633,10 +4636,10 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
4633
4636
  hmr: isDevelopmentRuntime()
4634
4637
  }).js.code;
4635
4638
  for (const [spec, compiledChildPath] of childModulePaths) {
4636
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
4639
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
4637
4640
  }
4638
4641
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
4639
- compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
4642
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, resolvedModuleImport);
4640
4643
  }
4641
4644
  const sourceId = JSON.stringify(relative3(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
4642
4645
  const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
@@ -4732,7 +4735,13 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
4732
4735
  ].join(`
4733
4736
  `) : nonVueLines.join(`
4734
4737
  `);
4735
- }, 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) => {
4738
+ }, RELATIVE_SPECIFIER_PATTERN, extractRelativeImports = (code) => Array.from(new Set(Array.from(code.matchAll(RELATIVE_SPECIFIER_PATTERN), (match) => match.groups?.spec).filter((spec) => spec !== undefined))), resolveFromSource = (spec, sourcePath) => {
4739
+ try {
4740
+ return Bun.resolveSync(spec, dirname5(sourcePath));
4741
+ } catch {
4742
+ return null;
4743
+ }
4744
+ }, compileVueServerModule = async (sourcePath) => {
4736
4745
  syncIslandGeneration2();
4737
4746
  const cachedModulePath = compiledModuleCache3.get(sourcePath);
4738
4747
  if (cachedModulePath)
@@ -4765,10 +4774,10 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
4765
4774
  ssr: true,
4766
4775
  ssrCssVars: descriptor.cssVars
4767
4776
  }).code : "const ssrRender = () => {};";
4768
- const childImportPaths = extractRelativeVueImports(compiledScript.content);
4769
- const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
4770
- compiledPath: await compileVueServerModule(resolve5(dirname5(sourcePath), relativeImport)),
4771
- spec: relativeImport
4777
+ const relativeImports = extractRelativeImports(compiledScript.content);
4778
+ const compiledChildren = await Promise.all(relativeImports.filter((spec) => spec.endsWith(".vue")).map(async (spec) => ({
4779
+ compiledPath: await compileVueServerModule(resolve5(dirname5(sourcePath), spec)),
4780
+ spec
4772
4781
  })));
4773
4782
  const strippedScript = stripExports(compiledScript.content);
4774
4783
  const transpiledScript = transpiler2.transformSync(strippedScript);
@@ -4780,10 +4789,22 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
4780
4789
  ].join(`
4781
4790
  `));
4782
4791
  const compiledModulePath = getCachedModulePath3(sourcePath);
4783
- let rewritten = assembled;
4792
+ const rewrittenSpecifiers = new Map;
4784
4793
  for (const child of compiledChildren) {
4785
- rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
4794
+ rewrittenSpecifiers.set(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
4786
4795
  }
4796
+ for (const spec of extractRelativeImports(assembled)) {
4797
+ if (rewrittenSpecifiers.has(spec))
4798
+ continue;
4799
+ const resolvedImport = resolveFromSource(spec, sourcePath);
4800
+ if (!resolvedImport)
4801
+ continue;
4802
+ rewrittenSpecifiers.set(spec, ensureRelativeImportPath2(compiledModulePath, resolvedImport));
4803
+ }
4804
+ const rewritten = assembled.replace(RELATIVE_SPECIFIER_PATTERN, (match, prefix, quote, spec) => {
4805
+ const target = rewrittenSpecifiers.get(spec);
4806
+ return target ? `${prefix}${quote}${target}${quote}` : match;
4807
+ });
4787
4808
  await mkdir3(dirname5(compiledModulePath), { recursive: true });
4788
4809
  await writeIfChanged2(compiledModulePath, rewritten);
4789
4810
  compiledModuleCache3.set(sourcePath, compiledModulePath);
@@ -4797,6 +4818,7 @@ var init_vueServerModule = __esm(() => {
4797
4818
  compiledModuleCache3.clear();
4798
4819
  });
4799
4820
  transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
4821
+ RELATIVE_SPECIFIER_PATTERN = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(?<spec>\.{1,2}\/[^'"]*)\2/g;
4800
4822
  });
4801
4823
 
4802
4824
  // src/core/renderIslandMarkup.ts
@@ -5854,5 +5876,5 @@ export {
5854
5876
  useIslandStore
5855
5877
  };
5856
5878
 
5857
- //# debugId=7998F139E6F8E34364756E2164756E21
5879
+ //# debugId=EB99DA4FD961DFEC64756E2164756E21
5858
5880
  //# sourceMappingURL=index.js.map