@absolutejs/absolute 0.19.0-beta.781 → 0.19.0-beta.783

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.
@@ -1009,11 +1009,14 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
1009
1009
  var exports_stylePreprocessor = {};
1010
1010
  __export(exports_stylePreprocessor, {
1011
1011
  stylePreprocessorPlugin: () => stylePreprocessorPlugin,
1012
+ recordStyleOutput: () => recordStyleOutput,
1012
1013
  isStylePath: () => isStylePath,
1013
1014
  isStyleModulePath: () => isStyleModulePath,
1014
1015
  isPreprocessableStylePath: () => isPreprocessableStylePath,
1015
1016
  getStyleBaseName: () => getStyleBaseName,
1016
1017
  getCssOutputExtension: () => getCssOutputExtension,
1018
+ forgetStyleEntry: () => forgetStyleEntry,
1019
+ findStyleEntriesImporting: () => findStyleEntriesImporting,
1017
1020
  createSvelteStylePreprocessor: () => createSvelteStylePreprocessor,
1018
1021
  createStyleTransformConfig: () => createStyleTransformConfig,
1019
1022
  createStylePreprocessorPlugin: () => createStylePreprocessorPlugin,
@@ -1021,10 +1024,18 @@ __export(exports_stylePreprocessor, {
1021
1024
  compileStyleFileIfNeededSync: () => compileStyleFileIfNeededSync,
1022
1025
  compileStyleFileIfNeeded: () => compileStyleFileIfNeeded
1023
1026
  });
1027
+ import { createHash } from "crypto";
1024
1028
  import { existsSync as existsSync4, readFileSync as readFileSync4 } from "fs";
1025
1029
  import { readFile } from "fs/promises";
1026
1030
  import { createRequire } from "module";
1027
- import { dirname as dirname2, extname, isAbsolute, join as join4, relative, resolve as resolve3 } from "path";
1031
+ import {
1032
+ dirname as dirname2,
1033
+ extname,
1034
+ isAbsolute,
1035
+ join as join4,
1036
+ relative,
1037
+ resolve as resolve3
1038
+ } from "path";
1028
1039
  import { fileURLToPath } from "url";
1029
1040
  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) => {
1030
1041
  const normalized = filePathOrLanguage.toLowerCase();
@@ -1037,7 +1048,22 @@ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTE
1037
1048
  if (normalized === "styl" || normalized === "stylus" || normalized.endsWith(".styl") || normalized.endsWith(".stylus"))
1038
1049
  return "stylus";
1039
1050
  return null;
1040
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), requireOptionalPeerSync = (specifier) => {
1051
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), throwPreprocessorError = (error, filePath, language) => {
1052
+ if (!(error instanceof Error)) {
1053
+ throw new Error(`${language} compile failed in ${filePath}: ${String(error)}`);
1054
+ }
1055
+ const detail = error;
1056
+ const sassLine = detail.span?.start?.line;
1057
+ const sassCol = detail.span?.start?.column;
1058
+ const line = detail.line ?? sassLine;
1059
+ const column = detail.column ?? sassCol;
1060
+ const location = typeof line === "number" ? `:${line}${typeof column === "number" ? `:${column}` : ""}` : "";
1061
+ const message = detail.formatted ?? detail.message;
1062
+ const wrapped = new Error(`${language} compile failed in ${filePath}${location}
1063
+ ${message}`);
1064
+ wrapped.cause = error;
1065
+ throw wrapped;
1066
+ }, requireOptionalPeerSync = (specifier) => {
1041
1067
  try {
1042
1068
  return requireFromCwd(specifier);
1043
1069
  } catch {
@@ -1076,7 +1102,10 @@ var CSS_EXTENSION_PATTERN, STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTE
1076
1102
  }, getAliasEntries = (config) => {
1077
1103
  const tsconfig = readTsconfigAliases();
1078
1104
  return {
1079
- aliases: [...normalizeAliasEntries(config?.aliases), ...tsconfig.aliases],
1105
+ aliases: [
1106
+ ...normalizeAliasEntries(config?.aliases),
1107
+ ...tsconfig.aliases
1108
+ ],
1080
1109
  baseUrl: tsconfig.baseUrl
1081
1110
  };
1082
1111
  }, aliasPatternToRegExp = (pattern) => new RegExp(`^${pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("(.+)")}$`), resolveAliasTargets = (specifier, config) => {
@@ -1237,7 +1266,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1237
1266
  ...postcssConfig.options
1238
1267
  });
1239
1268
  return result.css;
1240
- }, createSassImporter = (entryFile, loadPaths, language, config) => ({
1269
+ }, createSassImporter = (entryFile, loadPaths, language, config, deps) => ({
1241
1270
  canonicalize(specifier, options) {
1242
1271
  const fromDirectory = options.containingUrl ? dirname2(fileURLToPath(options.containingUrl)) : dirname2(entryFile);
1243
1272
  const resolved = resolveImportPath(specifier, fromDirectory, loadPaths, language, config);
@@ -1245,6 +1274,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1245
1274
  },
1246
1275
  load(canonicalUrl) {
1247
1276
  const filePath = fileURLToPath(canonicalUrl);
1277
+ deps?.add(filePath);
1248
1278
  const fileLanguage = getStyleLanguage(filePath);
1249
1279
  if (fileLanguage !== "scss" && fileLanguage !== "sass" && fileLanguage !== null)
1250
1280
  return null;
@@ -1253,7 +1283,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1253
1283
  syntax: filePath.endsWith(".sass") ? "indented" : "scss"
1254
1284
  };
1255
1285
  }
1256
- }), createLessFileManager = (entryFile, loadPaths, config) => ({
1286
+ }), createLessFileManager = (entryFile, loadPaths, config, deps) => ({
1257
1287
  install(less, pluginManager) {
1258
1288
  const baseManager = new less.FileManager;
1259
1289
  const manager = Object.create(baseManager);
@@ -1263,6 +1293,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1263
1293
  if (!resolved) {
1264
1294
  throw new Error(`Unable to resolve Less import "${filename}"`);
1265
1295
  }
1296
+ deps?.add(resolved);
1266
1297
  return {
1267
1298
  contents: preprocessLoadedStyle(await readFile(resolved, "utf-8"), resolved, entryFile, loadPaths, "less", config),
1268
1299
  filename: resolved
@@ -1270,7 +1301,7 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1270
1301
  };
1271
1302
  pluginManager.addFileManager(manager);
1272
1303
  }
1273
- }), renderStylus = async (contents, filePath, loadPaths, options) => {
1304
+ }), renderStylus = async (contents, filePath, loadPaths, options, deps) => {
1274
1305
  let stylus;
1275
1306
  try {
1276
1307
  const stylusModule = await importOptionalPeer("stylus");
@@ -1287,15 +1318,51 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1287
1318
  for (const path of loadPaths)
1288
1319
  renderer.include(path);
1289
1320
  renderer.render((error, css) => {
1290
- if (error)
1321
+ if (error) {
1291
1322
  reject(error);
1292
- else
1293
- resolveCss(css ?? "");
1323
+ return;
1324
+ }
1325
+ if (deps) {
1326
+ const stylusDeps = renderer.deps?.();
1327
+ if (Array.isArray(stylusDeps)) {
1328
+ for (const dep of stylusDeps)
1329
+ deps.add(resolve3(dep));
1330
+ }
1331
+ }
1332
+ resolveCss(css ?? "");
1294
1333
  });
1295
1334
  });
