@absolutejs/absolute 0.19.0-beta.693 → 0.19.0-beta.694
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/angular/index.js +247 -47
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +247 -47
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +386 -186
- package/dist/build.js.map +5 -5
- package/dist/index.js +433 -233
- package/dist/index.js.map +5 -5
- package/dist/islands/index.js +219 -19
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +219 -19
- package/dist/react/index.js.map +3 -3
- package/dist/svelte/index.js +229 -29
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +224 -24
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +17 -0
- package/dist/vue/index.js +219 -19
- package/dist/vue/index.js.map +3 -3
- package/package.json +12 -7
package/dist/build.js
CHANGED
|
@@ -2448,10 +2448,12 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
2448
2448
|
});
|
|
2449
2449
|
|
|
2450
2450
|
// src/build/stylePreprocessor.ts
|
|
2451
|
+
import { existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
|
|
2451
2452
|
import { readFile } from "fs/promises";
|
|
2452
2453
|
import { createRequire } from "module";
|
|
2453
|
-
import { dirname as dirname3, extname as extname3, join as join5, resolve as resolve6 } from "path";
|
|
2454
|
-
|
|
2454
|
+
import { dirname as dirname3, extname as extname3, isAbsolute, join as join5, relative as relative3, resolve as resolve6 } from "path";
|
|
2455
|
+
import { fileURLToPath } from "url";
|
|
2456
|
+
var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATTERN, importOptionalPeer, requireOptionalPeer, requireFromCwd, isPreprocessableStylePath = (filePath) => STYLE_EXTENSION_PATTERN.test(filePath), isStyleModulePath = (filePath) => STYLE_MODULE_EXTENSION_PATTERN.test(filePath), isStylePath = (filePath) => /\.(css|s[ac]ss|less|styl(?:us)?)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less|styl(?:us)?)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
|
|
2455
2457
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
2456
2458
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
2457
2459
|
return "scss";
|
|
@@ -2459,16 +2461,196 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
2459
2461
|
return "sass";
|
|
2460
2462
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
2461
2463
|
return "less";
|
|
2464
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
2465
|
+
return "stylus";
|
|
2462
2466
|
return null;
|
|
2463
2467
|
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
|
|
2464
2468
|
dirname3(filePath),
|
|
2465
2469
|
process.cwd(),
|
|
2466
2470
|
...paths.map((path) => resolve6(process.cwd(), path))
|
|
2467
|
-
],
|
|
2471
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
2472
|
+
pattern,
|
|
2473
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
2474
|
+
})), readTsconfigAliases = () => {
|
|
2475
|
+
const cwd = process.cwd();
|
|
2476
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
2477
|
+
return tsconfigAliasCache;
|
|
2478
|
+
const tsconfigPath = resolve6(cwd, "tsconfig.json");
|
|
2479
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
2480
|
+
if (!existsSync5(tsconfigPath)) {
|
|
2481
|
+
tsconfigAliasCache = empty;
|
|
2482
|
+
return empty;
|
|
2483
|
+
}
|
|
2484
|
+
try {
|
|
2485
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync3(tsconfigPath, "utf-8")));
|
|
2486
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
2487
|
+
const baseUrl = resolve6(cwd, compilerOptions.baseUrl ?? ".");
|
|
2488
|
+
tsconfigAliasCache = {
|
|
2489
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
2490
|
+
baseUrl,
|
|
2491
|
+
cwd
|
|
2492
|
+
};
|
|
2493
|
+
} catch {
|
|
2494
|
+
tsconfigAliasCache = empty;
|
|
2495
|
+
}
|
|
2496
|
+
return tsconfigAliasCache;
|
|
2497
|
+
}, getAliasEntries = (config) => {
|
|
2498
|
+
const tsconfig = readTsconfigAliases();
|
|
2499
|
+
return {
|
|
2500
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
2501
|
+
baseUrl: tsconfig.baseUrl
|
|
2502
|
+
};
|
|
2503
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
2504
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
2505
|
+
const targets = [];
|
|
2506
|
+
for (const alias of aliases) {
|
|
2507
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
2508
|
+
if (!match)
|
|
2509
|
+
continue;
|
|
2510
|
+
const wildcard = match[1] ?? "";
|
|
2511
|
+
for (const replacement of alias.replacements) {
|
|
2512
|
+
targets.push(resolve6(baseUrl, replacement.replace("*", wildcard)));
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
return targets;
|
|
2516
|
+
}, getLanguageExtensions = (language) => {
|
|
2517
|
+
if (language === "less")
|
|
2518
|
+
return [".less", ".css"];
|
|
2519
|
+
if (language === "stylus")
|
|
2520
|
+
return [".styl", ".stylus", ".css"];
|
|
2521
|
+
return [".scss", ".sass", ".css"];
|
|
2522
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
2523
|
+
const ext = extname3(basePath);
|
|
2524
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
2525
|
+
`${basePath}${extension}`,
|
|
2526
|
+
join5(basePath, `index${extension}`)
|
|
2527
|
+
]);
|
|
2528
|
+
if (language === "scss" || language === "sass") {
|
|
2529
|
+
return paths.flatMap((path) => {
|
|
2530
|
+
const dir = dirname3(path);
|
|
2531
|
+
const base = path.slice(dir.length + 1);
|
|
2532
|
+
return [path, join5(dir, `_${base}`)];
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
return paths;
|
|
2536
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
2537
|
+
const rawCandidates = [
|
|
2538
|
+
...resolveAliasTargets(specifier, config),
|
|
2539
|
+
isAbsolute(specifier) ? specifier : resolve6(fromDirectory, specifier),
|
|
2540
|
+
...loadPaths.map((path) => resolve6(path, specifier))
|
|
2541
|
+
];
|
|
2542
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
2543
|
+
if (existsSync5(candidate))
|
|
2544
|
+
return candidate;
|
|
2545
|
+
}
|
|
2546
|
+
return null;
|
|
2547
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
2548
|
+
const markerIndex = url.search(/[?#]/);
|
|
2549
|
+
if (markerIndex === -1)
|
|
2550
|
+
return { marker: "", path: url };
|
|
2551
|
+
return {
|
|
2552
|
+
marker: url.slice(markerIndex),
|
|
2553
|
+
path: url.slice(0, markerIndex)
|
|
2554
|
+
};
|
|
2555
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
2556
|
+
const sourceDir = dirname3(sourceFile);
|
|
2557
|
+
const entryDir = dirname3(entryFile);
|
|
2558
|
+
if (sourceDir === entryDir)
|
|
2559
|
+
return contents;
|
|
2560
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
2561
|
+
const trimmedUrl = rawUrl.trim();
|
|
2562
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
2563
|
+
return match;
|
|
2564
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
2565
|
+
const rebased = relative3(entryDir, resolve6(sourceDir, path)).replace(/\\/g, "/");
|
|
2566
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
2567
|
+
const nextQuote = quote || '"';
|
|
2568
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
2569
|
+
});
|
|
2570
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
2571
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
2572
|
+
return match;
|
|
2573
|
+
const resolved = resolveImportPath(specifier, dirname3(sourceFile), loadPaths, language, config);
|
|
2574
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
2575
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
2576
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
2577
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
2578
|
+
}, extractCssModuleExports = (css) => {
|
|
2579
|
+
const exports = {};
|
|
2580
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
2581
|
+
for (const declaration of body.split(";")) {
|
|
2582
|
+
const separator = declaration.indexOf(":");
|
|
2583
|
+
if (separator === -1)
|
|
2584
|
+
continue;
|
|
2585
|
+
const key = declaration.slice(0, separator).trim();
|
|
2586
|
+
const value = declaration.slice(separator + 1).trim();
|
|
2587
|
+
if (key && value)
|
|
2588
|
+
exports[key] = value;
|
|
2589
|
+
}
|
|
2590
|
+
return "";
|
|
2591
|
+
});
|
|
2592
|
+
return { css: nextCss, exports };
|
|
2593
|
+
}, getSassOptions = (config, language) => ({
|
|
2468
2594
|
...config?.sass ?? {},
|
|
2469
2595
|
...language === "scss" ? config?.scss ?? {} : {}
|
|
2470
|
-
}), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2471
|
-
${contents}` : contents,
|
|
2596
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
2597
|
+
${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
2598
|
+
canonicalize(specifier, options) {
|
|
2599
|
+
const fromDirectory = options.containingUrl ? dirname3(fileURLToPath(options.containingUrl)) : dirname3(entryFile);
|
|
2600
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
2601
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
2602
|
+
},
|
|
2603
|
+
load(canonicalUrl) {
|
|
2604
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
2605
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
2606
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
2607
|
+
return null;
|
|
2608
|
+
return {
|
|
2609
|
+
contents: preprocessLoadedStyle(readFileSync3(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
2610
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
2614
|
+
install(less, pluginManager) {
|
|
2615
|
+
const baseManager = new less.FileManager;
|
|
2616
|
+
const manager = Object.create(baseManager);
|
|
2617
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve6(currentDirectory), loadPaths, "less", config));
|
|
2618
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
2619
|
+
const resolved = resolveImportPath(filename, resolve6(currentDirectory), loadPaths, "less", config);
|
|
2620
|
+
if (!resolved) {
|
|
2621
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
2622
|
+
}
|
|
2623
|
+
return {
|
|
2624
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
2625
|
+
filename: resolved
|
|
2626
|
+
};
|
|
2627
|
+
};
|
|
2628
|
+
pluginManager.addFileManager(manager);
|
|
2629
|
+
}
|
|
2630
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
2631
|
+
let stylus;
|
|
2632
|
+
try {
|
|
2633
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
2634
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
2635
|
+
} catch {
|
|
2636
|
+
throw missingDependencyError("stylus", filePath);
|
|
2637
|
+
}
|
|
2638
|
+
return new Promise((resolveCss, reject) => {
|
|
2639
|
+
const renderer = stylus(contents);
|
|
2640
|
+
renderer.set("filename", filePath);
|
|
2641
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
2642
|
+
renderer.set(key, value);
|
|
2643
|
+
}
|
|
2644
|
+
for (const path of loadPaths)
|
|
2645
|
+
renderer.include(path);
|
|
2646
|
+
renderer.render((error, css) => {
|
|
2647
|
+
if (error)
|
|
2648
|
+
reject(error);
|
|
2649
|
+
else
|
|
2650
|
+
resolveCss(css ?? "");
|
|
2651
|
+
});
|
|
2652
|
+
});
|
|
2653
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
2472
2654
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
2473
2655
|
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
2474
2656
|
if (language === "scss" || language === "sass") {
|
|
@@ -2481,8 +2663,12 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2481
2663
|
throw missingDependencyError(packageName, filePath);
|
|
2482
2664
|
}
|
|
2483
2665
|
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2666
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
2484
2667
|
const result = sass.compileString(contents, {
|
|
2485
|
-
|
|
2668
|
+
importers: [
|
|
2669
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
2670
|
+
],
|
|
2671
|
+
loadPaths,
|
|
2486
2672
|
style: "expanded",
|
|
2487
2673
|
syntax: language === "sass" ? "indented" : "scss",
|
|
2488
2674
|
url: new URL(`file://${filePath}`)
|
|
@@ -2502,13 +2688,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2502
2688
|
if (!render)
|
|
2503
2689
|
throw missingDependencyError("less", filePath);
|
|
2504
2690
|
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
2691
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2505
2692
|
const result = await render(contents, {
|
|
2506
2693
|
...options.options ?? {},
|
|
2507
2694
|
filename: filePath,
|
|
2508
|
-
paths:
|
|
2695
|
+
paths: loadPaths,
|
|
2696
|
+
plugins: [
|
|
2697
|
+
...options.options?.plugins ?? [],
|
|
2698
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
2699
|
+
]
|
|
2509
2700
|
});
|
|
2510
2701
|
return result.css;
|
|
2511
2702
|
}
|
|
2703
|
+
if (language === "stylus") {
|
|
2704
|
+
const options = getStylusOptions(config);
|
|
2705
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
2706
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
2707
|
+
return renderStylus(contents, filePath, loadPaths, options);
|
|
2708
|
+
}
|
|
2512
2709
|
return rawContents;
|
|
2513
2710
|
}, createStylePreprocessorPlugin = (config) => ({
|
|
2514
2711
|
name: "absolute-style-preprocessor",
|
|
@@ -2519,21 +2716,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2519
2716
|
path: path.slice("absolute-style-module:".length)
|
|
2520
2717
|
}));
|
|
2521
2718
|
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
2522
|
-
const
|
|
2523
|
-
if (!
|
|
2719
|
+
const source = cssModuleSources.get(path);
|
|
2720
|
+
if (!source) {
|
|
2524
2721
|
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
2525
2722
|
}
|
|
2526
2723
|
return {
|
|
2527
|
-
contents:
|
|
2724
|
+
contents: source.css,
|
|
2528
2725
|
loader: "css"
|
|
2529
2726
|
};
|
|
2530
2727
|
});
|
|
2531
2728
|
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
2532
2729
|
if (isStyleModulePath(path)) {
|
|
2533
2730
|
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
2534
|
-
|
|
2731
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
2732
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
2733
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
2734
|
+
const exportSource = Object.keys(exports).length > 0 ? `import styles from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)}; export default Object.assign({}, styles, ${JSON.stringify(exports)});` : `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`;
|
|
2535
2735
|
return {
|
|
2536
|
-
contents:
|
|
2736
|
+
contents: exportSource,
|
|
2537
2737
|
loader: "js"
|
|
2538
2738
|
};
|
|
2539
2739
|
}
|
|
@@ -2564,9 +2764,9 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
2564
2764
|
return compileStyleSource(filePath, undefined, undefined, config);
|
|
2565
2765
|
};
|
|
2566
2766
|
var init_stylePreprocessor = __esm(() => {
|
|
2567
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
2568
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
2569
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
2767
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2768
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2769
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
2570
2770
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
2571
2771
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
2572
2772
|
requireFromCwd = createRequire(join5(process.cwd(), "package.json"));
|
|
@@ -2575,9 +2775,9 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
2575
2775
|
|
|
2576
2776
|
// src/core/svelteServerModule.ts
|
|
2577
2777
|
import { mkdir, readdir as readdir2 } from "fs/promises";
|
|
2578
|
-
import { basename as basename2, dirname as dirname4, extname as extname4, join as join6, relative as
|
|
2778
|
+
import { basename as basename2, dirname as dirname4, extname as extname4, join as join6, relative as relative4, resolve as resolve7 } from "path";
|
|
2579
2779
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
2580
|
-
const importPath =
|
|
2780
|
+
const importPath = relative4(dirname4(from), target).replace(/\\/g, "/");
|
|
2581
2781
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
2582
2782
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
2583
2783
|
for (const entry of entries) {
|
|
@@ -2641,7 +2841,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
2641
2841
|
const foundIndex = existResults.indexOf(true);
|
|
2642
2842
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
2643
2843
|
}, getCachedModulePath = (sourcePath) => {
|
|
2644
|
-
const relativeSourcePath =
|
|
2844
|
+
const relativeSourcePath = relative4(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
2645
2845
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
2646
2846
|
return join6(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
2647
2847
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -2961,7 +3161,7 @@ var init_staticStreaming = __esm(() => {
|
|
|
2961
3161
|
});
|
|
2962
3162
|
|
|
2963
3163
|
// src/build/staticIslandPages.ts
|
|
2964
|
-
import { readFileSync as
|
|
3164
|
+
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
2965
3165
|
var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:[\\s\\S]*?)<\\/(?:absolute-island|island)>)", ATTRIBUTE_RE_SOURCE = `([A-Za-z_:][-A-Za-z0-9_:.]*)\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, islandFrameworks, islandHydrationModes, isRecord5 = (value) => typeof value === "object" && value !== null, isIslandFramework = (value) => islandFrameworks.some((framework) => framework === value), isIslandHydrationMode = (value) => islandHydrationModes.some((mode) => mode === value), parseHtmlAttributes = (attributeString) => {
|
|
2966
3166
|
const attributeRe = new RegExp(ATTRIBUTE_RE_SOURCE, "g");
|
|
2967
3167
|
const attributes = new Map;
|
|
@@ -3090,7 +3290,7 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
|
|
|
3090
3290
|
}
|
|
3091
3291
|
return result + originalHtml.slice(nextIndex);
|
|
3092
3292
|
}, transformStaticPage = async (pagePath, registry) => {
|
|
3093
|
-
const originalHtml =
|
|
3293
|
+
const originalHtml = readFileSync4(pagePath, "utf-8");
|
|
3094
3294
|
const transformedHtml = await transformStaticPageHtml(originalHtml, registry);
|
|
3095
3295
|
if (transformedHtml !== originalHtml) {
|
|
3096
3296
|
writeFileSync3(pagePath, transformedHtml);
|
|
@@ -3143,10 +3343,10 @@ var init_outputLogs = __esm(() => {
|
|
|
3143
3343
|
});
|
|
3144
3344
|
|
|
3145
3345
|
// src/build/scanEntryPoints.ts
|
|
3146
|
-
import { existsSync as
|
|
3346
|
+
import { existsSync as existsSync6 } from "fs";
|
|
3147
3347
|
var {Glob: Glob2 } = globalThis.Bun;
|
|
3148
3348
|
var scanEntryPoints = async (dir, pattern) => {
|
|
3149
|
-
if (!
|
|
3349
|
+
if (!existsSync6(dir))
|
|
3150
3350
|
return [];
|
|
3151
3351
|
const entryPaths = [];
|
|
3152
3352
|
const glob = new Glob2(pattern);
|
|
@@ -3160,7 +3360,7 @@ var init_scanEntryPoints = () => {};
|
|
|
3160
3360
|
// src/build/scanConventions.ts
|
|
3161
3361
|
import { basename as basename3 } from "path";
|
|
3162
3362
|
var {Glob: Glob3 } = globalThis.Bun;
|
|
3163
|
-
import { existsSync as
|
|
3363
|
+
import { existsSync as existsSync7 } from "fs";
|
|
3164
3364
|
var CONVENTION_RE, classifyFile = (file, pageFiles, defaults, pages) => {
|
|
3165
3365
|
const fileName = basename3(file);
|
|
3166
3366
|
const match = CONVENTION_RE.exec(fileName);
|
|
@@ -3185,7 +3385,7 @@ var CONVENTION_RE, classifyFile = (file, pageFiles, defaults, pages) => {
|
|
|
3185
3385
|
else if (kind === "loading")
|
|
3186
3386
|
pages[pageName].loading = file;
|
|
3187
3387
|
}, scanConventions = async (pagesDir, pattern) => {
|
|
3188
|
-
if (!
|
|
3388
|
+
if (!existsSync7(pagesDir)) {
|
|
3189
3389
|
const pageFiles2 = [];
|
|
3190
3390
|
return { conventions: undefined, pageFiles: pageFiles2 };
|
|
3191
3391
|
}
|
|
@@ -3208,13 +3408,13 @@ var init_scanConventions = __esm(() => {
|
|
|
3208
3408
|
});
|
|
3209
3409
|
|
|
3210
3410
|
// src/build/scanCssEntryPoints.ts
|
|
3211
|
-
import { existsSync as
|
|
3411
|
+
import { existsSync as existsSync8 } from "fs";
|
|
3212
3412
|
var {Glob: Glob4 } = globalThis.Bun;
|
|
3213
3413
|
var scanCssEntryPoints = async (dir, ignore) => {
|
|
3214
|
-
if (!
|
|
3414
|
+
if (!existsSync8(dir))
|
|
3215
3415
|
return [];
|
|
3216
3416
|
const entryPaths = [];
|
|
3217
|
-
const glob = new Glob4("**/*.{css,scss,sass,less}");
|
|
3417
|
+
const glob = new Glob4("**/*.{css,scss,sass,less,styl,stylus}");
|
|
3218
3418
|
for await (const file of glob.scan({ absolute: true, cwd: dir })) {
|
|
3219
3419
|
const normalized = normalizePath(file);
|
|
3220
3420
|
if (isStyleModulePath(normalized) || ignore?.some((pattern) => normalized.includes(pattern)))
|
|
@@ -3228,7 +3428,7 @@ var init_scanCssEntryPoints = __esm(() => {
|
|
|
3228
3428
|
});
|
|
3229
3429
|
|
|
3230
3430
|
// src/utils/imageProcessing.ts
|
|
3231
|
-
import { existsSync as
|
|
3431
|
+
import { existsSync as existsSync9, mkdirSync as mkdirSync3, readFileSync as readFileSync5, writeFileSync as writeFileSync4 } from "fs";
|
|
3232
3432
|
import { join as join7, resolve as resolve8 } from "path";
|
|
3233
3433
|
var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY = 75, OPTIMIZATION_ENDPOINT = "/_absolute/image", BLUR_DEVIATION = 20, sharpModule = undefined, sharpLoaded = false, sharpWarned = false, snapToSize = (target, sizes) => {
|
|
3234
3434
|
for (const size of sizes) {
|
|
@@ -3283,7 +3483,7 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY = 75, OPTIMIZATIO
|
|
|
3283
3483
|
return [...device, ...image].sort((left, right) => left - right);
|
|
3284
3484
|
}, getCacheDir = (buildDir) => {
|
|
3285
3485
|
const dir = join7(buildDir, ".cache", "images");
|
|
3286
|
-
if (!
|
|
3486
|
+
if (!existsSync9(dir))
|
|
3287
3487
|
mkdirSync3(dir, { recursive: true });
|
|
3288
3488
|
return dir;
|
|
3289
3489
|
}, getCacheKey = (url, width, quality, format) => {
|
|
@@ -3341,11 +3541,11 @@ var DEFAULT_DEVICE_SIZES, DEFAULT_IMAGE_SIZES, DEFAULT_QUALITY = 75, OPTIMIZATIO
|
|
|
3341
3541
|
}, readFromCache = (cacheDir, cacheKey) => {
|
|
3342
3542
|
const metaPath = join7(cacheDir, `${cacheKey}.meta`);
|
|
3343
3543
|
const dataPath = join7(cacheDir, `${cacheKey}.data`);
|
|
3344
|
-
if (!
|
|
3544
|
+
if (!existsSync9(metaPath) || !existsSync9(dataPath))
|
|
3345
3545
|
return null;
|
|
3346
3546
|
try {
|
|
3347
|
-
const meta = JSON.parse(
|
|
3348
|
-
const buffer =
|
|
3547
|
+
const meta = JSON.parse(readFileSync5(metaPath, "utf-8"));
|
|
3548
|
+
const buffer = readFileSync5(dataPath);
|
|
3349
3549
|
return { buffer, meta };
|
|
3350
3550
|
} catch {
|
|
3351
3551
|
return null;
|
|
@@ -3460,14 +3660,14 @@ var init_optimizeHtmlImages = __esm(() => {
|
|
|
3460
3660
|
});
|
|
3461
3661
|
|
|
3462
3662
|
// src/cli/scripts/telemetry.ts
|
|
3463
|
-
import { existsSync as
|
|
3663
|
+
import { existsSync as existsSync10, mkdirSync as mkdirSync4, readFileSync as readFileSync6, writeFileSync as writeFileSync5 } from "fs";
|
|
3464
3664
|
import { homedir } from "os";
|
|
3465
3665
|
import { join as join8 } from "path";
|
|
3466
3666
|
var configDir, configPath, getTelemetryConfig = () => {
|
|
3467
3667
|
try {
|
|
3468
|
-
if (!
|
|
3668
|
+
if (!existsSync10(configPath))
|
|
3469
3669
|
return null;
|
|
3470
|
-
const raw =
|
|
3670
|
+
const raw = readFileSync6(configPath, "utf-8");
|
|
3471
3671
|
const config = JSON.parse(raw);
|
|
3472
3672
|
return config;
|
|
3473
3673
|
} catch {
|
|
@@ -3480,14 +3680,14 @@ var init_telemetry = __esm(() => {
|
|
|
3480
3680
|
});
|
|
3481
3681
|
|
|
3482
3682
|
// src/cli/telemetryEvent.ts
|
|
3483
|
-
import { existsSync as
|
|
3683
|
+
import { existsSync as existsSync11, readFileSync as readFileSync7 } from "fs";
|
|
3484
3684
|
import { arch, platform } from "os";
|
|
3485
3685
|
import { dirname as dirname5, join as join9, parse } from "path";
|
|
3486
3686
|
var checkCandidate = (candidate) => {
|
|
3487
|
-
if (!
|
|
3687
|
+
if (!existsSync11(candidate)) {
|
|
3488
3688
|
return null;
|
|
3489
3689
|
}
|
|
3490
|
-
const pkg = JSON.parse(
|
|
3690
|
+
const pkg = JSON.parse(readFileSync7(candidate, "utf-8"));
|
|
3491
3691
|
if (pkg.name === "@absolutejs/absolute") {
|
|
3492
3692
|
const ver = pkg.version;
|
|
3493
3693
|
return ver;
|
|
@@ -3592,17 +3792,17 @@ var init_updateAssetPaths = __esm(() => {
|
|
|
3592
3792
|
});
|
|
3593
3793
|
|
|
3594
3794
|
// src/dev/buildHMRClient.ts
|
|
3595
|
-
import { existsSync as
|
|
3795
|
+
import { existsSync as existsSync12 } from "fs";
|
|
3596
3796
|
import { resolve as resolve9 } from "path";
|
|
3597
3797
|
var {build: bunBuild } = globalThis.Bun;
|
|
3598
3798
|
var resolveHmrClientPath = () => {
|
|
3599
3799
|
const projectRoot = process.cwd();
|
|
3600
3800
|
const fromSource = resolve9(import.meta.dir, "client/hmrClient.ts");
|
|
3601
|
-
if (
|
|
3801
|
+
if (existsSync12(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
3602
3802
|
return fromSource;
|
|
3603
3803
|
}
|
|
3604
3804
|
const fromNodeModules = resolve9(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client/hmrClient.ts");
|
|
3605
|
-
if (
|
|
3805
|
+
if (existsSync12(fromNodeModules))
|
|
3606
3806
|
return fromNodeModules;
|
|
3607
3807
|
return resolve9(import.meta.dir, "dev/client/hmrClient.ts");
|
|
3608
3808
|
}, hmrClientPath2, buildHMRClient = async () => {
|
|
@@ -3794,8 +3994,8 @@ var devVendorPaths = null, getDevVendorPaths = () => devVendorPaths, setDevVendo
|
|
|
3794
3994
|
};
|
|
3795
3995
|
|
|
3796
3996
|
// src/build/angularLinkerPlugin.ts
|
|
3797
|
-
import { existsSync as
|
|
3798
|
-
import { dirname as dirname6, join as join10, relative as
|
|
3997
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync5, readFileSync as readFileSync8, writeFileSync as writeFileSync6 } from "fs";
|
|
3998
|
+
import { dirname as dirname6, join as join10, relative as relative5, resolve as resolve11 } from "path";
|
|
3799
3999
|
import { createHash } from "crypto";
|
|
3800
4000
|
var CACHE_DIR, angularLinkerPlugin;
|
|
3801
4001
|
var init_angularLinkerPlugin = __esm(() => {
|
|
@@ -3819,9 +4019,9 @@ var init_angularLinkerPlugin = __esm(() => {
|
|
|
3819
4019
|
}
|
|
3820
4020
|
const hash = createHash("md5").update(source).digest("hex");
|
|
3821
4021
|
const cachePath = join10(CACHE_DIR, `${hash}.js`);
|
|
3822
|
-
if (
|
|
4022
|
+
if (existsSync13(cachePath)) {
|
|
3823
4023
|
return {
|
|
3824
|
-
contents:
|
|
4024
|
+
contents: readFileSync8(cachePath, "utf-8"),
|
|
3825
4025
|
loader: "js"
|
|
3826
4026
|
};
|
|
3827
4027
|
}
|
|
@@ -3836,9 +4036,9 @@ var init_angularLinkerPlugin = __esm(() => {
|
|
|
3836
4036
|
linkerPlugin = mod.createEs2015LinkerPlugin({
|
|
3837
4037
|
fileSystem: {
|
|
3838
4038
|
dirname: dirname6,
|
|
3839
|
-
exists:
|
|
3840
|
-
readFile:
|
|
3841
|
-
relative:
|
|
4039
|
+
exists: existsSync13,
|
|
4040
|
+
readFile: readFileSync8,
|
|
4041
|
+
relative: relative5,
|
|
3842
4042
|
resolve: resolve11
|
|
3843
4043
|
},
|
|
3844
4044
|
linkerJitMode: false,
|
|
@@ -3879,11 +4079,11 @@ var HASHED_FILE_PATTERN, cleanStaleOutputs = async (buildPath, currentOutputPath
|
|
|
3879
4079
|
const currentPaths = new Set(currentOutputPaths.map((path) => resolve12(path)));
|
|
3880
4080
|
const glob = new Glob5("**/*");
|
|
3881
4081
|
const removals = [];
|
|
3882
|
-
for (const
|
|
3883
|
-
const absolute = resolve12(buildPath,
|
|
4082
|
+
for (const relative6 of glob.scanSync({ cwd: buildPath })) {
|
|
4083
|
+
const absolute = resolve12(buildPath, relative6);
|
|
3884
4084
|
if (currentPaths.has(absolute))
|
|
3885
4085
|
continue;
|
|
3886
|
-
if (!HASHED_FILE_PATTERN.test(
|
|
4086
|
+
if (!HASHED_FILE_PATTERN.test(relative6))
|
|
3887
4087
|
continue;
|
|
3888
4088
|
removals.push(rm2(absolute, { force: true }));
|
|
3889
4089
|
}
|
|
@@ -3941,11 +4141,11 @@ var commonAncestor = (paths, fallback) => {
|
|
|
3941
4141
|
var init_commonAncestor = () => {};
|
|
3942
4142
|
|
|
3943
4143
|
// src/utils/validateSafePath.ts
|
|
3944
|
-
import { resolve as resolve13, relative as
|
|
4144
|
+
import { resolve as resolve13, relative as relative6 } from "path";
|
|
3945
4145
|
var validateSafePath = (targetPath, baseDirectory) => {
|
|
3946
4146
|
const absoluteBase = resolve13(baseDirectory);
|
|
3947
4147
|
const absoluteTarget = resolve13(baseDirectory, targetPath);
|
|
3948
|
-
const relativePath = normalizePath(
|
|
4148
|
+
const relativePath = normalizePath(relative6(absoluteBase, absoluteTarget));
|
|
3949
4149
|
if (relativePath.startsWith("../") || relativePath === "..") {
|
|
3950
4150
|
throw new Error(`Unsafe path: ${targetPath}`);
|
|
3951
4151
|
}
|
|
@@ -4091,7 +4291,7 @@ __export(exports_compileSvelte, {
|
|
|
4091
4291
|
compileSvelte: () => compileSvelte,
|
|
4092
4292
|
clearSvelteCompilerCache: () => clearSvelteCompilerCache
|
|
4093
4293
|
});
|
|
4094
|
-
import { existsSync as
|
|
4294
|
+
import { existsSync as existsSync14 } from "fs";
|
|
4095
4295
|
import { mkdir as mkdir2, stat } from "fs/promises";
|
|
4096
4296
|
import {
|
|
4097
4297
|
dirname as dirname7,
|
|
@@ -4099,7 +4299,7 @@ import {
|
|
|
4099
4299
|
basename as basename4,
|
|
4100
4300
|
extname as extname5,
|
|
4101
4301
|
resolve as resolve14,
|
|
4102
|
-
relative as
|
|
4302
|
+
relative as relative7,
|
|
4103
4303
|
sep as sep2
|
|
4104
4304
|
} from "path";
|
|
4105
4305
|
import { env } from "process";
|
|
@@ -4107,11 +4307,11 @@ var {write, file, Transpiler } = globalThis.Bun;
|
|
|
4107
4307
|
var resolveDevClientDir2 = () => {
|
|
4108
4308
|
const projectRoot = process.cwd();
|
|
4109
4309
|
const fromSource = resolve14(import.meta.dir, "../dev/client");
|
|
4110
|
-
if (
|
|
4310
|
+
if (existsSync14(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
4111
4311
|
return fromSource;
|
|
4112
4312
|
}
|
|
4113
4313
|
const fromNodeModules = resolve14(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
4114
|
-
if (
|
|
4314
|
+
if (existsSync14(fromNodeModules))
|
|
4115
4315
|
return fromNodeModules;
|
|
4116
4316
|
return resolve14(import.meta.dir, "./dev/client");
|
|
4117
4317
|
}, devClientDir2, hmrClientPath3, persistentCache, sourceHashCache, clearSvelteCompilerCache = () => {
|
|
@@ -4191,8 +4391,8 @@ var resolveDevClientDir2 = () => {
|
|
|
4191
4391
|
return jsPath;
|
|
4192
4392
|
return null;
|
|
4193
4393
|
}, addModuleRewrite = (rewrites, rawSpec, resolvedModule, ssrOutputDir, clientOutputDir) => {
|
|
4194
|
-
const toServer =
|
|
4195
|
-
const toClient =
|
|
4394
|
+
const toServer = relative7(ssrOutputDir, resolvedModule).replace(/\\/g, "/");
|
|
4395
|
+
const toClient = relative7(clientOutputDir, resolvedModule).replace(/\\/g, "/");
|
|
4196
4396
|
rewrites.set(rawSpec, {
|
|
4197
4397
|
client: toClient.startsWith(".") || toClient.startsWith("/") ? toClient : `./${toClient}`,
|
|
4198
4398
|
server: toServer.startsWith(".") ? toServer : `./${toServer}`
|
|
@@ -4230,8 +4430,8 @@ var resolveDevClientDir2 = () => {
|
|
|
4230
4430
|
const preprocessedClient = isModule ? loweredClientSource.code : (await preprocess(loweredClientSource.code, svelteStylePreprocessor)).code;
|
|
4231
4431
|
const transpiledServer = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler2.transformSync(preprocessedServer) : preprocessedServer;
|
|
4232
4432
|
const transpiledClient = src.endsWith(".ts") || src.endsWith(".svelte.ts") ? transpiler2.transformSync(preprocessedClient) : preprocessedClient;
|
|
4233
|
-
const rawRel = dirname7(
|
|
4234
|
-
const relDir = rawRel.startsWith("..") ? `_ext/${
|
|
4433
|
+
const rawRel = dirname7(relative7(svelteRoot, src)).replace(/\\/g, "/");
|
|
4434
|
+
const relDir = rawRel.startsWith("..") ? `_ext/${relative7(process.cwd(), dirname7(src)).replace(/\\/g, "/")}` : rawRel;
|
|
4235
4435
|
const baseName = basename4(src).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
4236
4436
|
const importPaths = Array.from(transpiledServer.matchAll(/from\s+['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((path) => path !== undefined);
|
|
4237
4437
|
const resolvedModuleImports = await Promise.all(importPaths.map((importPath) => resolveRelativeModule2(importPath, src)));
|
|
@@ -4252,15 +4452,15 @@ var resolveDevClientDir2 = () => {
|
|
|
4252
4452
|
addModuleRewrite(externalRewrites, rawSpec, resolvedModule, ssrOutputDir, clientOutputDir);
|
|
4253
4453
|
if (!resolved)
|
|
4254
4454
|
continue;
|
|
4255
|
-
const childRel =
|
|
4455
|
+
const childRel = relative7(svelteRoot, resolved).replace(/\\/g, "/");
|
|
4256
4456
|
if (!childRel.startsWith(".."))
|
|
4257
4457
|
continue;
|
|
4258
4458
|
const childBuilt2 = cache.get(resolved);
|
|
4259
4459
|
if (!childBuilt2)
|
|
4260
4460
|
continue;
|
|
4261
4461
|
const origSpec = rawSpec.replace(/\.svelte(?:\.(?:ts|js))?$/, ".js");
|
|
4262
|
-
const toServer =
|
|
4263
|
-
const toClient =
|
|
4462
|
+
const toServer = relative7(ssrOutputDir, childBuilt2.ssr).replace(/\\/g, "/");
|
|
4463
|
+
const toClient = relative7(clientOutputDir, childBuilt2.client).replace(/\\/g, "/");
|
|
4264
4464
|
externalRewrites.set(origSpec, {
|
|
4265
4465
|
client: toClient.startsWith(".") ? toClient : `./${toClient}`,
|
|
4266
4466
|
server: toServer.startsWith(".") ? toServer : `./${toServer}`
|
|
@@ -4295,7 +4495,7 @@ var resolveDevClientDir2 = () => {
|
|
|
4295
4495
|
}).js.code;
|
|
4296
4496
|
let code = compiled.replace(/\.svelte(?:\.(?:ts|js))?(['"])/g, ".js$1");
|
|
4297
4497
|
if (mode === "client" && isDev) {
|
|
4298
|
-
const moduleKey = `/@src/${
|
|
4498
|
+
const moduleKey = `/@src/${relative7(process.cwd(), src).replace(/\\/g, "/")}`;
|
|
4299
4499
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
4300
4500
|
if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
4301
4501
|
var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleKey)}] = cb; };`);
|
|
@@ -4338,10 +4538,10 @@ var resolveDevClientDir2 = () => {
|
|
|
4338
4538
|
};
|
|
4339
4539
|
const roots = await Promise.all(entryPoints.map(build));
|
|
4340
4540
|
await Promise.all(roots.map(async ({ client, hasAwaitSlot }) => {
|
|
4341
|
-
const relClientDir = dirname7(
|
|
4541
|
+
const relClientDir = dirname7(relative7(clientDir, client));
|
|
4342
4542
|
const name = basename4(client, extname5(client));
|
|
4343
4543
|
const indexPath = join12(indexDir, relClientDir, `${name}.js`);
|
|
4344
|
-
const importRaw =
|
|
4544
|
+
const importRaw = relative7(dirname7(indexPath), client).split(sep2).join("/");
|
|
4345
4545
|
const importPath = importRaw.startsWith(".") || importRaw.startsWith("/") ? importRaw : `./${importRaw}`;
|
|
4346
4546
|
const hmrImports = isDev ? `window.__HMR_FRAMEWORK__ = "svelte";
|
|
4347
4547
|
import "${hmrClientPath3}";
|
|
@@ -4418,7 +4618,7 @@ if (typeof window !== "undefined") {
|
|
|
4418
4618
|
return {
|
|
4419
4619
|
svelteClientPaths: roots.map(({ client }) => client),
|
|
4420
4620
|
svelteIndexPaths: roots.map(({ client }) => {
|
|
4421
|
-
const rel = dirname7(
|
|
4621
|
+
const rel = dirname7(relative7(clientDir, client));
|
|
4422
4622
|
return join12(indexDir, rel, basename4(client));
|
|
4423
4623
|
}),
|
|
4424
4624
|
svelteServerPaths: roots.map(({ ssr }) => ssr)
|
|
@@ -4448,18 +4648,18 @@ __export(exports_compileVue, {
|
|
|
4448
4648
|
compileVue: () => compileVue,
|
|
4449
4649
|
clearVueHmrCaches: () => clearVueHmrCaches
|
|
4450
4650
|
});
|
|
4451
|
-
import { existsSync as
|
|
4651
|
+
import { existsSync as existsSync15 } from "fs";
|
|
4452
4652
|
import { mkdir as mkdir3 } from "fs/promises";
|
|
4453
|
-
import { basename as basename5, dirname as dirname8, join as join13, relative as
|
|
4653
|
+
import { basename as basename5, dirname as dirname8, join as join13, relative as relative8, resolve as resolve15 } from "path";
|
|
4454
4654
|
var {file: file2, write: write2, Transpiler: Transpiler2 } = globalThis.Bun;
|
|
4455
4655
|
var resolveDevClientDir3 = () => {
|
|
4456
4656
|
const projectRoot = process.cwd();
|
|
4457
4657
|
const fromSource = resolve15(import.meta.dir, "../dev/client");
|
|
4458
|
-
if (
|
|
4658
|
+
if (existsSync15(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
4459
4659
|
return fromSource;
|
|
4460
4660
|
}
|
|
4461
4661
|
const fromNodeModules = resolve15(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
4462
|
-
if (
|
|
4662
|
+
if (existsSync15(fromNodeModules))
|
|
4463
4663
|
return fromNodeModules;
|
|
4464
4664
|
return resolve15(import.meta.dir, "./dev/client");
|
|
4465
4665
|
}, devClientDir3, hmrClientPath4, transpiler3, scriptCache, scriptSetupCache, templateCache, styleCache, persistentBuildCache, vueSourceHashCache, vueHmrMetadata, clearVueHmrCaches = () => {
|
|
@@ -4500,7 +4700,7 @@ var resolveDevClientDir3 = () => {
|
|
|
4500
4700
|
return "template-only";
|
|
4501
4701
|
}
|
|
4502
4702
|
return "full";
|
|
4503
|
-
}, generateVueHmrId = (sourceFilePath, vueRootDir) =>
|
|
4703
|
+
}, generateVueHmrId = (sourceFilePath, vueRootDir) => relative8(vueRootDir, sourceFilePath).replace(/\\/g, "/").replace(/\.vue$/, ""), extractImports = (sourceCode) => Array.from(sourceCode.matchAll(/import\s+[\s\S]+?['"]([^'"]+)['"]/g)).map((match) => match[1]).filter((importPath) => importPath !== undefined), toJs = (filePath) => {
|
|
4504
4704
|
if (filePath.endsWith(".vue"))
|
|
4505
4705
|
return filePath.replace(/\.vue$/, ".js");
|
|
4506
4706
|
if (filePath.endsWith(".ts"))
|
|
@@ -4527,7 +4727,7 @@ var resolveDevClientDir3 = () => {
|
|
|
4527
4727
|
const cachedResult = cacheMap.get(sourceFilePath);
|
|
4528
4728
|
if (cachedResult)
|
|
4529
4729
|
return cachedResult;
|
|
4530
|
-
const relativeFilePath =
|
|
4730
|
+
const relativeFilePath = relative8(vueRootDir, sourceFilePath).replace(/\\/g, "/");
|
|
4531
4731
|
const relativeWithoutExtension = relativeFilePath.replace(/\.vue$/, "");
|
|
4532
4732
|
const fileBaseName = basename5(sourceFilePath, ".vue");
|
|
4533
4733
|
const componentId = toKebab(fileBaseName);
|
|
@@ -4651,7 +4851,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
4651
4851
|
let result2 = code;
|
|
4652
4852
|
for (const [bareImport, paths] of packageImportRewrites) {
|
|
4653
4853
|
const targetPath = mode === "server" ? paths.server : paths.client;
|
|
4654
|
-
let rel =
|
|
4854
|
+
let rel = relative8(dirname8(outputPath), targetPath).replace(/\\/g, "/");
|
|
4655
4855
|
if (!rel.startsWith("."))
|
|
4656
4856
|
rel = `./${rel}`;
|
|
4657
4857
|
result2 = result2.replaceAll(bareImport, rel);
|
|
@@ -4700,7 +4900,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
4700
4900
|
result.tsHelperPaths.forEach((path) => allTsHelperPaths.add(path));
|
|
4701
4901
|
const entryBaseName = basename5(entryPath, ".vue");
|
|
4702
4902
|
const indexOutputFile = join13(indexOutputDir, `${entryBaseName}.js`);
|
|
4703
|
-
const clientOutputFile = join13(clientOutputDir,
|
|
4903
|
+
const clientOutputFile = join13(clientOutputDir, relative8(vueRootDir, entryPath).replace(/\\/g, "/").replace(/\.vue$/, ".js"));
|
|
4704
4904
|
await mkdir3(dirname8(indexOutputFile), { recursive: true });
|
|
4705
4905
|
const vueHmrImports = isDev ? [
|
|
4706
4906
|
`window.__HMR_FRAMEWORK__ = "vue";`,
|
|
@@ -4708,7 +4908,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
4708
4908
|
] : [];
|
|
4709
4909
|
await write2(indexOutputFile, [
|
|
4710
4910
|
...vueHmrImports,
|
|
4711
|
-
`import Comp from "${
|
|
4911
|
+
`import Comp from "${relative8(dirname8(indexOutputFile), clientOutputFile).replace(/\\/g, "/")}";`,
|
|
4712
4912
|
'import { createSSRApp, createApp } from "vue";',
|
|
4713
4913
|
"",
|
|
4714
4914
|
"// HMR State Preservation: Check for preserved state from HMR",
|
|
@@ -4828,7 +5028,7 @@ if (typeof __VUE_HMR_RUNTIME__ !== 'undefined') {
|
|
|
4828
5028
|
await Promise.all(Array.from(allTsHelperPaths).map(async (tsPath) => {
|
|
4829
5029
|
const sourceCode = await file2(tsPath).text();
|
|
4830
5030
|
const transpiledCode = transpiler3.transformSync(sourceCode);
|
|
4831
|
-
const relativeJsPath =
|
|
5031
|
+
const relativeJsPath = relative8(vueRootDir, tsPath).replace(/\.ts$/, ".js");
|
|
4832
5032
|
const outClientPath = join13(clientOutputDir, relativeJsPath);
|
|
4833
5033
|
const outServerPath = join13(serverOutputDir, relativeJsPath);
|
|
4834
5034
|
await mkdir3(dirname8(outClientPath), { recursive: true });
|
|
@@ -5329,13 +5529,13 @@ __export(exports_compileAngular, {
|
|
|
5329
5529
|
compileAngularFile: () => compileAngularFile,
|
|
5330
5530
|
compileAngular: () => compileAngular
|
|
5331
5531
|
});
|
|
5332
|
-
import { existsSync as
|
|
5333
|
-
import { join as join14, basename as basename6, sep as sep3, dirname as dirname9, resolve as resolve16, relative as
|
|
5532
|
+
import { existsSync as existsSync16, readFileSync as readFileSync9, promises as fs } from "fs";
|
|
5533
|
+
import { join as join14, basename as basename6, sep as sep3, dirname as dirname9, resolve as resolve16, relative as relative9 } from "path";
|
|
5334
5534
|
import ts2 from "typescript";
|
|
5335
5535
|
import { createHash as createHash2 } from "crypto";
|
|
5336
5536
|
var computeConfigHash = () => {
|
|
5337
5537
|
try {
|
|
5338
|
-
const content =
|
|
5538
|
+
const content = readFileSync9("./tsconfig.json", "utf-8");
|
|
5339
5539
|
return createHash2("md5").update(content).digest("hex");
|
|
5340
5540
|
} catch {
|
|
5341
5541
|
return "";
|
|
@@ -5343,11 +5543,11 @@ var computeConfigHash = () => {
|
|
|
5343
5543
|
}, resolveDevClientDir4 = () => {
|
|
5344
5544
|
const projectRoot = process.cwd();
|
|
5345
5545
|
const fromSource = resolve16(import.meta.dir, "../dev/client");
|
|
5346
|
-
if (
|
|
5546
|
+
if (existsSync16(fromSource) && fromSource.startsWith(projectRoot)) {
|
|
5347
5547
|
return fromSource;
|
|
5348
5548
|
}
|
|
5349
5549
|
const fromNodeModules = resolve16(projectRoot, "node_modules/@absolutejs/absolute/dist/dev/client");
|
|
5350
|
-
if (
|
|
5550
|
+
if (existsSync16(fromNodeModules))
|
|
5351
5551
|
return fromNodeModules;
|
|
5352
5552
|
return resolve16(import.meta.dir, "./dev/client");
|
|
5353
5553
|
}, devClientDir4, hmrClientPath5, hmrRuntimePath, injectHMRRegistration = (content, sourceId) => {
|
|
@@ -5426,7 +5626,7 @@ ${registrations}
|
|
|
5426
5626
|
join14(basePath, "index.mts"),
|
|
5427
5627
|
join14(basePath, "index.cts")
|
|
5428
5628
|
];
|
|
5429
|
-
return candidates.map((candidate) => resolve16(candidate)).find((candidate) =>
|
|
5629
|
+
return candidates.map((candidate) => resolve16(candidate)).find((candidate) => existsSync16(candidate) && !candidate.endsWith(".d.ts")) ?? null;
|
|
5430
5630
|
}, readFileForAotTransform = async (fileName, readFile4) => {
|
|
5431
5631
|
const hostSource = readFile4?.(fileName);
|
|
5432
5632
|
if (typeof hostSource === "string")
|
|
@@ -5440,7 +5640,7 @@ ${registrations}
|
|
|
5440
5640
|
if (visited.has(resolvedPath))
|
|
5441
5641
|
return;
|
|
5442
5642
|
visited.add(resolvedPath);
|
|
5443
|
-
if (!
|
|
5643
|
+
if (!existsSync16(resolvedPath) || resolvedPath.endsWith(".d.ts"))
|
|
5444
5644
|
return;
|
|
5445
5645
|
const source = await readFileForAotTransform(resolvedPath, readFile4);
|
|
5446
5646
|
const transformed = await inlineResources(source, dirname9(resolvedPath), stylePreprocessors);
|
|
@@ -5455,7 +5655,7 @@ ${registrations}
|
|
|
5455
5655
|
await transformFile(inputPath);
|
|
5456
5656
|
return transformedSources;
|
|
5457
5657
|
}, compileAngularFile = async (inputPath, outDir, stylePreprocessors) => {
|
|
5458
|
-
const islandMetadataExports = buildIslandMetadataExports(
|
|
5658
|
+
const islandMetadataExports = buildIslandMetadataExports(readFileSync9(inputPath, "utf-8"));
|
|
5459
5659
|
const { readConfiguration, performCompilation, EmitFlags } = await import("@angular/compiler-cli");
|
|
5460
5660
|
const configHash = computeConfigHash();
|
|
5461
5661
|
const cached = globalThis.__angularCompilerCache;
|
|
@@ -5577,7 +5777,7 @@ ${registrations}
|
|
|
5577
5777
|
return entries.map(({ target }) => target);
|
|
5578
5778
|
}, jitContentCache, wrapperOutputCache, escapeTemplateContent = (content) => content.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), resolveAngularDeferImportSpecifier = () => {
|
|
5579
5779
|
const sourceEntry = resolve16(import.meta.dir, "../angular/components/index.ts");
|
|
5580
|
-
if (
|
|
5780
|
+
if (existsSync16(sourceEntry)) {
|
|
5581
5781
|
return sourceEntry.replace(/\\/g, "/");
|
|
5582
5782
|
}
|
|
5583
5783
|
return "@absolutejs/absolute/angular/components";
|
|
@@ -5705,7 +5905,7 @@ ${slot.resolvedBindings.map((binding) => ` "${binding.key}": this.__absoluteDef
|
|
|
5705
5905
|
${fields}
|
|
5706
5906
|
`);
|
|
5707
5907
|
}, readAndEscapeFile = async (filePath, stylePreprocessors) => {
|
|
5708
|
-
if (!
|
|
5908
|
+
if (!existsSync16(filePath))
|
|
5709
5909
|
return null;
|
|
5710
5910
|
const content = await compileStyleFileIfNeeded(filePath, stylePreprocessors);
|
|
5711
5911
|
return escapeTemplateContent(content);
|
|
@@ -5713,7 +5913,7 @@ ${fields}
|
|
|
5713
5913
|
const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
5714
5914
|
if (templateUrlMatch?.[1]) {
|
|
5715
5915
|
const templatePath = join14(fileDir, templateUrlMatch[1]);
|
|
5716
|
-
if (!
|
|
5916
|
+
if (!existsSync16(templatePath)) {
|
|
5717
5917
|
return { deferSlots: [], source };
|
|
5718
5918
|
}
|
|
5719
5919
|
const templateRaw2 = await fs.readFile(templatePath, "utf-8");
|
|
@@ -5744,10 +5944,10 @@ ${fields}
|
|
|
5744
5944
|
const templateUrlMatch = source.match(/templateUrl\s*:\s*['"]([^'"]+)['"]/);
|
|
5745
5945
|
if (templateUrlMatch?.[1]) {
|
|
5746
5946
|
const templatePath = join14(fileDir, templateUrlMatch[1]);
|
|
5747
|
-
if (!
|
|
5947
|
+
if (!existsSync16(templatePath)) {
|
|
5748
5948
|
return { deferSlots: [], source };
|
|
5749
5949
|
}
|
|
5750
|
-
const templateRaw2 =
|
|
5950
|
+
const templateRaw2 = readFileSync9(templatePath, "utf-8");
|
|
5751
5951
|
const lowered2 = lowerAngularDeferSyntax(templateRaw2);
|
|
5752
5952
|
const escaped2 = escapeTemplateContent(lowered2.template);
|
|
5753
5953
|
const replacedSource2 = source.replace(/templateUrl\s*:\s*['"][^'"]+['"]/, `template: \`${escaped2}\``);
|
|
@@ -5858,7 +6058,7 @@ ${fields}
|
|
|
5858
6058
|
let actualPath = resolved;
|
|
5859
6059
|
if (!actualPath.endsWith(".ts"))
|
|
5860
6060
|
actualPath += ".ts";
|
|
5861
|
-
if (!
|
|
6061
|
+
if (!existsSync16(actualPath))
|
|
5862
6062
|
return;
|
|
5863
6063
|
let sourceCode = await fs.readFile(actualPath, "utf-8");
|
|
5864
6064
|
const inlined = await inlineResources(sourceCode, dirname9(actualPath), stylePreprocessors);
|
|
@@ -5882,7 +6082,7 @@ ${fields}
|
|
|
5882
6082
|
}
|
|
5883
6083
|
const contentHash = Bun.hash(sourceCode).toString(BASE_36_RADIX);
|
|
5884
6084
|
const cacheKey2 = actualPath;
|
|
5885
|
-
if (jitContentCache.get(cacheKey2) === contentHash &&
|
|
6085
|
+
if (jitContentCache.get(cacheKey2) === contentHash && existsSync16(targetPath)) {
|
|
5886
6086
|
allOutputs.push(targetPath);
|
|
5887
6087
|
} else {
|
|
5888
6088
|
const processedContent = transpileAndRewrite(sourceCode, relativeDir, actualPath);
|
|
@@ -5910,7 +6110,7 @@ ${fields}
|
|
|
5910
6110
|
await fs.mkdir(indexesDir, { recursive: true });
|
|
5911
6111
|
const compileTasks = entryPoints.map(async (entry) => {
|
|
5912
6112
|
const resolvedEntry = resolve16(entry);
|
|
5913
|
-
const relativeEntry =
|
|
6113
|
+
const relativeEntry = relative9(outRoot, resolvedEntry).replace(/\.[tj]s$/, ".js");
|
|
5914
6114
|
const compileEntry = () => hmr ? compileAngularFileJIT(resolvedEntry, compiledRoot, outRoot, stylePreprocessors) : compileAngularFile(resolvedEntry, compiledRoot, stylePreprocessors);
|
|
5915
6115
|
let outputs = await compileEntry();
|
|
5916
6116
|
const fileBase = basename6(resolvedEntry).replace(/\.[tj]s$/, "");
|
|
@@ -5925,12 +6125,12 @@ ${fields}
|
|
|
5925
6125
|
...candidatePaths.map((file3) => resolve16(file3)),
|
|
5926
6126
|
...compiledFallbackPaths
|
|
5927
6127
|
];
|
|
5928
|
-
let candidate = normalizedCandidates.find((file3) =>
|
|
6128
|
+
let candidate = normalizedCandidates.find((file3) => existsSync16(file3) && file3.endsWith(`${sep3}pages${sep3}${jsName}`));
|
|
5929
6129
|
if (!candidate) {
|
|
5930
|
-
candidate = normalizedCandidates.find((file3) =>
|
|
6130
|
+
candidate = normalizedCandidates.find((file3) => existsSync16(file3) && file3.endsWith(`${sep3}${jsName}`));
|
|
5931
6131
|
}
|
|
5932
6132
|
if (!candidate) {
|
|
5933
|
-
candidate = normalizedCandidates.find((file3) =>
|
|
6133
|
+
candidate = normalizedCandidates.find((file3) => existsSync16(file3));
|
|
5934
6134
|
}
|
|
5935
6135
|
return candidate;
|
|
5936
6136
|
};
|
|
@@ -5938,11 +6138,11 @@ ${fields}
|
|
|
5938
6138
|
if (!rawServerFile) {
|
|
5939
6139
|
rawServerFile = resolveRawServerFile([]);
|
|
5940
6140
|
}
|
|
5941
|
-
if (rawServerFile && !
|
|
6141
|
+
if (rawServerFile && !existsSync16(rawServerFile)) {
|
|
5942
6142
|
outputs = await compileEntry();
|
|
5943
6143
|
rawServerFile = resolveRawServerFile(outputs);
|
|
5944
6144
|
}
|
|
5945
|
-
if (!rawServerFile || !
|
|
6145
|
+
if (!rawServerFile || !existsSync16(rawServerFile)) {
|
|
5946
6146
|
throw new Error(`Compiled output not found for ${entry}. Looking for: ${jsName}. Available: ${[
|
|
5947
6147
|
...outputs,
|
|
5948
6148
|
...compiledFallbackPaths
|
|
@@ -5953,7 +6153,7 @@ ${fields}
|
|
|
5953
6153
|
const serverContentHash = Bun.hash(original).toString(BASE_36_RADIX);
|
|
5954
6154
|
const cachedWrapper = wrapperOutputCache.get(resolvedEntry);
|
|
5955
6155
|
const clientFile = join14(indexesDir, jsName);
|
|
5956
|
-
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash &&
|
|
6156
|
+
if (hmr && cachedWrapper && cachedWrapper.serverHash === serverContentHash && existsSync16(clientFile)) {
|
|
5957
6157
|
return {
|
|
5958
6158
|
clientPath: clientFile,
|
|
5959
6159
|
indexUnchanged: true,
|
|
@@ -5987,7 +6187,7 @@ export default ${componentClassName};
|
|
|
5987
6187
|
await fs.writeFile(ssrDepsFile, ssrDepsContent, "utf-8");
|
|
5988
6188
|
}
|
|
5989
6189
|
await fs.writeFile(rawServerFile, rewritten, "utf-8");
|
|
5990
|
-
const relativePath =
|
|
6190
|
+
const relativePath = relative9(indexesDir, rawServerFile).replace(/\\/g, "/");
|
|
5991
6191
|
const normalizedImportPath = relativePath.startsWith(".") ? relativePath : `./${relativePath}`;
|
|
5992
6192
|
const hmrPreamble = hmr ? `window.__HMR_FRAMEWORK__ = "angular";
|
|
5993
6193
|
import "${hmrRuntimePath}";
|
|
@@ -6152,7 +6352,7 @@ __export(exports_buildReactVendor, {
|
|
|
6152
6352
|
computeVendorPaths: () => computeVendorPaths,
|
|
6153
6353
|
buildReactVendor: () => buildReactVendor
|
|
6154
6354
|
});
|
|
6155
|
-
import { existsSync as
|
|
6355
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync6 } from "fs";
|
|
6156
6356
|
import { join as join15, resolve as resolve17 } from "path";
|
|
6157
6357
|
import { rm as rm4 } from "fs/promises";
|
|
6158
6358
|
var {build: bunBuild2 } = globalThis.Bun;
|
|
@@ -6166,7 +6366,7 @@ var resolveJsxDevRuntimeCompatPath = () => {
|
|
|
6166
6366
|
resolve17(import.meta.dir, "..", "..", "src", "react", "jsxDevRuntimeCompat.ts")
|
|
6167
6367
|
];
|
|
6168
6368
|
for (const candidate of candidates) {
|
|
6169
|
-
if (
|
|
6369
|
+
if (existsSync17(candidate)) {
|
|
6170
6370
|
return candidate.replace(/\\/g, "/");
|
|
6171
6371
|
}
|
|
6172
6372
|
}
|
|
@@ -6342,11 +6542,11 @@ var vueSpecifiers, toSafeFileName3 = (specifier) => specifier.replace(/\//g, "_"
|
|
|
6342
6542
|
console.warn("\u26A0\uFE0F Vue vendor build had errors:", result.logs);
|
|
6343
6543
|
return;
|
|
6344
6544
|
}
|
|
6345
|
-
const { readFileSync:
|
|
6545
|
+
const { readFileSync: readFileSync10, writeFileSync: writeFileSync7, readdirSync } = await import("fs");
|
|
6346
6546
|
const files = readdirSync(vendorDir).filter((f) => f.endsWith(".js"));
|
|
6347
6547
|
for (const file3 of files) {
|
|
6348
6548
|
const filePath = join17(vendorDir, file3);
|
|
6349
|
-
const content =
|
|
6549
|
+
const content = readFileSync10(filePath, "utf-8");
|
|
6350
6550
|
if (!content.includes("__VUE_HMR_RUNTIME__"))
|
|
6351
6551
|
continue;
|
|
6352
6552
|
const patched = content.replace(/getGlobalThis\(\)\.__VUE_HMR_RUNTIME__\s*=\s*\{/, "getGlobalThis().__VUE_HMR_RUNTIME__ = getGlobalThis().__VUE_HMR_RUNTIME__ || {");
|
|
@@ -6469,14 +6669,14 @@ var init_rewriteImports = __esm(() => {
|
|
|
6469
6669
|
import {
|
|
6470
6670
|
copyFileSync,
|
|
6471
6671
|
cpSync,
|
|
6472
|
-
existsSync as
|
|
6672
|
+
existsSync as existsSync18,
|
|
6473
6673
|
mkdirSync as mkdirSync10,
|
|
6474
|
-
readFileSync as
|
|
6674
|
+
readFileSync as readFileSync10,
|
|
6475
6675
|
rmSync as rmSync2,
|
|
6476
6676
|
statSync,
|
|
6477
6677
|
writeFileSync as writeFileSync7
|
|
6478
6678
|
} from "fs";
|
|
6479
|
-
import { basename as basename7, dirname as dirname10, join as join19, relative as
|
|
6679
|
+
import { basename as basename7, dirname as dirname10, join as join19, relative as relative10, resolve as resolve18 } from "path";
|
|
6480
6680
|
import { cwd, env as env2, exit } from "process";
|
|
6481
6681
|
var {build: bunBuild6, Glob: Glob6 } = globalThis.Bun;
|
|
6482
6682
|
var isDev, collectConventionSourceFiles = (entry) => {
|
|
@@ -6592,7 +6792,7 @@ var isDev, collectConventionSourceFiles = (entry) => {
|
|
|
6592
6792
|
addWorkerPathIfExists(file3, relPath, workerPaths);
|
|
6593
6793
|
}
|
|
6594
6794
|
}, collectWorkerPathsFromFile = (file3, patterns, workerPaths) => {
|
|
6595
|
-
const content =
|
|
6795
|
+
const content = readFileSync10(file3, "utf-8");
|
|
6596
6796
|
for (const pattern of patterns) {
|
|
6597
6797
|
collectWorkerPathsFromContent(content, pattern, file3, workerPaths);
|
|
6598
6798
|
}
|
|
@@ -6637,13 +6837,13 @@ var isDev, collectConventionSourceFiles = (entry) => {
|
|
|
6637
6837
|
copyVueDevIndexes(vueDir, vuePagesPath, vueEntries, devIndexDir);
|
|
6638
6838
|
}
|
|
6639
6839
|
}, copyReactDevIndexes = (reactIndexesPath, reactPagesPath, devIndexDir, readDir) => {
|
|
6640
|
-
if (!
|
|
6840
|
+
if (!existsSync18(reactIndexesPath)) {
|
|
6641
6841
|
return;
|
|
6642
6842
|
}
|
|
6643
6843
|
const indexFiles = readDir(reactIndexesPath).filter((file3) => file3.endsWith(".tsx"));
|
|
6644
|
-
const pagesRel =
|
|
6844
|
+
const pagesRel = relative10(process.cwd(), resolve18(reactPagesPath)).replace(/\\/g, "/");
|
|
6645
6845
|
for (const file3 of indexFiles) {
|
|
6646
|
-
let content =
|
|
6846
|
+
let content = readFileSync10(join19(reactIndexesPath, file3), "utf-8");
|
|
6647
6847
|
content = content.replace(/from\s*['"]([^'"]*\/pages\/([^'"]+))['"]/g, (_match, _fullPath, componentName) => `from '/@src/${pagesRel}/${componentName}'`);
|
|
6648
6848
|
writeFileSync7(join19(devIndexDir, file3), content);
|
|
6649
6849
|
}
|
|
@@ -6653,10 +6853,10 @@ var isDev, collectConventionSourceFiles = (entry) => {
|
|
|
6653
6853
|
for (const entry of sveltePageEntries) {
|
|
6654
6854
|
const name = basename7(entry).replace(/\.svelte(\.(ts|js))?$/, "");
|
|
6655
6855
|
const indexFile = join19(svelteIndexDir, "pages", `${name}.js`);
|
|
6656
|
-
if (!
|
|
6856
|
+
if (!existsSync18(indexFile))
|
|
6657
6857
|
continue;
|
|
6658
|
-
let content =
|
|
6659
|
-
const srcRel =
|
|
6858
|
+
let content = readFileSync10(indexFile, "utf-8");
|
|
6859
|
+
const srcRel = relative10(process.cwd(), resolve18(entry)).replace(/\\/g, "/");
|
|
6660
6860
|
content = content.replace(/import\s+Component\s+from\s+['"]([^'"]+)['"]/, `import Component from "/@src/${srcRel}"`);
|
|
6661
6861
|
writeFileSync7(join19(devIndexDir, `${name}.svelte.js`), content);
|
|
6662
6862
|
}
|
|
@@ -6666,10 +6866,10 @@ var isDev, collectConventionSourceFiles = (entry) => {
|
|
|
6666
6866
|
for (const entry of vuePageEntries) {
|
|
6667
6867
|
const name = basename7(entry, ".vue");
|
|
6668
6868
|
const indexFile = join19(vueIndexDir, `${name}.js`);
|
|
6669
|
-
if (!
|
|
6869
|
+
if (!existsSync18(indexFile))
|
|
6670
6870
|
continue;
|
|
6671
|
-
let content =
|
|
6672
|
-
const srcRel =
|
|
6871
|
+
let content = readFileSync10(indexFile, "utf-8");
|
|
6872
|
+
const srcRel = relative10(process.cwd(), resolve18(entry)).replace(/\\/g, "/");
|
|
6673
6873
|
content = content.replace(/import\s+Comp\s+from\s+['"]([^'"]+)['"]/, `import Comp from "/@src/${srcRel}"`);
|
|
6674
6874
|
writeFileSync7(join19(devIndexDir, `${name}.vue.js`), content);
|
|
6675
6875
|
}
|
|
@@ -6719,7 +6919,7 @@ var isDev, collectConventionSourceFiles = (entry) => {
|
|
|
6719
6919
|
}
|
|
6720
6920
|
return result;
|
|
6721
6921
|
}, VUE_HMR_RUNTIME, injectVueComposableTracking = (outputPath, projectRoot) => {
|
|
6722
|
-
let content =
|
|
6922
|
+
let content = readFileSync10(outputPath, "utf-8");
|
|
6723
6923
|
const usePattern = /^var\s+(use[A-Z]\w*)\s*=/gm;
|
|
6724
6924
|
const useNames = [];
|
|
6725
6925
|
let match;
|
|
@@ -6744,7 +6944,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
6744
6944
|
}, buildDevUrlFileMap = (urlReferencedFiles, projectRoot) => {
|
|
6745
6945
|
const urlFileMap = new Map;
|
|
6746
6946
|
for (const srcPath of urlReferencedFiles) {
|
|
6747
|
-
const rel =
|
|
6947
|
+
const rel = relative10(projectRoot, srcPath).replace(/\\/g, "/");
|
|
6748
6948
|
const name = basename7(srcPath);
|
|
6749
6949
|
const mtime = Math.round(statSync(srcPath).mtimeMs);
|
|
6750
6950
|
const url = `/@src/${rel}?v=${mtime}`;
|
|
@@ -6759,7 +6959,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
6759
6959
|
const output = nonReactClientOutputs.find((artifact) => basename7(artifact.path).startsWith(`${srcBase}.`));
|
|
6760
6960
|
if (!output)
|
|
6761
6961
|
continue;
|
|
6762
|
-
urlFileMap.set(basename7(srcPath), `/${
|
|
6962
|
+
urlFileMap.set(basename7(srcPath), `/${relative10(buildPath, output.path).replace(/\\/g, "/")}`);
|
|
6763
6963
|
}
|
|
6764
6964
|
return urlFileMap;
|
|
6765
6965
|
}, buildUrlFileMap = (urlReferencedFiles, hmr, projectRoot, buildPath, nonReactClientOutputs) => {
|
|
@@ -6769,7 +6969,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
6769
6969
|
}, rewriteUrlReferences = (outputPaths, urlFileMap) => {
|
|
6770
6970
|
const urlPattern = /new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g;
|
|
6771
6971
|
for (const outputPath of outputPaths) {
|
|
6772
|
-
let content =
|
|
6972
|
+
let content = readFileSync10(outputPath, "utf-8");
|
|
6773
6973
|
let changed = false;
|
|
6774
6974
|
content = content.replace(urlPattern, (_match, relPath) => {
|
|
6775
6975
|
const targetName = basename7(relPath);
|
|
@@ -7426,7 +7626,7 @@ ${content.slice(firstUseIdx)}`;
|
|
|
7426
7626
|
const injectHMRIntoHTMLFile = (filePath, framework) => {
|
|
7427
7627
|
if (!hmrClientBundle)
|
|
7428
7628
|
return;
|
|
7429
|
-
let html =
|
|
7629
|
+
let html = readFileSync10(filePath, "utf-8");
|
|
7430
7630
|
if (html.includes("data-hmr-client"))
|
|
7431
7631
|
return;
|
|
7432
7632
|
const tag = `<script>window.__HMR_FRAMEWORK__="${framework}";</script><script data-hmr-client>${hmrClientBundle}</script>`;
|
|
@@ -7587,7 +7787,7 @@ var init_build = __esm(() => {
|
|
|
7587
7787
|
});
|
|
7588
7788
|
|
|
7589
7789
|
// src/dev/dependencyGraph.ts
|
|
7590
|
-
import { existsSync as
|
|
7790
|
+
import { existsSync as existsSync19, readFileSync as readFileSync11 } from "fs";
|
|
7591
7791
|
var {Glob: Glob7 } = globalThis.Bun;
|
|
7592
7792
|
import { resolve as resolve19 } from "path";
|
|
7593
7793
|
var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath) => {
|
|
@@ -7599,7 +7799,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7599
7799
|
if (lower.endsWith(".html") || lower.endsWith(".htm"))
|
|
7600
7800
|
return "html";
|
|
7601
7801
|
return null;
|
|
7602
|
-
},
|
|
7802
|
+
}, resolveImportPath2 = (importPath, fromFile) => {
|
|
7603
7803
|
if (!importPath.startsWith(".") && !importPath.startsWith("/")) {
|
|
7604
7804
|
return null;
|
|
7605
7805
|
}
|
|
@@ -7617,10 +7817,10 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7617
7817
|
];
|
|
7618
7818
|
for (const ext of extensions) {
|
|
7619
7819
|
const withExt = normalized + ext;
|
|
7620
|
-
if (
|
|
7820
|
+
if (existsSync19(withExt))
|
|
7621
7821
|
return withExt;
|
|
7622
7822
|
}
|
|
7623
|
-
if (
|
|
7823
|
+
if (existsSync19(normalized))
|
|
7624
7824
|
return normalized;
|
|
7625
7825
|
return null;
|
|
7626
7826
|
}, clearExistingDependents = (graph, normalizedPath) => {
|
|
@@ -7635,7 +7835,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7635
7835
|
}
|
|
7636
7836
|
}, addFileToGraph = (graph, filePath) => {
|
|
7637
7837
|
const normalizedPath = resolve19(filePath);
|
|
7638
|
-
if (!
|
|
7838
|
+
if (!existsSync19(normalizedPath))
|
|
7639
7839
|
return;
|
|
7640
7840
|
const dependencies = extractDependencies(normalizedPath);
|
|
7641
7841
|
clearExistingDependents(graph, normalizedPath);
|
|
@@ -7651,7 +7851,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7651
7851
|
}, IGNORED_SEGMENTS, buildInitialDependencyGraph = (graph, directories) => {
|
|
7652
7852
|
const processedFiles = new Set;
|
|
7653
7853
|
const glob = new Glob7("**/*.{ts,tsx,js,jsx,vue,svelte,html,htm}");
|
|
7654
|
-
const resolvedDirs = directories.map((dir) => resolve19(dir)).filter((dir) =>
|
|
7854
|
+
const resolvedDirs = directories.map((dir) => resolve19(dir)).filter((dir) => existsSync19(dir));
|
|
7655
7855
|
const allFiles = resolvedDirs.flatMap((dir) => Array.from(glob.scanSync({ absolute: true, cwd: dir })));
|
|
7656
7856
|
for (const file3 of allFiles) {
|
|
7657
7857
|
const fullPath = resolve19(file3);
|
|
@@ -7670,7 +7870,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7670
7870
|
const [, href] = matchLink;
|
|
7671
7871
|
if (!href)
|
|
7672
7872
|
continue;
|
|
7673
|
-
const resolvedHref =
|
|
7873
|
+
const resolvedHref = resolveImportPath2(href, filePath);
|
|
7674
7874
|
if (resolvedHref)
|
|
7675
7875
|
dependencies.push(resolvedHref);
|
|
7676
7876
|
}
|
|
@@ -7680,7 +7880,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7680
7880
|
while ((match = regex.exec(content)) !== null) {
|
|
7681
7881
|
if (!match[1])
|
|
7682
7882
|
continue;
|
|
7683
|
-
const resolved =
|
|
7883
|
+
const resolved = resolveImportPath2(match[1], filePath);
|
|
7684
7884
|
if (resolved)
|
|
7685
7885
|
dependencies.push(resolved);
|
|
7686
7886
|
}
|
|
@@ -7690,7 +7890,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7690
7890
|
while ((urlMatch = stringLiteralRegex.exec(matchContent)) !== null) {
|
|
7691
7891
|
if (!urlMatch[1])
|
|
7692
7892
|
continue;
|
|
7693
|
-
const resolved =
|
|
7893
|
+
const resolved = resolveImportPath2(urlMatch[1], filePath);
|
|
7694
7894
|
if (resolved)
|
|
7695
7895
|
dependencies.push(resolved);
|
|
7696
7896
|
}
|
|
@@ -7713,7 +7913,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7713
7913
|
const imports = transpiler4.scanImports(content);
|
|
7714
7914
|
const dependencies = [];
|
|
7715
7915
|
for (const imp of imports) {
|
|
7716
|
-
const resolved =
|
|
7916
|
+
const resolved = resolveImportPath2(imp.path, filePath);
|
|
7717
7917
|
if (resolved)
|
|
7718
7918
|
dependencies.push(resolved);
|
|
7719
7919
|
}
|
|
@@ -7723,7 +7923,7 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7723
7923
|
return dependencies;
|
|
7724
7924
|
}, resolveScannedImports = (imports, filePath, dependencies) => {
|
|
7725
7925
|
for (const imp of imports) {
|
|
7726
|
-
const resolved =
|
|
7926
|
+
const resolved = resolveImportPath2(imp.path, filePath);
|
|
7727
7927
|
if (resolved)
|
|
7728
7928
|
dependencies.push(resolved);
|
|
7729
7929
|
}
|
|
@@ -7748,15 +7948,15 @@ var emptyDependencyGraph, tsTranspiler, jsTranspiler, loaderForFile = (filePath)
|
|
|
7748
7948
|
const lowerPath = filePath.toLowerCase();
|
|
7749
7949
|
const isSvelteOrVue = lowerPath.endsWith(".svelte") || lowerPath.endsWith(".vue");
|
|
7750
7950
|
if (loader === "html") {
|
|
7751
|
-
const content =
|
|
7951
|
+
const content = readFileSync11(filePath, "utf-8");
|
|
7752
7952
|
return extractHtmlDependencies(filePath, content);
|
|
7753
7953
|
}
|
|
7754
7954
|
if (loader === "tsx" || loader === "js") {
|
|
7755
|
-
const content =
|
|
7955
|
+
const content = readFileSync11(filePath, "utf-8");
|
|
7756
7956
|
return extractJsDependencies(filePath, content, loader);
|
|
7757
7957
|
}
|
|
7758
7958
|
if (isSvelteOrVue) {
|
|
7759
|
-
const content =
|
|
7959
|
+
const content = readFileSync11(filePath, "utf-8");
|
|
7760
7960
|
return extractSvelteVueDependencies(filePath, content);
|
|
7761
7961
|
}
|
|
7762
7962
|
return [];
|
|
@@ -8039,12 +8239,12 @@ var STYLE_EXTENSION_PATTERN2, detectFramework = (filePath, resolved) => {
|
|
|
8039
8239
|
};
|
|
8040
8240
|
var init_pathUtils = __esm(() => {
|
|
8041
8241
|
init_commonAncestor();
|
|
8042
|
-
STYLE_EXTENSION_PATTERN2 = /\.(css|s[ac]ss|less)$/i;
|
|
8242
|
+
STYLE_EXTENSION_PATTERN2 = /\.(css|s[ac]ss|less|styl(?:us)?)$/i;
|
|
8043
8243
|
});
|
|
8044
8244
|
|
|
8045
8245
|
// src/dev/fileWatcher.ts
|
|
8046
8246
|
import { watch } from "fs";
|
|
8047
|
-
import { existsSync as
|
|
8247
|
+
import { existsSync as existsSync20 } from "fs";
|
|
8048
8248
|
import { join as join20, resolve as resolve21 } from "path";
|
|
8049
8249
|
var safeRemoveFromGraph = (graph, fullPath) => {
|
|
8050
8250
|
try {
|
|
@@ -8076,12 +8276,12 @@ var safeRemoveFromGraph = (graph, fullPath) => {
|
|
|
8076
8276
|
if (shouldIgnorePath(fullPath, state.resolvedPaths)) {
|
|
8077
8277
|
return;
|
|
8078
8278
|
}
|
|
8079
|
-
if (event === "rename" && !
|
|
8279
|
+
if (event === "rename" && !existsSync20(fullPath)) {
|
|
8080
8280
|
safeRemoveFromGraph(state.dependencyGraph, fullPath);
|
|
8081
8281
|
onFileChange(fullPath);
|
|
8082
8282
|
return;
|
|
8083
8283
|
}
|
|
8084
|
-
if (
|
|
8284
|
+
if (existsSync20(fullPath)) {
|
|
8085
8285
|
onFileChange(fullPath);
|
|
8086
8286
|
safeAddToGraph(state.dependencyGraph, fullPath);
|
|
8087
8287
|
}
|
|
@@ -8091,7 +8291,7 @@ var safeRemoveFromGraph = (graph, fullPath) => {
|
|
|
8091
8291
|
const stylesDir = state.resolvedPaths?.stylesDir;
|
|
8092
8292
|
paths.forEach((path) => {
|
|
8093
8293
|
const absolutePath = resolve21(path).replace(/\\/g, "/");
|
|
8094
|
-
if (!
|
|
8294
|
+
if (!existsSync20(absolutePath)) {
|
|
8095
8295
|
return;
|
|
8096
8296
|
}
|
|
8097
8297
|
const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
|
|
@@ -8102,7 +8302,7 @@ var safeRemoveFromGraph = (graph, fullPath) => {
|
|
|
8102
8302
|
const stylesDir = state.resolvedPaths?.stylesDir;
|
|
8103
8303
|
watchPaths.forEach((path) => {
|
|
8104
8304
|
const absolutePath = resolve21(path).replace(/\\/g, "/");
|
|
8105
|
-
if (!
|
|
8305
|
+
if (!existsSync20(absolutePath)) {
|
|
8106
8306
|
return;
|
|
8107
8307
|
}
|
|
8108
8308
|
const isStylesDir = Boolean(stylesDir && absolutePath.startsWith(stylesDir));
|
|
@@ -8223,7 +8423,7 @@ var init_assetStore = __esm(() => {
|
|
|
8223
8423
|
});
|
|
8224
8424
|
|
|
8225
8425
|
// src/islands/pageMetadata.ts
|
|
8226
|
-
import { readFileSync as
|
|
8426
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
8227
8427
|
import { dirname as dirname11, resolve as resolve23 } from "path";
|
|
8228
8428
|
var pagePatterns, getPageDirs = (config) => [
|
|
8229
8429
|
{ dir: config.angularDirectory, framework: "angular" },
|
|
@@ -8265,7 +8465,7 @@ var pagePatterns, getPageDirs = (config) => [
|
|
|
8265
8465
|
return;
|
|
8266
8466
|
const files = await scanEntryPoints(resolve23(entry.dir), pattern);
|
|
8267
8467
|
for (const filePath of files) {
|
|
8268
|
-
const source =
|
|
8468
|
+
const source = readFileSync12(filePath, "utf-8");
|
|
8269
8469
|
const islands = extractIslandUsagesFromSource(source);
|
|
8270
8470
|
pageMetadata.set(resolve23(filePath), {
|
|
8271
8471
|
islands: resolveIslandUsages(islands, islandSourceLookup),
|
|
@@ -8295,10 +8495,10 @@ var init_pageMetadata = __esm(() => {
|
|
|
8295
8495
|
});
|
|
8296
8496
|
|
|
8297
8497
|
// src/dev/fileHashTracker.ts
|
|
8298
|
-
import { readFileSync as
|
|
8498
|
+
import { readFileSync as readFileSync13 } from "fs";
|
|
8299
8499
|
var computeFileHash = (filePath) => {
|
|
8300
8500
|
try {
|
|
8301
|
-
const fileContent =
|
|
8501
|
+
const fileContent = readFileSync13(filePath);
|
|
8302
8502
|
return Number(Bun.hash(fileContent));
|
|
8303
8503
|
} catch {
|
|
8304
8504
|
return UNFOUND_INDEX;
|
|
@@ -9855,8 +10055,8 @@ __export(exports_moduleServer, {
|
|
|
9855
10055
|
createModuleServer: () => createModuleServer,
|
|
9856
10056
|
SRC_URL_PREFIX: () => SRC_URL_PREFIX
|
|
9857
10057
|
});
|
|
9858
|
-
import { existsSync as
|
|
9859
|
-
import { basename as basename12, dirname as dirname14, extname as extname6, resolve as resolve27, relative as
|
|
10058
|
+
import { existsSync as existsSync21, readFileSync as readFileSync14, statSync as statSync2 } from "fs";
|
|
10059
|
+
import { basename as basename12, dirname as dirname14, extname as extname6, resolve as resolve27, relative as relative11 } from "path";
|
|
9860
10060
|
var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPILABLE, ALL_EXPORTS_RE, STRING_CONTENTS_RE, preserveTypeExports = (originalSource, transpiled, valueExports) => {
|
|
9861
10061
|
const codeOnly = originalSource.replace(STRING_CONTENTS_RE, '""');
|
|
9862
10062
|
const allExports = [];
|
|
@@ -9876,7 +10076,7 @@ var SRC_PREFIX = "/@src/", jsTranspiler2, tsTranspiler2, tsxTranspiler, TRANSPIL
|
|
|
9876
10076
|
${stubs}
|
|
9877
10077
|
`;
|
|
9878
10078
|
}, resolveRelativeExtension = (srcPath, projectRoot, extensions) => {
|
|
9879
|
-
const found = extensions.find((ext) =>
|
|
10079
|
+
const found = extensions.find((ext) => existsSync21(resolve27(projectRoot, srcPath + ext)));
|
|
9880
10080
|
return found ? srcPath + found : srcPath;
|
|
9881
10081
|
}, IMPORT_EXTENSIONS, SIDE_EFFECT_EXTENSIONS, MODULE_EXTENSIONS, RESOLVED_MODULE_EXTENSIONS, REACT_EXTENSIONS, escapeRegex3 = (str) => str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), buildImportRewriter = (vendorPaths) => {
|
|
9882
10082
|
const entries = Object.entries(vendorPaths).sort(([a], [b]) => b.length - a.length);
|
|
@@ -9904,17 +10104,17 @@ ${stubs}
|
|
|
9904
10104
|
}
|
|
9905
10105
|
}, resolveRelativeImport = (relPath, fileDir, projectRoot, extensions) => {
|
|
9906
10106
|
const absPath = resolve27(fileDir, relPath);
|
|
9907
|
-
const rel =
|
|
10107
|
+
const rel = relative11(projectRoot, absPath);
|
|
9908
10108
|
const extension = extname6(rel);
|
|
9909
10109
|
let srcPath = RESOLVED_MODULE_EXTENSIONS.has(extension) ? rel : resolveRelativeExtension(rel, projectRoot, extensions);
|
|
9910
10110
|
if (extname6(srcPath) === ".svelte") {
|
|
9911
|
-
srcPath =
|
|
10111
|
+
srcPath = relative11(projectRoot, resolveSvelteModulePath(resolve27(projectRoot, srcPath)));
|
|
9912
10112
|
}
|
|
9913
10113
|
return srcUrl(srcPath, projectRoot);
|
|
9914
10114
|
}, resolveAbsoluteSpecifier = (specifier, projectRoot) => {
|
|
9915
10115
|
try {
|
|
9916
10116
|
const target = resolvePackageImport(specifier, ["browser", "import"]) ?? Bun.resolveSync(specifier, projectRoot);
|
|
9917
|
-
return
|
|
10117
|
+
return relative11(projectRoot, target);
|
|
9918
10118
|
} catch {
|
|
9919
10119
|
return;
|
|
9920
10120
|
}
|
|
@@ -9947,20 +10147,20 @@ ${stubs}
|
|
|
9947
10147
|
result = result.replace(/(import\s*["'])(\.\.?\/[^"']+)(["']\s*;?)/g, (_match, prefix, relPath, suffix) => `${prefix}${resolveRelativeImport(relPath, fileDir, projectRoot, SIDE_EFFECT_EXTENSIONS)}${suffix}`);
|
|
9948
10148
|
result = result.replace(/((?:from|import)\s*["'])(\/[^"']+\.(tsx?|jsx?|ts))(["'])/g, (_match, prefix, absPath, _ext, suffix) => {
|
|
9949
10149
|
if (absPath.startsWith(projectRoot)) {
|
|
9950
|
-
const rel2 =
|
|
10150
|
+
const rel2 = relative11(projectRoot, absPath).replace(/\\/g, "/");
|
|
9951
10151
|
return `${prefix}${srcUrl(rel2, projectRoot)}${suffix}`;
|
|
9952
10152
|
}
|
|
9953
|
-
const rel =
|
|
10153
|
+
const rel = relative11(projectRoot, absPath).replace(/\\/g, "/");
|
|
9954
10154
|
return `${prefix}${srcUrl(rel, projectRoot)}${suffix}`;
|
|
9955
10155
|
});
|
|
9956
10156
|
result = result.replace(/new\s+URL\(\s*["'](\.\.?\/[^"']+)["']\s*,\s*import\.meta\.url\s*\)/g, (_match, relPath) => {
|
|
9957
10157
|
const absPath = resolve27(fileDir, relPath);
|
|
9958
|
-
const rel =
|
|
10158
|
+
const rel = relative11(projectRoot, absPath);
|
|
9959
10159
|
return `new URL('${srcUrl(rel, projectRoot)}', import.meta.url)`;
|
|
9960
10160
|
});
|
|
9961
10161
|
result = result.replace(/import\.meta\.resolve\(\s*["'](\.\.?\/[^"']+)["']\s*\)/g, (_match, relPath) => {
|
|
9962
10162
|
const absPath = resolve27(fileDir, relPath);
|
|
9963
|
-
const rel =
|
|
10163
|
+
const rel = relative11(projectRoot, absPath);
|
|
9964
10164
|
return `'${srcUrl(rel, projectRoot)}'`;
|
|
9965
10165
|
});
|
|
9966
10166
|
return result;
|
|
@@ -9988,7 +10188,7 @@ ${stubs}
|
|
|
9988
10188
|
`)}
|
|
9989
10189
|
${code}`;
|
|
9990
10190
|
}, reactTranspilerOptions, reactTranspiler, transformReactFile = (filePath, projectRoot, rewriter) => {
|
|
9991
|
-
const raw =
|
|
10191
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
9992
10192
|
const valueExports = tsxTranspiler.scan(raw).exports;
|
|
9993
10193
|
let transpiled = reactTranspiler.transformSync(raw);
|
|
9994
10194
|
transpiled = preserveTypeExports(raw, transpiled, valueExports);
|
|
@@ -9999,12 +10199,12 @@ ${code}`;
|
|
|
9999
10199
|
transpiled = `var $RefreshReg$ = window.$RefreshReg$ || function(){};
|
|
10000
10200
|
` + `var $RefreshSig$ = window.$RefreshSig$ || function(){ return function(t){ return t; }; };
|
|
10001
10201
|
${transpiled}`;
|
|
10002
|
-
const relPath =
|
|
10202
|
+
const relPath = relative11(projectRoot, filePath).replace(/\\/g, "/");
|
|
10003
10203
|
transpiled = transpiled.replace(/\binput\.tsx:/g, `${relPath}:`);
|
|
10004
10204
|
transpiled += buildIslandMetadataExports(raw);
|
|
10005
10205
|
return rewriteImports2(transpiled, filePath, projectRoot, rewriter);
|
|
10006
10206
|
}, transformPlainFile = (filePath, projectRoot, rewriter, vueDir) => {
|
|
10007
|
-
const raw =
|
|
10207
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
10008
10208
|
const ext = extname6(filePath);
|
|
10009
10209
|
const isTS = ext === ".ts" || ext === ".tsx";
|
|
10010
10210
|
const isTSX = ext === ".tsx" || ext === ".jsx";
|
|
@@ -10150,17 +10350,17 @@ ${code}`;
|
|
|
10150
10350
|
if (compiled.css?.code) {
|
|
10151
10351
|
const cssPath = `${filePath}.css`;
|
|
10152
10352
|
svelteExternalCss.set(cssPath, compiled.css.code);
|
|
10153
|
-
const cssUrl = srcUrl(
|
|
10353
|
+
const cssUrl = srcUrl(relative11(projectRoot, cssPath), projectRoot);
|
|
10154
10354
|
code = `import "${cssUrl}";
|
|
10155
10355
|
${code}`;
|
|
10156
10356
|
}
|
|
10157
|
-
const moduleUrl = `${SRC_PREFIX}${
|
|
10357
|
+
const moduleUrl = `${SRC_PREFIX}${relative11(projectRoot, filePath).replace(/\\/g, "/")}`;
|
|
10158
10358
|
code = code.replace(/if\s*\(import\.meta\.hot\)\s*\{/, `if (typeof window !== "undefined") {
|
|
10159
10359
|
` + ` if (!window.__SVELTE_HMR_ACCEPT__) window.__SVELTE_HMR_ACCEPT__ = {};
|
|
10160
10360
|
` + ` var __hmr_accept = function(cb) { window.__SVELTE_HMR_ACCEPT__[${JSON.stringify(moduleUrl)}] = cb; };`);
|
|
10161
10361
|
return code.replace(/import\.meta\.hot\.accept\(/g, "__hmr_accept(");
|
|
10162
10362
|
}, transformSvelteFile = async (filePath, projectRoot, rewriter, stylePreprocessors) => {
|
|
10163
|
-
const raw =
|
|
10363
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
10164
10364
|
if (!svelteCompiler) {
|
|
10165
10365
|
svelteCompiler = await import("svelte/compiler");
|
|
10166
10366
|
}
|
|
@@ -10218,7 +10418,7 @@ export default __script__;`;
|
|
|
10218
10418
|
return `${cssInjection}
|
|
10219
10419
|
${code}`;
|
|
10220
10420
|
}, transformVueFile = async (filePath, projectRoot, rewriter, vueDir, stylePreprocessors) => {
|
|
10221
|
-
const raw =
|
|
10421
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
10222
10422
|
if (!vueCompiler) {
|
|
10223
10423
|
vueCompiler = await import("@vue/compiler-sfc");
|
|
10224
10424
|
}
|
|
@@ -10236,7 +10436,7 @@ ${code}`;
|
|
|
10236
10436
|
return rewriteImports2(code, filePath, projectRoot, rewriter);
|
|
10237
10437
|
}, injectVueHmr = (code, filePath, projectRoot, vueDir) => {
|
|
10238
10438
|
const hmrBase = vueDir ? resolve27(vueDir) : projectRoot;
|
|
10239
|
-
const hmrId =
|
|
10439
|
+
const hmrId = relative11(hmrBase, filePath).replace(/\\/g, "/").replace(/\.vue$/, "");
|
|
10240
10440
|
let result = code.replace(/export\s+default\s+/, "var __hmr_comp__ = ");
|
|
10241
10441
|
result += [
|
|
10242
10442
|
"",
|
|
@@ -10250,11 +10450,11 @@ ${code}`;
|
|
|
10250
10450
|
`);
|
|
10251
10451
|
return result;
|
|
10252
10452
|
}, resolveSvelteModulePath = (path) => {
|
|
10253
|
-
if (
|
|
10453
|
+
if (existsSync21(path))
|
|
10254
10454
|
return path;
|
|
10255
|
-
if (
|
|
10455
|
+
if (existsSync21(`${path}.ts`))
|
|
10256
10456
|
return `${path}.ts`;
|
|
10257
|
-
if (
|
|
10457
|
+
if (existsSync21(`${path}.js`))
|
|
10258
10458
|
return `${path}.js`;
|
|
10259
10459
|
return path;
|
|
10260
10460
|
}, jsResponse = (body) => {
|
|
@@ -10267,7 +10467,7 @@ ${code}`;
|
|
|
10267
10467
|
}
|
|
10268
10468
|
});
|
|
10269
10469
|
}, handleCssRequest = (filePath) => {
|
|
10270
|
-
const raw =
|
|
10470
|
+
const raw = readFileSync14(filePath, "utf-8");
|
|
10271
10471
|
const escaped = raw.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$/g, "\\$");
|
|
10272
10472
|
return [
|
|
10273
10473
|
`const style = document.createElement('style');`,
|
|
@@ -10400,7 +10600,7 @@ export default {};
|
|
|
10400
10600
|
return { ext, filePath: resolveSvelteModulePath(filePath) };
|
|
10401
10601
|
if (ext)
|
|
10402
10602
|
return { ext, filePath };
|
|
10403
|
-
const found = MODULE_EXTENSIONS.find((candidate) =>
|
|
10603
|
+
const found = MODULE_EXTENSIONS.find((candidate) => existsSync21(filePath + candidate));
|
|
10404
10604
|
if (!found)
|
|
10405
10605
|
return { ext, filePath };
|
|
10406
10606
|
const resolved = filePath + found;
|
|
@@ -10605,8 +10805,8 @@ var handleHTMXUpdate = async (htmxFilePath) => {
|
|
|
10605
10805
|
var init_simpleHTMXHMR = () => {};
|
|
10606
10806
|
|
|
10607
10807
|
// src/dev/rebuildTrigger.ts
|
|
10608
|
-
import { existsSync as
|
|
10609
|
-
import { basename as basename13, dirname as dirname15, relative as
|
|
10808
|
+
import { existsSync as existsSync22 } from "fs";
|
|
10809
|
+
import { basename as basename13, dirname as dirname15, relative as relative12, resolve as resolve30 } from "path";
|
|
10610
10810
|
var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseErrorLocationFromMessage = (msg) => {
|
|
10611
10811
|
const pathLineCol = msg.match(/^([^\s:]+):(\d+)(?::(\d+))?/);
|
|
10612
10812
|
if (pathLineCol) {
|
|
@@ -10674,7 +10874,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10674
10874
|
detectedFw = detected !== "ignored" ? detected : affectedFrameworks[0];
|
|
10675
10875
|
}
|
|
10676
10876
|
return { ...parsed, framework: detectedFw };
|
|
10677
|
-
}, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) &&
|
|
10877
|
+
}, isValidDeletedAffectedFile = (affectedFile, deletedPathResolved, processedFiles) => affectedFile !== deletedPathResolved && !processedFiles.has(affectedFile) && existsSync22(affectedFile), collectDeletedFileAffected = (state, filePathInSet, processedFiles, validFiles) => {
|
|
10678
10878
|
state.fileHashes.delete(filePathInSet);
|
|
10679
10879
|
try {
|
|
10680
10880
|
const affectedFiles = getAffectedFiles(state.dependencyGraph, filePathInSet);
|
|
@@ -10692,7 +10892,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10692
10892
|
if (!dependents || dependents.size === 0) {
|
|
10693
10893
|
return;
|
|
10694
10894
|
}
|
|
10695
|
-
const dependentFiles = Array.from(dependents).filter((file3) =>
|
|
10895
|
+
const dependentFiles = Array.from(dependents).filter((file3) => existsSync22(file3));
|
|
10696
10896
|
if (dependentFiles.length === 0) {
|
|
10697
10897
|
return;
|
|
10698
10898
|
}
|
|
@@ -10708,7 +10908,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10708
10908
|
try {
|
|
10709
10909
|
const affectedFiles = getAffectedFiles(state.dependencyGraph, normalizedFilePath);
|
|
10710
10910
|
affectedFiles.forEach((affectedFile) => {
|
|
10711
|
-
if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath &&
|
|
10911
|
+
if (!processedFiles.has(affectedFile) && affectedFile !== normalizedFilePath && existsSync22(affectedFile)) {
|
|
10712
10912
|
validFiles.push(affectedFile);
|
|
10713
10913
|
processedFiles.add(affectedFile);
|
|
10714
10914
|
}
|
|
@@ -10733,7 +10933,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10733
10933
|
collectChangedFileAffected(state, normalizedFilePath, processedFiles, validFiles);
|
|
10734
10934
|
}, processFilePathSet = (state, filePathSet, processedFiles, validFiles) => {
|
|
10735
10935
|
filePathSet.forEach((filePathInSet) => {
|
|
10736
|
-
if (!
|
|
10936
|
+
if (!existsSync22(filePathInSet)) {
|
|
10737
10937
|
collectDeletedFileAffected(state, filePathInSet, processedFiles, validFiles);
|
|
10738
10938
|
return;
|
|
10739
10939
|
}
|
|
@@ -10801,7 +11001,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10801
11001
|
if (framework === "unknown") {
|
|
10802
11002
|
const { invalidate: invalidate2 } = (init_transformCache(), __toCommonJS(exports_transformCache));
|
|
10803
11003
|
invalidate2(resolve30(filePath));
|
|
10804
|
-
const relPath =
|
|
11004
|
+
const relPath = relative12(process.cwd(), filePath);
|
|
10805
11005
|
logHmrUpdate(relPath);
|
|
10806
11006
|
return;
|
|
10807
11007
|
}
|
|
@@ -10841,7 +11041,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10841
11041
|
return componentFile;
|
|
10842
11042
|
}
|
|
10843
11043
|
const tsCounterpart = componentFile.replace(/\.html$/, ".ts");
|
|
10844
|
-
if (
|
|
11044
|
+
if (existsSync22(tsCounterpart)) {
|
|
10845
11045
|
return tsCounterpart;
|
|
10846
11046
|
}
|
|
10847
11047
|
if (!graph)
|
|
@@ -10987,7 +11187,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10987
11187
|
}, resolveReactEntryForPageFile = (normalized, pagesPathResolved, reactIndexesPath) => {
|
|
10988
11188
|
const pageName = basename13(normalized, ".tsx");
|
|
10989
11189
|
const indexPath = resolve30(reactIndexesPath, `${pageName}.tsx`);
|
|
10990
|
-
if (!
|
|
11190
|
+
if (!existsSync22(indexPath)) {
|
|
10991
11191
|
return;
|
|
10992
11192
|
}
|
|
10993
11193
|
return indexPath;
|
|
@@ -10999,7 +11199,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
10999
11199
|
}
|
|
11000
11200
|
const pageName = basename13(dep, ".tsx");
|
|
11001
11201
|
const indexPath = resolve30(reactIndexesPath, `${pageName}.tsx`);
|
|
11002
|
-
if (
|
|
11202
|
+
if (existsSync22(indexPath) && !reactEntries.includes(indexPath)) {
|
|
11003
11203
|
reactEntries.push(indexPath);
|
|
11004
11204
|
}
|
|
11005
11205
|
});
|
|
@@ -11082,7 +11282,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11082
11282
|
}, getModuleUrl = async (pageFile) => {
|
|
11083
11283
|
const { invalidateModule: invalidateModule2, warmCache: warmCache2, SRC_URL_PREFIX: SRC_URL_PREFIX2 } = await Promise.resolve().then(() => (init_moduleServer(), exports_moduleServer));
|
|
11084
11284
|
invalidateModule2(pageFile);
|
|
11085
|
-
const rel =
|
|
11285
|
+
const rel = relative12(process.cwd(), pageFile).replace(/\\/g, "/");
|
|
11086
11286
|
const url = `${SRC_URL_PREFIX2}${rel}`;
|
|
11087
11287
|
warmCache2(url);
|
|
11088
11288
|
return url;
|
|
@@ -11114,7 +11314,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11114
11314
|
const pageModuleUrl = await getReactModuleUrl(broadcastTarget);
|
|
11115
11315
|
if (pageModuleUrl) {
|
|
11116
11316
|
const serverDuration = Date.now() - startTime;
|
|
11117
|
-
state.lastHmrPath =
|
|
11317
|
+
state.lastHmrPath = relative12(process.cwd(), primaryFile).replace(/\\/g, "/");
|
|
11118
11318
|
state.lastHmrFramework = "react";
|
|
11119
11319
|
broadcastToClients(state, {
|
|
11120
11320
|
data: {
|
|
@@ -11578,7 +11778,7 @@ var moduleServerPromise, getModuleServer = () => moduleServerPromise, parseError
|
|
|
11578
11778
|
const baseName = fileName.replace(/\.vue$/, "");
|
|
11579
11779
|
const pascalName = toPascal(baseName);
|
|
11580
11780
|
const vueRoot = config.vueDirectory;
|
|
11581
|
-
const hmrId = vueRoot ?
|
|
11781
|
+
const hmrId = vueRoot ? relative12(vueRoot, vuePagePath).replace(/\\/g, "/").replace(/\.vue$/, "") : baseName;
|
|
11582
11782
|
const cssKey = `${pascalName}CSS`;
|
|
11583
11783
|
const cssUrl = manifest[cssKey] || null;
|
|
11584
11784
|
const { vueHmrMetadata: vueHmrMetadata2 } = await Promise.resolve().then(() => (init_compileVue(), exports_compileVue));
|
|
@@ -12226,7 +12426,7 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
|
|
|
12226
12426
|
return Array.from(specifiers).filter(isResolvable3);
|
|
12227
12427
|
}, generateEntrySource2 = (specifier) => `export * from '${specifier}';
|
|
12228
12428
|
`, rewriteVendorFiles = async (vendorDir) => {
|
|
12229
|
-
const { readdirSync: readdirSync2, readFileSync:
|
|
12429
|
+
const { readdirSync: readdirSync2, readFileSync: readFileSync15, writeFileSync: writeFileSync8 } = await import("fs");
|
|
12230
12430
|
const { computeVendorPaths: computeVendorPaths2 } = await Promise.resolve().then(() => (init_buildReactVendor(), exports_buildReactVendor));
|
|
12231
12431
|
const reactPaths = Object.entries(computeVendorPaths2());
|
|
12232
12432
|
const rewriteContent = (content) => reactPaths.reduce((acc, [specifier, webPath]) => {
|
|
@@ -12237,7 +12437,7 @@ var toSafeFileName5 = (specifier) => specifier.replace(/\//g, "_").replace(/@/g,
|
|
|
12237
12437
|
const files = readdirSync2(vendorDir).filter((f) => f.endsWith(".js"));
|
|
12238
12438
|
for (const file3 of files) {
|
|
12239
12439
|
const filePath = join22(vendorDir, file3);
|
|
12240
|
-
const original =
|
|
12440
|
+
const original = readFileSync15(filePath, "utf-8");
|
|
12241
12441
|
const rewritten = rewriteContent(original);
|
|
12242
12442
|
if (rewritten !== original)
|
|
12243
12443
|
writeFileSync8(filePath, rewritten);
|
|
@@ -12636,5 +12836,5 @@ export {
|
|
|
12636
12836
|
build
|
|
12637
12837
|
};
|
|
12638
12838
|
|
|
12639
|
-
//# debugId=
|
|
12839
|
+
//# debugId=E51CE14B6945493364756E2164756E21
|
|
12640
12840
|
//# sourceMappingURL=build.js.map
|