@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.
package/dist/vue/index.js CHANGED
@@ -4752,7 +4752,7 @@ import { basename as basename4, dirname as dirname6, extname as extname2, join a
4752
4752
  var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandGeneration, transpiler, ensureRelativeImportPath = (from, target) => {
4753
4753
  const importPath = relative3(dirname6(from), target).replace(/\\/g, "/");
4754
4754
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
4755
- }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
4755
+ }, 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) => {
4756
4756
  for (const entry of entries) {
4757
4757
  const entryPath = join8(dir, entry.name);
4758
4758
  if (entry.isDirectory())
@@ -4797,18 +4797,21 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
4797
4797
  return null;
4798
4798
  }
4799
4799
  const basePath = resolve6(dirname6(from), spec);
4800
+ const extensions = [
4801
+ ".ts",
4802
+ ".tsx",
4803
+ ".mts",
4804
+ ".cts",
4805
+ ".js",
4806
+ ".jsx",
4807
+ ".mjs",
4808
+ ".cjs",
4809
+ ".json"
4810
+ ];
4800
4811
  const candidates = [
4801
4812
  basePath,
4802
- `${basePath}.ts`,
4803
- `${basePath}.js`,
4804
- `${basePath}.mjs`,
4805
- `${basePath}.cjs`,
4806
- `${basePath}.json`,
4807
- join8(basePath, "index.ts"),
4808
- join8(basePath, "index.js"),
4809
- join8(basePath, "index.mjs"),
4810
- join8(basePath, "index.cjs"),
4811
- join8(basePath, "index.json")
4813
+ ...extensions.map((extension) => `${basePath}${extension}`),
4814
+ ...extensions.map((extension) => join8(basePath, `index${extension}`))
4812
4815
  ];
4813
4816
  const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
4814
4817
  const foundIndex = existResults.indexOf(true);
@@ -4893,7 +4896,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
4893
4896
  rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
4894
4897
  }
4895
4898
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
4896
- transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
4899
+ transpiled = replaceQuotedSpecifier(transpiled, spec, resolvedModuleImport);
4897
4900
  }
4898
4901
  let compiledCode = compile(transpiled, {
4899
4902
  css: "injected",
@@ -4905,10 +4908,10 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
4905
4908
  hmr: isDevelopmentRuntime()
4906
4909
  }).js.code;
4907
4910
  for (const [spec, compiledChildPath] of childModulePaths) {
4908
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
4911
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
4909
4912
  }
4910
4913
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
4911
- compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
4914
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, resolvedModuleImport);
4912
4915
  }
4913
4916
  const sourceId = JSON.stringify(relative3(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
4914
4917
  const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
@@ -5004,7 +5007,13 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
5004
5007
  ].join(`
5005
5008
  `) : nonVueLines.join(`
5006
5009
  `);
5007
- }, 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) => {
5010
+ }, 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) => {
5011
+ try {
5012
+ return Bun.resolveSync(spec, dirname7(sourcePath));
5013
+ } catch {
5014
+ return null;
5015
+ }
5016
+ }, compileVueServerModule = async (sourcePath) => {
5008
5017
  syncIslandGeneration2();
5009
5018
  const cachedModulePath = compiledModuleCache3.get(sourcePath);
5010
5019
  if (cachedModulePath)
@@ -5037,10 +5046,10 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
5037
5046
  ssr: true,
5038
5047
  ssrCssVars: descriptor.cssVars
5039
5048
  }).code : "const ssrRender = () => {};";
5040
- const childImportPaths = extractRelativeVueImports(compiledScript.content);
5041
- const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
5042
- compiledPath: await compileVueServerModule(resolve7(dirname7(sourcePath), relativeImport)),
5043
- spec: relativeImport
5049
+ const relativeImports = extractRelativeImports(compiledScript.content);
5050
+ const compiledChildren = await Promise.all(relativeImports.filter((spec) => spec.endsWith(".vue")).map(async (spec) => ({
5051
+ compiledPath: await compileVueServerModule(resolve7(dirname7(sourcePath), spec)),
5052
+ spec
5044
5053
  })));
5045
5054
  const strippedScript = stripExports(compiledScript.content);
5046
5055
  const transpiledScript = transpiler2.transformSync(strippedScript);
@@ -5052,10 +5061,22 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
5052
5061
  ].join(`
5053
5062
  `));
5054
5063
  const compiledModulePath = getCachedModulePath3(sourcePath);
5055
- let rewritten = assembled;
5064
+ const rewrittenSpecifiers = new Map;
5056
5065
  for (const child of compiledChildren) {
5057
- rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
5066
+ rewrittenSpecifiers.set(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
5058
5067
  }
5068
+ for (const spec of extractRelativeImports(assembled)) {
5069
+ if (rewrittenSpecifiers.has(spec))
5070
+ continue;
5071
+ const resolvedImport = resolveFromSource(spec, sourcePath);
5072
+ if (!resolvedImport)
5073
+ continue;
5074
+ rewrittenSpecifiers.set(spec, ensureRelativeImportPath2(compiledModulePath, resolvedImport));
5075
+ }
5076
+ const rewritten = assembled.replace(RELATIVE_SPECIFIER_PATTERN, (match, prefix, quote, spec) => {
5077
+ const target = rewrittenSpecifiers.get(spec);
5078
+ return target ? `${prefix}${quote}${target}${quote}` : match;
5079
+ });
5059
5080
  await mkdir3(dirname7(compiledModulePath), { recursive: true });
5060
5081
  await writeIfChanged2(compiledModulePath, rewritten);
5061
5082
  compiledModuleCache3.set(sourcePath, compiledModulePath);
@@ -5069,6 +5090,7 @@ var init_vueServerModule = __esm(() => {
5069
5090
  compiledModuleCache3.clear();
5070
5091
  });
5071
5092
  transpiler2 = new Transpiler({ loader: "ts", target: "browser" });
5093
+ RELATIVE_SPECIFIER_PATTERN = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(?<spec>\.{1,2}\/[^'"]*)\2/g;
5072
5094
  });
5073
5095
 
5074
5096
  // src/core/renderIslandMarkup.ts
@@ -7541,5 +7563,5 @@ export {
7541
7563
  useServerData
7542
7564
  };
7543
7565
 
7544
- //# debugId=3A0CD60AE9E8377764756E2164756E21
7566
+ //# debugId=9F5483EBA9A0E22964756E2164756E21
7545
7567
  //# sourceMappingURL=index.js.map