@absolutejs/absolute 0.19.0-beta.692 → 0.19.0-beta.693

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.
@@ -2504,7 +2504,7 @@ var init_lowerAwaitSlotSyntax = __esm(() => {
2504
2504
  // src/build/stylePreprocessor.ts
2505
2505
  import { readFile } from "fs/promises";
2506
2506
  import { createRequire } from "module";
2507
- import { dirname as dirname2, extname, join as join3 } from "path";
2507
+ import { dirname as dirname2, extname, join as join3, resolve as resolve4 } from "path";
2508
2508
  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)$/i.test(filePath), getStyleBaseName = (filePath) => filePath.replace(/\.(css|s[ac]ss|less)$/i, ""), getStyleLanguage = (filePathOrLanguage) => {
2509
2509
  const normalized = filePathOrLanguage.toLowerCase();
2510
2510
  if (normalized === "scss" || normalized.endsWith(".scss"))
@@ -2514,18 +2514,29 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2514
2514
  if (normalized === "less" || normalized.endsWith(".less"))
2515
2515
  return "less";
2516
2516
  return null;
2517
- }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), compileStyleSource = async (filePath, source, languageHint) => {
2517
+ }, missingDependencyError = (name, filePath) => new Error(`Unable to compile ${filePath}: install optional dependency "${name}" to use this stylesheet preprocessor.`), normalizeLoadPaths = (filePath, paths = []) => [
2518
+ dirname2(filePath),
2519
+ process.cwd(),
2520
+ ...paths.map((path) => resolve4(process.cwd(), path))
2521
+ ], getSassOptions = (config, language) => ({
2522
+ ...config?.sass ?? {},
2523
+ ...language === "scss" ? config?.scss ?? {} : {}
2524
+ }), getLessOptions = (config) => config?.less ?? {}, withAdditionalData = (contents, additionalData) => additionalData ? `${additionalData}
2525
+ ${contents}` : contents, compileStyleSource = async (filePath, source, languageHint, config) => {
2518
2526
  const language = getStyleLanguage(languageHint ?? filePath);
2519
- const contents = source ?? await readFile(filePath, "utf-8");
2527
+ const rawContents = source ?? await readFile(filePath, "utf-8");
2520
2528
  if (language === "scss" || language === "sass") {
2529
+ const options = getSassOptions(config, language);
2530
+ const packageName = options.implementation ?? "sass";
2521
2531
  let sass;
2522
2532
  try {
2523
- sass = await importOptionalPeer("sass");
2533
+ sass = await importOptionalPeer(packageName);
2524
2534
  } catch {
2525
- throw missingDependencyError("sass", filePath);
2535
+ throw missingDependencyError(packageName, filePath);
2526
2536
  }
2537
+ const contents = withAdditionalData(rawContents, options.additionalData);
2527
2538
  const result = sass.compileString(contents, {
2528
- loadPaths: [dirname2(filePath), process.cwd()],
2539
+ loadPaths: normalizeLoadPaths(filePath, options.loadPaths),
2529
2540
  style: "expanded",
2530
2541
  syntax: language === "sass" ? "indented" : "scss",
2531
2542
  url: new URL(`file://${filePath}`)
@@ -2533,6 +2544,7 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2533
2544
  return result.css;
2534
2545
  }
2535
2546
  if (language === "less") {
2547
+ const options = getLessOptions(config);
2536
2548
  let lessModule;
2537
2549
  try {
2538
2550
  lessModule = await importOptionalPeer("less");
@@ -2543,14 +2555,49 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2543
2555
  const render = less?.render;
2544
2556
  if (!render)
2545
2557
  throw missingDependencyError("less", filePath);
2558
+ const contents = withAdditionalData(rawContents, options.additionalData);
2546
2559
  const result = await render(contents, {
2560
+ ...options.options ?? {},
2547
2561
  filename: filePath,
2548
- paths: [dirname2(filePath), process.cwd()]
2562
+ paths: normalizeLoadPaths(filePath, options.paths)
2549
2563
  });
2550
2564
  return result.css;
2551
2565
  }
2552
- return contents;
2553
- }, stylePreprocessorPlugin, createSvelteStylePreprocessor = () => ({
2566
+ return rawContents;
2567
+ }, createStylePreprocessorPlugin = (config) => ({
2568
+ name: "absolute-style-preprocessor",
2569
+ setup(build) {
2570
+ const cssModuleSources = new Map;
2571
+ build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
2572
+ namespace: "absolute-style-module",
2573
+ path: path.slice("absolute-style-module:".length)
2574
+ }));
2575
+ build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
2576
+ const sourcePath = cssModuleSources.get(path);
2577
+ if (!sourcePath) {
2578
+ throw new Error(`Unable to resolve CSS module source for ${path}`);
2579
+ }
2580
+ return {
2581
+ contents: await compileStyleSource(sourcePath, undefined, undefined, config),
2582
+ loader: "css"
2583
+ };
2584
+ });
2585
+ build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
2586
+ if (isStyleModulePath(path)) {
2587
+ const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
2588
+ cssModuleSources.set(cssModulePath, path);
2589
+ return {
2590
+ contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
2591
+ loader: "js"
2592
+ };
2593
+ }
2594
+ return {
2595
+ contents: await compileStyleSource(path, undefined, undefined, config),
2596
+ loader: "css"
2597
+ };
2598
+ });
2599
+ }
2600
+ }), stylePreprocessorPlugin, createSvelteStylePreprocessor = (config) => ({
2554
2601
  style: async ({
2555
2602
  attributes,
2556
2603
  content,
@@ -2561,14 +2608,14 @@ var STYLE_EXTENSION_PATTERN, STYLE_MODULE_EXTENSION_PATTERN, STYLE_LANGUAGE_PATT
2561
2608
  return;
2562
2609
  const path = filename ?? `style.${language}`;
2563
2610
  return {
2564
- code: await compileStyleSource(path, content, language)
2611
+ code: await compileStyleSource(path, content, language, config)
2565
2612
  };
2566
2613
  }
2567
- }), compileStyleFileIfNeeded = async (filePath) => {
2614
+ }), compileStyleFileIfNeeded = async (filePath, config) => {
2568
2615
  if (!isPreprocessableStylePath(filePath)) {
2569
2616
  return readFile(filePath, "utf-8");
2570
2617
  }
2571
- return compileStyleSource(filePath);
2618
+ return compileStyleSource(filePath, undefined, undefined, config);
2572
2619
  };
