@visulima/rollup-plugin-css 1.0.0-alpha.30 → 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 (70) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/css-modules-types.d.ts +38 -0
  3. package/dist/css-plugin.d.ts +44 -0
  4. package/dist/index.d.ts +40 -19
  5. package/dist/loaders/less/importer.d.ts +2 -0
  6. package/dist/loaders/less/index.d.ts +36 -15
  7. package/dist/loaders/less/types.d.ts +24 -0
  8. package/dist/loaders/lightningcss.d.ts +13 -15
  9. package/dist/loaders/loader-manager.d.ts +78 -0
  10. package/dist/loaders/postcss/constants.d.ts +20 -0
  11. package/dist/loaders/postcss/icss/index.d.ts +8 -0
  12. package/dist/loaders/postcss/icss/load.d.ts +5 -0
  13. package/dist/loaders/postcss/icss/resolve.d.ts +6 -0
  14. package/dist/loaders/postcss/import/apply-conditions.d.ts +10 -0
  15. package/dist/loaders/postcss/import/apply-raws.d.ts +3 -0
  16. package/dist/loaders/postcss/import/apply-styles.d.ts +10 -0
  17. package/dist/loaders/postcss/import/constants.d.ts +12 -0
  18. package/dist/loaders/postcss/import/import-resolve.d.ts +3 -0
  19. package/dist/loaders/postcss/import/index.d.ts +12 -0
  20. package/dist/loaders/postcss/import/parser/parse-at-import.d.ts +9 -0
  21. package/dist/loaders/postcss/import/parser/parse-styles.d.ts +6 -0
  22. package/dist/loaders/postcss/import/parser/parse-stylesheet.d.ts +10 -0
  23. package/dist/loaders/postcss/import/types.d.ts +95 -0
  24. package/dist/loaders/postcss/import/utils/base64-encoded-import.d.ts +3 -0
  25. package/dist/loaders/postcss/import/utils/data-url.d.ts +2 -0
  26. package/dist/loaders/postcss/import/utils/format-import-prelude.d.ts +2 -0
  27. package/dist/loaders/postcss/import/utils/load-content.d.ts +2 -0
  28. package/dist/loaders/postcss/import/utils/process-content.d.ts +4 -0
  29. package/dist/loaders/postcss/import/utils/statement.d.ts +6 -0
  30. package/dist/loaders/postcss/index.d.ts +27 -15
  31. package/dist/loaders/postcss/load-config.d.ts +6 -0
  32. package/dist/loaders/postcss/modules/generate.d.ts +11 -0
  33. package/dist/loaders/postcss/modules/index.d.ts +35 -0
  34. package/dist/loaders/postcss/noop.d.ts +22 -0
  35. package/dist/loaders/postcss/url/generate.d.ts +2 -0
  36. package/dist/loaders/postcss/url/index.d.ts +46 -0
  37. package/dist/loaders/postcss/url/inline.d.ts +20 -0
  38. package/dist/loaders/postcss/url/url-resolve.d.ts +12 -0
  39. package/dist/loaders/postcss/url/utils.d.ts +4 -0
  40. package/dist/loaders/sass/index.d.ts +4 -16
  41. package/dist/loaders/sass/modern/importer.d.ts +3 -0
  42. package/dist/loaders/sass/types.d.ts +20 -0
  43. package/dist/loaders/sass/utils/get-sass-compiler.d.ts +8 -0
  44. package/dist/loaders/sass/utils/get-sass-options.d.ts +7 -0
  45. package/dist/loaders/sass/utils/normalize-source-map.d.ts +3 -0
  46. package/dist/loaders/sass/utils/resolve-syntax.d.ts +2 -0
  47. package/dist/loaders/sass/utils/sass-error-factory.d.ts +15 -0
  48. package/dist/loaders/sourcemap.d.ts +24 -15
  49. package/dist/loaders/stylus/index.d.ts +7 -16
  50. package/dist/loaders/stylus/types.d.ts +87 -0
  51. package/dist/loaders/tailwindcss-oxide.d.ts +5 -15
  52. package/dist/loaders/types.d.ts +102 -0
  53. package/dist/loaders/utils/ensure-auto-modules.d.ts +39 -0
  54. package/dist/loaders/utils/match-file.d.ts +32 -0
  55. package/dist/minifiers/cssnano.d.ts +30 -15
  56. package/dist/minifiers/lightningcss.d.ts +29 -15
  57. package/dist/minifiers/types.d.ts +64 -0
  58. package/dist/types.d.ts +224 -0
  59. package/dist/utils/array-fmt.d.ts +18 -0
  60. package/dist/utils/concat.d.ts +34 -0
  61. package/dist/utils/generate-js-exports.d.ts +78 -0
  62. package/dist/utils/index.d.ts +9 -72
  63. package/dist/utils/load-module.d.ts +3 -0
  64. package/dist/utils/options.d.ts +155 -0
  65. package/dist/utils/resolve.d.ts +35 -0
  66. package/dist/utils/safe-id.d.ts +23 -0
  67. package/dist/utils/sourcemap.d.ts +42 -0
  68. package/dist/utils/url.d.ts +8 -0
  69. package/package.json +5 -5
  70. package/dist/packem_shared/types-B7InbTq8.d.ts +0 -206
