@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.
@@ -1551,7 +1551,7 @@ var transpiler2, toJs = (filePath, sourceDir) => {
1551
1551
  return `${filePath}/index.js`;
1552
1552
  }
1553
1553
  return `${filePath}.js`;
1554
- }, stripExports = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports = (code) => {
1554
+ }, mergeVueImports = (code) => {
1555
1555
  const lines = code.split(`
1556
1556
  `);
1557
1557
  const specifierSet = new Set;
@@ -1623,19 +1623,20 @@ const ${localName} = (source) => ${importedName}(
1623
1623
  return content;
1624
1624
  }
1625
1625
  },
1626
+ genDefaultAs: "script",
1626
1627
  id: componentId,
1627
1628
  inlineTemplate: false,
1628
1629
  sourceMap: true
1629
- }) : { bindings: {}, content: "export default {};", map: undefined };
1630
+ }) : { bindings: {}, content: "const script = {};", map: undefined };
1630
1631
  const typeDependencies = "deps" in compiledScript ? compiledScript.deps ?? [] : [];
1631
1632
  for (const dep of typeDependencies) {
1632
1633
  if (dep in typeDepHashes || !existsSync5(dep))
1633
1634
  continue;
1634
1635
  typeDepHashes[dep] = hashContent(readFileSync6(dep, "utf-8"));
1635
1636
  }
1636
- const strippedScript = stripExports(compiledScript.content);
1637
+ const scriptCode = compiledScript.content;
1637
1638
  const sourceDir = dirname6(sourceFilePath);
1638
- const transpiledScript = rewriteRelativeImports(transpiler2.transformSync(strippedScript), sourceDir);
1639
+ const transpiledScript = rewriteRelativeImports(transpiler2.transformSync(scriptCode), sourceDir);
1639
1640
  const generateRenderFunction = (ssr) => {
1640
1641
  const rendered = compiler.compileTemplate({
1641
1642
  compilerOptions: {
@@ -1701,7 +1702,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
1701
1702
  const inlineSourceMapFor = (finalContent) => {
1702
1703
  if (!compiledScript.map || !hasScript)
1703
1704
  return "";
1704
- const remap = buildLineRemap(strippedScript, finalContent);
1705
+ const remap = buildLineRemap(scriptCode, finalContent);
1705
1706
  const mappings = remapGeneratedLines(compiledScript.map.mappings, remap);
1706
1707
  const map = {
1707
1708
  ...compiledScript.map,
package/dist/build.js CHANGED
@@ -5106,7 +5106,7 @@ import { basename as basename3, dirname as dirname5, extname as extname6, join a
5106
5106
  var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandGeneration, transpiler, ensureRelativeImportPath = (from, target) => {
5107
5107
  const importPath = relative7(dirname5(from), target).replace(/\\/g, "/");
5108
5108
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
5109
- }, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
5109
+ }, 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) => {
5110
5110
  for (const entry of entries) {
5111
5111
  const entryPath = join10(dir, entry.name);
5112
5112
  if (entry.isDirectory())
@@ -5151,18 +5151,21 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
5151
5151
  return null;
5152
5152
  }
5153
5153
  const basePath = resolve10(dirname5(from), spec);
5154
+ const extensions = [
5155
+ ".ts",
5156
+ ".tsx",
5157
+ ".mts",
5158
+ ".cts",
5159
+ ".js",
5160
+ ".jsx",
5161
+ ".mjs",
5162
+ ".cjs",
5163
+ ".json"
5164
+ ];
5154
5165
  const candidates = [
5155
5166
  basePath,
5156
- `${basePath}.ts`,
5157
- `${basePath}.js`,
5158
- `${basePath}.mjs`,
5159
- `${basePath}.cjs`,
5160
- `${basePath}.json`,
5161
- join10(basePath, "index.ts"),
5162
- join10(basePath, "index.js"),
5163
- join10(basePath, "index.mjs"),
5164
- join10(basePath, "index.cjs"),
5165
- join10(basePath, "index.json")
5167
+ ...extensions.map((extension) => `${basePath}${extension}`),
5168
+ ...extensions.map((extension) => join10(basePath, `index${extension}`))
5166
5169
  ];
5167
5170
  const existResults = await Promise.all(candidates.map((candidate) => Bun.file(candidate).exists()));
5168
5171
  const foundIndex = existResults.indexOf(true);
@@ -5247,7 +5250,7 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
5247
5250
  rewrittenModulePaths.set(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), resolvedModuleImport));
5248
5251
  }
5249
5252
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
5250
- transpiled = transpiled.replaceAll(spec, resolvedModuleImport);
5253
+ transpiled = replaceQuotedSpecifier(transpiled, spec, resolvedModuleImport);
5251
5254
  }
5252
5255
  let compiledCode = compile(transpiled, {
5253
5256
  css: "injected",
@@ -5259,10 +5262,10 @@ var serverCacheRoot2, compiledModuleCache2, originalSourcePathCache, syncIslandG
5259
5262
  hmr: isDevelopmentRuntime()
5260
5263
  }).js.code;
5261
5264
  for (const [spec, compiledChildPath] of childModulePaths) {
5262
- compiledCode = compiledCode.replaceAll(spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
5265
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, ensureRelativeImportPath(getCachedModulePath2(sourcePath), compiledChildPath));
5263
5266
  }
5264
5267
  for (const [spec, resolvedModuleImport] of rewrittenModulePaths) {
5265
- compiledCode = compiledCode.replaceAll(spec, resolvedModuleImport);
5268
+ compiledCode = replaceQuotedSpecifier(compiledCode, spec, resolvedModuleImport);
5266
5269
  }
5267
5270
  const sourceId = JSON.stringify(relative7(process.cwd(), resolutionSourcePath).replace(/\\/g, "/"));
5268
5271
  const componentName = /export default function ([\w$]+)\s*\(/.exec(compiledCode)?.[1];
@@ -5358,7 +5361,13 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
5358
5361
  ].join(`
5359
5362
  `) : nonVueLines.join(`
5360
5363
  `);
5361
- }, 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) => {
5364
+ }, 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) => {
5365
+ try {
5366
+ return Bun.resolveSync(spec, dirname6(sourcePath));
5367
+ } catch {
5368
+ return null;
5369
+ }
5370
+ }, compileVueServerModule = async (sourcePath) => {
5362
5371
  syncIslandGeneration2();
5363
5372
  const cachedModulePath = compiledModuleCache3.get(sourcePath);
5364
5373
  if (cachedModulePath)
@@ -5391,10 +5400,10 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
5391
5400
  ssr: true,
5392
5401
  ssrCssVars: descriptor.cssVars
5393
5402
  }).code : "const ssrRender = () => {};";
