@visulima/rollup-plugin-css 1.0.0-alpha.4 → 1.0.0-alpha.40
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/CHANGELOG.md +329 -0
- package/LICENSE.md +83 -79
- package/README.md +164 -146
- package/dist/css-modules-types.d.ts +38 -0
- package/dist/css-plugin.d.ts +44 -0
- package/dist/index.d.ts +40 -20
- package/dist/index.js +1 -0
- package/dist/loaders/less/importer.d.ts +2 -0
- package/dist/loaders/less/index.d.ts +37 -9
- package/dist/loaders/less/index.js +1 -0
- package/dist/loaders/less/types.d.ts +24 -0
- package/dist/loaders/lightningcss.d.ts +13 -16
- package/dist/loaders/lightningcss.js +3 -0
- package/dist/loaders/loader-manager.d.ts +78 -0
- package/dist/loaders/postcss/constants.d.ts +20 -0
- package/dist/loaders/postcss/icss/index.d.ts +8 -0
- package/dist/loaders/postcss/icss/load.d.ts +5 -0
- package/dist/loaders/postcss/icss/resolve.d.ts +6 -0
- package/dist/loaders/postcss/import/apply-conditions.d.ts +10 -0
- package/dist/loaders/postcss/import/apply-raws.d.ts +3 -0
- package/dist/loaders/postcss/import/apply-styles.d.ts +10 -0
- package/dist/loaders/postcss/import/constants.d.ts +12 -0
- package/dist/loaders/postcss/import/import-resolve.d.ts +3 -0
- package/dist/loaders/postcss/import/index.d.ts +12 -0
- package/dist/loaders/postcss/import/parser/parse-at-import.d.ts +9 -0
- package/dist/loaders/postcss/import/parser/parse-styles.d.ts +6 -0
- package/dist/loaders/postcss/import/parser/parse-stylesheet.d.ts +10 -0
- package/dist/loaders/postcss/import/types.d.ts +95 -0
- package/dist/loaders/postcss/import/utils/base64-encoded-import.d.ts +3 -0
- package/dist/loaders/postcss/import/utils/data-url.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/format-import-prelude.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/load-content.d.ts +2 -0
- package/dist/loaders/postcss/import/utils/process-content.d.ts +4 -0
- package/dist/loaders/postcss/import/utils/statement.d.ts +6 -0
- package/dist/loaders/postcss/index.d.ts +27 -16
- package/dist/loaders/postcss/index.js +6 -0
- package/dist/loaders/postcss/load-config.d.ts +6 -0
- package/dist/loaders/postcss/modules/generate.d.ts +11 -0
- package/dist/loaders/postcss/modules/index.d.ts +35 -0
- package/dist/loaders/postcss/noop.d.ts +22 -0
- package/dist/loaders/postcss/url/generate.d.ts +2 -0
- package/dist/loaders/postcss/url/index.d.ts +46 -0
- package/dist/loaders/postcss/url/inline.d.ts +20 -0
- package/dist/loaders/postcss/url/url-resolve.d.ts +12 -0
- package/dist/loaders/postcss/url/utils.d.ts +4 -0
- package/dist/loaders/sass/index.d.ts +5 -9
- package/dist/loaders/sass/{index.mjs → index.js} +5 -5
- package/dist/loaders/sass/modern/importer.d.ts +3 -0
- package/dist/loaders/sass/types.d.ts +20 -0
- package/dist/loaders/sass/utils/get-sass-compiler.d.ts +8 -0
- package/dist/loaders/sass/utils/get-sass-options.d.ts +7 -0
- package/dist/loaders/sass/utils/normalize-source-map.d.ts +3 -0
- package/dist/loaders/sass/utils/resolve-syntax.d.ts +2 -0
- package/dist/loaders/sass/utils/sass-error-factory.d.ts +15 -0
- package/dist/loaders/sourcemap.d.ts +24 -16
- package/dist/loaders/sourcemap.js +1 -0
- package/dist/loaders/stylus/index.d.ts +8 -9
- package/dist/loaders/stylus/index.js +2 -0
- package/dist/loaders/stylus/types.d.ts +87 -0
- package/dist/loaders/tailwindcss-oxide.d.ts +5 -16
- package/dist/loaders/tailwindcss-oxide.js +1 -0
- package/dist/loaders/types.d.ts +102 -0
- package/dist/loaders/utils/ensure-auto-modules.d.ts +39 -0
- package/dist/loaders/utils/match-file.d.ts +32 -0
- package/dist/minifiers/cssnano.d.ts +30 -16
- package/dist/minifiers/lightningcss.d.ts +29 -16
- package/dist/minifiers/types.d.ts +64 -0
- package/dist/packem_shared/concat-WcWAYbOc.js +3 -0
- package/dist/packem_shared/{cssModulesTypesPlugin-B9_bJo_B.mjs → cssModulesTypesPlugin-CjGroK2y.js} +1 -1
- package/dist/packem_shared/{generate-js-exports-Dqps7nWG.mjs → generate-js-exports-BhS4eLrN.js} +1 -1
- package/dist/packem_shared/getMap-TR-0DXUr.js +1 -0
- package/dist/packem_shared/inferModeOption-9h3Eq6JH.js +1 -0
- package/dist/packem_shared/loadModule-D20jQQNu.js +1 -0
- package/dist/packem_shared/resolve-anj9ucIq.js +1 -0
- package/dist/packem_shared/rollupCssPlugin-BxRedPmA.js +3 -0
- package/dist/packem_shared/{sourcemap-DGfgaUBb.mjs → sourcemap-CB6ochh0.js} +1 -1
- package/dist/types.d.ts +224 -0
- package/dist/utils/array-fmt.d.ts +18 -0
- package/dist/utils/concat.d.ts +34 -0
- package/dist/utils/generate-js-exports.d.ts +78 -0
- package/dist/utils/index.d.ts +9 -73
- package/dist/utils/index.js +1 -0
- package/dist/utils/load-module.d.ts +3 -0
- package/dist/utils/options.d.ts +155 -0
- package/dist/utils/resolve.d.ts +35 -0
- package/dist/utils/safe-id.d.ts +23 -0
- package/dist/utils/sourcemap.d.ts +42 -0
- package/dist/utils/url.d.ts +8 -0
- package/package.json +56 -41
- package/dist/index.d.mts +0 -20
- package/dist/index.mjs +0 -1
- package/dist/loaders/less/index.d.mts +0 -17
- package/dist/loaders/less/index.mjs +0 -1
- package/dist/loaders/lightningcss.d.mts +0 -17
- package/dist/loaders/lightningcss.mjs +0 -3
- package/dist/loaders/postcss/index.d.mts +0 -17
- package/dist/loaders/postcss/index.mjs +0 -6
- package/dist/loaders/sass/index.d.mts +0 -18
- package/dist/loaders/sourcemap.d.mts +0 -17
- package/dist/loaders/sourcemap.mjs +0 -1
- package/dist/loaders/stylus/index.d.mts +0 -17
- package/dist/loaders/stylus/index.mjs +0 -1
- package/dist/loaders/tailwindcss-oxide.d.mts +0 -17
- package/dist/loaders/tailwindcss-oxide.mjs +0 -1
- package/dist/minifiers/cssnano.d.mts +0 -17
- package/dist/minifiers/lightningcss.d.mts +0 -17
- package/dist/packem_shared/concat-BbvpVPBg.mjs +0 -3
- package/dist/packem_shared/getMap-BL5hKEnR.mjs +0 -1
- package/dist/packem_shared/inferModeOption-fAc592HP.mjs +0 -1
- package/dist/packem_shared/loadModule-CovDETwT.mjs +0 -1
- package/dist/packem_shared/resolve-nqhcPNJ9.mjs +0 -1
- package/dist/packem_shared/rollupCssPlugin-CJSS-7Mi.mjs +0 -3
- package/dist/packem_shared/types-CA9pSumu.d.mts +0 -189
- package/dist/packem_shared/types-CA9pSumu.d.ts +0 -189
- package/dist/utils/index.d.mts +0 -73
- package/dist/utils/index.mjs +0 -1
- /package/dist/minifiers/{cssnano.mjs → cssnano.js} +0 -0
- /package/dist/minifiers/{lightningcss.mjs → lightningcss.js} +0 -0
- /package/dist/packem_shared/{arrayFmt-Dek5cB7m.mjs → arrayFmt-Dek5cB7m.js} +0 -0
- /package/dist/packem_shared/{ensure-auto-modules-BU3xWEjl.mjs → ensure-auto-modules-BU3xWEjl.js} +0 -0
- /package/dist/packem_shared/{hasModuleSpecifier-DIZeev_W.mjs → hasModuleSpecifier-DIZeev_W.js} +0 -0
- /package/dist/packem_shared/{safeId-BN5akJYJ.mjs → safeId-BN5akJYJ.js} +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import type { Environment } from "@visulima/packem-share/types";
|
|
2
|
+
import type { RollupLogger } from "@visulima/packem-share/utils";
|
|
3
|
+
import type { CustomPluginOptions, PluginContext } from "rollup";
|
|
4
|
+
import type { RawSourceMap } from "source-map-js";
|
|
5
|
+
import type { InternalStyleOptions } from "../types.d.ts";
|
|
6
|
+
export interface Extracted {
|
|
7
|
+
/** CSS */
|
|
8
|
+
css: string;
|
|
9
|
+
/** Source file path */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Sourcemap */
|
|
12
|
+
map?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* @param T type of loader's options
|
|
16
|
+
*/
|
|
17
|
+
export interface Loader<T = Record<string, unknown>> {
|
|
18
|
+
/** Skip testing, always process the file */
|
|
19
|
+
alwaysProcess?: boolean;
|
|
20
|
+
/** Name */
|
|
21
|
+
name: string;
|
|
22
|
+
/** Function for processing */
|
|
23
|
+
process: (this: LoaderContext<T>, payload: Payload) => Payload | Promise<Payload>;
|
|
24
|
+
/**
|
|
25
|
+
* Test to control if file should be processed.
|
|
26
|
+
* Also used for plugin's supported files test.
|
|
27
|
+
*/
|
|
28
|
+
test?: RegExp | ((file: string) => boolean);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @param T type of loader's options
|
|
32
|
+
*/
|
|
33
|
+
export interface LoaderContext<T = Record<string, unknown>> {
|
|
34
|
+
readonly alias?: Record<string, string>;
|
|
35
|
+
/** Assets to emit */
|
|
36
|
+
readonly assets: Map<string, Uint8Array>;
|
|
37
|
+
/** @see {@link InternalStyleOptions.autoModules} */
|
|
38
|
+
readonly autoModules: InternalStyleOptions["autoModules"];
|
|
39
|
+
/** Browser targets */
|
|
40
|
+
readonly browserTargets: string[];
|
|
41
|
+
readonly cwd?: string;
|
|
42
|
+
readonly debug?: boolean;
|
|
43
|
+
/** Files to watch */
|
|
44
|
+
readonly deps: Set<string>;
|
|
45
|
+
/** @see {@link InternalStyleOptions.dts} */
|
|
46
|
+
readonly dts: InternalStyleOptions["dts"];
|
|
47
|
+
/** @see {@link InternalStyleOptions.emit} */
|
|
48
|
+
readonly emit: InternalStyleOptions["emit"];
|
|
49
|
+
readonly environment: Environment;
|
|
50
|
+
/** @see {@link InternalStyleOptions.extensions} */
|
|
51
|
+
readonly extensions: InternalStyleOptions["extensions"];
|
|
52
|
+
/** @see {@link InternalStyleOptions.extract} */
|
|
53
|
+
readonly extract: InternalStyleOptions["extract"];
|
|
54
|
+
/** Resource path */
|
|
55
|
+
readonly id: string;
|
|
56
|
+
/** @see {@link InternalStyleOptions.inject} */
|
|
57
|
+
readonly inject: InternalStyleOptions["inject"];
|
|
58
|
+
/** @see {@link InternalStyleOptions.inline} */
|
|
59
|
+
readonly inline: InternalStyleOptions["inline"];
|
|
60
|
+
/** Rollup-compatible logger for plugin messages */
|
|
61
|
+
readonly logger: RollupLogger;
|
|
62
|
+
/** @see {@link InternalStyleOptions.namedExports} */
|
|
63
|
+
readonly namedExports: InternalStyleOptions["namedExports"];
|
|
64
|
+
/**
|
|
65
|
+
* Type-safe configuration options passed to the loader instance
|
|
66
|
+
* @default {}
|
|
67
|
+
*/
|
|
68
|
+
readonly options: T;
|
|
69
|
+
/** [Plugin's context](https://rollupjs.org/guide/en#plugin-context) */
|
|
70
|
+
readonly plugin: PluginContext;
|
|
71
|
+
readonly sourceDir?: string;
|
|
72
|
+
/** @see {@link InternalStyleOptions.sourceMap} */
|
|
73
|
+
readonly sourceMap: false | (SourceMapOptions & {
|
|
74
|
+
inline: boolean;
|
|
75
|
+
});
|
|
76
|
+
readonly useSourcemap: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface Payload {
|
|
79
|
+
/** File content */
|
|
80
|
+
code: string;
|
|
81
|
+
dts?: string;
|
|
82
|
+
/** Extracted data */
|
|
83
|
+
extracted?: Extracted;
|
|
84
|
+
/** Sourcemap */
|
|
85
|
+
map?: string;
|
|
86
|
+
/** Additional metadata exposed to other Rollup plugins */
|
|
87
|
+
meta?: CustomPluginOptions;
|
|
88
|
+
}
|
|
89
|
+
export type PostCSSMeta = {
|
|
90
|
+
icssDependencies: string[];
|
|
91
|
+
moduleContents: string;
|
|
92
|
+
types: string;
|
|
93
|
+
};
|
|
94
|
+
export interface SourceMapOptions {
|
|
95
|
+
/**
|
|
96
|
+
* Include sources content
|
|
97
|
+
* @default true
|
|
98
|
+
*/
|
|
99
|
+
content?: boolean;
|
|
100
|
+
/** Function for transforming resulting sourcemap */
|
|
101
|
+
transform?: (map: RawSourceMap, name?: string) => void;
|
|
102
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { AutoModules } from "../../types.d.ts";
|
|
2
|
+
/**
|
|
3
|
+
* Determines if CSS modules should be enabled for a given file.
|
|
4
|
+
*
|
|
5
|
+
* This function checks various conditions to decide whether CSS modules
|
|
6
|
+
* processing should be applied to a file:
|
|
7
|
+
*
|
|
8
|
+
* 1. If AutoModules is undefined, defaults to true (enable modules)
|
|
9
|
+
* 2. If AutoModules is a function, calls it with the file ID
|
|
10
|
+
* 3. If AutoModules is a RegExp, tests it against the file ID
|
|
11
|
+
* 4. If AutoModules is true, uses the default module file pattern
|
|
12
|
+
* 5. If AutoModules is false, modules are disabled
|
|
13
|
+
*
|
|
14
|
+
* The default pattern matches files with `.module.` in their name,
|
|
15
|
+
* following the convention used by Vite and other build tools.
|
|
16
|
+
* @param am AutoModules configuration (function, RegExp, boolean, or undefined)
|
|
17
|
+
* @param id File identifier/path to test
|
|
18
|
+
* @returns True if CSS modules should be enabled for this file
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // Function-based detection
|
|
22
|
+
* ensureAutoModules((id) => id.includes('.module.'), 'styles.module.css') // true
|
|
23
|
+
*
|
|
24
|
+
* // RegExp-based detection
|
|
25
|
+
* ensureAutoModules(/\.module\./, 'styles.module.css') // true
|
|
26
|
+
*
|
|
27
|
+
* // Boolean enable with default pattern
|
|
28
|
+
* ensureAutoModules(true, 'styles.module.css') // true
|
|
29
|
+
* ensureAutoModules(true, 'styles.css') // false
|
|
30
|
+
*
|
|
31
|
+
* // Boolean disable
|
|
32
|
+
* ensureAutoModules(false, 'styles.module.css') // false
|
|
33
|
+
*
|
|
34
|
+
* // Undefined defaults to true with pattern check
|
|
35
|
+
* ensureAutoModules(undefined, 'styles.module.css') // true
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const ensureAutoModules: (am: AutoModules | undefined, id: string) => boolean;
|
|
39
|
+
export default ensureAutoModules;
|
|
@@ -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,17 +1,31 @@
|
|
|
1
|
-
import { Options } from
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
*/
|
|
15
30
|
declare const cssnanoMinifier: Minifier<Options>;
|
|
16
|
-
|
|
17
|
-
export = cssnanoMinifier;
|
|
31
|
+
export default cssnanoMinifier;
|
|
@@ -1,17 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
*/
|
|
15
29
|
declare const lightningcssMinifier: Minifier<NonNullable<InternalStyleOptions["lightningcss"]>>;
|
|
16
|
-
|
|
17
|
-
export = lightningcssMinifier;
|
|
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,3 @@
|
|
|
1
|
+
var l=Object.defineProperty;var u=(o,n)=>l(o,"name",{value:n,configurable:!0});import{SourceMapGenerator as p}from"source-map-js";import{m as f}from"./sourcemap-CB6ochh0.js";var g=Object.defineProperty,d=u((o,n)=>g(o,"name",{value:n,configurable:!0}),"u");const j=d(async o=>{const n=new p({file:""}),a=[];let c=0;for await(const{css:s,map:m}of o){a.push(s);const i=f(m),t=i.toObject();if(t){const r=i.toConsumer();if(r&&(r.eachMapping(e=>{n.addMapping({generated:{column:e.generatedColumn,line:c+e.generatedLine},name:e.name,original:{column:e.originalColumn,line:e.originalLine},source:e.source})}),t.sourcesContent))for(const e of t.sources)n.setSourceContent(e,r.sourceContentFor(e,!0))}c+=s.split(`
|
|
2
|
+
`).length}return{css:a.join(`
|
|
3
|
+
`),map:n}},"concat");export{j as default};
|
package/dist/packem_shared/{cssModulesTypesPlugin-B9_bJo_B.mjs → cssModulesTypesPlugin-CjGroK2y.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var a=Object.defineProperty;var c=(s,e)=>a(s,"name",{value:e,configurable:!0});import{isAccessible as r,writeFile as m}from"@visulima/fs";import{normalize as p}from"@visulima/path";import{n as l}from"./ensure-auto-modules-BU3xWEjl.
|
|
1
|
+
var a=Object.defineProperty;var c=(s,e)=>a(s,"name",{value:e,configurable:!0});import{isAccessible as r,writeFile as m}from"@visulima/fs";import{normalize as p}from"@visulima/path";import{n as l}from"./ensure-auto-modules-BU3xWEjl.js";var u=Object.defineProperty,d=c((s,e)=>u(s,"name",{value:e,configurable:!0}),"u");const g=`
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
/* prettier-ignore */
|
|
4
4
|
// @ts-nocheck
|
package/dist/packem_shared/{generate-js-exports-Dqps7nWG.mjs → generate-js-exports-BhS4eLrN.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var G=Object.defineProperty;var C=(r,s)=>G(r,"name",{value:s,configurable:!0});import{relative as V,basename as P}from"@visulima/path";import R from"./safeId-BN5akJYJ.
|
|
1
|
+
var G=Object.defineProperty;var C=(r,s)=>G(r,"name",{value:s,configurable:!0});import{relative as V,basename as P}from"@visulima/path";import R from"./safeId-BN5akJYJ.js";var W=Object.defineProperty,w=C((r,s)=>W(r,"name",{value:s,configurable:!0}),"j");const d="css",F=new Set(["abstract","arguments","await","boolean","break","byte","case","catch","char","class","const","continue",d,"debugger","default","delete","do","double","else","enum","eval","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","let","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with","yield"]),D=w(r=>{const s=r.replaceAll(/[^\w$]/g,"_");return F.has(s)?`_${s}`:s},"getClassNameIdentifier"),H=w(({css:r,cssVariableName:s,cwd:l,dts:y,dtsOutput:m,id:j,logger:c,modulesExports:e,modulesVariableName:b,namedExports:$,supportModules:g})=>{const o=[`var ${s} = ${JSON.stringify(r)};`];if($&&Object.keys(e).length>0){const u=typeof $=="function"?$:D;for(const[h,a]of Object.entries(e)){const t=u(h);if(h!==t&&c){const v=l?V(l,j):j;c.warn({message:`Exported \`${h}\` as \`${t}\` in ${v}`})}const n=JSON.stringify(a);o.push(`var ${t} = ${n};`),y&&m.push(`declare const ${t}: ${n};`)}}Object.keys(e).length>0&&o.push(`var ${b} = ${JSON.stringify(e)};`);const p=`
|
|
2
2
|
export default ${g?b:s};
|
|
3
3
|
`;return o.push(p),y&&(m.push(`declare const ${s}: string;`),g&&m.push(`
|
|
4
4
|
interface ModulesExports {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"@visulima/fs";import"@visulima/path";import"source-map-js";import{g as o,m as s,s as i}from"./sourcemap-CB6ochh0.js";export{o as getMap,s as mm,i as stripMap};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var f=Object.defineProperty;var l=(n,r)=>f(n,"name",{value:r,configurable:!0});import p from"./arrayFmt-Dek5cB7m.js";import d from"./loadModule-D20jQQNu.js";var y=Object.defineProperty,o=l((n,r)=>y(n,"name",{value:r,configurable:!0}),"o");const u=["inject","extract","emit","inline"],S=p(u),P=o(n=>{const r=Array.isArray(n)?n:[n];if(r[0]&&!u.includes(r[0]))throw new Error(`Incorrect mode provided, allowed modes are ${S}`);const t=r[0]??"inject";let e=!1,i=!1;return t==="extract"&&(e=r[1]??!0),t==="inject"&&(i=r[1]??!0),{emit:t==="emit",extract:e,inject:i,inline:t==="inline"}},"inferModeOption"),O=o((n,r)=>typeof n=="boolean"?n&&{}:typeof n=="object"?n:r,"inferOption"),j=o(n=>{const r=Array.isArray(n)?n:[n];return r[0]?{content:!0,...r[1],inline:r[0]==="inline"}:!1},"inferSourceMapOption"),b=o((n,r)=>{const t=O(n,{});return r&&typeof t=="object"&&!t.alias&&(t.alias=r),t},"inferHandlerOption"),a=o(async(n,r,t,e)=>{if(typeof n!="string")return n;const i=await d(n,t,e);if(!i)throw new Error(`Unable to load PostCSS ${r} \`${n}\``);return i},"ensurePCSSOption"),h=o(async(n,r,t)=>{if(n===void 0)return[];if(n.length===0)return[];const e=[];for await(const i of n.filter(Boolean)){if(!Array.isArray(i)){e.push(await a(i,"plugin",r,t));continue}const[s,c]=i;c?e.push((await a(s,"plugin",r,t))(c)):e.push(await a(s,"plugin",r,t))}return e},"ensurePCSSPlugins");export{a as ensurePCSSOption,h as ensurePCSSPlugins,b as inferHandlerOption,P as inferModeOption,O as inferOption,j as inferSourceMapOption};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var d=Object.defineProperty;var n=(e,t)=>d(e,"name",{value:t,configurable:!0});import{createRequire as c}from"node:module";import{interopDefault as m,loadModule as f}from"mlly";import{resolve as p}from"./resolve-anj9ucIq.js";var g=Object.defineProperty,u=n((e,t)=>g(e,"name",{value:t,configurable:!0}),"a");const o={},R=[".js",".mjs",".cjs",".json"],y=u(async(e,t)=>{try{return t(e)}catch(r){const s=r;if(s.code==="ERR_REQUIRE_ESM")return m(await f(e));throw s}},"loadModuleFromPath"),E=u(async(e,t,r)=>{if(o[e])return o[e];if(o[e]===null)return;const s={baseDirs:[t],caller:"Module loader",extensions:R,symlinks:!1},i=c(import.meta.url);try{const a=p([e,`./${e}`],s);if(a.startsWith("data:")){r.warn({message:`Skipping data URL module: ${e}`,module:e,plugin:"css"}),o[e]=null;return}o[e]=await y(a,i)}catch(a){r.warn({message:`Failed to resolve or load module: ${a instanceof Error?a.message:String(a)}`,module:e,plugin:"css"}),o[e]=null;return}const l=o[e];return l?.default??l},"loadModule");export{E as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var a=Object.defineProperty;var i=(o,e)=>a(o,"name",{value:e,configurable:!0});import{fileURLToPath as m}from"node:url";import{dirname as f}from"@visulima/path";import{ResolverFactory as x}from"oxc-resolver";import d from"./arrayFmt-Dek5cB7m.js";var u=Object.defineProperty,v=i((o,e)=>u(o,"name",{value:e,configurable:!0}),"l");const b=f(m(import.meta.url)),k=v((o,e)=>{const s={baseDirs:[b],caller:"Resolver",extensions:[".mjs",".js",".cjs",".json"],symlinks:!0,...e},c=new x({extensions:s.extensions,symlinks:s.symlinks});for(const n of s.baseDirs)for(const t of o)try{const{error:r,path:l}=c.sync(n,t);if(l)return l;r&&console.debug(r,{context:[{basedir:n,caller:e.caller,extensions:e.extensions,id:t}]})}catch(r){console.debug(r.message,{context:[{basedir:n,caller:e.caller,error:r,extensions:e.extensions,id:t}]})}throw new Error(`${s.caller} could not resolve ${d(o)}`)},"resolve");export{k as resolve};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
var Y=Object.defineProperty;var N=(e,s)=>Y(e,"name",{value:s,configurable:!0});import{createFilter as ee}from"@rollup/pluginutils";import{createRollupLogger as se}from"@visulima/packem-share/utils";import{dirname as L,normalize as M,isAbsolute as te,relative as U,resolve as oe,parse as T,join as _,basename as V}from"@visulima/path";import{isRelative as ie}from"@visulima/path/utils";import re from"p-queue";import ne from"./concat-WcWAYbOc.js";import{inferSourceMapOption as ae,inferModeOption as ce,inferHandlerOption as W,inferOption as G,ensurePCSSOption as R,ensurePCSSPlugins as le}from"./inferModeOption-9h3Eq6JH.js";import{m as q}from"./sourcemap-CB6ochh0.js";var de=Object.defineProperty,ue=N((e,s)=>de(e,"name",{value:s,configurable:!0}),"r");const J=ue((e,s)=>{if(!s)return!1;if(typeof s=="function")return s(e);if(typeof s.test=="function")return s.test(e);throw new Error("Invalid condition type")},"matchFile");var pe=Object.defineProperty,fe=N((e,s)=>pe(e,"name",{value:s,configurable:!0}),"a");const me=4,ge=process.env.UV_THREADPOOL_SIZE?Number.parseInt(process.env.UV_THREADPOOL_SIZE,10):me;class he{static{N(this,"g")}static{fe(this,"LoaderManager")}test;loaders=new Map;options;workQueue;logger;constructor({extensions:s,loaders:c,logger:y,options:O}){this.test=S=>s.some(f=>S.toLowerCase().endsWith(f)),c.length>0&&this.add(...c),this.options=O,this.logger=y}add(...s){for(const c of s)this.loaders.has(c.name)||this.loaders.set(c.name,c)}isSupported(s){if(this.test(s))return!0;for(const[,c]of this.loaders)if(J(s,c.test))return!0;return!1}async process(s,c){this.workQueue||(this.workQueue=new re({concurrency:ge-1}));for await(const[y,O]of this.loaders){const S={...c,options:this.options[y]??{}};if(O.alwaysProcess||J(S.id,O.test)){this.logger.debug({message:`Processing ${y} loader for ${S.id}`,plugin:"css"});try{const f=await this.workQueue.add(O.process.bind(S,s));f&&(s={...f,extracted:f.extracted??s.extracted,meta:f.meta??s.meta},this.logger.debug({message:`Completed ${y} loader for ${S.id}`,outputSize:f.code?.length||0,plugin:"css"}))}catch(f){throw this.logger.error({file:S.id,loader:y,message:`Error in ${y} loader for ${S.id}: ${f instanceof Error?f.message:String(f)}`,plugin:"css"}),f}}}return s}}var xe=Object.defineProperty,z=N((e,s)=>xe(e,"name",{value:s,configurable:!0}),"b");const ye=z(async(e,s)=>e.sort((c,y)=>s.indexOf(c.name)-s.indexOf(y.name)),"sortByNameOrder"),Fe=z(async(e,s,c,y,O,S,f,Z,K)=>{const C={...K,...e.alias},B=ee(e.include,e.exclude),E=ae(e.sourceMap),i={...ce(e.mode),autoModules:e.autoModules??!1,dts:e.dts,extensions:e.extensions,namedExports:e.namedExports};let a,I,H=!1;if(e.loaders)for(const r of e.loaders)r.name==="postcss"&&(H=!0);else e.loaders=[];H&&(i.postcss={...e.postcss,config:G(e.postcss?.config,{}),import:W(e.postcss?.import,C),modules:G(e.postcss?.modules,void 0),to:e.postcss?.to,url:W(e.postcss?.url,C)});let b=[];const F=z((r,d)=>{const g=[];for(const o of Object.keys(r)){const u=new Set;let h=[o];do{const $=[];for(const m of h){if(u.has(m))continue;if(I.isSupported(m)){B(m)&&$.push(m);continue}u.add(m);const P=d(m);P&&$.push(...P.importedIds)}h=$}while(h.some($=>!I.isSupported($)));g.push(...h)}return g},"traverseImportedModules");return{augmentChunkHash(r){if(b.length===0)return;const d=F(r.modules,this.getModuleInfo),g=b.filter(o=>d.includes(o.id)).sort((o,u)=>d.lastIndexOf(o.id)-d.lastIndexOf(u.id)).map(o=>`${V(o.id)}:${o.css}`);if(g.length!==0)return g.join(":")},async buildStart(){b=[],a=se(this,"css"),H&&i.postcss&&(e.postcss?.parser&&(i.postcss.parser=await R(e.postcss.parser,"parser",c,a)),e.postcss?.syntax&&(i.postcss.syntax=await R(e.postcss.syntax,"syntax",c,a)),e.postcss?.stringifier&&(i.postcss.stringifier=await R(e.postcss.stringifier,"stringifier",c,a)),e.postcss?.plugins&&(i.postcss.plugins=await le(e.postcss.plugins,c,a))),I=new he({extensions:i.extensions,loaders:await ye(e.loaders||[],["sourcemap","stylus","less","sass","postcss"]),logger:a,options:{...e,...i,alias:C}}),a.info({extract:typeof i.extract=="string"?i.extract:"individual",loaders:e.loaders?.map(r=>r.name)||[],message:"CSS plugin initialized",minify:!!(Z&&e.minifier),namedExports:!!i.namedExports,plugin:"css",sourceMap:!!S}),typeof i.inject=="object"&&i.inject.treeshakeable&&(i.namedExports=!1,a.info({message:"Disabling named exports due to `inject.treeshakeable` option",plugin:"css"}))},async generateBundle(r,d){if(b.length===0||!(r.dir||r.file))return;const g=Object.values(d),o=r.dir??L(r.file),u=g.filter(n=>n.type==="chunk"),h=u.filter(n=>!n.facadeModuleId),$=r.preserveModules?u:u.filter(n=>n.isEntry||n.isDynamicEntry),m=[],P=z(async(n,l)=>{const t=typeof i.extract=="string"?M(i.extract).replace(/^\.[/\\]/,""):M(`${n}.css`);te(t)&&this.error(["Extraction path must be relative to the output directory,",`which is ${U(c,o)}`].join(`
|
|
2
|
+
`)),ie(t)&&this.error(["Extraction path must be nested inside output directory,",`which is ${U(c,o)}`].join(`
|
|
3
|
+
`));const w=b.filter(x=>l.includes(x.id)).sort((x,v)=>l.lastIndexOf(x.id)-l.lastIndexOf(v.id)),D=await ne(w);return{css:D.css,map:q(D.map.toString()).relative(L(oe(o,t))).toString(),name:t}},"getExtractedData"),A=z(n=>{if(r.file)return T(r.file).name;if(r.preserveModules){const{dir:l,name:t}=T(n.fileName);return l?_(l,t):t}return n.name},"getName"),k=[];if(typeof i.extract=="string"){a.debug({message:`Extracting to ${i.extract}`,prefix:"css"});const n=[];for(const t of h){const w=F(t.modules,this.getModuleInfo);k.push(...w),n.push(...w)}for(const t of $)n.push(...F(t.modules,this.getModuleInfo).filter(w=>!k.includes(w)));const l=A(u[0]);m.push([l,n])}else{a.debug({message:"Extracting to individual files",prefix:"css"});for(const n of h){const l=F(n.modules,this.getModuleInfo);if(l.length===0)continue;k.push(...l);const t=A(n);m.push([t,l])}for(const n of $){const l=F(n.modules,this.getModuleInfo).filter(w=>!k.includes(w));if(l.length===0)continue;const t=A(n);m.push([t,l])}}for await(const[n,l]of m){const t=await P(n,l);if(typeof e.onExtract=="function"&&!e.onExtract(t))continue;if(Z&&e.minifier){a.info({message:`Minifying ${t.name} with ${e.minifier.name}`,prefix:"css"});const{css:x,map:v}=await e.minifier.handler.bind({browserTargets:s,logger:a})(t,E,e[e.minifier.name]??{});t.css=x,t.map=v}const w={fileName:t.name,name:t.name,names:[t.name],originalFileName:t.name,originalFileNames:[t.name],source:t.css,type:"asset"},D=this.emitFile(w);if(a.info({chunkIds:l.length,hasSourceMap:!!(t.map&&E),message:`Emitted CSS file: ${t.name}`,plugin:"css",size:t.css.length}),t.map&&E){const x=this.getFileName(D);let v="assert";typeof r.assetFileNames=="string"?v=M(L(r.assetFileNames)):typeof r.assetFileNames=="function"&&(v=M(L(r.assetFileNames(w))));const j=q(t.map).modify(p=>(p.file=V(x),p)).modifySources(p=>{if(p==="<no source>"||v.length<=1)return p;p=`../${p}`;for(const Q of v)Q==="/"&&(p=`../${p}`);return p});if(E.inline)j.modify(p=>E.transform?.(p,M(_(o,x)))),d[x].source+=j.toCommentData(),a.debug({message:`Generated inline source map for ${x}`,plugin:"css"});else{const p=`${x}.map`;j.modify(X=>E.transform?.(X,M(_(o,p)))),this.emitFile({fileName:p,source:j.toString(),type:"asset"});const{base:Q}=T(p);d[x].source+=j.toCommentFile(Q),a.debug({message:`Generated external source map: ${p}`,plugin:"css"})}}}m.length>0&&a.info({filesEmitted:m.length,message:"CSS processing complete",plugin:"css",totalExtracted:b.length,totalSize:m.reduce((n,[,l])=>n+l.length,0)})},name:"rollup-plugin-css",async transform(r,d){if(!B(d)||!I.isSupported(d))return;if(r.replaceAll(/\s/g,"")===""){a.debug({message:`Skipping empty file: ${d}`,plugin:"css"});return}a.info({message:`Processing CSS file: ${d}`,plugin:"css",size:r.length}),typeof e.onImport=="function"&&e.onImport(r,d);const g={alias:C,assets:new Map,autoModules:i.autoModules,browserTargets:s,cwd:c,debug:f,deps:new Set,dts:i.dts,emit:i.emit,environment:O,extensions:i.extensions,extract:i.extract,id:d,inject:i.inject,inline:i.inline,logger:a,namedExports:i.namedExports,options:{},plugin:this,sourceDir:y,sourceMap:E,useSourcemap:S},o=await I.process({code:r},g);a.info({assets:g.assets.size,dependencies:g.deps.size,hasExtracted:!!o.extracted,message:`Processed ${d}`,outputSize:o.code.length,plugin:"css"});for(const u of g.deps)this.addWatchFile(u);for(const[u,h]of g.assets)this.emitFile({fileName:u,source:h,type:"asset"}),a.debug({message:`Emitted asset: ${u}`,plugin:"css",size:h.length});if(o.extracted){const{id:u}=o.extracted;b=b.filter(h=>h.id!==u),b.push(o.extracted),a.debug({cssSize:o.extracted.css.length,hasSourceMap:!!o.extracted.map,message:`Extracted CSS from ${u}`,plugin:"css"})}return{code:o.code,map:E&&o.map?o.map:{mappings:""},meta:{styles:o.meta},moduleSideEffects:o.extracted?!0:void 0}}}},"cssPlugin");export{Fe as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var m=Object.defineProperty;var a=(e,s)=>m(e,"name",{value:s,configurable:!0});import{isAccessibleSync as u,readFileSync as h}from"@visulima/fs";import{resolve as n,
|
|
1
|
+
var m=Object.defineProperty;var a=(e,s)=>m(e,"name",{value:s,configurable:!0});import{isAccessibleSync as u,readFileSync as h}from"@visulima/fs";import{resolve as n,isAbsolute as f,relative as l,normalize as d,dirname as S}from"@visulima/path";import{SourceMapConsumer as g}from"source-map-js";const w=/\[hash(?::(\d+))?\]/,x=/(?<!^|[/\\])(\.[^\s.]+)/,y=/data:[^\n\r;]+(?:;charset=[^\n\r;]+)?;base64,([\d+/A-Za-z]+={0,2})/;var M=Object.defineProperty,t=a((e,s)=>M(e,"name",{value:s,configurable:!0}),"i");const p=/(?:\n|\r\n)?\/\*[#*@]+\s*sourceMappingURL\s*=\s*(\S+)\s*\*+\//g,c=/(?:\n|\r\n)?\/\/[#@]+\s*sourceMappingURL\s*=\s*(\S+)\s*/g;class b{static{a(this,"S")}static{t(this,"MapModifier")}map;constructor(s){if(typeof s=="string")try{this.map=JSON.parse(s)}catch{}else this.map=s}modify(s){return this.map?(s(this.map),this):this}modifySources(s){return this.map?(this.map.sources&&(this.map.sources=this.map.sources.map(r=>s(r))),this):this}resolve(s=process.cwd()){return this.modifySources(r=>r==="<no source>"?r:n(s,r))}relative(s=process.cwd()){return this.modifySources(r=>r==="<no source>"?r:f(r)?l(s,r):d(r))}toObject(){return this.map}toString(){return this.map?JSON.stringify(this.map):this.map}toConsumer(){return this.map?new g(this.map):this.map}toCommentData(){const s=this.toString();return s?`
|
|
2
2
|
/*# sourceMappingURL=data:application/json;base64,${Buffer.from(s).toString("base64")} */`:""}toCommentFile(s){return this.map?`
|
|
3
3
|
/*# sourceMappingURL=${s} */`:""}}const O=t(async(e,s)=>{const[,r]=p.exec(e)??c.exec(e)??[];if(!r)return;const[,i]=y.exec(r)??[];if(i)return Buffer.from(i,"base64").toString();if(!s)throw new Error("Extracted map detected, but no ID is provided");const o=n(S(s),r);if(u(o))return h(o)},"getMap"),U=t(e=>e.replaceAll(p,"").replaceAll(c,""),"stripMap"),_=t(e=>new b(e),"mm");export{y as D,x as F,w as H,O as g,_ as m,U as s};
|
package/dist/types.d.ts
ADDED
|
@@ -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 `<style>` tag(s)
|
|
27
|
+
* - ex.: `{"id":"global"}`
|
|
28
|
+
*/
|
|
29
|
+
attributes?: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Container for `<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 `<style>` tag(s) to the beginning of the container
|
|
47
|
+
* @default false
|
|
48
|
+
*/
|
|
49
|
+
prepend?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Inject CSS into single `<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 `<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
|
+
}
|