@@ -0,0 +1,32 @@
1
+ import type { Loader } from "../types.d.ts";
2
+ /**
3
+ * Tests whether a file matches a loader's test condition.
4
+ *
5
+ * This function handles different types of test conditions that can be
6
+ * specified in a loader configuration:
7
+ *
8
+ * 1. **Function**: Calls the function with the file path
9
+ * 2. **RegExp**: Uses the RegExp's test method
10
+ * 3. **undefined/null**: Returns false (no match)
11
+ * @param file File path to test against the condition
12
+ * @param condition The test condition from a loader (function, RegExp, or undefined)
13
+ * @returns True if the file matches the condition, false otherwise
14
+ * @throws Error if the condition type is invalid/unsupported
15
+ * @example
16
+ * ```typescript
17
+ * // Function-based matching
18
+ * matchFile('styles.css', (file) => file.endsWith('.css')) // true
19
+ *
20
+ * // RegExp-based matching
21
+ * matchFile('styles.sass', /\.(sass|scss)$/i) // false
22
+ * matchFile('styles.scss', /\.(sass|scss)$/i) // true
23
+ *
24
+ * // No condition (undefined)
25
+ * matchFile('any-file.txt', undefined) // false
26
+ *
27
+ * // Invalid condition throws error
28
+ * matchFile('file.css', { invalid: 'condition' }) // throws Error
29
+ * ```
30
+ */
31
+ declare const matchFile: (file: string, condition: Loader["test"]) => boolean;
32
+ export default matchFile;
@@ -1,16 +1,31 @@
1
- import { Options } from 'cssnano';
2
- import { M as Minifier } from '../packem_shared/types-B7InbTq8.js';
3
- import 'lightningcss';
4
- import 'postcss';
5
- import 'postcss-load-config';
6
- import '@visulima/packem-share/types';
7
- import 'sass';
8
- import 'sass-embedded';
9
- import 'stylus';
10
- import '@visulima/packem-share/utils';
11
- import 'rollup';
12
- import 'source-map-js';
13
-
1
+ import type { Options } from "cssnano";
2
+ import type { Minifier } from "./types.d.ts";
3
+ /**
4
+ * CSSNano minifier implementation for optimizing CSS content.
5
+ *
6
+ * This minifier uses CSSNano, a modular CSS minifier built on PostCSS,
7
+ * to optimize CSS through various transformations including:
8
+ * - Removing whitespace and comments
9
+ * - Merging and deduplicating rules
10
+ * - Optimizing values and selectors
11
+ * - Removing unused code
12
+ * - Converting values to shorter equivalents
13
+ *
14
+ * The minifier preserves source maps when available and provides detailed
15
+ * error messages for debugging minification issues.
16
+ * @example
17
+ * ```typescript
18
+ * // Usage in plugin configuration
19
+ * {
20
+ * minifier: cssnanoMinifier,
21
+ * cssnano: {
22
+ * preset: ['default', {
23
+ * discardComments: { removeAll: true },
24
+ * normalizeWhitespace: false
25
+ * }]
26
+ * }
27
+ * }
28
+ * ```
29
+ */
14
30
  declare const cssnanoMinifier: Minifier<Options>;