1335
+ }, styleDependencyGraph, styleOutputHashes, recordStyleDeps = (entry, deps) => {
1336
+ const key = resolve3(entry);
1337
+ const stripped = new Set;
1338
+ for (const dep of deps) {
1339
+ const resolved = resolve3(dep);
1340
+ if (resolved !== key)
1341
+ stripped.add(resolved);
1342
+ }
1343
+ styleDependencyGraph.set(key, stripped);
1344
+ }, findStyleEntriesImporting = (changedPath) => {
1345
+ const target = resolve3(changedPath);
1346
+ const importers = [];
1347
+ for (const [entry, deps] of styleDependencyGraph) {
1348
+ if (deps.has(target))
1349
+ importers.push(entry);
1350
+ }
1351
+ return importers;
1352
+ }, recordStyleOutput = (entry, css) => {
1353
+ const key = resolve3(entry);
1354
+ const hash = createHash("sha1").update(css).digest("hex");
1355
+ const previous = styleOutputHashes.get(key);
1356
+ styleOutputHashes.set(key, hash);
1357
+ return previous !== hash;
1358
+ }, forgetStyleEntry = (entry) => {
1359
+ const key = resolve3(entry);
1360
+ styleDependencyGraph.delete(key);
1361
+ styleOutputHashes.delete(key);
1296
1362
  }, compileStyleSource = async (filePath, source, languageHint, config) => {
1297
1363
  const language = getStyleLanguage(languageHint ?? filePath);
1298
1364
  const rawContents = source ?? await readFile(filePath, "utf-8");
1365
+ const deps = new Set;
1299
1366
  if (language === "scss" || language === "sass") {
1300
1367
  const options = getSassOptions(config, language);
1301
1368
  const packageName = options.implementation ?? "sass";
@@ -1307,16 +1374,22 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1307
1374
  }
1308
1375
  const contents = withAdditionalData(rawContents, options.additionalData);
1309
1376
  const loadPaths = normalizeLoadPaths(filePath, options.loadPaths);
1310
- const result = sass.compileString(contents, {
1311
- importers: [
1312
- createSassImporter(filePath, loadPaths, language, config)
1313
- ],
1314
- loadPaths,
1315
- style: "expanded",
1316
- syntax: language === "sass" ? "indented" : "scss",
1317
- url: new URL(`file://${filePath}`)
1318
- });
1319
- return runPostcss(result.css, filePath, config);
1377
+ try {
1378
+ const result = sass.compileString(contents, {
1379
+ importers: [
1380
+ createSassImporter(filePath, loadPaths, language, config, deps)
1381
+ ],
1382
+ loadPaths,
1383
+ style: "expanded",
1384
+ syntax: language === "sass" ? "indented" : "scss",
1385
+ url: new URL(`file://${filePath}`)
1386
+ });
1387
+ const css = await runPostcss(result.css, filePath, config);
1388
+ recordStyleDeps(filePath, deps);
1389
+ return css;
1390
+ } catch (error) {
1391
+ throwPreprocessorError(error, filePath, language);
1392
+ }
1320
1393
  }
