@visulima/rollup-plugin-css 1.0.0-alpha.3 → 1.0.0-alpha.31

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.
Files changed (122) hide show
  1. package/CHANGELOG.md +278 -0
  2. package/LICENSE.md +83 -79
  3. package/README.md +164 -146
  4. package/dist/css-modules-types.d.ts +38 -0
  5. package/dist/css-plugin.d.ts +44 -0
  6. package/dist/index.d.ts +40 -20
  7. package/dist/index.js +1 -0
  8. package/dist/loaders/less/importer.d.ts +2 -0
  9. package/dist/loaders/less/index.d.ts +37 -9
  10. package/dist/loaders/less/index.js +1 -0
  11. package/dist/loaders/less/types.d.ts +24 -0
  12. package/dist/loaders/lightningcss.d.ts +13 -16
  13. package/dist/loaders/lightningcss.js +3 -0
  14. package/dist/loaders/loader-manager.d.ts +78 -0
  15. package/dist/loaders/postcss/constants.d.ts +20 -0
  16. package/dist/loaders/postcss/icss/index.d.ts +8 -0
  17. package/dist/loaders/postcss/icss/load.d.ts +5 -0
  18. package/dist/loaders/postcss/icss/resolve.d.ts +6 -0
  19. package/dist/loaders/postcss/import/apply-conditions.d.ts +10 -0
  20. package/dist/loaders/postcss/import/apply-raws.d.ts +3 -0
  21. package/dist/loaders/postcss/import/apply-styles.d.ts +10 -0
  22. package/dist/loaders/postcss/import/constants.d.ts +12 -0
  23. package/dist/loaders/postcss/import/import-resolve.d.ts +3 -0
  24. package/dist/loaders/postcss/import/index.d.ts +12 -0
  25. package/dist/loaders/postcss/import/parser/parse-at-import.d.ts +9 -0
  26. package/dist/loaders/postcss/import/parser/parse-styles.d.ts +6 -0
  27. package/dist/loaders/postcss/import/parser/parse-stylesheet.d.ts +10 -0
  28. package/dist/loaders/postcss/import/types.d.ts +95 -0
  29. package/dist/loaders/postcss/import/utils/base64-encoded-import.d.ts +3 -0
  30. package/dist/loaders/postcss/import/utils/data-url.d.ts +2 -0
  31. package/dist/loaders/postcss/import/utils/format-import-prelude.d.ts +2 -0
  32. package/dist/loaders/postcss/import/utils/load-content.d.ts +2 -0
  33. package/dist/loaders/postcss/import/utils/process-content.d.ts +4 -0
  34. package/dist/loaders/postcss/import/utils/statement.d.ts +6 -0
  35. package/dist/loaders/postcss/index.d.ts +27 -16
  36. package/dist/loaders/postcss/index.js +6 -0
  37. package/dist/loaders/postcss/load-config.d.ts +6 -0
  38. package/dist/loaders/postcss/modules/generate.d.ts +11 -0
  39. package/dist/loaders/postcss/modules/index.d.ts +35 -0
  40. package/dist/loaders/postcss/noop.d.ts +22 -0
  41. package/dist/loaders/postcss/url/generate.d.ts +2 -0
  42. package/dist/loaders/postcss/url/index.d.ts +46 -0
  43. package/dist/loaders/postcss/url/inline.d.ts +20 -0
  44. package/dist/loaders/postcss/url/url-resolve.d.ts +12 -0
  45. package/dist/loaders/postcss/url/utils.d.ts +4 -0
  46. package/dist/loaders/sass/index.d.ts +5 -9
  47. package/dist/loaders/sass/{index.mjs → index.js} +5 -5
  48. package/dist/loaders/sass/modern/importer.d.ts +3 -0
  49. package/dist/loaders/sass/types.d.ts +20 -0
  50. package/dist/loaders/sass/utils/get-sass-compiler.d.ts +8 -0
  51. package/dist/loaders/sass/utils/get-sass-options.d.ts +7 -0
  52. package/dist/loaders/sass/utils/normalize-source-map.d.ts +3 -0
  53. package/dist/loaders/sass/utils/resolve-syntax.d.ts +2 -0
  54. package/dist/loaders/sass/utils/sass-error-factory.d.ts +15 -0
  55. package/dist/loaders/sourcemap.d.ts +24 -16
  56. package/dist/loaders/sourcemap.js +1 -0
  57. package/dist/loaders/stylus/index.d.ts +8 -9
  58. package/dist/loaders/stylus/index.js +2 -0
  59. package/dist/loaders/stylus/types.d.ts +87 -0
  60. package/dist/loaders/tailwindcss-oxide.d.ts +5 -16
  61. package/dist/loaders/tailwindcss-oxide.js +1 -0
  62. package/dist/loaders/types.d.ts +102 -0
  63. package/dist/loaders/utils/ensure-auto-modules.d.ts +39 -0
  64. package/dist/loaders/utils/match-file.d.ts +32 -0
  65. package/dist/minifiers/cssnano.d.ts +30 -16
  66. package/dist/minifiers/lightningcss.d.ts +29 -16
  67. package/dist/minifiers/types.d.ts +64 -0
  68. package/dist/packem_shared/concat-WcWAYbOc.js +3 -0
  69. package/dist/packem_shared/{cssModulesTypesPlugin-B9_bJo_B.mjs → cssModulesTypesPlugin-CjGroK2y.js} +1 -1
  70. package/dist/packem_shared/{generate-js-exports-Dqps7nWG.mjs → generate-js-exports-BhS4eLrN.js} +1 -1
  71. package/dist/packem_shared/getMap-TR-0DXUr.js +1 -0
  72. package/dist/packem_shared/inferModeOption-9h3Eq6JH.js +1 -0
  73. package/dist/packem_shared/loadModule-D20jQQNu.js +1 -0
  74. package/dist/packem_shared/resolve-anj9ucIq.js +1 -0
  75. package/dist/packem_shared/rollupCssPlugin-BxRedPmA.js +3 -0
  76. package/dist/packem_shared/{sourcemap-DGfgaUBb.mjs → sourcemap-CB6ochh0.js} +1 -1
  77. package/dist/types.d.ts +224 -0
  78. package/dist/utils/array-fmt.d.ts +18 -0
  79. package/dist/utils/concat.d.ts +34 -0
  80. package/dist/utils/generate-js-exports.d.ts +78 -0
  81. package/dist/utils/index.d.ts +9 -73
  82. package/dist/utils/index.js +1 -0
  83. package/dist/utils/load-module.d.ts +3 -0
  84. package/dist/utils/options.d.ts +155 -0
  85. package/dist/utils/resolve.d.ts +35 -0
  86. package/dist/utils/safe-id.d.ts +23 -0
  87. package/dist/utils/sourcemap.d.ts +42 -0
  88. package/dist/utils/url.d.ts +8 -0
  89. package/package.json +56 -41
  90. package/dist/index.d.mts +0 -20
  91. package/dist/index.mjs +0 -1
  92. package/dist/loaders/less/index.d.mts +0 -17
  93. package/dist/loaders/less/index.mjs +0 -1
  94. package/dist/loaders/lightningcss.d.mts +0 -17
  95. package/dist/loaders/lightningcss.mjs +0 -3
  96. package/dist/loaders/postcss/index.d.mts +0 -17
  97. package/dist/loaders/postcss/index.mjs +0 -6
  98. package/dist/loaders/sass/index.d.mts +0 -18
  99. package/dist/loaders/sourcemap.d.mts +0 -17
  100. package/dist/loaders/sourcemap.mjs +0 -1
  101. package/dist/loaders/stylus/index.d.mts +0 -17
  102. package/dist/loaders/stylus/index.mjs +0 -1
  103. package/dist/loaders/tailwindcss-oxide.d.mts +0 -17
  104. package/dist/loaders/tailwindcss-oxide.mjs +0 -1
  105. package/dist/minifiers/cssnano.d.mts +0 -17
  106. package/dist/minifiers/lightningcss.d.mts +0 -17
  107. package/dist/packem_shared/concat-BbvpVPBg.mjs +0 -3
  108. package/dist/packem_shared/getMap-BL5hKEnR.mjs +0 -1
  109. package/dist/packem_shared/inferModeOption-fAc592HP.mjs +0 -1
  110. package/dist/packem_shared/loadModule-CovDETwT.mjs +0 -1
  111. package/dist/packem_shared/resolve-nqhcPNJ9.mjs +0 -1
  112. package/dist/packem_shared/rollupCssPlugin-CJSS-7Mi.mjs +0 -3
  113. package/dist/packem_shared/types-CA9pSumu.d.mts +0 -189
  114. package/dist/packem_shared/types-CA9pSumu.d.ts +0 -189
  115. package/dist/utils/index.d.mts +0 -73
  116. package/dist/utils/index.mjs +0 -1
  117. /package/dist/minifiers/{cssnano.mjs → cssnano.js} +0 -0
  118. /package/dist/minifiers/{lightningcss.mjs → lightningcss.js} +0 -0
  119. /package/dist/packem_shared/{arrayFmt-Dek5cB7m.mjs → arrayFmt-Dek5cB7m.js} +0 -0
  120. /package/dist/packem_shared/{ensure-auto-modules-BU3xWEjl.mjs → ensure-auto-modules-BU3xWEjl.js} +0 -0
  121. /package/dist/packem_shared/{hasModuleSpecifier-DIZeev_W.mjs → hasModuleSpecifier-DIZeev_W.js} +0 -0
  122. /package/dist/packem_shared/{safeId-BN5akJYJ.mjs → safeId-BN5akJYJ.js} +0 -0
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Formats an array of strings into a human-readable list format.
3
+ *
4
+ * Converts an array into a grammatically correct string with proper conjunctions:
5
+ * - Single item: "`item`"
6
+ * - Two items: "`item1` or `item2`"
7
+ * - Multiple items: "`item1`, `item2`, or `item3`"
8
+ * @param array Array of strings to format
9
+ * @returns Formatted string with proper conjunctions and backticks
10
+ * @example
11
+ * ```typescript
12
+ * arrayFmt(['inject']) // "`inject`"
13
+ * arrayFmt(['inject', 'extract']) // "`inject` or `extract`"
14
+ * arrayFmt(['inject', 'extract', 'emit']) // "`inject`, `extract`, or `emit`"
15
+ * ```
16
+ */
17
+ declare const arrayFmt: (array: string[]) => string;
18
+ export default arrayFmt;
@@ -0,0 +1,34 @@
1
+ import { SourceMapGenerator } from "source-map-js";
2
+ import type { Extracted } from "../loaders/types.d.ts";
3
+ interface Concatenated {
4
+ css: string;
5
+ map: SourceMapGenerator;
6
+ }
7
+ /**
8
+ * Concatenates multiple CSS data objects into a single unified object with source map support.
9
+ *
10
+ * This utility function merges CSS content from multiple sources while
11
+ * properly handling source maps and metadata. It's used during the build
12
+ * process to combine CSS from different modules or chunks while preserving
13
+ * accurate source mapping information for debugging.
14
+ *
15
+ * The function:
16
+ * - Concatenates CSS content with newline separators
17
+ * - Merges source maps from all inputs
18
+ * - Adjusts line/column mappings for the combined output
19
+ * - Preserves source content for debugging
20
+ * @param extracted Array of extracted CSS data objects to concatenate
21
+ * @returns Promise resolving to concatenated CSS with merged source maps
22
+ * @example
23
+ * ```typescript
24
+ * const extracted = [
25
+ * { css: '.header {}', map: headerSourceMap },
26
+ * { css: '.footer {}', map: footerSourceMap }
27
+ * ];
28
+ *
29
+ * const result = await concat(extracted);
30
+ * // Result: Combined CSS with properly merged source maps
31
+ * ```
32
+ */
33
+ declare const concat: (extracted: Extracted[]) => Promise<Concatenated>;
34
+ export default concat;
@@ -0,0 +1,78 @@
1
+ import type { InjectOptions } from "../types.d.ts";
2
+ export interface JsExportOptions {
3
+ /** CSS content to export */
4
+ css: string;
5
+ /** Current working directory for relative path calculations */
6
+ cwd?: string;
7
+ /** Whether to generate TypeScript declarations */
8
+ dts?: boolean;
9
+ /** Whether to emit CSS instead of JavaScript */
10
+ emit?: boolean;
11
+ /** Whether to extract CSS to separate files */
12
+ extract?: boolean | string;
13
+ /** ICSS dependencies for CSS modules */
14
+ icssDependencies?: string[];
15
+ /** File ID for safe identifier generation */
16
+ id: string;
17
+ /** CSS injection configuration */
18
+ inject?: InjectOptions | boolean | ((varname: string, id: string, output: string[]) => string);
19
+ /** Whether to inline CSS as strings */
20
+ inline?: boolean;
21
+ /** Logger for warnings */
22
+ logger?: {
23
+ warn: (log: {
24
+ message: string;
25
+ plugin?: string;
26
+ }) => void;
27
+ };
28
+ /** Source map for the CSS */
29
+ map?: string;
30
+ /** CSS modules exports mapping class names to hashed names */
31
+ modulesExports: Record<string, string>;
32
+ /** Named exports configuration */
33
+ namedExports?: boolean | ((name: string) => string);
34
+ /** Whether CSS modules are supported */
35
+ supportModules: boolean;
36
+ }
37
+ export interface JsExportResult {
38
+ /** Generated JavaScript code */
39
+ code: string;
40
+ /** Extracted CSS data for file extraction */
41
+ extracted?: {
42
+ css: string;
43
+ id: string;
44
+ map?: string;
45
+ };
46
+ /** Source map */
47
+ map?: string;
48
+ /** Metadata including types and module contents */
49
+ meta?: {
50
+ icssDependencies?: string[];
51
+ moduleContents?: string;
52
+ types?: string;
53
+ };
54
+ /** Module side effects configuration */
55
+ moduleSideEffects: boolean | "no-treeshake";
56
+ /** Generated TypeScript declarations */
57
+ types?: string;
58
+ }
59
+ /**
60
+ * Generates JavaScript exports for CSS content with support for CSS modules and injection
61
+ * @param options Configuration options for export generation
62
+ * @param options.css CSS content to export
63
+ * @param options.cwd Current working directory for relative path calculations
64
+ * @param options.dts Whether to generate TypeScript declarations
65
+ * @param options.emit Whether to emit CSS instead of JavaScript
66
+ * @param options.extract Whether to extract CSS to separate files
67
+ * @param options.icssDependencies ICSS dependencies for CSS modules
68
+ * @param options.id File ID for safe identifier generation
69
+ * @param options.inject CSS injection configuration
70
+ * @param options.inline Whether to inline CSS as strings
71
+ * @param options.logger Logger for warnings
72
+ * @param options.map Source map for the CSS
73
+ * @param options.modulesExports CSS modules exports mapping class names to hashed names
74
+ * @param options.namedExports Named exports configuration
75
+ * @param options.supportModules Whether CSS modules are supported
76
+ * @returns Generated JavaScript code and TypeScript declarations
77
+ */
78
+ export declare const generateJsExports: ({ css, cwd, dts, emit, extract, icssDependencies, id, inject, inline, logger, map, modulesExports, namedExports, supportModules, }: JsExportOptions) => JsExportResult;
@@ -1,73 +1,9 @@
1
- import { SourceMapGenerator, RawSourceMap, SourceMapConsumer } from 'source-map-js';
2
- import { h as Extracted, b as PostCSSOptions, S as StyleOptions, a as InternalStyleOptions, i as LoaderContext } from '../packem_shared/types-CA9pSumu.js';
3
- import { RollupLogger } from '@visulima/packem-share/utils';
4
- import { Result } from 'postcss-load-config';
5
- import { NapiResolveOptions } from 'oxc-resolver';
6
- import 'cssnano';
7
- import 'lightningcss';
8
- import 'postcss';
9
- import 'less';
10
- import '@visulima/packem-share/types';
11
- import 'sass';
12
- import 'sass-embedded';
13
- import 'stylus';
14
- import 'rollup';
15
-
16
- declare const arrayFmt: (array: string[]) => string;
17
-
18
- interface Concatenated {
19
- css: string;
20
- map: SourceMapGenerator;
21
- }
22
- declare const concat: (extracted: Extracted[]) => Promise<Concatenated>;
23
-
24
- declare const loadModule: (moduleId: string, cwd: string, logger: RollupLogger) => Promise<any>;
25
-
26
- interface Mode {
27
- emit: InternalStyleOptions["emit"];
28
- extract: InternalStyleOptions["extract"];
29
- inject: InternalStyleOptions["inject"];
30
- inline: InternalStyleOptions["inline"];
31
- }
32
- type PCSSOption = "parser" | "plugin" | "stringifier" | "syntax";
33
- declare const inferModeOption: (mode: StyleOptions["mode"]) => Mode;
34
- declare const inferOption: <T, TDefine extends T | boolean | undefined>(option: T | boolean | undefined, defaultValue: TDefine) => OptionType<T, TDefine>;
35
- declare const inferSourceMapOption: (sourceMap: StyleOptions["sourceMap"]) => LoaderContext["sourceMap"];
36
- declare const inferHandlerOption: <T extends {
37
- alias?: Record<string, string>;
38
- }>(option: T | boolean | undefined, alias: T["alias"]) => T | false;
39
- declare const ensurePCSSOption: <T>(option: T | string, type: PCSSOption, cwd: string, logger: RollupLogger) => Promise<T>;
40
- declare const ensurePCSSPlugins: (plugins: PostCSSOptions["plugins"], cwd: string, logger: RollupLogger) => Promise<Result["plugins"]>;
41
- type OptionType<T, TDefine extends T | boolean | undefined> = T | TDefine | false;
42
-
43
- declare const resolve: (ids: string[], userOptions: ResolveOptions) => string;
44
- interface ResolveOptions extends NapiResolveOptions {
45
- baseDirs?: string[];
46
- caller?: string;
47
- }
48
-
49
- declare const safeId: (id: string, ...salt: string[]) => string;
50
-
51
- declare class MapModifier {
52
- private readonly map?;
53
- constructor(map?: RawSourceMap | string);
54
- modify(f: (m: RawSourceMap) => void): this;
55
- modifySources(op: (source: string) => string): this;
56
- resolve(directory?: string): this;
57
- relative(directory?: string): this;
58
- toObject(): RawSourceMap | undefined;
59
- toString(): string | undefined;
60
- toConsumer(): SourceMapConsumer | undefined;
61
- toCommentData(): string;
62
- toCommentFile(fileName: string): string;
63
- }
64
- declare const getMap: (code: string, id?: string) => Promise<string | undefined>;
65
- declare const stripMap: (code: string) => string;
66
- declare const mm: (map?: RawSourceMap | string) => MapModifier;
67
-
68
- declare const hasModuleSpecifier: (url: string) => boolean;
69
- declare const getUrlOfPartial: (url: string) => string;
70
- declare const normalizeUrl: (url: string) => string;
71
-
72
- export { arrayFmt, concat, ensurePCSSOption, ensurePCSSPlugins, getMap, getUrlOfPartial, hasModuleSpecifier, inferHandlerOption, inferModeOption, inferOption, inferSourceMapOption, loadModule, mm, normalizeUrl, resolve, safeId, stripMap };
73
- export type { ResolveOptions };
1
+ export { default as arrayFmt } from "./array-fmt.d.ts";
2
+ export { default as concat } from "./concat.d.ts";
3
+ export { default as loadModule } from "./load-module.d.ts";
4
+ export { ensurePCSSOption, ensurePCSSPlugins, inferHandlerOption, inferModeOption, inferOption, inferSourceMapOption } from "./options.d.ts";
5
+ export type { ResolveOptions } from "./resolve.d.ts";
6
+ export { resolve } from "./resolve.d.ts";
7
+ export { default as safeId } from "./safe-id.d.ts";
8
+ export { getMap, mm, stripMap } from "./sourcemap.d.ts";
9
+ export { getUrlOfPartial, hasModuleSpecifier, normalizeUrl } from "./url.d.ts";
@@ -0,0 +1 @@
1
+ import{default as o}from"../packem_shared/arrayFmt-Dek5cB7m.js";import{default as t}from"../packem_shared/concat-WcWAYbOc.js";import{default as p}from"../packem_shared/loadModule-D20jQQNu.js";import{ensurePCSSOption as n,ensurePCSSPlugins as s,inferHandlerOption as l,inferModeOption as m,inferOption as d,inferSourceMapOption as u}from"../packem_shared/inferModeOption-9h3Eq6JH.js";import{resolve as M}from"../packem_shared/resolve-anj9ucIq.js";import{default as S}from"../packem_shared/safeId-BN5akJYJ.js";import{g,m as P,s as C}from"../packem_shared/sourcemap-CB6ochh0.js";import{getUrlOfPartial as h,hasModuleSpecifier as v,normalizeUrl as y}from"../packem_shared/hasModuleSpecifier-DIZeev_W.js";export{o as arrayFmt,t as concat,n as ensurePCSSOption,s as ensurePCSSPlugins,g as getMap,h as getUrlOfPartial,v as hasModuleSpecifier,l as inferHandlerOption,m as inferModeOption,d as inferOption,u as inferSourceMapOption,p as loadModule,P as mm,y as normalizeUrl,M as resolve,S as safeId,C as stripMap};
@@ -0,0 +1,3 @@
1
+ import type { RollupLogger } from "@visulima/packem-share/utils";
2
+ declare const loadModule: (moduleId: string, cwd: string, logger: RollupLogger) => Promise<any>;
3
+ export default loadModule;
@@ -0,0 +1,155 @@
1
+ import type { RollupLogger } from "@visulima/packem-share/utils";
2
+ import type { Result } from "postcss-load-config";
3
+ import type { LoaderContext } from "../loaders/types.d.ts";
4
+ import type { InternalStyleOptions, PostCSSOptions, StyleOptions } from "../types.d.ts";
5
+ /**
6
+ * Internal mode configuration for style processing.
7
+ *
8
+ * Represents the resolved mode options that determine how CSS is handled:
9
+ * - emit: Output raw CSS for further processing
10
+ * - extract: Extract CSS to separate files
11
+ * - inject: Inject CSS into JavaScript at runtime
12
+ */
13
+ interface Mode {
14
+ /** Whether to emit raw CSS for further processing */
15
+ emit: InternalStyleOptions["emit"];
16
+ /** Whether to extract CSS to separate files (boolean or filename) */
17
+ extract: InternalStyleOptions["extract"];
18
+ /** Whether to inject CSS at runtime (boolean or injection options) */
19
+ inject: InternalStyleOptions["inject"];
20
+ /** Whether to inline CSS as strings in JavaScript */
21
+ inline: InternalStyleOptions["inline"];
22
+ }
23
+ /** PostCSS option types for error messages */
24
+ type PCSSOption = "parser" | "plugin" | "stringifier" | "syntax";
25
+ /**
26
+ * Infers and validates the CSS processing mode from user options.
27
+ *
28
+ * Converts the user-provided mode configuration into internal mode settings.
29
+ * Supports both simple string modes and tuple modes with additional options.
30
+ * @param mode User-provided mode configuration
31
+ * @returns Resolved mode configuration object
32
+ * @throws Error if an invalid mode is provided
33
+ * @example
34
+ * ```typescript
35
+ * // Simple mode
36
+ * inferModeOption('extract') // { emit: false, extract: true, inject: false }
37
+ *
38
+ * // Mode with options
39
+ * inferModeOption(['inject', { singleTag: true }])
40
+ * // { emit: false, extract: false, inject: { singleTag: true } }
41
+ *
42
+ * // Default mode (inject)
43
+ * inferModeOption(undefined) // { emit: false, extract: false, inject: true }
44
+ * ```
45
+ */
46
+ export declare const inferModeOption: (mode: StyleOptions["mode"]) => Mode;
47
+ /**
48
+ * Infers option values from boolean or object configurations.
49
+ *
50
+ * This utility handles the common pattern where options can be:
51
+ * - `true`: Enable with default settings (returns empty object)
52
+ * - `false`: Disable the option (returns false)
53
+ * - `object`: Use the provided configuration
54
+ * - `undefined`: Use the provided default value
55
+ * @param option The option value to process
56
+ * @param defaultValue Default value when option is undefined
57
+ * @returns Processed option value
58
+ * @example
59
+ * ```typescript
60
+ * inferOption(true, {}) // {}
61
+ * inferOption(false, {}) // false
62
+ * inferOption({ custom: 'value' }, {}) // { custom: 'value' }
63
+ * inferOption(undefined, { default: true }) // { default: true }
64
+ * ```
65
+ */
66
+ export declare const inferOption: <T, TDefine extends T | boolean | undefined>(option: T | boolean | undefined, defaultValue: TDefine) => OptionType<T, TDefine>;
67
+ /**
68
+ * Infers source map configuration from user options.
69
+ *
70
+ * Processes source map options which can be specified as:
71
+ * - `boolean`: Enable/disable with default settings
72
+ * - `"inline"`: Enable with inline source maps
73
+ * - `[boolean | "inline", SourceMapOptions]`: Enable with custom options
74
+ * @param sourceMap User-provided source map configuration
75
+ * @returns Processed source map configuration for loaders
76
+ * @example
77
+ * ```typescript
78
+ * inferSourceMapOption(true) // { content: true, inline: false }
79
+ * inferSourceMapOption('inline') // { content: true, inline: true }
80
+ * inferSourceMapOption([true, { transform: fn }]) // { content: true, inline: false, transform: fn }
81
+ * inferSourceMapOption(false) // false
82
+ * ```
83
+ */
84
+ export declare const inferSourceMapOption: (sourceMap: StyleOptions["sourceMap"]) => LoaderContext["sourceMap"];
85
+ /**
86
+ * Infers handler options that support alias configuration.
87
+ *
88
+ * Processes options for handlers (like import/url resolvers) that can use aliases.
89
+ * If aliases are provided and the option doesn't already have aliases, they are merged.
90
+ * @param option Handler option configuration
91
+ * @param alias Path aliases to merge if not already present
92
+ * @returns Processed handler option with aliases
93
+ * @example
94
+ * ```typescript
95
+ * const aliases = { '@': '/src' };
96
+ *
97
+ * inferHandlerOption(true, aliases) // { alias: { '@': '/src' } }
98
+ * inferHandlerOption({ custom: true }, aliases) // { custom: true, alias: { '@': '/src' } }
99
+ * inferHandlerOption({ alias: { '~': '/lib' } }, aliases) // { alias: { '~': '/lib' } }
100
+ * ```
101
+ */
102
+ export declare const inferHandlerOption: <T extends {
103
+ alias?: Record<string, string>;
104
+ }>(option: T | boolean | undefined, alias: T["alias"]) => T | false;
105
+ /**
106
+ * Ensures a PostCSS option is properly loaded and resolved.
107
+ *
108
+ * PostCSS options can be specified as strings (module names) or objects.
109
+ * This function loads string-based options as modules and validates they exist.
110
+ * @param option PostCSS option (string module name or object)
111
+ * @param type Type of PostCSS option for error messages
112
+ * @param cwd Current working directory for module resolution
113
+ * @param logger Optional logger for warnings
114
+ * @returns Promise resolving to the loaded PostCSS option
115
+ * @throws Error if string module cannot be loaded
116
+ * @example
117
+ * ```typescript
118
+ * // Load parser module
119
+ * await ensurePCSSOption('sugarss', 'parser', process.cwd()) // Loaded sugarss module
120
+ *
121
+ * // Pass through object
122
+ * await ensurePCSSOption(parserObject, 'parser', process.cwd()) // parserObject
123
+ * ```
124
+ */
125
+ export declare const ensurePCSSOption: <T>(option: T | string, type: PCSSOption, cwd: string, logger: RollupLogger) => Promise<T>;
126
+ /**
127
+ * Ensures PostCSS plugins are properly loaded and configured.
128
+ *
129
+ * PostCSS plugins can be specified in various formats:
130
+ * - String module names
131
+ * - Plugin objects
132
+ * - Arrays of [plugin, options]
133
+ * - Mixed arrays of the above
134
+ *
135
+ * This function normalizes all formats and loads string-based plugins as modules.
136
+ * @param plugins PostCSS plugins configuration
137
+ * @param cwd Current working directory for module resolution
138
+ * @param logger Optional logger for warnings
139
+ * @returns Promise resolving to array of loaded PostCSS plugins
140
+ * @example
141
+ * ```typescript
142
+ * // Load plugins from various formats
143
+ * await ensurePCSSPlugins([
144
+ * 'autoprefixer', // String module name
145
+ * ['cssnano', { preset: 'default' }], // Plugin with options
146
+ * pluginObject // Direct plugin object
147
+ * ], process.cwd())
148
+ * ```
149
+ */
150
+ export declare const ensurePCSSPlugins: (plugins: PostCSSOptions["plugins"], cwd: string, logger: RollupLogger) => Promise<Result["plugins"]>;
151
+ /**
152
+ * Type alias for option function return types
153
+ */
154
+ export type OptionType<T, TDefine extends T | boolean | undefined> = T | TDefine | false;
155
+ export {};
@@ -0,0 +1,35 @@
1
+ import type { NapiResolveOptions } from "oxc-resolver";
2
+ /**
3
+ * Resolves module identifiers using advanced resolution strategies.
4
+ *
5
+ * This function implements sophisticated module resolution logic using the OXC resolver,
6
+ * supporting various resolution strategies and providing detailed error reporting.
7
+ * It's primarily used for resolving CSS imports, PostCSS plugins, and other dependencies.
8
+ *
9
+ * Features:
10
+ * - Multiple base directory support
11
+ * - Configurable file extensions
12
+ * - Symlink resolution
13
+ * - Detailed error reporting and debugging
14
+ * - Fallback resolution strategies
15
+ * @param ids Array of module identifiers to resolve
16
+ * @param userOptions Resolution configuration options
17
+ * @returns Absolute path to the resolved module
18
+ * @throws Error if no module can be resolved
19
+ * @example
20
+ * ```typescript
21
+ * // Resolving a PostCSS plugin
22
+ * const pluginPath = resolve(['autoprefixer'], {
23
+ * caller: 'PostCSS',
24
+ * baseDirs: ['/project/node_modules'],
25
+ * extensions: ['.js', '.mjs']
26
+ * });
27
+ * ```
28
+ */
29
+ export declare const resolve: (ids: string[], userOptions: ResolveOptions) => string;
30
+ export interface ResolveOptions extends NapiResolveOptions {
31
+ /** directories to begin resolving from (defaults to `[__dirname]`) */
32
+ baseDirs?: string[];
33
+ /** name of the caller for error message (default to `Resolver`) */
34
+ caller?: string;
35
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Generates a safe, unique JavaScript identifier from an input string.
3
+ *
4
+ * Creates a legal JavaScript identifier by:
5
+ * 1. Combining the input ID with a salt and additional salt parameters
6
+ * 2. Generating a hash of the combined string
7
+ * 3. Appending the hash to the ID to ensure uniqueness
8
+ * 4. Making the result a legal JavaScript identifier
9
+ *
10
+ * This is useful for generating variable names that won't conflict with
11
+ * reserved words or other identifiers in the generated code.
12
+ * @param id Base identifier string
13
+ * @param salt Additional salt values for uniqueness
14
+ * @returns Legal JavaScript identifier with hash suffix
15
+ * @example
16
+ * ```typescript
17
+ * safeId('myVar') // "myVar_a1b2c3d4"
18
+ * safeId('class', 'module') // "class_e5f6g7h8"
19
+ * safeId('my-component', 'css') // "my_component_i9j0k1l2"
20
+ * ```
21
+ */
22
+ declare const safeId: (id: string, ...salt: string[]) => string;
23
+ export default safeId;
@@ -0,0 +1,42 @@
1
+ import type { RawSourceMap } from "source-map-js";
2
+ import { SourceMapConsumer } from "source-map-js";
3
+ declare class MapModifier {
4
+ private readonly map?;
5
+ constructor(map?: RawSourceMap | string);
6
+ modify(f: (m: RawSourceMap) => void): this;
7
+ modifySources(op: (source: string) => string): this;
8
+ resolve(directory?: string): this;
9
+ relative(directory?: string): this;
10
+ toObject(): RawSourceMap | undefined;
11
+ toString(): string | undefined;
12
+ toConsumer(): SourceMapConsumer | undefined;
13
+ toCommentData(): string;
14
+ toCommentFile(fileName: string): string;
15
+ }
16
+ export declare const getMap: (code: string, id?: string) => Promise<string | undefined>;
17
+ export declare const stripMap: (code: string) => string;
18
+ /**
19
+ * Creates a MapModifier instance for source map manipulation.
20
+ *
21
+ * This utility function provides a convenient way to create MapModifier instances
22
+ * for working with source maps in CSS processing pipelines. The MapModifier class
23
+ * offers comprehensive source map manipulation capabilities including:
24
+ * - Path resolution and relativization
25
+ * - Source map merging and modification
26
+ * - Format conversion (object, string, consumer)
27
+ * - Comment generation for inline or external maps
28
+ * @param map Source map input (raw object or JSON string)
29
+ * @returns MapModifier instance for source map operations
30
+ * @example
31
+ * ```typescript
32
+ * // Working with source map objects
33
+ * const modifier = mm(rawSourceMap);
34
+ * modifier.resolve('/project/src').relative('/project');
35
+ *
36
+ * // Converting to different formats
37
+ * const mapString = modifier.toString();
38
+ * const consumer = modifier.toConsumer();
39
+ * ```
40
+ */
41
+ export declare const mm: (map?: RawSourceMap | string) => MapModifier;
42
+ export {};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Checks if the URL starts with a tilde followed by a digit, '@', or a letter (case-insensitive)
3
+ * @param url
4
+ * @returns
5
+ */
6
+ export declare const hasModuleSpecifier: (url: string) => boolean;
7
+ export declare const getUrlOfPartial: (url: string) => string;
8
+ export declare const normalizeUrl: (url: string) => string;