5394
- const childImportPaths = extractRelativeVueImports(compiledScript.content);
5395
- const compiledChildren = await Promise.all(childImportPaths.map(async (relativeImport) => ({
5396
- compiledPath: await compileVueServerModule(resolve11(dirname6(sourcePath), relativeImport)),
5397
- spec: relativeImport
5403
+ const relativeImports = extractRelativeImports(compiledScript.content);
5404
+ const compiledChildren = await Promise.all(relativeImports.filter((spec) => spec.endsWith(".vue")).map(async (spec) => ({
5405
+ compiledPath: await compileVueServerModule(resolve11(dirname6(sourcePath), spec)),
5406
+ spec
5398
5407
  })));
5399
5408
  const strippedScript = stripExports(compiledScript.content);
5400
5409
  const transpiledScript = transpiler2.transformSync(strippedScript);
@@ -5406,10 +5415,22 @@ var serverCacheRoot3, compiledModuleCache3, syncIslandGeneration2, transpiler2,
5406
5415
  ].join(`
5407
5416
  `));
5408
5417
  const compiledModulePath = getCachedModulePath3(sourcePath);
5409
- let rewritten = assembled;
5418
+ const rewrittenSpecifiers = new Map;
5410
5419
  for (const child of compiledChildren) {
5411
- rewritten = rewritten.replaceAll(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
5420
+ rewrittenSpecifiers.set(child.spec, ensureRelativeImportPath2(compiledModulePath, child.compiledPath));
5421
+ }
5422
+ for (const spec of extractRelativeImports(assembled)) {
5423
+ if (rewrittenSpecifiers.has(spec))
5424
+ continue;
5425
+ const resolvedImport = resolveFromSource(spec, sourcePath);
5426
+ if (!resolvedImport)
5427
+ continue;
5428
+ rewrittenSpecifiers.set(spec, ensureRelativeImportPath2(compiledModulePath, resolvedImport));
5412
5429
  }
5430
+ const rewritten = assembled.replace(RELATIVE_SPECIFIER_PATTERN, (match, prefix, quote, spec) => {
5431
+ const target = rewrittenSpecifiers.get(spec);
5432
+ return target ? `${prefix}${quote}${target}${quote}` : match;
5433
+ });
5413
5434
  await mkdir3(dirname6(compiledModulePath), { recursive: true });
5414
5435
  await writeIfChanged2(compiledModulePath, rewritten);
5415
5436
  compiledModuleCache3.set(sourcePath, compiledModulePath);
@@ -5423,6 +5444,7 @@ var init_vueServerModule = __esm(() => {
5423
5444
  compiledModuleCache3.clear();
5424
5445
  });
5425
5446
  transpiler2 = new Transpiler2({ loader: "ts", target: "browser" });
5447
+ RELATIVE_SPECIFIER_PATTERN = /(\bfrom\s*|\bimport\s*\(\s*|\bimport\s+)(['"])(?<spec>\.{1,2}\/[^'"]*)\2/g;
5426
5448
  });
5427
5449
 
5428
5450
  // src/core/islandMarkupAttributes.ts
@@ -5935,7 +5957,7 @@ var init_scanConventions = __esm(() => {
5935
5957
  // src/core/serverOnlyStaticFiles.ts
5936
5958
  import { existsSync as existsSync9, readFileSync as readFileSync8 } from "fs";
5937
5959
  import { isAbsolute as isAbsolute2, join as join12, relative as relative9, sep as sep2 } from "path";
5938
- var STATIC_PLUGIN_DEFAULTS, SERVER_OUTPUTS_FILE = "server-outputs.json", RUNTIME_FILE_NAMES, SERVER_ONLY_PATTERNS, escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string"), readServerOutputs = (buildDir) => {
5960
+ var STATIC_PLUGIN_DEFAULTS, SERVER_OUTPUTS_FILE = "server-outputs.json", RUNTIME_FILE_NAMES, SERVER_ONLY_PATTERNS, escapeRegExp2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string"), readServerOutputs = (buildDir) => {
5939
5961
  const path = join12(buildDir, SERVER_OUTPUTS_FILE);
5940
5962
  if (!existsSync9(path))
5941
5963
  return [];
@@ -5949,7 +5971,7 @@ var STATIC_PLUGIN_DEFAULTS, SERVER_OUTPUTS_FILE = "server-outputs.json", RUNTIME
5949
5971
  const outputs = readServerOutputs(buildDir);
5950
5972
  if (outputs.length === 0)
5951
5973
  return null;
5952
- return new RegExp(`^/(?:${outputs.map(escapeRegExp).join("|")})(?:\\.br|\\.gz|\\.map)?$`);
5974
+ return new RegExp(`^/(?:${outputs.map(escapeRegExp2).join("|")})(?:\\.br|\\.gz|\\.map)?$`);
5953
5975
  }, productionStaticIgnorePatterns = (buildDir, serverBundle) => {
5954
5976
  const patterns = [
5955
5977
  ...STATIC_PLUGIN_DEFAULTS,
@@ -5962,7 +5984,7 @@ var STATIC_PLUGIN_DEFAULTS, SERVER_OUTPUTS_FILE = "server-outputs.json", RUNTIME
5962
5984
  const insideBuildDir = bundlePath !== "" && !bundlePath.startsWith("..") && !isAbsolute2(bundlePath);
5963
5985
  if (insideBuildDir) {
5964
5986
  const urlPath = bundlePath.split(sep2).join("/");
5965
- patterns.push(new RegExp(`^/${escapeRegExp(urlPath)}(?:\\.br|\\.gz|\\.map)?$`));
5987
+ patterns.push(new RegExp(`^/${escapeRegExp2(urlPath)}(?:\\.br|\\.gz|\\.map)?$`));
5966
5988
  }
5967
5989
  return patterns;
5968
5990
  };
@@ -6399,7 +6421,7 @@ var CLIENT_FRAMEWORK_PACKAGES, CLIENT_FRAMEWORKS, isPackageInstalled = (packageN
6399
6421
  vue: config.vueDirectory
6400
6422
  },
6401
6423
  projectRoot
6402
- }), escapeRegExp2 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), packagePattern = (pattern) => pattern.endsWith("/*") ? `${escapeRegExp2(pattern.slice(0, -1))}.+` : `${escapeRegExp2(pattern)}(?:/.*)?`, missingFrameworkSpecifierPattern = (frameworks) => {
6424
+ }), escapeRegExp3 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), packagePattern = (pattern) => pattern.endsWith("/*") ? `${escapeRegExp3(pattern.slice(0, -1))}.+` : `${escapeRegExp3(pattern)}(?:/.*)?`, missingFrameworkSpecifierPattern = (frameworks) => {
6403
6425
  const alternatives = frameworks.flatMap((framework) => CLIENT_FRAMEWORK_PACKAGES[framework].packages.map(packagePattern));
6404
6426
  return alternatives.length > 0 ? new RegExp(`^(?:${alternatives.join("|")})$`) : null;
6405
6427
  }, frameworkOf = (specifier) => CLIENT_FRAMEWORKS.find((framework) => {
@@ -14353,7 +14375,7 @@ var VALID_FRAMEWORKS, getObjectPropertyName2 = (name) => lazyTypescript.isIdenti
14353
14375
  output = output.slice(0, edit.start) + edit.text + output.slice(edit.end);
14354
14376
  }
14355
14377
  return output;
14356
- }, escapeRegExp3 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), loaderForPath = (filePath) => {
14378
+ }, escapeRegExp4 = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), loaderForPath = (filePath) => {
14357
14379
  if (filePath.endsWith(".tsx"))
14358
14380
  return "tsx";
14359
14381
  if (filePath.endsWith(".jsx"))
@@ -14364,7 +14386,7 @@ var VALID_FRAMEWORKS, getObjectPropertyName2 = (name) => lazyTypescript.isIdenti
14364
14386
  return "ts";
14365
14387
  }, createIslandRegistryDefinitionPlugin = (info) => {
14366
14388
  const registryBase = basename11(info.resolvedRegistryPath).replace(/\.[mc]?[jt]sx?$/, "");
14367
- const filter = new RegExp(`(^|[/\\\\])${escapeRegExp3(registryBase)}\\.[mc]?[jt]sx?$`);
14389
+ const filter = new RegExp(`(^|[/\\\\])${escapeRegExp4(registryBase)}\\.[mc]?[jt]sx?$`);
14368
14390
  return {
14369
14391
  name: "absolute-island-registry-definitions",
14370
14392
  setup(build) {
@@ -21246,7 +21268,7 @@ import { createHash as createHash5 } from "crypto";
21246
21268
  import { existsSync as existsSync33, readFileSync as readFileSync30 } from "fs";
21247
21269
  import { mkdir as mkdir8, rename, writeFile as writeFile9 } from "fs/promises";
21248
21270
  import { join as join45, resolve as resolve32 } from "path";
21249
- var CACHE_DIR_NAME = "compile-cache", ABSOLUTE_CACHE_DIR_NAME2 = ".absolutejs", CACHE_FORMAT_VERSION = 3, FILE_NAME_HASH_LENGTH = 32, vueCompileCacheEnabled = () => process.env.ABSOLUTE_COMPILE_CACHE !== "0", hashContent = (content) => createHash5("sha256").update(content).digest("hex"), hashParts = (parts) => {
21271
+ var CACHE_DIR_NAME = "compile-cache", ABSOLUTE_CACHE_DIR_NAME2 = ".absolutejs", CACHE_FORMAT_VERSION = 4, FILE_NAME_HASH_LENGTH = 32, vueCompileCacheEnabled = () => process.env.ABSOLUTE_COMPILE_CACHE !== "0", hashContent = (content) => createHash5("sha256").update(content).digest("hex"), hashParts = (parts) => {
21250
21272
  const hash = createHash5("sha256");
21251
21273
  for (const part of parts) {
21252
21274
  hash.update(part);
@@ -21512,7 +21534,7 @@ var transpiler5, toJs = (filePath, sourceDir) => {
21512
21534
  return `${filePath}/index.js`;
21513
21535
  }
21514
21536
  return `${filePath}.js`;
21515
- }, stripExports2 = (code) => code.replace(/export\s+default/, "const script ="), mergeVueImports2 = (code) => {
21537
+ }, mergeVueImports2 = (code) => {
21516
21538
  const lines = code.split(`
21517
21539
  `);
21518
21540
  const specifierSet = new Set;
@@ -21584,19 +21606,20 @@ const ${localName} = (source) => ${importedName}(
21584
21606
  return content;
21585
21607
  }
21586
21608
  },
21609
+ genDefaultAs: "script",
21587
21610
  id: componentId,
21588
21611
  inlineTemplate: false,
21589
21612
  sourceMap: true
21590
- }) : { bindings: {}, content: "export default {};", map: undefined };
21613
+ }) : { bindings: {}, content: "const script = {};", map: undefined };
21591
21614
  const typeDependencies = "deps" in compiledScript ? compiledScript.deps ?? [] : [];
21592
21615
  for (const dep of typeDependencies) {
21593
21616
  if (dep in typeDepHashes || !existsSync35(dep))
21594
21617
  continue;
21595
21618
  typeDepHashes[dep] = hashContent(readFileSync32(dep, "utf-8"));
21596
21619
  }
21597
- const strippedScript = stripExports2(compiledScript.content);
21620
+ const scriptCode = compiledScript.content;
21598
21621
  const sourceDir = dirname28(sourceFilePath);
21599
- const transpiledScript = rewriteRelativeImports(transpiler5.transformSync(strippedScript), sourceDir);
21622
+ const transpiledScript = rewriteRelativeImports(transpiler5.transformSync(scriptCode), sourceDir);
21600
21623
  const generateRenderFunction = (ssr) => {
21601
21624
  const rendered = compiler.compileTemplate({
21602
21625
  compilerOptions: {
@@ -21662,7 +21685,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
21662
21685
  const inlineSourceMapFor = (finalContent) => {
21663
21686
  if (!compiledScript.map || !hasScript)
21664
21687
  return "";
21665
- const remap = buildLineRemap(strippedScript, finalContent);
21688
+ const remap = buildLineRemap(scriptCode, finalContent);
21666
21689
  const mappings = remapGeneratedLines(compiledScript.map.mappings, remap);
21667
21690
  const map = {
21668
21691
  ...compiledScript.map,
@@ -36307,8 +36330,10 @@ ${code}`;
36307
36330
  }, compileVueTemplate = (descriptor, compiledScript, filePath, componentId) => {
36308
36331
  const compiler = getLoadedVueCompiler();
36309
36332
  const scriptContent = compiledScript.content;
36310
- if (!descriptor.template)
36311
- return scriptContent;
36333
+ if (!descriptor.template) {
36334
+ return `${scriptContent}
36335
+ export default __script__;`;
36336
+ }
36312
36337
  const isScoped = descriptor.styles.some((style) => style.scoped);
36313
36338
  const templateResult = compiler.compileTemplate({
36314
36339
  compilerOptions: {
@@ -36322,8 +36347,7 @@ ${code}`;
36322
36347
  scoped: isScoped,
36323
36348
  source: descriptor.template.content
36324
36349
  });
36325
- let code = scriptContent.replace("export default", "const __script__ =");
36326
- code += `
36350
+ let code = `${scriptContent}
36327
36351
  ${templateResult.code}`;
36328
36352
  code += `
36329
36353
  __script__.render = render;`;
@@ -36375,9 +36399,10 @@ ${code}`;
36375
36399
  realpath: realpathSync9,
36376
36400
  readFile: (file) => isFile(file) ? readFileSync53(file, "utf-8") : undefined
36377
36401
  },
36402
+ genDefaultAs: "__script__",
36378
36403
  id: componentId,
36379
36404
  inlineTemplate: false
36380
- }) : { bindings: {}, content: "export default {};" };
36405
+ }) : { bindings: {}, content: "const __script__ = {};" };
36381
36406
  const compiledSfcScript = {
36382
36407
  bindings: compiledScript.bindings ?? {},
36383
36408
  content: compiledScript.content
@@ -42212,5 +42237,5 @@ export {
42212
42237
  devBuild
42213
42238
  };
42214
42239
 
42215
- //# debugId=016613A38B1FF09364756E2164756E21
42240
+ //# debugId=6F7474A77E6F0F0D64756E2164756E21
42216
42241
  //# sourceMappingURL=build.js.map