15
-
16
- export { cssnanoMinifier as default };
31
+ export default cssnanoMinifier;
@@ -1,16 +1,30 @@
1
- import { M as Minifier, a as InternalStyleOptions } from '../packem_shared/types-B7InbTq8.js';
2
- import 'cssnano';
3
- import 'lightningcss';
4
- import 'postcss';
5
- import 'postcss-load-config';
6
- import '@visulima/packem-share/types';
7
- import 'sass';
8
- import 'sass-embedded';
9
- import 'stylus';
10
- import '@visulima/packem-share/utils';
11
- import 'rollup';
12
- import 'source-map-js';
13
-
1
+ import type { InternalStyleOptions } from "../types.d.ts";
2
+ import type { Minifier } from "./types.d.ts";
3
+ /**
4
+ * LightningCSS minifier implementation for high-performance CSS optimization.
5
+ *
6
+ * This minifier uses LightningCSS, a fast CSS parser and transformer written in Rust,
7
+ * to optimize CSS with excellent performance characteristics. It provides:
8
+ * - Ultra-fast parsing and minification
9
+ * - Browser-specific optimizations based on targets
10
+ * - Advanced CSS transformations and vendor prefixing
11
+ * - Built-in support for modern CSS features
12
+ * - Comprehensive warning system for potential issues
13
+ *
14
+ * The minifier automatically converts browserslist targets to LightningCSS format
15
+ * and reports any warnings encountered during the minification process.
16
+ * @example
17
+ * ```typescript
18
+ * // Usage in plugin configuration
19
+ * {
20
+ * minifier: lightningcssMinifier,
21
+ * lightningcss: {
22
+ * targets: { chrome: 90 },
23
+ * unusedSymbols: ['old-class'],
24
+ * errorRecovery: true
25
+ * }
26
+ * }
27
+ * ```
28
+ */
14
29
  declare const lightningcssMinifier: Minifier<NonNullable<InternalStyleOptions["lightningcss"]>>;