1321
1394
  if (language === "less") {
1322
1395
  const options = getLessOptions(config);
@@ -1332,22 +1405,34 @@ ${contents}` : contents, normalizePostcssModule = (mod) => {
1332
1405
  throw missingDependencyError("less", filePath);
1333
1406
  const contents = withAdditionalData(rawContents, options.additionalData);
1334
1407
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
1335
- const result = await render(contents, {
1336
- ...options.options ?? {},
1337
- filename: filePath,
1338
- paths: loadPaths,
1339
- plugins: [
1340
- ...options.options?.plugins ?? [],
1341
- createLessFileManager(filePath, loadPaths, config)
1342
- ]
1343
- });
1344
- return runPostcss(result.css, filePath, config);
1408
+ try {
1409
+ const result = await render(contents, {
1410
+ ...options.options ?? {},
1411
+ filename: filePath,
1412
+ paths: loadPaths,
1413
+ plugins: [
1414
+ ...options.options?.plugins ?? [],
1415
+ createLessFileManager(filePath, loadPaths, config, deps)
1416
+ ]
1417
+ });
1418
+ const css = await runPostcss(result.css, filePath, config);
1419
+ recordStyleDeps(filePath, deps);
1420
+ return css;
1421
+ } catch (error) {
1422
+ throwPreprocessorError(error, filePath, "less");
1423
+ }
1345
1424
  }
1346
1425
  if (language === "stylus") {
1347
1426
  const options = getStylusOptions(config);
1348
1427
  const loadPaths = normalizeLoadPaths(filePath, options.paths);
1349
1428
  const contents = withAdditionalData(preprocessLoadedStyle(rawContents, filePath, filePath, loadPaths, "stylus", config), options.additionalData);
1350
- return runPostcss(await renderStylus(contents, filePath, loadPaths, options), filePath, config);
1429
+ try {
1430
+ const css = await runPostcss(await renderStylus(contents, filePath, loadPaths, options, deps), filePath, config);
1431
+ recordStyleDeps(filePath, deps);
1432
+ return css;
1433
+ } catch (error) {
1434
+ throwPreprocessorError(error, filePath, "stylus");
1435
+ }
1351
1436
  }
1352
1437
  return runPostcss(rawContents, filePath, config);
1353
1438
  }, createStylePreprocessorPlugin = (config) => ({
@@ -1452,6 +1537,8 @@ var init_stylePreprocessor = __esm(() => {
1452
1537
  importOptionalPeer = new Function("specifier", "return import(specifier)");
1453
1538
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
1454
1539
  requireFromCwd = createRequire(join4(process.cwd(), "package.json"));
1540
+ styleDependencyGraph = new Map;
1541
+ styleOutputHashes = new Map;
1455
1542
  stylePreprocessorPlugin = createStylePreprocessorPlugin();
1456
1543
  });
1457
1544
 
@@ -1904,5 +1991,5 @@ export {
1904
1991
  createIslandStore
1905
1992
  };
1906
1993
 
1907
- //# debugId=9B407368C3733D6664756E2164756E21
1994
+ //# debugId=9DD653AD3479FFA464756E2164756E21
1908
1995
  //# sourceMappingURL=index.js.map