2573
2620
  var init_stylePreprocessor = __esm(() => {
2574
2621
  STYLE_EXTENSION_PATTERN = /\.(s[ac]ss|less)$/i;
@@ -2577,45 +2624,12 @@ var init_stylePreprocessor = __esm(() => {
2577
2624
  importOptionalPeer = new Function("specifier", "return import(specifier)");
2578
2625
  requireOptionalPeer = new Function("specifier", "return require(specifier)");
2579
2626
  requireFromCwd = createRequire(join3(process.cwd(), "package.json"));
2580
- stylePreprocessorPlugin = {
2581
- name: "absolute-style-preprocessor",
2582
- setup(build) {
2583
- const cssModuleSources = new Map;
2584
- build.onResolve({ filter: /^absolute-style-module:/ }, ({ path }) => ({
2585
- namespace: "absolute-style-module",
2586
- path: path.slice("absolute-style-module:".length)
2587
- }));
2588
- build.onLoad({ filter: /\.module\.css$/i, namespace: "absolute-style-module" }, async ({ path }) => {
2589
- const sourcePath = cssModuleSources.get(path);
2590
- if (!sourcePath) {
2591
- throw new Error(`Unable to resolve CSS module source for ${path}`);
2592
- }
2593
- return {
2594
- contents: await compileStyleSource(sourcePath),
2595
- loader: "css"
2596
- };
2597
- });
2598
- build.onLoad({ filter: STYLE_EXTENSION_PATTERN }, async ({ path }) => {
2599
- if (isStyleModulePath(path)) {
2600
- const cssModulePath = path.replace(STYLE_EXTENSION_PATTERN, ".css");
2601
- cssModuleSources.set(cssModulePath, path);
2602
- return {
2603
- contents: `export { default } from ${JSON.stringify(`absolute-style-module:${cssModulePath}`)};`,
2604
- loader: "js"
2605
- };
2606
- }
2607
- return {
2608
- contents: await compileStyleSource(path),
2609
- loader: "css"
2610
- };
2611
- });
2612
- }
2613
- };
2627
+ stylePreprocessorPlugin = createStylePreprocessorPlugin();
2614
2628
  });
2615
2629
 
2616
2630
  // src/core/svelteServerModule.ts
2617
2631
  import { mkdir, readdir } from "fs/promises";
2618
- import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative, resolve as resolve4 } from "path";
2632
+ import { basename as basename2, dirname as dirname3, extname as extname2, join as join4, relative, resolve as resolve5 } from "path";
2619
2633
  var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, ensureRelativeImportPath = (from, target) => {
2620
2634
  const importPath = relative(dirname3(from), target).replace(/\\/g, "/");
2621
2635
  return importPath.startsWith(".") ? importPath : `./${importPath}`;
@@ -2663,7 +2677,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2663
2677
  if (!spec.startsWith(".")) {
2664
2678
  return null;
2665
2679
  }
2666
- const basePath = resolve4(dirname3(from), spec);
2680
+ const basePath = resolve5(dirname3(from), spec);
2667
2681
  const candidates = [
2668
2682
  basePath,
2669
2683
  `${basePath}.ts`,
@@ -2695,7 +2709,7 @@ var serverCacheRoot, compiledModuleCache, originalSourcePathCache, transpiler, e
2695
2709
  if (!spec.startsWith(".")) {
2696
2710
  return null;
2697
2711
  }
2698
- const explicitPath = resolve4(dirname3(from), spec);
2712
+ const explicitPath = resolve5(dirname3(from), spec);
2699
2713
  if (extname2(explicitPath) === ".svelte") {
2700
2714
  return explicitPath;
2701
2715
  }
@@ -3088,5 +3102,5 @@ export {
3088
3102
  Island
3089
3103
  };
3090
3104
 
3091
- //# debugId=438587C8B71E076B64756E2164756E21
3105
+ //# debugId=03F71698475F88C764756E2164756E21
3092
3106
  //# sourceMappingURL=index.js.map