@absolutejs/absolute 0.19.0-beta.692 → 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 +354 -140
- package/dist/angular/index.js.map +4 -4
- package/dist/angular/server.js +336 -122
- package/dist/angular/server.js.map +4 -4
- package/dist/build.js +667 -442
- package/dist/build.js.map +11 -11
- package/dist/index.js +736 -510
- package/dist/index.js.map +12 -12
- package/dist/islands/index.js +270 -56
- package/dist/islands/index.js.map +3 -3
- package/dist/react/index.js +270 -56
- package/dist/react/index.js.map +3 -3
- package/dist/src/build/compileAngular.d.ts +4 -3
- package/dist/src/build/compileSvelte.d.ts +2 -1
- package/dist/src/build/compileVue.d.ts +2 -1
- package/dist/src/build/stylePreprocessor.d.ts +6 -4
- package/dist/src/core/build.d.ts +1 -1
- package/dist/src/dev/moduleServer.d.ts +2 -0
- package/dist/svelte/index.js +284 -70
- package/dist/svelte/index.js.map +3 -3
- package/dist/svelte/server.js +275 -61
- package/dist/svelte/server.js.map +3 -3
- package/dist/types/build.d.ts +45 -0
- package/dist/vue/index.js +270 -56
- package/dist/vue/index.js.map +3 -3
- package/package.json +12 -7
package/dist/svelte/server.js
CHANGED
|
@@ -359,10 +359,12 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
|
|
|
359
359
|
});
|
|
360
360
|
|
|
361
361
|
// src/build/stylePreprocessor.ts
|
|
362
|
+
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
362
363
|
import { readFile } from "fs/promises";
|
|
363
364
|
import { createRequire } from "module";
|
|
364
|
-
import { dirname, extname, join as join2 } from "path";
|
|
365
|
-
|
|
365
|
+
import { dirname, extname, isAbsolute, join as join2, relative, resolve as resolve2 } from "path";
|
|
366
|
+
import { fileURLToPath } from "url";
|
|
367
|
+
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) => {
|
|
366
368
|
const normalized = filePathOrLanguage.toLowerCase();
|
|
367
369
|
if (normalized === "scss" || normalized.endsWith(".scss"))
|
|
368
370
|
return "scss";
|
|
@@ -370,19 +372,214 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
370
372
|
return "sass";
|
|
371
373
|
if (normalized === "less" || normalized.endsWith(".less"))
|
|
372
374
|
return "less";
|
|
375
|
+
if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
|
|
376
|
+
return "stylus";
|
|
373
377
|
return null;
|
|
374
|
-
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`),
|
|
378
|
+
}, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
|
|
379
|
+
dirname(filePath),
|
|
380
|
+
process.cwd(),
|
|
381
|
+
...paths.map((path) => resolve2(process.cwd(), path))
|
|
382
|
+
], tsconfigAliasCache, stripJsonComments = (source) => source.replace(/\/\*[\s\S]*?\*\//g, "").replace(/(^|[^:])\/\/.*$/gm, "$1"), normalizeAliasEntries = (aliases) => Object.entries(aliases ?? {}).map(([pattern, value]) => ({
|
|
383
|
+
pattern,
|
|
384
|
+
replacements: Array.isArray(value) ? value : [value]
|
|
385
|
+
})), readTsconfigAliases = () => {
|
|
386
|
+
const cwd = process.cwd();
|
|
387
|
+
if (tsconfigAliasCache?.cwd === cwd)
|
|
388
|
+
return tsconfigAliasCache;
|
|
389
|
+
const tsconfigPath = resolve2(cwd, "tsconfig.json");
|
|
390
|
+
const empty = { aliases: [], baseUrl: cwd, cwd };
|
|
391
|
+
if (!existsSync2(tsconfigPath)) {
|
|
392
|
+
tsconfigAliasCache = empty;
|
|
393
|
+
return empty;
|
|
394
|
+
}
|
|
395
|
+
try {
|
|
396
|
+
const parsed = JSON.parse(stripJsonComments(readFileSync2(tsconfigPath, "utf-8")));
|
|
397
|
+
const compilerOptions = parsed.compilerOptions ?? {};
|
|
398
|
+
const baseUrl = resolve2(cwd, compilerOptions.baseUrl ?? ".");
|
|
399
|
+
tsconfigAliasCache = {
|
|
400
|
+
aliases: normalizeAliasEntries(compilerOptions.paths),
|
|
401
|
+
baseUrl,
|
|
402
|
+
cwd
|
|
403
|
+
};
|
|
404
|
+
} catch {
|
|
405
|
+
tsconfigAliasCache = empty;
|
|
406
|
+
}
|
|
407
|
+
return tsconfigAliasCache;
|
|
408
|
+
}, getAliasEntries = (config) => {
|
|
409
|
+
const tsconfig = readTsconfigAliases();
|
|
410
|
+
return {
|
|
411
|
+
aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
|
|
412
|
+
baseUrl: tsconfig.baseUrl
|
|
413
|
+
};
|
|
414
|
+
}, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
|
|
415
|
+
const { aliases, baseUrl } = getAliasEntries(config);
|
|
416
|
+
const targets = [];
|
|
417
|
+
for (const alias of aliases) {
|
|
418
|
+
const match = specifier.match(aliasPatternToRegExp(alias.pattern));
|
|
419
|
+
if (!match)
|
|
420
|
+
continue;
|
|
421
|
+
const wildcard = match[1] ?? "";
|
|
422
|
+
for (const replacement of alias.replacements) {
|
|
423
|
+
targets.push(resolve2(baseUrl, replacement.replace("*", wildcard)));
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
return targets;
|
|
427
|
+
}, getLanguageExtensions = (language) => {
|
|
428
|
+
if (language === "less")
|
|
429
|
+
return [".less", ".css"];
|
|
430
|
+
if (language === "stylus")
|
|
431
|
+
return [".styl", ".stylus", ".css"];
|
|
432
|
+
return [".scss", ".sass", ".css"];
|
|
433
|
+
}, getCandidatePaths = (basePath, language) => {
|
|
434
|
+
const ext = extname(basePath);
|
|
435
|
+
const paths = ext ? [basePath] : getLanguageExtensions(language).flatMap((extension) => [
|
|
436
|
+
`${basePath}${extension}`,
|
|
437
|
+
join2(basePath, `index${extension}`)
|
|
438
|
+
]);
|
|
439
|
+
if (language === "scss" || language === "sass") {
|
|
440
|
+
return paths.flatMap((path) => {
|
|
441
|
+
const dir = dirname(path);
|
|
442
|
+
const base = path.slice(dir.length + 1);
|
|
443
|
+
return [path, join2(dir, `_${base}`)];
|
|
444
|
+
});
|
|
445
|
+
}
|
|
446
|
+
return paths;
|
|
447
|
+
}, resolveImportPath = (specifier, fromDirectory, loadPaths, language, config) => {
|
|
448
|
+
const rawCandidates = [
|
|
449
|
+
...resolveAliasTargets(specifier, config),
|
|
450
|
+
isAbsolute(specifier) ? specifier : resolve2(fromDirectory, specifier),
|
|
451
|
+
...loadPaths.map((path) => resolve2(path, specifier))
|
|
452
|
+
];
|
|
453
|
+
for (const candidate of rawCandidates.flatMap((path) => getCandidatePaths(path, language))) {
|
|
454
|
+
if (existsSync2(candidate))
|
|
455
|
+
return candidate;
|
|
456
|
+
}
|
|
457
|
+
return null;
|
|
458
|
+
}, isExternalCssUrl = (url) => /^(?:[a-z][a-z0-9+.-]*:|\/\/|#|\/)/i.test(url), splitCssUrl = (url) => {
|
|
459
|
+
const markerIndex = url.search(/[?#]/);
|
|
460
|
+
if (markerIndex === -1)
|
|
461
|
+
return { marker: "", path: url };
|
|
462
|
+
return {
|
|
463
|
+
marker: url.slice(markerIndex),
|
|
464
|
+
path: url.slice(0, markerIndex)
|
|
465
|
+
};
|
|
466
|
+
}, rebaseCssUrls = (contents, sourceFile, entryFile) => {
|
|
467
|
+
const sourceDir = dirname(sourceFile);
|
|
468
|
+
const entryDir = dirname(entryFile);
|
|
469
|
+
if (sourceDir === entryDir)
|
|
470
|
+
return contents;
|
|
471
|
+
return contents.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, rawUrl) => {
|
|
472
|
+
const trimmedUrl = rawUrl.trim();
|
|
473
|
+
if (!trimmedUrl || isExternalCssUrl(trimmedUrl))
|
|
474
|
+
return match;
|
|
475
|
+
const { marker, path } = splitCssUrl(trimmedUrl);
|
|
476
|
+
const rebased = relative(entryDir, resolve2(sourceDir, path)).replace(/\\/g, "/");
|
|
477
|
+
const normalized = rebased.startsWith(".") ? rebased : `./${rebased}`;
|
|
478
|
+
const nextQuote = quote || '"';
|
|
479
|
+
return `url(${nextQuote}${normalized}${marker}${nextQuote})`;
|
|
480
|
+
});
|
|
481
|
+
}, rewriteAliasedStyleImports = (contents, sourceFile, loadPaths, language, config) => contents.replace(/(@(?:use|forward|import|require)\s+)(["'])([^"']+)\2/g, (match, prefix, quote, specifier) => {
|
|
482
|
+
if (specifier.startsWith(".") || isAbsolute(specifier) || isExternalCssUrl(specifier))
|
|
483
|
+
return match;
|
|
484
|
+
const resolved = resolveImportPath(specifier, dirname(sourceFile), loadPaths, language, config);
|
|
485
|
+
return resolved ? `${prefix}${quote}${resolved}${quote}` : match;
|
|
486
|
+
}), preprocessLoadedStyle = (contents, sourceFile, entryFile, loadPaths = [], language, config) => {
|
|
487
|
+
const rebased = rebaseCssUrls(contents, sourceFile, entryFile);
|
|
488
|
+
return language ? rewriteAliasedStyleImports(rebased, sourceFile, loadPaths, language, config) : rebased;
|
|
489
|
+
}, extractCssModuleExports = (css) => {
|
|
490
|
+
const exports = {};
|
|
491
|
+
const nextCss = css.replace(/:export\s*\{([^}]*)\}/g, (_, body) => {
|
|
492
|
+
for (const declaration of body.split(";")) {
|
|
493
|
+
const separator = declaration.indexOf(":");
|
|
494
|
+
if (separator === -1)
|
|
495
|
+
continue;
|
|
496
|
+
const key = declaration.slice(0, separator).trim();
|
|
497
|
+
const value = declaration.slice(separator + 1).trim();
|
|
498
|
+
if (key && value)
|
|
499
|
+
exports[key] = value;
|
|
500
|
+
}
|
|
501
|
+
return "";
|
|
502
|
+
});
|
|
503
|
+
return { css: nextCss, exports };
|
|
504
|
+
}, getSassOptions = (config, language) => ({
|
|
505
|
+
...config?.sass ?? {},
|
|
506
|
+
...language === "scss" ? config?.scss ?? {} : {}
|
|
507
|
+
}), getLessOptions = (config) => config?.less ?? {}, getStylusOptions = (config) => config?.stylus ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
|
|
508
|
+
${contents}` : contents, createSassImporter = (entryFile, loadPaths, language, config) => ({
|
|
509
|
+
canonicalize(specifier, options) {
|
|
510
|
+
const fromDirectory = options.containingUrl ? dirname(fileURLToPath(options.containingUrl)) : dirname(entryFile);
|
|
511
|
+
const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
|
|
512
|
+
return resolved ? new URL(`file://${resolved}`) : null;
|
|
513
|
+
},
|
|
514
|
+
load(canonicalUrl) {
|
|
515
|
+
const filePath = fileURLToPath(canonicalUrl);
|
|
516
|
+
const fileLanguage = getStyleLanguage(filePath);
|
|
517
|
+
if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
|
|
518
|
+
return null;
|
|
519
|
+
return {
|
|
520
|
+
contents: preprocessLoadedStyle(readFileSync2(filePath, "utf-8"), filePath, entryFile, loadPaths, language, config),
|
|
521
|
+
syntax: filePath.endsWith(".sass") ? "indented" : "scss"
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
}), createLessFileManager = (entryFile, loadPaths, config) => ({
|
|
525
|
+
install(less, pluginManager) {
|
|
526
|
+
const baseManager = new less.FileManager;
|
|
527
|
+
const manager = Object.create(baseManager);
|
|
528
|
+
manager.supports = (filename, currentDirectory) => Boolean(resolveImportPath(filename, resolve2(currentDirectory), loadPaths, "less", config));
|
|
529
|
+
manager.loadFile = async (filename, currentDirectory) => {
|
|
530
|
+
const resolved = resolveImportPath(filename, resolve2(currentDirectory), loadPaths, "less", config);
|
|
531
|
+
if (!resolved) {
|
|
532
|
+
throw new Error(`Unable to resolve Less import "${filename}"`);
|
|
533
|
+
}
|
|
534
|
+
return {
|
|
535
|
+
contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
|
|
536
|
+
filename: resolved
|
|
537
|
+
};
|
|
538
|
+
};
|
|
539
|
+
pluginManager.addFileManager(manager);
|
|
540
|
+
}
|
|
541
|
+
}), renderStylus = async (contents, filePath, loadPaths, options) => {
|
|
542
|
+
let stylus;
|
|
543
|
+
try {
|
|
544
|
+
const stylusModule = await importOptionalPeer("stylus");
|
|
545
|
+
stylus = stylusModule.default ?? stylusModule;
|
|
546
|
+
} catch {
|
|
547
|
+
throw missingDependencyError("stylus", filePath);
|
|
548
|
+
}
|
|
549
|
+
return new Promise((resolveCss, reject) => {
|
|
550
|
+
const renderer = stylus(contents);
|
|
551
|
+
renderer.set("filename", filePath);
|
|
552
|
+
for (const [key, value] of Object.entries(options.options ?? {})) {
|
|
553
|
+
renderer.set(key, value);
|
|
554
|
+
}
|
|
555
|
+
for (const path of loadPaths)
|
|
556
|
+
renderer.include(path);
|
|
557
|
+
renderer.render((error, css) => {
|
|
558
|
+
if (error)
|
|
559
|
+
reject(error);
|
|
560
|
+
else
|
|
561
|
+
resolveCss(css ?? "");
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
}, compileStyleSource = async (filePath, source, languageHint, config) => {
|
|
375
565
|
const language = getStyleLanguage(languageHint ?? filePath);
|
|
376
|
-
const
|
|
566
|
+
const rawContents = source ?? await readFile(filePath, "utf-8");
|
|
377
567
|
if (language === "scss" || language === "sass") {
|
|
568
|
+
const options = getSassOptions(config, language);
|
|
569
|
+
const packageName = options.implementation ?? "sass";
|
|
378
570
|
let sass;
|
|
379
571
|
try {
|
|
380
|
-
sass = await importOptionalPeer(
|
|
572
|
+
sass = await importOptionalPeer(packageName);
|
|
381
573
|
} catch {
|
|
382
|
-
throw missingDependencyError(
|
|
574
|
+
throw missingDependencyError(packageName, filePath);
|
|
383
575
|
}
|
|
576
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
577
|
+
const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
|
|
384
578
|
const result = sass.compileString(contents, {
|
|
385
|
-
|
|
579
|
+
importers: [
|
|
580
|
+
createSassImporter(filePath, loadPaths, language, config)
|
|
581
|
+
],
|
|
582
|
+
loadPaths,
|
|
386
583
|
style: "expanded",
|
|
387
584
|
syntax: language === "sass" ? "indented" : "scss",
|
|
388
585
|
url: new URL(`file://${filePath}`)
|
|
@@ -390,6 +587,7 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
390
587
|
return result.css;
|
|
391
588
|
}
|
|
392
589
|
if (language === "less") {
|
|
590
|
+
const options = getLessOptions(config);
|
|
393
591
|
let lessModule;
|
|
394
592
|
try {
|
|
395
593
|
lessModule = await importOptionalPeer("less");
|
|
@@ -400,14 +598,63 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
400
598
|
const render = less?.render;
|
|
401
599
|
if (!render)
|
|
402
600
|
throw missingDependencyError("less", filePath);
|
|
601
|
+
const contents = withAdditionalData(rawContents, options.additionalData);
|
|
602
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
403
603
|
const result = await render(contents, {
|
|
604
|
+
...options.options ?? {},
|
|
404
605
|
filename: filePath,
|
|
405
|
-
paths:
|
|
606
|
+
paths: loadPaths,
|
|
607
|
+
plugins: [
|
|
608
|
+
...options.options?.plugins ?? [],
|
|
609
|
+
createLessFileManager(filePath, loadPaths, config)
|
|
610
|
+
]
|
|
406
611
|
});
|
|
407
612
|
return result.css;
|
|
408
613
|
}
|
|
409
|
-
|
|
410
|
-
|
|
614
|
+
if (language === "stylus") {
|
|
615
|
+
const options = getStylusOptions(config);
|
|
616
|
+
const loadPaths = normalizeLoadPaths(filePath, options.paths);
|
|
617
|
+
const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
|
|
618
|
+
return renderStylus(contents, filePath, loadPaths, options);
|
|
619
|
+
}
|
|
620
|
+
return rawContents;
|
|
621
|
+
}, createStylePreprocessorPlugin = (config) => ({
|
|
622
|
+
name: "absolute-style-preprocessor",
|
|
623
|
+
setup(build) {
|
|
624
|
+
const cssModuleSources = new Map;
|
|
625
|
+
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
626
|
+
namespace: "absolute-style-module",
|
|
627
|
+
path: path.slice("absolute-style-module:".length)
|
|
628
|
+
}));
|
|
629
|
+
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
630
|
+
const source = cssModuleSources.get(path);
|
|
631
|
+
if (!source) {
|
|
632
|
+
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
633
|
+
}
|
|
634
|
+
return {
|
|
635
|
+
contents: source.css,
|
|
636
|
+
loader: "css"
|
|
637
|
+
};
|
|
638
|
+
});
|
|
639
|
+
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
640
|
+
if (isStyleModulePath(path)) {
|
|
641
|
+
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
642
|
+
const compiled = await compileStyleSource(path, undefined, undefined, config);
|
|
643
|
+
const { css, exports } = extractCssModuleExports(compiled);
|
|
644
|
+
cssModuleSources.set(cssModulePath, { css, exports });
|
|
645
|
+
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}`)};`;
|
|
646
|
+
return {
|
|
647
|
+
contents: exportSource,
|
|
648
|
+
loader: "js"
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
return {
|
|
652
|
+
contents: await compileStyleSource(path, undefined, undefined, config),
|
|
653
|
+
loader: "css"
|
|
654
|
+
};
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
}), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
|
|
411
658
|
style: async ({
|
|
412
659
|
attributes,
|
|
413
660
|
content,
|
|
@@ -418,63 +665,30 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
|
|
|
418
665
|
return;
|
|
419
666
|
const path = filename ?? `style.${language}`;
|
|
420
667
|
return {
|
|
421
|
-
code: await compileStyleSource(path, content, language)
|
|
668
|
+
code: await compileStyleSource(path, content, language, config)
|
|
422
669
|
};
|
|
423
670
|
}
|
|
424
|
-
}), compileStyleFileIfNeeded = async (filePath) => {
|
|
671
|
+
}), compileStyleFileIfNeeded = async (filePath, config) => {
|
|
425
672
|
if (!isPreprocessableStylePath(filePath)) {
|
|
426
673
|
return readFile(filePath, "utf-8");
|
|
427
674
|
}
|
|
428
|
-
return compileStyleSource(filePath);
|
|
675
|
+
return compileStyleSource(filePath, undefined, undefined, config);
|
|
429
676
|
};
|
|
430
677
|
var init_stylePreprocessor = __esm(() => {
|
|
431
|
-
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
|
|
432
|
-
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less)$/i;
|
|
433
|
-
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less)$/i;
|
|
678
|
+
STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
679
|
+
STYLE_MODULE_EXTENSION_PATTERN = /\.module\.(s[ac]ss|less|styl(?:us)?)$/i;
|
|
680
|
+
STYLE_LANGUAGE_PATTERN = /^(s[ac]ss|less|styl(?:us)?)$/i;
|
|
434
681
|
importOptionalPeer = new Function("specifier", "return import(specifier)");
|
|
435
682
|
requireOptionalPeer = new Function("specifier", "return require(specifier)");
|
|
436
683
|
requireFromCwd = createRequire(join2(process.cwd(), "package.json"));
|
|
437
|
-
stylePreprocessorPlugin =
|
|
438
|
-
name: "absolute-style-preprocessor",
|
|
439
|
-
setup(build) {
|
|
440
|
-
const cssModuleSources = new Map;
|
|
441
|
-
build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
|
|
442
|
-
namespace: "absolute-style-module",
|
|
443
|
-
path: path.slice("absolute-style-module:".length)
|
|
444
|
-
}));
|
|
445
|
-
build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
|
|
446
|
-
const sourcePath = cssModuleSources.get(path);
|
|
447
|
-
if (!sourcePath) {
|
|
448
|
-
throw new Error(`Unable to resolve CSS module source for ${path}`);
|
|
449
|
-
}
|
|
450
|
-
return {
|
|
451
|
-
contents: await compileStyleSource(sourcePath),
|
|
452
|
-
loader: "css"
|
|
453
|
-
};
|
|
454
|
-
});
|
|
455
|
-
build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
|
|
456
|
-
if (isStyleModulePath(path)) {
|
|
457
|
-
const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
|
|
458
|
-
cssModuleSources.set(cssModulePath, path);
|
|
459
|
-
return {
|
|
460
|
-
contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
|
|
461
|
-
loader: "js"
|
|
462
|
-
};
|
|
463
|
-
}
|
|
464
|
-
return {
|
|
465
|
-
contents: await compileStyleSource(path),
|
|
466
|
-
loader: "css"
|
|
467
|
-
};
|
|
468
|
-
});
|
|
469
|
-
}
|
|
470
|
-
};
|
|
684
|
+
stylePreprocessorPlugin = createStylePreprocessorPlugin();
|
|
471
685
|
});
|
|
472
686
|
|
|
473
687
|
// src/core/svelteServerModule.ts
|
|
474
688
|
import { mkdir, readdir } from "fs/promises";
|
|
475
|
-
import { basename, dirname as dirname2, extname as extname2, join as join3, relative, resolve as
|
|
689
|
+
import { basename, dirname as dirname2, extname as extname2, join as join3, relative as relative2, resolve as resolve3 } from "path";
|
|
476
690
|
var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
|
|
477
|
-
const importPath =
|
|
691
|
+
const importPath = relative2(dirname2(from), target).replace(/\\/g, "/");
|
|
478
692
|
return importPath.startsWith(".") ? importPath : `./${importPath}`;
|
|
479
693
|
}, processDirectoryEntries = (entries, dir, targetFileName, stack) => {
|
|
480
694
|
for (const entry of entries) {
|
|
@@ -520,7 +734,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
520
734
|
if (!spec.startsWith(".")) {
|
|
521
735
|
return null;
|
|
522
736
|
}
|
|
523
|
-
const basePath =
|
|
737
|
+
const basePath = resolve3(dirname2(from), spec);
|
|
524
738
|
const candidates = [
|
|
525
739
|
basePath,
|
|
526
740
|
`${basePath}.ts`,
|
|
@@ -538,7 +752,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
538
752
|
const foundIndex = existResults.indexOf(true);
|
|
539
753
|
return foundIndex >= 0 ? candidates[foundIndex] ?? null : null;
|
|
540
754
|
}, getCachedModulePath = (sourcePath) => {
|
|
541
|
-
const relativeSourcePath =
|
|
755
|
+
const relativeSourcePath = relative2(process.cwd(), sourcePath).replace(/\\/g, "/");
|
|
542
756
|
const normalizedSourcePath = relativeSourcePath.startsWith("..") ? sourcePath.replace(/[:\\/]/g, "_") : relativeSourcePath;
|
|
543
757
|
return join3(serverCacheRoot, `${normalizedSourcePath}.server.js`);
|
|
544
758
|
}, resolveSvelteImport = async (spec, from) => {
|
|
@@ -552,7 +766,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
|
|
|
552
766
|
if (!spec.startsWith(".")) {
|
|
553
767
|
return null;
|
|
554
768
|
}
|
|
555
|
-
const explicitPath =
|
|
769
|
+
const explicitPath = resolve3(dirname2(from), spec);
|
|
556
770
|
if (extname2(explicitPath) === ".svelte") {
|
|
557
771
|
return explicitPath;
|
|
558
772
|
}
|
|
@@ -1736,12 +1950,12 @@ var init_startupBanner = __esm(() => {
|
|
|
1736
1950
|
// src/utils/logger.ts
|
|
1737
1951
|
var colors2, frameworkColors, formatPath = (filePath) => {
|
|
1738
1952
|
const cwd = process.cwd();
|
|
1739
|
-
let
|
|
1740
|
-
|
|
1741
|
-
if (!
|
|
1742
|
-
|
|
1953
|
+
let relative3 = filePath.startsWith(cwd) ? filePath.slice(cwd.length + 1) : filePath;
|
|
1954
|
+
relative3 = relative3.replace(/\\/g, "/");
|
|
1955
|
+
if (!relative3.startsWith("/")) {
|
|
1956
|
+
relative3 = `/${relative3}`;
|
|
1743
1957
|
}
|
|
1744
|
-
return
|
|
1958
|
+
return relative3;
|
|
1745
1959
|
}, getFrameworkColor = (framework) => frameworkColors[framework] || colors2.white, log = (action, options) => {
|
|
1746
1960
|
const timestamp = `${colors2.dim}${formatTimestamp()}${colors2.reset}`;
|
|
1747
1961
|
const tag = `${colors2.cyan}[hmr]${colors2.reset}`;
|
|
@@ -2287,5 +2501,5 @@ export {
|
|
|
2287
2501
|
handleSveltePageRequest
|
|
2288
2502
|
};
|
|
2289
2503
|
|
|
2290
|
-
//# debugId=
|
|
2504
|
+
//# debugId=B4B4A0E1AC4FA91264756E2164756E21
|
|
2291
2505
|
//# sourceMappingURL=server.js.map
|