15
-
16
- export { lightningcssMinifier as default };
30
+ export default lightningcssMinifier;
@@ -0,0 +1,64 @@
1
+ import type { RollupLogger } from "@visulima/packem-share/utils";
2
+ import type { LoaderContext } from "../loaders/types.d.ts";
3
+ import type { ExtractedData } from "../types.d.ts";
4
+ /**
5
+ * Context object provided to minifier handlers during CSS minification.
6
+ *
7
+ * Contains build-time information and utilities needed for proper minification:
8
+ * - Browser compatibility targets for optimization decisions
9
+ * - Logging system for reporting minification issues
10
+ */
11
+ type MinifierContext = {
12
+ /** Browser targets for compatibility-aware minification */
13
+ readonly browserTargets: string[];
14
+ /**
15
+ * Rollup-compatible logger for reporting minification issues.
16
+ * Provides consistent logging across all plugin operations.
17
+ */
18
+ readonly logger: RollupLogger;
19
+ };
20
+ /**
21
+ * Interface for CSS minification plugins.
22
+ *
23
+ * Minifiers are responsible for optimizing CSS content while preserving
24
+ * functionality and maintaining source maps when available. They receive
25
+ * extracted CSS data and return optimized versions.
26
+ * @template Options Configuration options type for the minifier
27
+ * @example
28
+ * ```typescript
29
+ * const myMinifier: Minifier<MyOptions> = {
30
+ * name: 'my-minifier',
31
+ * async handler(data, sourceMap, options) {
32
+ * // Minify CSS content
33
+ * const minified = await minifyCss(data.css, options);
34
+ *
35
+ * // Report any warnings
36
+ * if (minified.warnings.length > 0) {
37
+ * this.logger.warn({ message: `Minification warnings: ${minified.warnings.join(', ')}` });
38
+ * }
39
+ *
40
+ * return {
41
+ * ...data,
42
+ * css: minified.css,
43
+ * map: minified.map
44
+ * };
45
+ * }
46
+ * };
47
+ * ```
48
+ */
49
+ export interface Minifier<Options = Record<string, any>> {
50
+ /**
51
+ * Minification handler function.
52
+ *
53
+ * Processes CSS content and returns optimized version with updated source maps.
54
+ * The handler is called with minifier context containing browser targets and warning utilities.
55
+ * @param data Extracted CSS data to minify
56
+ * @param sourceMap Source map configuration from loader context
57
+ * @param options Minifier-specific configuration options
58
+ * @returns Promise resolving to minified CSS data
59
+ */
60
+ handler: (this: MinifierContext, data: ExtractedData, sourceMap: LoaderContext["sourceMap"], options: Options) => Promise<ExtractedData>;
61
+ /** Unique name identifier for the minifier */
62
+ name: string;
63
+ }
64
+ export {};
@@ -0,0 +1,224 @@
1
+ import type { Options } from "cssnano";
2
+ import type { CustomAtRules, TransformOptions } from "lightningcss";
3
+ import type { AcceptedPlugin, PluginCreator } from "postcss";
4
+ import type { Config as PostCSSConfig } from "postcss-load-config";
5
+ import type { LESSLoaderOptions } from "./loaders/less/types.d.ts";
6
+ import type { ImportOptions } from "./loaders/postcss/import/types.d.ts";
7
+ import type { ModulesOptions } from "./loaders/postcss/modules/index.d.ts";
8
+ import type { UrlOptions } from "./loaders/postcss/url/index.d.ts";
9
+ import type { SassLoaderOptions } from "./loaders/sass/types.d.ts";
10
+ import type { StylusLoaderOptions } from "./loaders/stylus/types.d.ts";
11
+ import type { Loader, SourceMapOptions } from "./loaders/types.d.ts";
12
+ import type { Minifier } from "./minifiers/types.d.ts";
13
+ export type AutoModules = RegExp | boolean | ((id: string) => boolean);
14
+ /** CSS data for extraction */
15
+ export interface ExtractedData {
16
+ /** CSS */
17
+ css: string;
18
+ /** Sourcemap */
19
+ map?: string;
20
+ /** Output name for CSS */
21
+ name: string;
22
+ }
23
+ /** Options for CSS injection */
24
+ export interface InjectOptions {
25
+ /**
26
+ * Set attributes of injected `&lt;style>` tag(s)
27
+ * - ex.: `{"id":"global"}`
28
+ */
29
+ attributes?: Record<string, string>;
30
+ /**
31
+ * Container for `&lt;style>` tag(s) injection
32
+ * @default "head"
33
+ */
34
+ container?: string;
35
+ /**
36
+ * Package method name to use with the package
37
+ * @default "cssStyleInject"
38
+ */
39
+ method?: string;
40
+ /**
41
+ * Package to import the CSS injector from
42
+ * @default "@visulima/css-style-inject"
43
+ */
44
+ package?: string;
45
+ /**
46
+ * Insert `&lt;style>` tag(s) to the beginning of the container
47
+ * @default false
48
+ */
49
+ prepend?: boolean;
50
+ /**
51
+ * Inject CSS into single `&lt;style>` tag only
52
+ * @default false
53
+ */
54
+ singleTag?: boolean;
55
+ /**
56
+ * Makes injector treeshakeable,
57
+ * as it is only called when either classes are referenced directly,
58
+ * or `inject` function is called from the default export.
59
+ *
60
+ * Incompatible with `namedExports` option.
61
+ */
62
+ treeshakeable?: boolean;
63
+ }
64
+ export interface InternalStyleOptions extends StyleOptions {
65
+ /** @see {@link StyleOptions.mode} */
66
+ emit: boolean;
67
+ extensions: NonNullable<StyleOptions["extensions"]>;
68
+ /** @see {@link StyleOptions.mode} */
69
+ extract: boolean | string;
70
+ /** @see {@link StyleOptions.mode} */
71
+ inject: InjectOptions | boolean | ((varname: string, id: string, output: string[]) => string);
72
+ /** @see {@link StyleOptions.mode} */
73
+ inline: boolean;
74
+ }
75
+ export type LightningCSSOptions = Omit<TransformOptions<CustomAtRules>, "code" | "cssModules" | "filename" | "minify" | "targets"> & {
76
+ modules?: TransformOptions<CustomAtRules>["cssModules"] & {
77
+ /**
78
+ * Files to include for [CSS Modules](https://github.com/css-modules/css-modules)
79
+ * for files named `[name].module.[ext]`
80
+ * (e.g. `foo.module.css`, `bar.module.stylus`),
81
+ * or pass your own function or regular expression
82
+ * @default false
83
+ */
84
+ include?: AutoModules;
85
+ };
86
+ };
87
+ /** Options for PostCSS config loader */
88
+ export interface PostCSSConfigLoaderOptions {
89
+ /**
90
+ * Context object passed to PostCSS config file
91
+ */
92
+ ctx?: Record<string, unknown>;
93
+ /** Path to PostCSS config file directory */
94
+ path?: string;
95
+ }
96
+ export interface PostCSSOptions {
97
+ /**
98
+ * Enable/disable or pass options for PostCSS config loader.
99
+ */
100
+ config?: PostCSSConfigLoaderOptions | false;
101
+ /**
102
+ * Enable/disable or pass options for CSS `@import` resolver.
103
+ */
104
+ import?: Partial<ImportOptions> | false;
105
+ /**
106
+ * Enable/disable or pass options for
107
+ * [CSS Modules](https://github.com/css-modules/css-modules)
108
+ * @default false
109
+ */
110
+ modules?: ModulesOptions | boolean;
111
+ /**
112
+ * Set PostCSS parser, e.g. `sugarss`.
113
+ * Overrides the one loaded from PostCSS config file, if any.
114
+ */
115
+ parser?: PostCSSConfig["parser"] | string;
116
+ /**
117
+ * A list of plugins for PostCSS,
118
+ * which are used before plugins loaded from PostCSS config file, if any.
119
+ */
120
+ plugins?: (AcceptedPlugin | string | [PluginCreator<unknown> | string, Record<string, unknown>] | [PluginCreator<unknown> | string] | null | undefined)[] | Record<string, unknown>;
121
+ /**
122
+ * Set PostCSS stringifier.
123
+ * Overrides the one loaded from PostCSS config file, if any.
124
+ */
125
+ stringifier?: PostCSSConfig["stringifier"] | string;
126
+ /**
127
+ * Set PostCSS syntax.
128
+ * Overrides the one loaded from PostCSS config file, if any.
129
+ */
130
+ syntax?: PostCSSConfig["syntax"] | string;
131
+ /** `to` option for PostCSS, required for some plugins. */
132
+ to?: PostCSSConfig["to"];
133
+ /**
134
+ * Enable/disable or pass options for CSS URL resolver.
135
+ */
136
+ url?: Partial<UrlOptions> | false;
137
+ }
138
+ /** `rollup-plugin-styles`'s full option list */
139
+ export interface StyleOptions {
140
+ /**
141
+ * Aliases for URL and import paths
142
+ * - ex.: `{"foo":"bar"}`
143
+ */
144
+ alias?: Record<string, string>;
145
+ /**
146
+ * Automatically enable
147
+ * [CSS Modules](https://github.com/css-modules/css-modules)
148
+ * for files named `[name].module.[ext]`
149
+ * (e.g. `foo.module.css`, `bar.module.stylus`),
150
+ * or pass your own function or regular expression
151
+ * @default false
152
+ */
153
+ autoModules?: AutoModules;
154
+ /**
155
+ * Options for cssnano minifier
156
+ */
157
+ cssnano?: Options;
158
+ /**
159
+ * Generate TypeScript declarations files for input style files
160
+ */
161
+ dts?: boolean;
162
+ /** Files to exclude from processing */
163
+ exclude?: ReadonlyArray<RegExp | string> | RegExp | string | undefined;
164
+ /**
165
+ * Plugin will process files ending with these extensions
166
+ * @default [".css", ".pcss", ".postcss", ".sss"]
167
+ */
168
+ extensions?: string[];
169
+ /** Files to include for processing */
170
+ include?: ReadonlyArray<RegExp | string> | RegExp | string | undefined;
171
+ /** Options for Less loader */
172
+ less?: LESSLoaderOptions;
173
+ /** Options for LightningCSS */
174
+ lightningcss?: LightningCSSOptions;
175
+ /** Array of custom loaders */
176
+ loaders?: Loader[];
177
+ /** Enable the css minifier */
178
+ minifier?: Minifier;
179
+ /**
180
+ * Select mode for this plugin:
181
+ * - `"inject"` *(default)* - Embeds CSS inside JS and injects it into `&lt;head>` at runtime.
182
+ * You can also pass options for CSS injection.
183
+ * Alternatively, you can pass your own CSS injector.
184
+ * - `"extract"` - Extract CSS to the same location where JS file is generated but with `.css` extension.
185
+ * You can also set extraction path manually,
186
+ * relative to output dir/output file's basedir,
187
+ * but not outside of it.
188
+ * - `"emit"` - Emit pure processed CSS and pass it along the build pipeline.
189
+ * Useful if you want to preprocess CSS before using it with CSS consuming plugins.
190
+ * - `"inline"` - Embed CSS directly as strings in JavaScript modules.
191
+ * Reduces HTTP requests but increases bundle size. Ideal for small CSS files or critical CSS.
192
+ * @default "inject"
193
+ */
194
+ mode?: "emit" | "extract" | "inject" | "inline" | ["extract", string] | ["inject", InjectOptions | ((varname: string, id: string) => string)];
195
+ /**
196
+ * Use named exports alongside default export.
197
+ * You can pass a function to control how exported name is generated.
198
+ * @default false
199
+ */
200
+ namedExports?: boolean | ((name: string) => string);
201
+ /**
202
+ * Function which is invoked on CSS file extraction.
203
+ * Return `boolean` to control if file should be extracted or not.
204
+ */
205
+ onExtract?: (data: ExtractedData) => boolean;
206
+ /**
207
+ * Function which is invoked on CSS file import,
208
+ * before any transformations are applied
209
+ */
210
+ onImport?: (code: string, id: string) => void;
211
+ /**
212
+ * Options for PostCSS
213
+ */
214
+ postcss?: PostCSSOptions;
215
+ /** Options for Sass loader */
216
+ sass?: SassLoaderOptions;
217
+ /**
218
+ * Enable/disable or configure sourcemaps
219
+ * @default false
220
+ */
221
+ sourceMap?: boolean | "inline" | [boolean | "inline", SourceMapOptions] | [boolean | "inline"];
222
+ /** Options for Stylus loader */
223
+ stylus?: StylusLoaderOptions;
224
+ }
@@ -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,72 +1,9 @@
1
- import { SourceMapGenerator, RawSourceMap, SourceMapConsumer } from 'source-map-js';
2
- import { k as Extracted, b as PostCSSOptions, S as StyleOptions, a as InternalStyleOptions, l as LoaderContext } from '../packem_shared/types-B7InbTq8.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 '@visulima/packem-share/types';
10
- import 'sass';
11
- import 'sass-embedded';
12
- import 'stylus';
13
- import 'rollup';
14
-
15
- declare const arrayFmt: (array: string[]) => string;
16
-
17
- interface Concatenated {
18
- css: string;
19
- map: SourceMapGenerator;
20
- }
21
- declare const concat: (extracted: Extracted[]) => Promise<Concatenated>;
22
-
23
- declare const loadModule: (moduleId: string, cwd: string, logger: RollupLogger) => Promise<any>;
24
-
25
- interface Mode {
26
- emit: InternalStyleOptions["emit"];
27
- extract: InternalStyleOptions["extract"];
28
- inject: InternalStyleOptions["inject"];
29
- inline: InternalStyleOptions["inline"];
30
- }
31
- type PCSSOption = "parser" | "plugin" | "stringifier" | "syntax";
32
- declare const inferModeOption: (mode: StyleOptions["mode"]) => Mode;
33
- declare const inferOption: <T, TDefine extends T | boolean | undefined>(option: T | boolean | undefined, defaultValue: TDefine) => OptionType<T, TDefine>;
34
- declare const inferSourceMapOption: (sourceMap: StyleOptions["sourceMap"]) => LoaderContext["sourceMap"];
35
- declare const inferHandlerOption: <T extends {
36
- alias?: Record<string, string>;
37
- }>(option: T | boolean | undefined, alias: T["alias"]) => T | false;
38
- declare const ensurePCSSOption: <T>(option: T | string, type: PCSSOption, cwd: string, logger: RollupLogger) => Promise<T>;
39
- declare const ensurePCSSPlugins: (plugins: PostCSSOptions["plugins"], cwd: string, logger: RollupLogger) => Promise<Result["plugins"]>;
40
- type OptionType<T, TDefine extends T | boolean | undefined> = T | TDefine | false;
41
-
42
- declare const resolve: (ids: string[], userOptions: ResolveOptions) => string;
43
- interface ResolveOptions extends NapiResolveOptions {
44
- baseDirs?: string[];
45
- caller?: string;
46
- }
47
-
48
- declare const safeId: (id: string, ...salt: string[]) => string;
49
-
50
- declare class MapModifier {
51
- private readonly map?;
52
- constructor(map?: RawSourceMap | string);
53
- modify(f: (m: RawSourceMap) => void): this;
54
- modifySources(op: (source: string) => string): this;
55
- resolve(directory?: string): this;
56
- relative(directory?: string): this;
57
- toObject(): RawSourceMap | undefined;
58
- toString(): string | undefined;
59
- toConsumer(): SourceMapConsumer | undefined;
60
- toCommentData(): string;
61
- toCommentFile(fileName: string): string;
62
- }
63
- declare const getMap: (code: string, id?: string) => Promise<string | undefined>;
64
- declare const stripMap: (code: string) => string;
65
- declare const mm: (map?: RawSourceMap | string) => MapModifier;
66
-
67
- declare const hasModuleSpecifier: (url: string) => boolean;
68
- declare const getUrlOfPartial: (url: string) => string;
69
- declare const normalizeUrl: (url: string) => string;
70
-
71
- export { arrayFmt, concat, ensurePCSSOption, ensurePCSSPlugins, getMap, getUrlOfPartial, hasModuleSpecifier, inferHandlerOption, inferModeOption, inferOption, inferSourceMapOption, loadModule, mm, normalizeUrl, resolve, safeId, stripMap };
72
- 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,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;