@absolutejs/absolute 0.19.0-beta.693 → 0.19.0-beta.695
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 +377 -53
- package/dist/angular/index.js.map +3 -3
- package/dist/angular/server.js +377 -53
- package/dist/angular/server.js.map +3 -3
- package/dist/build.js +539 -208
- package/dist/build.js.map +7 -7
- package/dist/cli/index.js +1 -0
- package/dist/index.js +2004 -1828
- package/dist/index.js.map +28 -35
- package/dist/islands/index.js +349 -25
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +354 -25
- package/dist/react/index.js.map +3 -3
- package/dist/react/server.js +6 -1
- package/dist/react/server.js.map +2 -2
- package/dist/src/build/stylePreprocessor.d.ts +2 -1
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/core/pageHandlers.d.ts +2 -1
- package/dist/svelte/index.js +359 -35
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +354 -30
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +30 -0
- package/dist/vue/index.js +349 -25
- package/dist/vue/index.js.map +3 -3
- package/package.json +16 -7
package/dist/svelte/server.js
CHANGED
|
@@ -359,10 +359,27 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
359
359
|
});
|
|
360
360
|
|
|
361
361
|
// src/build/stylePreprocessor.ts
|
|
362
|
+
var exports_stylePreprocessor = {};
|
|
363
|
+
__export(exports_stylePreprocessor, {
|
|
364
|
+
stylePreprocessorPlugin: () => stylePreprocessorPlugin,
|
|
365
|
+
isStylePath: () => isStylePath,
|
|
366
|
+
isStyleModulePath: () => isStyleModulePath,
|
|
367
|
+
isPreprocessableStylePath: () => isPreprocessableStylePath,
|
|
368
|
+
getStyleBaseName: () => getStyleBaseName,
|
|
369
|
+
getCssOutputExtension: () => getCssOutputExtension,
|
|
370
|
+
createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
|
|
371
|
+
createStyleTransformConfig: () => createStyleTransformConfig,
|
|
372
|
+
createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
|
|
373
|
+
compileStyleSource: () => compileStyleSource,
|
|
374
|
+
compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
|
|
375
|
+
compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
|
|
376
|
+
});
|
|
377
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
362
378
|
import { readFile } from "fs/promises";
|
|
363
379
|
import { createRequire } from "module";
|
|
364
|
-
import { dirname, extname, join as join2, resolve as resolve2 } from "path";
|
|
365
|
-
|
|
380
|
+
import { dirname, extname, isAbsolute, join as join2, relative, resolve as resolve2 } from "path";
|
|
381
|
+
import { fileURLToPath } from "url";
|
|
382
|
+
var CSS_EXTENSION_PATTERN, 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) => {
|
|
366
383
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
367
384
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
368
385
|
return "scss";
|
|
@@ -370,16 +387,266 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
370
387
|
return "sass";
|
|
371
388
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
372
389
|
return "less";
|
|
390
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
391
|
+
return "stylus";
|
|
373
392
|
return null;
|
|
374
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
393
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
|
|
394
|
+
try {
|
|
395
|
+
return requireFromCwd(specifier);
|
|
396
|
+
} catch {
|
|
397
|
+
return requireOptionalPeer(specifier);
|
|
398
|
+
}
|
|
399
|
+
}, normalizeLoadPaths = (filePath, paths = []) => [
|
|
375
400
|
dirname(filePath),
|
|
376
401
|
process.cwd(),
|
|
377
402
|
...paths.map((path) => resolve2(process.cwd(), path))
|
|
378
|
-
],
|
|
403
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
404
|
+
pattern,
|
|
405
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
406
|
+
})), readTsconfigAliases = () => {
|
|
407
|
+
const cwd = process.cwd();
|
|
408
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
409
|
+
return tsconfigAliasCache;
|
|
410
|
+
const tsconfigPath = resolve2(cwd, "tsconfig.json");
|
|
411
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
412
|
+
if (!existsSync2(tsconfigPath)) {
|
|
413
|
+
tsconfigAliasCache = empty;
|
|
414
|
+
return empty;
|
|
415
|
+
}
|
|
416
|
+
try {
|
|
417
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync2(tsconfigPath, "utf-8")));
|
|
418
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
419
|
+
const baseUrl = resolve2(cwd, compilerOptions.baseUrl ?? ".");
|
|
420
|
+
tsconfigAliasCache = {
|
|
421
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
422
|
+
baseUrl,
|
|
423
|
+
cwd
|
|
424
|
+
};
|
|
425
|
+
} catch {
|
|
426
|
+
tsconfigAliasCache = empty;
|
|
427
|
+
}
|
|
428
|
+
return tsconfigAliasCache;
|
|
429
|
+
}, getAliasEntries = (config) => {
|
|
430
|
+
const tsconfig = readTsconfigAliases();
|
|
431
|
+
return {
|
|
432
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
433
|
+
baseUrl: tsconfig.baseUrl
|
|
434
|
+
};
|
|
435
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
436
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
437
|
+
const targets = [];
|
|
438
|
+
for (const alias of aliases) {
|
|
439
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
440
|
+
if (!match)
|
|
441
|
+
continue;
|
|
442
|
+
const wildcard = match[1] ?? "";
|
|
443
|
+
for (const replacement of alias.replacements) {
|
|
444
|
+
targets.push(resolve2(baseUrl, replacement.replace("*", wildcard)));
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return targets;
|
|
448
|
+
}, getLanguageExtensions = (language) => {
|
|
449
|
+
if (language === "less")
|
|
450
|
+
return [".less", ".css"];
|
|
451
|
+
if (language === "stylus")
|
|
452
|
+
return [".styl", ".stylus", ".css"];
|
|
453
|
+
return [".scss", ".sass", ".css"];
|
|
454
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
455
|
+
const ext = extname(basePath);
|
|
456
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
457
|
+
`${basePath}${extension}`,
|
|
458
|
+
join2(basePath, `index${extension}`)
|
|
459
|
+
]);
|
|
460
|
+
if (language === "scss" || language === "sass") {
|
|
461
|
+
return paths.flatMap((path) => {
|
|
462
|
+
const dir = dirname(path);
|
|
463
|
+
const base = path.slice(dir.length + 1);
|
|
464
|
+
return [path, join2(dir, `_${base}`)];
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
return paths;
|
|
468
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
469
|
+
const rawCandidates = [
|
|
470
|
+
...resolveAliasTargets(specifier, config),
|
|
471
|
+
isAbsolute(specifier) ? specifier : resolve2(fromDirectory, specifier),
|
|
472
|
+
...loadPaths.map((path) => resolve2(path, specifier))
|
|
473
|
+
];
|
|
474
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
475
|
+
if (existsSync2(candidate))
|
|
476
|
+
return candidate;
|
|
477
|
+
}
|
|
478
|
+
return null;
|
|
479
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
480
|
+
const markerIndex = url.search(/[?#]/);
|
|
481
|
+
if (markerIndex === -1)
|
|
482
|
+
return { marker: "", path: url };
|
|
483
|
+
return {
|
|
484
|
+
marker: url.slice(markerIndex),
|
|
485
|
+
path: url.slice(0, markerIndex)
|
|
486
|
+
};
|
|
487
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
488
|
+
const sourceDir = dirname(sourceFile);
|
|
489
|
+
const entryDir = dirname(entryFile);
|
|
490
|
+
if (sourceDir === entryDir)
|
|
491
|
+
return contents;
|
|
492
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
493
|
+
const trimmedUrl = rawUrl.trim();
|
|
494
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
495
|
+
return match;
|
|
496
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
497
|
+
const rebased = relative(entryDir, resolve2(sourceDir, path)).replace(/\\/g, "/");
|
|
498
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
499
|
+
const nextQuote = quote || '"';
|
|
500
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
501
|
+
});
|
|
502
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
503
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
504
|
+
return match;
|
|
505
|
+
const resolved = resolveImportPath(specifier, dirname(sourceFile), loadPaths, language, config);
|
|
506
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
507
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
508
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
509
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
510
|
+
}, extractCssModuleExports = (css) => {
|
|
511
|
+
const exports = {};
|
|
512
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
513
|
+
for (const declaration of body.split(";")) {
|
|
514
|
+
const separator = declaration.indexOf(":");
|
|
515
|
+
if (separator === -1)
|
|
516
|
+
continue;
|
|
517
|
+
const key = declaration.slice(0, separator).trim();
|
|
518
|
+
const value = declaration.slice(separator + 1).trim();
|
|
519
|
+
if (key && value)
|
|
520
|
+
exports[key] = value;
|
|
521
|
+
}
|
|
522
|
+
return "";
|
|
523
|
+
});
|
|
524
|
+
return { css: nextCss, exports };
|
|
525
|
+
}, getSassOptions = (config, language) => ({
|
|
379
526
|
...config?.sass ?? {},
|
|
380
527
|
...language === "scss" ? config?.scss ?? {} : {}
|
|
381
|
-
}), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
382
|
-
${contents}` : contents,
|
|
528
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, createStyleTransformConfig = (stylePreprocessors, postcss) => postcss === undefined ? stylePreprocessors : { ...stylePreprocessors ?? {}, postcss }, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
529
|
+
${contents}` : contents, normalizePostcssModule = (mod) => {
|
|
530
|
+
if (mod && typeof mod === "object" && "default" in mod) {
|
|
531
|
+
return mod.default ?? mod;
|
|
532
|
+
}
|
|
533
|
+
return mod;
|
|
534
|
+
}, loadPostcssConfigFile = async (configPath) => {
|
|
535
|
+
const resolved = resolve2(process.cwd(), configPath);
|
|
536
|
+
const loaded = resolved.endsWith(".cjs") || resolved.endsWith(".cts") ? requireOptionalPeerSync(resolved) : await importOptionalPeer(`${new URL(`file://${resolved}`).href}?t=${Date.now()}`);
|
|
537
|
+
const config = normalizePostcssModule(loaded);
|
|
538
|
+
const value = typeof config === "function" ? await config({
|
|
539
|
+
cwd: process.cwd(),
|
|
540
|
+
env: "development"
|
|
541
|
+
}) : config;
|
|
542
|
+
return normalizePostcssModule(value) ?? {};
|
|
543
|
+
}, normalizePostcssPlugins = (plugins) => {
|
|
544
|
+
if (!plugins)
|
|
545
|
+
return [];
|
|
546
|
+
if (Array.isArray(plugins))
|
|
547
|
+
return plugins.filter(Boolean);
|
|
548
|
+
const resolved = [];
|
|
549
|
+
for (const [specifier, options] of Object.entries(plugins)) {
|
|
550
|
+
if (options === false)
|
|
551
|
+
continue;
|
|
552
|
+
const mod = normalizePostcssModule(requireOptionalPeerSync(specifier));
|
|
553
|
+
const plugin = typeof mod === "function" ? mod(options === true ? undefined : options) : mod;
|
|
554
|
+
if (plugin)
|
|
555
|
+
resolved.push(plugin);
|
|
556
|
+
}
|
|
557
|
+
return resolved;
|
|
558
|
+
}, resolvePostcssConfig = async (config) => {
|
|
559
|
+
const inlineConfig = config?.postcss;
|
|
560
|
+
if (!inlineConfig)
|
|
561
|
+
return null;
|
|
562
|
+
const fileConfig = inlineConfig.config ? await loadPostcssConfigFile(inlineConfig.config) : {};
|
|
563
|
+
const plugins = [
|
|
564
|
+
...normalizePostcssPlugins(fileConfig.plugins),
|
|
565
|
+
...normalizePostcssPlugins(inlineConfig.plugins)
|
|
566
|
+
];
|
|
567
|
+
if (plugins.length === 0)
|
|
568
|
+
return null;
|
|
569
|
+
return {
|
|
570
|
+
options: {
|
|
571
|
+
...fileConfig.options ?? {},
|
|
572
|
+
...inlineConfig.options ?? {}
|
|
573
|
+
},
|
|
574
|
+
plugins
|
|
575
|
+
};
|
|
576
|
+
}, runPostcss = async (css, filePath, config) => {
|
|
577
|
+
const postcssConfig = await resolvePostcssConfig(config);
|
|
578
|
+
if (!postcssConfig)
|
|
579
|
+
return css;
|
|
580
|
+
let postcssModule;
|
|
581
|
+
try {
|
|
582
|
+
postcssModule = await importOptionalPeer("postcss");
|
|
583
|
+
} catch {
|
|
584
|
+
throw missingDependencyError("postcss", filePath);
|
|
585
|
+
}
|
|
586
|
+
const postcss = postcssModule.default ?? postcssModule;
|
|
587
|
+
const result = await postcss(postcssConfig.plugins).process(css, {
|
|
588
|
+
from: filePath,
|
|
589
|
+
map: false,
|
|
590
|
+
...postcssConfig.options
|
|
591
|
+
});
|
|
592
|
+
return result.css;
|
|
593
|
+
}, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
594
|
+
canonicalize(specifier, options) {
|
|
595
|
+
const fromDirectory = options.containingUrl ? dirname(fileURLToPath(options.containingUrl)) : dirname(entryFile);
|
|
596
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
597
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
598
|
+
},
|
|
599
|
+
load(canonicalUrl) {
|
|
600
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
601
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
602
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
603
|
+
return null;
|
|
604
|
+
return {
|
|
605
|
+
contents: preprocessLoadedStyle(readFileSync2(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
606
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
607
|
+
};
|
|
608
|
+
}
|
|
609
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
610
|
+
install(less, pluginManager) {
|
|
611
|
+
const baseManager = new less.FileManager;
|
|
612
|
+
const manager = Object.create(baseManager);
|
|
613
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve2(currentDirectory), loadPaths, "less", config));
|
|
614
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
615
|
+
const resolved = resolveImportPath(filename, resolve2(currentDirectory), loadPaths, "less", config);
|
|
616
|
+
if (!resolved) {
|
|
617
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
618
|
+
}
|
|
619
|
+
return {
|
|
620
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
621
|
+
filename: resolved
|
|
622
|
+
};
|
|
623
|
+
};
|
|
624
|
+
pluginManager.addFileManager(manager);
|
|
625
|
+
}
|
|
626
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
627
|
+
let stylus;
|
|
628
|
+
try {
|
|
629
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
630
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
631
|
+
} catch {
|
|
632
|
+
throw missingDependencyError("stylus", filePath);
|
|
633
|
+
}
|
|
634
|
+
return new Promise((resolveCss, reject) => {
|
|
635
|
+
const renderer = stylus(contents);
|
|
636
|
+
renderer.set("filename", filePath);
|
|
637
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
638
|
+
renderer.set(key, value);
|
|
639
|
+
}
|
|
640
|
+
for (const path of loadPaths)
|
|
641
|
+
renderer.include(path);
|
|
642
|
+
renderer.render((error, css) => {
|
|
643
|
+
if (error)
|
|
644
|
+
reject(error);
|
|
645
|
+
else
|
|
646
|
+
resolveCss(css ?? "");
|
|
647
|
+
});
|
|
648
|
+
});
|
|
649
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
383
650
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
384
651
|
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
385
652
|
if (language === "scss" || language === "sass") {
|
|
@@ -392,13 +659,17 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
392
659
|
throw missingDependencyError(packageName, filePath);
|
|
393
660
|
}
|
|
394
661
|
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
662
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
395
663
|
const result = sass.compileString(contents, {
|
|
396
|
-
|
|
664
|
+
importers: [
|
|
665
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
666
|
+
],
|
|
667
|
+
loadPaths,
|
|
397
668
|
style: "expanded",
|
|
398
669
|
syntax: language === "sass" ? "indented" : "scss",
|
|
399
670
|
url: new URL(`file://${filePath}`)
|
|
400
671
|
});
|
|
401
|
-
return result.css;
|
|
672
|
+
return runPostcss(result.css, filePath, config);
|
|
402
673
|
}
|
|
403
674
|
if (language === "less") {
|
|
404
675
|
const options = getLessOptions(config);
|
|
@@ -413,14 +684,25 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
413
684
|
if (!render)
|
|
414
685
|
throw missingDependencyError("less", filePath);
|
|
415
686
|
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
687
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
416
688
|
const result = await render(contents, {
|
|
417
689
|
...options.options ?? {},
|
|
418
690
|
filename: filePath,
|
|
419
|
-
paths:
|
|
691
|
+
paths: loadPaths,
|
|
692
|
+
plugins: [
|
|
693
|
+
...options.options?.plugins ?? [],
|
|
694
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
695
|
+
]
|
|
420
696
|
});
|
|
421
|
-
return result.css;
|
|
697
|
+
return runPostcss(result.css, filePath, config);
|
|
422
698
|
}
|
|
423
|
-
|
|
699
|
+
if (language === "stylus") {
|
|
700
|
+
const options = getStylusOptions(config);
|
|
701
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
702
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
703
|
+
return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
|
|
704
|
+
}
|
|
705
|
+
return runPostcss(rawContents, filePath, config);
|
|
424
706
|
}, createStylePreprocessorPlugin = (config) => ({
|
|
425
707
|
name: "absolute-style-preprocessor",
|
|
426
708
|
setup(build) {
|
|
@@ -430,21 +712,24 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
430
712
|
path: path.slice("absolute-style-module:".length)
|
|
431
713
|
}));
|
|
432
714
|
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
433
|
-
const
|
|
434
|
-
if (!
|
|
715
|
+
const source = cssModuleSources.get(path);
|
|
716
|
+
if (!source) {
|
|
435
717
|
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
436
718
|
}
|
|
437
719
|
return {
|
|
438
|
-
contents:
|
|
720
|
+
contents: source.css,
|
|
439
721
|
loader: "css"
|
|
440
722
|
};
|
|
441
723
|
});
|
|
442
724
|
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
443
725
|
if (isStyleModulePath(path)) {
|
|
444
726
|
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
445
|
-
|
|
727
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
728
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
729
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
730
|
+
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}`)};`;
|
|
446
731
|
return {
|
|
447
|
-
contents:
|
|
732
|
+
contents: exportSource,
|
|
448
733
|
loader: "js"
|
|
449
734
|
};
|
|
450
735
|
}
|
|
@@ -453,6 +738,10 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
453
738
|
loader: "css"
|
|
454
739
|
};
|
|
455
740
|
});
|
|
741
|
+
build.onLoad({ filter: CSS_EXTENSION_PATTERN }, async ({ path }) => ({
|
|
742
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
743
|
+
loader: "css"
|
|
744
|
+
}));
|
|
456
745
|
}
|
|
457
746
|
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
458
747
|
style: async ({
|
|
@@ -470,14 +759,49 @@ ${contents}` : contents, compileStyleSource = async (filePath, source, languageH
|
|
|
470
759
|
}
|
|
471
760
|
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
472
761
|
if (!isPreprocessableStylePath(filePath)) {
|
|
473
|
-
return readFile(filePath, "utf-8");
|
|
762
|
+
return runPostcss(await readFile(filePath, "utf-8"), filePath, config);
|
|
474
763
|
}
|
|
475
764
|
return compileStyleSource(filePath, undefined, undefined, config);
|
|
476
|
-
}
|
|
765
|
+
}, compileStyleFileIfNeededSync = (filePath, config) => {
|
|
766
|
+
const rawContents = readFileSync2(filePath, "utf-8");
|
|
767
|
+
const language = getStyleLanguage(filePath);
|
|
768
|
+
if (config?.postcss) {
|
|
769
|
+
throw new Error(`Unable to compile ${filePath}: PostCSS preprocessing is async-only.`);
|
|
770
|
+
}
|
|
771
|
+
if (language === "scss" || language === "sass") {
|
|
772
|
+
const options = getSassOptions(config, language);
|
|
773
|
+
const packageName = options.implementation ?? "sass";
|
|
774
|
+
let sass;
|
|
775
|
+
try {
|
|
776
|
+
sass = requireOptionalPeerSync(packageName);
|
|
777
|
+
} catch {
|
|
778
|
+
throw missingDependencyError(packageName, filePath);
|
|
779
|
+
}
|
|
780
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
781
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
782
|
+
return sass.compileString(contents, {
|
|
783
|
+
importers: [
|
|
784
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
785
|
+
],
|
|
786
|
+
loadPaths,
|
|
787
|
+
style: "expanded",
|
|
788
|
+
syntax: language === "sass" ? "indented" : "scss",
|
|
789
|
+
url: new URL(`file://${filePath}`)
|
|
790
|
+
}).css;
|
|
791
|
+
}
|
|
792
|
+
if (language === "less") {
|
|
793
|
+
throw new Error(`Unable to compile ${filePath}: Less styleUrl preprocessing is async-only. Import the Less file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
794
|
+
}
|
|
795
|
+
if (language === "stylus") {
|
|
796
|
+
throw new Error(`Unable to compile ${filePath}: Stylus styleUrl preprocessing is async-only. Import the Stylus file from a bundled entrypoint or use SCSS/CSS for Angular styleUrl.`);
|
|
797
|
+
}
|
|
798
|
+
return rawContents;
|
|
799
|
+
}, getCssOutputExtension = (filePath) => isPreprocessableStylePath(filePath) ? ".css" : extname(filePath);
|
|
477
800
|
var init_stylePreprocessor = __esm(() => {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
801
|
+
CSS_EXTENSION_PATTERN = /\.css$/i;
|
|
802
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
803
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
804
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
481
805
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
482
806
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
483
807
|
requireFromCwd = createRequire(join2(process.cwd(), "package.json"));
|
|
@@ -486,9 +810,9 @@ var init_stylePreprocessor = __esm(() => {
|
|
|
486
810
|
|
|
487
811
|
// src/core/svelteServerModule.ts
|
|
488
812
|
import { mkdir, readdir } from "fs/promises";
|
|
489
|
-
import { basename, dirname as dirname2, extname as extname2, join as join3, relative, resolve as resolve3 } from "path";
|
|
813
|
+
import { basename, dirname as dirname2, extname as extname2, join as join3, relative as relative2, resolve as resolve3 } from "path";
|
|
490
814
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
491
|
-
const importPath =
|
|
815
|
+
const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
|
|
492
816
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
493
817
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
494
818
|
for (const entry of entries) {
|
|
@@ -552,7 +876,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
552
876
|
const foundIndex = existResults.indexOf(true);
|
|
553
877
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
554
878
|
}, getCachedModulePath = (sourcePath) => {
|
|
555
|
-
const relativeSourcePath =
|
|
879
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
556
880
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
557
881
|
return join3(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
558
882
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -1750,12 +2074,12 @@ var init_startupBanner = __esm(() => {
|
|
|
1750
2074
|
// src/utils/logger.ts
|
|
1751
2075
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
1752
2076
|
const cwd = process.cwd();
|
|
1753
|
-
let
|
|
1754
|
-
|
|
1755
|
-
if (!
|
|
1756
|
-
|
|
2077
|
+
let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
2078
|
+
relative3 = relative3.replace(/\\/g, "/");
|
|
2079
|
+
if (!relative3.startsWith("/")) {
|
|
2080
|
+
relative3 = `/${relative3}`;
|
|
1757
2081
|
}
|
|
1758
|
-
return
|
|
2082
|
+
return relative3;
|
|
1759
2083
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
1760
2084
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1761
2085
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -2301,5 +2625,5 @@ export {
|
|
|
2301
2625
|
handleSveltePageRequest
|
|
2302
2626
|
};
|
|
2303
2627
|
|
|
2304
|
-
//# debugId=
|
|
2628
|
+
//# debugId=C7312D0D59797E0964756E2164756E21
|
|
2305
2629
|
//# sourceMappingURL=server.js.map
|