@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
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CompilerOptions } from '@angular/compiler-cli';
|
|
2
2
|
import ts from 'typescript';
|
|
3
|
+
import type { StylePreprocessorConfig } from '../../types/build';
|
|
3
4
|
type AngularCompilerCache = {
|
|
4
5
|
host: ts.CompilerHost;
|
|
5
6
|
options: CompilerOptions;
|
|
@@ -10,14 +11,14 @@ type AngularCompilerCache = {
|
|
|
10
11
|
declare global {
|
|
11
12
|
var __angularCompilerCache: AngularCompilerCache | undefined;
|
|
12
13
|
}
|
|
13
|
-
export declare const compileAngularFile: (inputPath: string, outDir: string) => Promise<string[]>;
|
|
14
|
+
export declare const compileAngularFile: (inputPath: string, outDir: string, stylePreprocessors?: StylePreprocessorConfig) => Promise<string[]>;
|
|
14
15
|
/** Angular HMR Runtime Layer (Level 3) — JIT-mode compilation for dev/HMR builds.
|
|
15
16
|
* Uses ts.transpileModule() instead of Angular AOT performCompilation().
|
|
16
17
|
* Inlines templateUrl → template and styleUrls → styles from disk.
|
|
17
18
|
* Recursively transpiles all local imports so Bun's bundler can resolve them.
|
|
18
19
|
* ~50-100ms for a tree of ~10 files vs ~500-700ms for AOT. */
|
|
19
|
-
export declare const compileAngularFileJIT: (inputPath: string, outDir: string, rootDir?: string) => Promise<string[]>;
|
|
20
|
-
export declare const compileAngular: (entryPoints: string[], outRoot: string, hmr?: boolean) => Promise<{
|
|
20
|
+
export declare const compileAngularFileJIT: (inputPath: string, outDir: string, rootDir?: string, stylePreprocessors?: StylePreprocessorConfig) => Promise<string[]>;
|
|
21
|
+
export declare const compileAngular: (entryPoints: string[], outRoot: string, hmr?: boolean, stylePreprocessors?: StylePreprocessorConfig) => Promise<{
|
|
21
22
|
clientPaths: string[];
|
|
22
23
|
serverPaths: string[];
|
|
23
24
|
allIndexesUnchanged?: undefined;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StylePreprocessorConfig } from '../../types/build';
|
|
1
2
|
type Built = {
|
|
2
3
|
ssr: string;
|
|
3
4
|
client: string;
|
|
@@ -5,7 +6,7 @@ type Built = {
|
|
|
5
6
|
};
|
|
6
7
|
type Cache = Map<string, Built>;
|
|
7
8
|
export declare const clearSvelteCompilerCache: () => void;
|
|
8
|
-
export declare const compileSvelte: (entryPoints: string[], svelteRoot: string, cache?: Cache, isDev?: boolean) => Promise<{
|
|
9
|
+
export declare const compileSvelte: (entryPoints: string[], svelteRoot: string, cache?: Cache, isDev?: boolean, stylePreprocessors?: StylePreprocessorConfig) => Promise<{
|
|
9
10
|
svelteClientPaths: string[];
|
|
10
11
|
svelteIndexPaths: string[];
|
|
11
12
|
svelteServerPaths: string[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SFCDescriptor } from '@vue/compiler-sfc';
|
|
2
|
+
import type { StylePreprocessorConfig } from '../../types/build';
|
|
2
3
|
export type VueChangeType = 'style-only' | 'template-only' | 'script' | 'full';
|
|
3
4
|
export declare const vueHmrMetadata: Map<string, {
|
|
4
5
|
hmrId: string;
|
|
@@ -7,7 +8,7 @@ export declare const vueHmrMetadata: Map<string, {
|
|
|
7
8
|
export declare const clearVueHmrCaches: () => void;
|
|
8
9
|
export declare const detectVueChangeType: (filePath: string, descriptor: SFCDescriptor) => "script" | "template-only" | "full" | "style-only";
|
|
9
10
|
export declare const generateVueHmrId: (sourceFilePath: string, vueRootDir: string) => string;
|
|
10
|
-
export declare const compileVue: (entryPoints: string[], vueRootDir: string, isDev?: boolean) => Promise<{
|
|
11
|
+
export declare const compileVue: (entryPoints: string[], vueRootDir: string, isDev?: boolean, stylePreprocessors?: StylePreprocessorConfig) => Promise<{
|
|
11
12
|
hmrMetadata: Map<string, {
|
|
12
13
|
hmrId: string;
|
|
13
14
|
changeType: VueChangeType;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import type { BunPlugin } from 'bun';
|
|
2
|
+
import type { StylePreprocessorConfig } from '../../types/build';
|
|
2
3
|
export declare const isPreprocessableStylePath: (filePath: string) => boolean;
|
|
3
4
|
export declare const isStyleModulePath: (filePath: string) => boolean;
|
|
4
5
|
export declare const isStylePath: (filePath: string) => boolean;
|
|
5
6
|
export declare const getStyleBaseName: (filePath: string) => string;
|
|
6
|
-
export declare const compileStyleSource: (filePath: string, source?: string, languageHint?: string) => Promise<string>;
|
|
7
|
+
export declare const compileStyleSource: (filePath: string, source?: string, languageHint?: string, config?: StylePreprocessorConfig) => Promise<string>;
|
|
8
|
+
export declare const createStylePreprocessorPlugin: (config?: StylePreprocessorConfig) => BunPlugin;
|
|
7
9
|
export declare const stylePreprocessorPlugin: BunPlugin;
|
|
8
|
-
export declare const createSvelteStylePreprocessor: () => {
|
|
10
|
+
export declare const createSvelteStylePreprocessor: (config?: StylePreprocessorConfig) => {
|
|
9
11
|
style: ({ attributes, content, filename }: {
|
|
10
12
|
attributes: Record<string, string | boolean>;
|
|
11
13
|
content: string;
|
|
@@ -14,6 +16,6 @@ export declare const createSvelteStylePreprocessor: () => {
|
|
|
14
16
|
code: string;
|
|
15
17
|
} | undefined>;
|
|
16
18
|
};
|
|
17
|
-
export declare const compileStyleFileIfNeeded: (filePath: string) => Promise<string>;
|
|
18
|
-
export declare const compileStyleFileIfNeededSync: (filePath: string) => string;
|
|
19
|
+
export declare const compileStyleFileIfNeeded: (filePath: string, config?: StylePreprocessorConfig) => Promise<string>;
|
|
20
|
+
export declare const compileStyleFileIfNeededSync: (filePath: string, config?: StylePreprocessorConfig) => string;
|
|
19
21
|
export declare const getCssOutputExtension: (filePath: string) => string;
|
package/dist/src/core/build.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ConventionsMap } from '../../types/conventions';
|
|
2
2
|
import type { BuildConfig } from '../../types/build';
|
|
3
|
-
export declare const build: ({ buildDirectory, assetsDirectory, publicDirectory, islands, reactDirectory, htmlDirectory, htmxDirectory, angularDirectory, svelteDirectory, vueDirectory, stylesConfig, tailwind, options, incrementalFiles, mode }: BuildConfig) => Promise<{
|
|
3
|
+
export declare const build: ({ buildDirectory, assetsDirectory, publicDirectory, islands, reactDirectory, htmlDirectory, htmxDirectory, angularDirectory, svelteDirectory, vueDirectory, stylesConfig, stylePreprocessors, tailwind, options, incrementalFiles, mode }: BuildConfig) => Promise<{
|
|
4
4
|
conventions?: undefined;
|
|
5
5
|
manifest?: undefined;
|
|
6
6
|
} | {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { StylePreprocessorConfig } from '../../types/build';
|
|
1
2
|
type ModuleServerConfig = {
|
|
2
3
|
projectRoot: string;
|
|
3
4
|
vendorPaths: Record<string, string>;
|
|
@@ -7,6 +8,7 @@ type ModuleServerConfig = {
|
|
|
7
8
|
svelte?: string;
|
|
8
9
|
vue?: string;
|
|
9
10
|
};
|
|
11
|
+
stylePreprocessors?: StylePreprocessorConfig;
|
|
10
12
|
};
|
|
11
13
|
export declare const warmCompilers: (frameworks: {
|
|
12
14
|
svelte?: boolean;
|
package/dist/svelte/index.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}`;
|
|
@@ -2282,8 +2496,8 @@ var init_pageHandler = __esm(() => {
|
|
|
2282
2496
|
});
|
|
2283
2497
|
|
|
2284
2498
|
// src/angular/injectorPatch.ts
|
|
2285
|
-
import { existsSync as
|
|
2286
|
-
import { dirname as dirname3, join as join4, resolve as
|
|
2499
|
+
import { existsSync as existsSync3, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
2500
|
+
import { dirname as dirname3, join as join4, resolve as resolve4 } from "path";
|
|
2287
2501
|
var applyInjectorPatch = (chunkPath, content) => {
|
|
2288
2502
|
if (content.includes('Symbol.for("angular.currentInjector")')) {
|
|
2289
2503
|
return;
|
|
@@ -2319,8 +2533,8 @@ var applyInjectorPatch = (chunkPath, content) => {
|
|
|
2319
2533
|
}
|
|
2320
2534
|
writeFileSync(chunkPath, patched, "utf-8");
|
|
2321
2535
|
}, resolveAngularCoreDir = () => {
|
|
2322
|
-
const fromProject =
|
|
2323
|
-
if (
|
|
2536
|
+
const fromProject = resolve4(process.cwd(), "node_modules/@angular/core");
|
|
2537
|
+
if (existsSync3(join4(fromProject, "package.json"))) {
|
|
2324
2538
|
return fromProject;
|
|
2325
2539
|
}
|
|
2326
2540
|
return dirname3(__require.resolve("@angular/core/package.json"));
|
|
@@ -2328,7 +2542,7 @@ var applyInjectorPatch = (chunkPath, content) => {
|
|
|
2328
2542
|
try {
|
|
2329
2543
|
const coreDir = resolveAngularCoreDir();
|
|
2330
2544
|
const chunkPath = join4(coreDir, "fesm2022", "_not_found-chunk.mjs");
|
|
2331
|
-
const content =
|
|
2545
|
+
const content = readFileSync3(chunkPath, "utf-8");
|
|
2332
2546
|
applyInjectorPatch(chunkPath, content);
|
|
2333
2547
|
} catch {}
|
|
2334
2548
|
};
|
|
@@ -2337,11 +2551,11 @@ var init_injectorPatch = __esm(() => {
|
|
|
2337
2551
|
});
|
|
2338
2552
|
|
|
2339
2553
|
// src/angular/resolveAngularPackage.ts
|
|
2340
|
-
import { existsSync as
|
|
2341
|
-
import { resolve as
|
|
2554
|
+
import { existsSync as existsSync4 } from "fs";
|
|
2555
|
+
import { resolve as resolve5 } from "path";
|
|
2342
2556
|
var resolveAngularPackage = (specifier) => {
|
|
2343
|
-
const fromProject =
|
|
2344
|
-
if (
|
|
2557
|
+
const fromProject = resolve5(process.cwd(), "node_modules", specifier);
|
|
2558
|
+
if (existsSync4(fromProject)) {
|
|
2345
2559
|
return fromProject;
|
|
2346
2560
|
}
|
|
2347
2561
|
return specifier;
|
|
@@ -3160,5 +3374,5 @@ export {
|
|
|
3160
3374
|
createTypedIsland
|
|
3161
3375
|
};
|
|
3162
3376
|
|
|
3163
|
-
//# debugId=
|
|
3377
|
+
//# debugId=436071CA69710DBB64756E2164756E21
|
|
3164
3378
|
//# sourceMappingURL=index.js.map
|