@bleedingdev/modern-js-builder 3.9.0-ultramodern.2 → 3.9.0-ultramodern.3

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.
@@ -0,0 +1,20 @@
1
+ Copyright JS Foundation and other contributors
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,154 @@
1
+ type BasePluginOptions = {
2
+ /**
3
+ * Test rule
4
+ */
5
+ test?: Rule | undefined;
6
+ /**
7
+ * Include rule
8
+ */
9
+ include?: Rule | undefined;
10
+ /**
11
+ * Exclude rule
12
+ */
13
+ exclude?: Rule | undefined;
14
+ /**
15
+ * Warnings filter
16
+ */
17
+ warningsFilter?: WarningsFilter | undefined;
18
+ /**
19
+ * Parallel option
20
+ */
21
+ parallel?: Parallel | undefined;
22
+ };
23
+ type Rule = RegExp | string;
24
+ type WarningsFilter = (
25
+ warning: Warning | WarningObject | string,
26
+ file: string,
27
+ source?: string,
28
+ ) => boolean;
29
+ type Warning =
30
+ | (Error & {
31
+ plugin?: string;
32
+ text?: string;
33
+ source?: string;
34
+ })
35
+ | string;
36
+ type WarningObject = {
37
+ /**
38
+ * Warning message
39
+ */
40
+ message: string;
41
+ /**
42
+ * Plugin name
43
+ */
44
+ plugin?: string | undefined;
45
+ /**
46
+ * Warning text
47
+ */
48
+ text?: string | undefined;
49
+ /**
50
+ * Line number
51
+ */
52
+ line?: number | undefined;
53
+ /**
54
+ * Column number
55
+ */
56
+ column?: number | undefined;
57
+ };
58
+ type Parallel = undefined | boolean | number;
59
+ type DefinedDefaultMinimizerAndOptions<T> = T extends CssNanoOptionsExtended
60
+ ? {
61
+ minify?: MinimizerImplementation<T> | undefined;
62
+ minimizerOptions?: MinimizerOptions<T> | undefined;
63
+ }
64
+ : {
65
+ minify: MinimizerImplementation<T>;
66
+ minimizerOptions?: MinimizerOptions<T> | undefined;
67
+ };
68
+ type CssNanoOptionsExtended = CssNanoOptions & {
69
+ processorOptions?: ProcessOptionsExtender;
70
+ };
71
+ type CssNanoOptions = Record<string, unknown>;
72
+ type ProcessOptionsExtender =
73
+ | ProcessOptions
74
+ | {
75
+ from?: string;
76
+ to?: string;
77
+ parser?: string | Syntax | Parser;
78
+ stringifier?: string | Syntax | Stringifier;
79
+ syntax?: string | Syntax;
80
+ };
81
+ type ProcessOptions = import("postcss").ProcessOptions;
82
+ type Syntax = import("postcss").Syntax;
83
+ type Parser = import("postcss").Parser;
84
+ type Stringifier = import("postcss").Stringifier;
85
+ type MinimizerImplementation<T> = T extends EXPECTED_ANY[]
86
+ ? {
87
+ [P in keyof T]: BasicMinimizerImplementation<T[P]> &
88
+ MinimizeFunctionHelpers;
89
+ }
90
+ : BasicMinimizerImplementation<T> & MinimizeFunctionHelpers;
91
+ type EXPECTED_ANY = any;
92
+ type BasicMinimizerImplementation<T> = (
93
+ input: Input,
94
+ sourceMap: RawSourceMap | undefined,
95
+ minifyOptions: InferDefaultType<T>,
96
+ ) => Promise<MinimizedResult> | MinimizedResult;
97
+ type Input = {
98
+ [file: string]: string;
99
+ };
100
+ type RawSourceMap = import("@jridgewell/trace-mapping").EncodedSourceMap & {
101
+ sources: string[];
102
+ sourcesContent?: string[];
103
+ file: string;
104
+ };
105
+ type InferDefaultType<T> = T extends infer U ? U : CustomOptions;
106
+ type CustomOptions = {
107
+ [key: string]: unknown;
108
+ };
109
+ type MinimizedResult = {
110
+ /**
111
+ * Minimized code
112
+ */
113
+ code: string;
114
+ /**
115
+ * Source map
116
+ */
117
+ map?: RawSourceMap | undefined;
118
+ /**
119
+ * Errors
120
+ */
121
+ errors?: (Error | ErrorObject | string)[] | undefined;
122
+ /**
123
+ * Warnings
124
+ */
125
+ warnings?: (Warning | WarningObject | string)[] | undefined;
126
+ };
127
+ type ErrorObject = {
128
+ /**
129
+ * Error message
130
+ */
131
+ message: string;
132
+ /**
133
+ * Line number
134
+ */
135
+ line?: number | undefined;
136
+ /**
137
+ * Column number
138
+ */
139
+ column?: number | undefined;
140
+ /**
141
+ * Error stack trace
142
+ */
143
+ stack?: string | undefined;
144
+ };
145
+ type MinimizeFunctionHelpers = {
146
+ /**
147
+ * Check if worker threads are supported
148
+ */
149
+ supportsWorkerThreads?: (() => boolean | undefined) | undefined;
150
+ };
151
+ type MinimizerOptions<T> = T extends EXPECTED_ANY[]
152
+ ? { [P in keyof T]?: InferDefaultType<T[P]> }
153
+ : InferDefaultType<T>;
154
+ export type PluginCssMinimizerOptions = { pluginOptions?: import('@rsbuild/core').ConfigChain<BasePluginOptions & DefinedDefaultMinimizerAndOptions<CssNanoOptionsExtended>> };
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present Bytedance, Inc. and its affiliates.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,36 @@
1
+ import type { ConfigChainWithContext, Rspack } from '@rsbuild/core';
2
+ import type { LegacyOptions as LegacySassOptions, Options as SassOptions } from 'sass-embedded';
3
+ import type { LoaderOptions } from './loader.js';
4
+ export type SassLoaderOptions = Omit<LoaderOptions, 'api' | 'sassOptions' | 'additionalData'> & ({
5
+ api?: 'modern' | 'modern-compiler';
6
+ sassOptions?: SassOptions<'async'>;
7
+ } | {
8
+ api: 'legacy';
9
+ sassOptions?: Partial<LegacySassOptions<'async'>>;
10
+ }) & {
11
+ // Use `Rspack.LoaderContext` instead of `webpack.LoaderContext`
12
+ // see https://github.com/web-infra-dev/rsbuild/pull/2708
13
+ additionalData?: string | ((content: string | Buffer, loaderContext: Rspack.LoaderContext) => string);
14
+ };
15
+ export type PluginSassOptions = {
16
+ /**
17
+ * Options passed to sass-loader.
18
+ * @see https://github.com/webpack/sass-loader
19
+ */ sassLoaderOptions?: ConfigChainWithContext<SassLoaderOptions, {
20
+ /**
21
+ * @deprecated
22
+ * use `exclude` option instead.
23
+ */ addExcludes: (items: string | RegExp | (string | RegExp)[]) => void;
24
+ }>;
25
+ /**
26
+ * Include some `.scss` or `.sass` files, they will be transformed by sass-loader.
27
+ * @default /\.s(?:a|c)ss$/
28
+ */ include?: Rspack.RuleSetCondition;
29
+ /**
30
+ * Exclude some `.scss` or `.sass` files, they will not be transformed by sass-loader.
31
+ */ exclude?: Rspack.RuleSetCondition;
32
+ /**
33
+ * Whether to use `resolve-url-loader` to rewrite urls.
34
+ * @default true
35
+ */ rewriteUrls?: boolean;
36
+ };
@@ -0,0 +1,957 @@
1
+ /// <reference types="node" />
2
+ import * as Sass from 'sass-embedded';
3
+ import type { Rspack } from '@rsbuild/core';
4
+
5
+ type ImporterReturnType =
6
+ | { file: string }
7
+ | { file?: string | undefined; contents: string }
8
+ | Error
9
+ | null
10
+ | types.Null
11
+ | types.Error;
12
+
13
+ /**
14
+ * The context value is a value that is shared for the duration of a single render.
15
+ * The context object is the implicit `this` for importers and sass functions
16
+ * that are implemented in javascript.
17
+ *
18
+ * A render can be detected as asynchronous if the `callback` property is set on the context object.
19
+ */
20
+ interface Context {
21
+ options: Options;
22
+ callback: SassRenderCallback | undefined;
23
+ [data: string]: any;
24
+ }
25
+
26
+ interface AsyncContext extends Context {
27
+ callback: SassRenderCallback;
28
+ }
29
+
30
+ interface SyncContext extends Context {
31
+ callback: undefined;
32
+ }
33
+
34
+ type AsyncImporter = (
35
+ this: AsyncContext,
36
+ url: string,
37
+ prev: string,
38
+ done: (data: ImporterReturnType) => void,
39
+ ) => void;
40
+ type SyncImporter = (this: SyncContext, url: string, prev: string) => ImporterReturnType;
41
+ type Importer = AsyncImporter | SyncImporter;
42
+
43
+ // These function types enumerate up to 6 js arguments. More than that will be incorrectly marked by the compiler as an error.
44
+
45
+ // ** Sync Sass functions receiving fixed # of arguments ***
46
+ type SyncSassFn = (this: SyncContext, ...$args: types.Value[]) => types.ReturnValue;
47
+
48
+ // ** Sync Sass functions receiving variable # of arguments ***
49
+ type SyncSassVarArgFn1 = (this: SyncContext, $arg1: types.Value[]) => types.ReturnValue;
50
+ type SyncSassVarArgFn2 = (this: SyncContext, $arg1: types.Value, $arg2: types.Value[]) => types.ReturnValue;
51
+ type SyncSassVarArgFn3 = (
52
+ this: SyncContext,
53
+ $arg1: types.Value,
54
+ $arg2: types.Value,
55
+ $arg3: types.Value[],
56
+ ) => types.ReturnValue;
57
+ type SyncSassVarArgFn4 = (
58
+ this: SyncContext,
59
+ $arg1: types.Value,
60
+ $arg2: types.Value,
61
+ $arg3: types.Value,
62
+ $arg4: types.Value[],
63
+ ) => types.ReturnValue;
64
+ type SyncSassVarArgFn5 = (
65
+ this: SyncContext,
66
+ $arg1: types.Value,
67
+ $arg2: types.Value,
68
+ $arg3: types.Value,
69
+ $arg4: types.Value,
70
+ $arg5: types.Value[],
71
+ ) => types.ReturnValue;
72
+ type SyncSassVarArgFn6 = (
73
+ this: SyncContext,
74
+ $arg1: types.Value,
75
+ $arg2: types.Value,
76
+ $arg3: types.Value,
77
+ $arg4: types.Value,
78
+ $arg5: types.Value,
79
+ $arg6: types.Value[],
80
+ ) => types.ReturnValue;
81
+
82
+ type SassFunctionCallback = ($result: types.ReturnValue) => void;
83
+
84
+ // ** Async Sass functions receiving fixed # of arguments ***
85
+ type AsyncSassFn0 = (this: AsyncContext, cb: SassFunctionCallback) => void;
86
+ type AsyncSassFn1 = (this: AsyncContext, $arg1: types.Value, cb: SassFunctionCallback) => void;
87
+ type AsyncSassFn2 = (
88
+ this: AsyncContext,
89
+ $arg1: types.Value,
90
+ $arg2: types.Value,
91
+ cb: SassFunctionCallback,
92
+ ) => void;
93
+ type AsyncSassFn3 = (
94
+ this: AsyncContext,
95
+ $arg1: types.Value,
96
+ $arg2: types.Value,
97
+ $arg3: types.Value,
98
+ cb: SassFunctionCallback,
99
+ ) => void;
100
+ type AsyncSassFn4 = (
101
+ this: AsyncContext,
102
+ $arg1: types.Value,
103
+ $arg2: types.Value,
104
+ $arg3: types.Value,
105
+ $arg4: types.Value,
106
+ cb: SassFunctionCallback,
107
+ ) => void;
108
+ type AsyncSassFn5 = (
109
+ this: AsyncContext,
110
+ $arg1: types.Value,
111
+ $arg2: types.Value,
112
+ $arg3: types.Value,
113
+ $arg4: types.Value,
114
+ $arg5: types.Value,
115
+ cb: SassFunctionCallback,
116
+ ) => void;
117
+ type AsyncSassFn6 = (
118
+ this: AsyncContext,
119
+ $arg1: types.Value,
120
+ $arg2: types.Value,
121
+ $arg3: types.Value,
122
+ $arg4: types.Value,
123
+ $arg5: types.Value,
124
+ $arg6: types.Value,
125
+ cb: SassFunctionCallback,
126
+ ) => void;
127
+
128
+ // *** Async Sass Functions receiving variable # of arguments ***
129
+ type AsyncSassVarArgFn1 = (this: AsyncContext, $arg1: types.Value[], cb: SassFunctionCallback) => void;
130
+ type AsyncSassVarArgFn2 = (
131
+ this: AsyncContext,
132
+ $arg1: types.Value,
133
+ $arg2: types.Value[],
134
+ cb: SassFunctionCallback,
135
+ ) => void;
136
+ type AsyncSassVarArgFn3 = (
137
+ this: AsyncContext,
138
+ $arg1: types.Value,
139
+ $arg2: types.Value,
140
+ $arg3: types.Value[],
141
+ cb: SassFunctionCallback,
142
+ ) => void;
143
+ type AsyncSassVarArgFn4 = (
144
+ this: AsyncContext,
145
+ $arg1: types.Value,
146
+ $arg2: types.Value,
147
+ $arg3: types.Value,
148
+ $arg4: types.Value[],
149
+ cb: SassFunctionCallback,
150
+ ) => void;
151
+ type AsyncSassVarArgFn5 = (
152
+ this: AsyncContext,
153
+ $arg1: types.Value,
154
+ $arg2: types.Value,
155
+ $arg3: types.Value,
156
+ $arg4: types.Value,
157
+ $arg5: types.Value[],
158
+ cb: SassFunctionCallback,
159
+ ) => void;
160
+ type AsyncSassVarArgFn6 = (
161
+ this: AsyncContext,
162
+ $arg1: types.Value,
163
+ $arg2: types.Value,
164
+ $arg3: types.Value,
165
+ $arg4: types.Value,
166
+ $arg5: types.Value,
167
+ $arg6: types.Value[],
168
+ cb: SassFunctionCallback,
169
+ ) => void;
170
+
171
+ type SyncSassFunction =
172
+ | SyncSassFn
173
+ | SyncSassVarArgFn1
174
+ | SyncSassVarArgFn2
175
+ | SyncSassVarArgFn3
176
+ | SyncSassVarArgFn4
177
+ | SyncSassVarArgFn5
178
+ | SyncSassVarArgFn6;
179
+
180
+ type AsyncSassFunction =
181
+ | AsyncSassFn0
182
+ | AsyncSassFn1
183
+ | AsyncSassFn2
184
+ | AsyncSassFn3
185
+ | AsyncSassFn4
186
+ | AsyncSassFn5
187
+ | AsyncSassFn6
188
+ | AsyncSassVarArgFn1
189
+ | AsyncSassVarArgFn2
190
+ | AsyncSassVarArgFn3
191
+ | AsyncSassVarArgFn4
192
+ | AsyncSassVarArgFn5
193
+ | AsyncSassVarArgFn6;
194
+
195
+ type SassFunction = SyncSassFunction | AsyncSassFunction;
196
+
197
+ type FunctionDeclarations<FunctionType extends SassFunction = SassFunction> = Record<string, FunctionType>;
198
+
199
+ interface Options {
200
+ file?: string | undefined;
201
+ data?: string | undefined;
202
+ importer?: Importer | Importer[] | undefined;
203
+ functions?: FunctionDeclarations | undefined;
204
+ includePaths?: string[] | undefined;
205
+ indentedSyntax?: boolean | undefined;
206
+ indentType?: string | undefined;
207
+ indentWidth?: number | undefined;
208
+ linefeed?: string | undefined;
209
+ omitSourceMapUrl?: boolean | undefined;
210
+ outFile?: string | undefined;
211
+ outputStyle?: "compact" | "compressed" | "expanded" | "nested" | undefined;
212
+ precision?: number | undefined;
213
+ sourceComments?: boolean | undefined;
214
+ sourceMap?: boolean | string | undefined;
215
+ sourceMapContents?: boolean | undefined;
216
+ sourceMapEmbed?: boolean | undefined;
217
+ sourceMapRoot?: string | undefined;
218
+ [key: string]: any;
219
+ }
220
+
221
+ /**
222
+ * The error object returned to javascript by sass's render methods.
223
+ *
224
+ * This is not the same thing as types.Error.
225
+ */
226
+ interface SassError extends Error {
227
+ message: string;
228
+ line: number;
229
+ column: number;
230
+ status: number;
231
+ file: string;
232
+ }
233
+
234
+ /**
235
+ * The result of successfully compiling a Sass file.
236
+ */
237
+ interface Result {
238
+ css: Buffer;
239
+ map: Buffer;
240
+ stats: {
241
+ entry: string;
242
+ start: number;
243
+ end: number;
244
+ duration: number;
245
+ includedFiles: string[];
246
+ };
247
+ }
248
+ type SassRenderCallback = (err: SassError, result: Result) => any;
249
+
250
+ // Note, most node-sass constructors can be invoked as a function or with a new
251
+ // operator. The exception: the types Null and Boolean for which new is
252
+ // forbidden.
253
+ //
254
+ // Because of this, the new-able object notation is used here, a class does not
255
+ // work for these types.
256
+ declare namespace types {
257
+ /**
258
+ * Values that are received from Sass as an argument to a javascript function.
259
+ */
260
+ export type Value = Null | Number | String | Color | Boolean | List | Map;
261
+
262
+ /**
263
+ * Values that are legal to return to Sass from a javascript function.
264
+ */
265
+ export type ReturnValue = Value | Error;
266
+
267
+ // *** Sass Null ***
268
+
269
+ export interface Null {
270
+ /**
271
+ * This property doesn't exist, but its presence forces the typescript
272
+ * compiler to properly type check this type. Without it, it seems to
273
+ * allow things that aren't types.Null to match it in case statements and
274
+ * assignments.
275
+ */
276
+ readonly ___NULL___: unique symbol;
277
+ }
278
+
279
+ interface NullConstructor {
280
+ (): Null;
281
+ NULL: Null;
282
+ }
283
+ export const Null: NullConstructor;
284
+
285
+ // *** Sass Number ***
286
+
287
+ export interface Number {
288
+ getValue(): number;
289
+ setValue(n: number): void;
290
+ getUnit(): string;
291
+ setUnit(u: string): void;
292
+ }
293
+ interface NumberConstructor {
294
+ /**
295
+ * Constructs a new Sass number. Does not require use of the `new` keyword.
296
+ */
297
+ new(value: number, unit?: string): Number;
298
+ /**
299
+ * Constructs a new Sass number. Can also be used with the `new` keyword.
300
+ */
301
+ (value: number, unit?: string): Number;
302
+ }
303
+
304
+ export const Number: NumberConstructor;
305
+
306
+ // *** Sass String ***
307
+
308
+ export interface String {
309
+ getValue(): string;
310
+ setValue(s: string): void;
311
+ }
312
+
313
+ interface StringConstructor {
314
+ /**
315
+ * Constructs a new Sass string. Does not require use of the `new` keyword.
316
+ */
317
+ new(value: string): String;
318
+ /**
319
+ * Constructs a new Sass string. Can also be used with the `new` keyword.
320
+ */
321
+ (value: string): String;
322
+ }
323
+
324
+ export const String: StringConstructor;
325
+
326
+ // *** Sass Color ***
327
+
328
+ export interface Color {
329
+ /**
330
+ * Get the red component of the color.
331
+ * @returns integer between 0 and 255 inclusive;
332
+ */
333
+ getR(): number;
334
+ /**
335
+ * Set the red component of the color.
336
+ * @returns integer between 0 and 255 inclusive;
337
+ */
338
+ setR(r: number): void;
339
+ /**
340
+ * Get the green component of the color.
341
+ * @returns integer between 0 and 255 inclusive;
342
+ */
343
+ getG(): number;
344
+ /**
345
+ * Set the green component of the color.
346
+ * @param g integer between 0 and 255 inclusive;
347
+ */
348
+ setG(g: number): void;
349
+ /**
350
+ * Get the blue component of the color.
351
+ * @returns integer between 0 and 255 inclusive;
352
+ */
353
+ getB(): number;
354
+ /**
355
+ * Set the blue component of the color.
356
+ * @param b integer between 0 and 255 inclusive;
357
+ */
358
+ setB(b: number): void;
359
+ /**
360
+ * Get the alpha transparency component of the color.
361
+ * @returns number between 0 and 1 inclusive;
362
+ */
363
+ getA(): number;
364
+ /**
365
+ * Set the alpha component of the color.
366
+ * @param a number between 0 and 1 inclusive;
367
+ */
368
+ setA(a: number): void;
369
+ }
370
+
371
+ interface ColorConstructor {
372
+ /**
373
+ * Constructs a new Sass color given the RGBA component values. Do not invoke with the `new` keyword.
374
+ *
375
+ * @param r integer 0-255 inclusive
376
+ * @param g integer 0-255 inclusive
377
+ * @param b integer 0-255 inclusive
378
+ * @param [a] float 0 - 1 inclusive
379
+ * @returns a SassColor instance.
380
+ */
381
+ new(r: number, g: number, b: number, a?: number): Color;
382
+
383
+ /**
384
+ * Constructs a new Sass color given a 4 byte number. Do not invoke with the `new` keyword.
385
+ *
386
+ * If a single number is passed it is assumed to be a number that contains
387
+ * all the components which are extracted using bitmasks and bitshifting.
388
+ *
389
+ * @param hexN A number that is usually written in hexadecimal form. E.g. 0xff0088cc.
390
+ * @returns a Sass Color instance.
391
+ * @example
392
+ * // Comparison with byte array manipulation
393
+ * let a = new ArrayBuffer(4);
394
+ * let hexN = 0xCCFF0088; // 0xAARRGGBB
395
+ * let a32 = new Uint32Array(a); // Uint32Array [ 0 ]
396
+ * a32[0] = hexN;
397
+ * let a8 = new Uint8Array(a); // Uint8Array [ 136, 0, 255, 204 ]
398
+ * let componentBytes = [a8[2], a8[1], a8[0], a8[3] / 255] // [ 136, 0, 255, 0.8 ]
399
+ * let c = sass.types.Color(hexN);
400
+ * let components = [c.getR(), c.getG(), c.getR(), c.getA()] // [ 136, 0, 255, 0.8 ]
401
+ * assert.deepEqual(componentBytes, components); // does not raise.
402
+ */
403
+ new(hexN: number): Color;
404
+
405
+ /**
406
+ * Constructs a new Sass color given the RGBA component values. Do not invoke with the `new` keyword.
407
+ *
408
+ * @param r integer 0-255 inclusive
409
+ * @param g integer 0-255 inclusive
410
+ * @param b integer 0-255 inclusive
411
+ * @param [a] float 0 - 1 inclusive
412
+ * @returns a SassColor instance.
413
+ */
414
+ (r: number, g: number, b: number, a?: number): Color;
415
+
416
+ /**
417
+ * Constructs a new Sass color given a 4 byte number. Do not invoke with the `new` keyword.
418
+ *
419
+ * If a single number is passed it is assumed to be a number that contains
420
+ * all the components which are extracted using bitmasks and bitshifting.
421
+ *
422
+ * @param hexN A number that is usually written in hexadecimal form. E.g. 0xff0088cc.
423
+ * @returns a Sass Color instance.
424
+ * @example
425
+ * // Comparison with byte array manipulation
426
+ * let a = new ArrayBuffer(4);
427
+ * let hexN = 0xCCFF0088; // 0xAARRGGBB
428
+ * let a32 = new Uint32Array(a); // Uint32Array [ 0 ]
429
+ * a32[0] = hexN;
430
+ * let a8 = new Uint8Array(a); // Uint8Array [ 136, 0, 255, 204 ]
431
+ * let componentBytes = [a8[2], a8[1], a8[0], a8[3] / 255] // [ 136, 0, 255, 0.8 ]
432
+ * let c = sass.types.Color(hexN);
433
+ * let components = [c.getR(), c.getG(), c.getR(), c.getA()] // [ 136, 0, 255, 0.8 ]
434
+ * assert.deepEqual(componentBytes, components); // does not raise.
435
+ */
436
+ (hexN: number): Color;
437
+ }
438
+
439
+ export const Color: ColorConstructor;
440
+
441
+ // *** Sass Boolean ***
442
+
443
+ export interface Boolean {
444
+ getValue(): boolean;
445
+ }
446
+
447
+ interface BooleanConstructor {
448
+ (bool: boolean): Boolean;
449
+ TRUE: Boolean;
450
+ FALSE: Boolean;
451
+ }
452
+
453
+ export const Boolean: BooleanConstructor;
454
+
455
+ // *** Sass List ***
456
+
457
+ export interface Enumerable {
458
+ getValue(index: number): Value;
459
+ setValue(index: number, value: Value): void;
460
+ getLength(): number;
461
+ }
462
+
463
+ export interface List extends Enumerable {
464
+ getSeparator(): boolean;
465
+ setSeparator(isComma: boolean): void;
466
+ }
467
+ interface ListConstructor {
468
+ new(length: number, commaSeparator?: boolean): List;
469
+ (length: number, commaSeparator?: boolean): List;
470
+ }
471
+ export const List: ListConstructor;
472
+
473
+ // *** Sass Map ***
474
+
475
+ export interface Map extends Enumerable {
476
+ getKey(index: number): Value;
477
+ setKey(index: number, key: Value): void;
478
+ }
479
+ interface MapConstructor {
480
+ new(length: number): Map;
481
+ (length: number): Map;
482
+ }
483
+ export const Map: MapConstructor;
484
+
485
+ // *** Sass Error ***
486
+
487
+ export interface Error {
488
+ /**
489
+ * This property doesn't exist, but its presence forces the typescript
490
+ * compiler to properly type check this type. Without it, it seems to
491
+ * allow things that aren't types.Error to match it in case statements and
492
+ * assignments.
493
+ */
494
+ readonly ___SASS_ERROR___: unique symbol;
495
+ // why isn't there a getMessage() method?
496
+ }
497
+
498
+ interface ErrorConstructor {
499
+ /**
500
+ * An error return value for async functions.
501
+ * For synchronous functions, this can be returned or a standard error object can be thrown.
502
+ */
503
+ new(message: string): Error;
504
+ /**
505
+ * An error return value for async functions.
506
+ * For synchronous functions, this can be returned or a standard error object can be thrown.
507
+ */
508
+ (message: string): Error;
509
+ }
510
+ export const Error: ErrorConstructor;
511
+ }
512
+
513
+ interface LoaderOptions {
514
+ /**
515
+ * The special `implementation` option determines which implementation of Sass
516
+ * to use.
517
+ *
518
+ * By default the loader resolve the implementation based on your dependencies.
519
+ * Just add required implementation to `package.json` (`node-sass` or `sass`
520
+ * package) and install dependencies.
521
+ *
522
+ * Example where the `sass-loader` loader uses the `sass` (`dart-sass`)
523
+ * implementation:
524
+ *
525
+ * **package.json**
526
+ *
527
+ * ```json
528
+ * {
529
+ * "devDependencies": {
530
+ * "sass-loader": "^7.2.0",
531
+ * "sass": "^1.22.10"
532
+ * }
533
+ * }
534
+ * ```
535
+ *
536
+ * Example where the `sass-loader` loader uses the `node-sass` implementation:
537
+ *
538
+ * **package.json**
539
+ *
540
+ * ```json
541
+ * {
542
+ * "devDependencies": {
543
+ * "sass-loader": "^7.2.0",
544
+ * "node-sass": "^4.0.0"
545
+ * }
546
+ * }
547
+ * ```
548
+ *
549
+ * Beware the situation when `node-sass` and `sass` were installed! By default
550
+ * the `sass-loader` prefers `node-sass`. In order to avoid this situation you
551
+ * can use the `implementation` option.
552
+ *
553
+ * The `implementation` options either accepts `node-sass` or `sass` (`Dart Sass`)
554
+ * as a module.
555
+ *
556
+ * For example, to use Dart Sass, you'd pass:
557
+ *
558
+ * ```js
559
+ * module.exports = {
560
+ * module: {
561
+ * rules: [
562
+ * {
563
+ * test: /\.s[ac]ss$/i,
564
+ * use: [
565
+ * 'style-loader',
566
+ * 'css-loader',
567
+ * {
568
+ * loader: 'sass-loader',
569
+ * options: {
570
+ * // Prefer `dart-sass`
571
+ * implementation: require('sass'),
572
+ * },
573
+ * },
574
+ * ],
575
+ * },
576
+ * ],
577
+ * },
578
+ * };
579
+ * ```
580
+ *
581
+ * Note that when using `sass` (`Dart Sass`), **synchronous compilation is twice
582
+ * as fast as asynchronous compilation** by default, due to the overhead of
583
+ * asynchronous callbacks. To avoid this overhead, you can use the [fibers](https://www.npmjs.com/package/fibers)
584
+ * package to call asynchronous importers from the synchronous code path.
585
+ *
586
+ * We automatically inject the [`fibers`](https://github.com/laverdet/node-fibers)
587
+ * package (setup `sassOptions.fiber`) if is possible (i.e. you need install the
588
+ * [`fibers`](https://github.com/laverdet/node-fibers) package).
589
+ *
590
+ * **package.json**
591
+ *
592
+ * ```json
593
+ * {
594
+ * "devDependencies": {
595
+ * "sass-loader": "^7.2.0",
596
+ * "sass": "^1.22.10",
597
+ * "fibers": "^4.0.1"
598
+ * }
599
+ * }
600
+ * ```
601
+ *
602
+ * You can disable automatically injecting the [`fibers`](https://github.com/laverdet/node-fibers)
603
+ * package by passing a `false` value for the `sassOptions.fiber` option.
604
+ *
605
+ * **webpack.config.js**
606
+ *
607
+ * ```js
608
+ * module.exports = {
609
+ * module: {
610
+ * rules: [
611
+ * {
612
+ * test: /\.s[ac]ss$/i,
613
+ * use: [
614
+ * 'style-loader',
615
+ * 'css-loader',
616
+ * {
617
+ * loader: 'sass-loader',
618
+ * options: {
619
+ * implementation: require('sass'),
620
+ * sassOptions: {
621
+ * fiber: false,
622
+ * },
623
+ * },
624
+ * },
625
+ * ],
626
+ * },
627
+ * ],
628
+ * },
629
+ * };
630
+ * ```
631
+ *
632
+ * You can also pass the `fiber` value using this code:
633
+ *
634
+ * **webpack.config.js**
635
+ *
636
+ * ```js
637
+ * module.exports = {
638
+ * module: {
639
+ * rules: [
640
+ * {
641
+ * test: /\.s[ac]ss$/i,
642
+ * use: [
643
+ * 'style-loader',
644
+ * 'css-loader',
645
+ * {
646
+ * loader: 'sass-loader',
647
+ * options: {
648
+ * implementation: require('sass'),
649
+ * sassOptions: {
650
+ * fiber: require('fibers'),
651
+ * },
652
+ * },
653
+ * },
654
+ * ],
655
+ * },
656
+ * ],
657
+ * },
658
+ * };
659
+ * ```
660
+ */
661
+ implementation?: any;
662
+
663
+ /**
664
+ * Options for [Node Sass](https://github.com/sass/node-sass) or [Dart Sass](http://sass-lang.com/dart-sass)
665
+ * implementation.
666
+ *
667
+ * > ℹ️ The `indentedSyntax` option has `true` value for the `sass` extension.
668
+ *
669
+ * > ℹ️ Options such as `file` and `outFile` are unavailable.
670
+ *
671
+ * > ℹ️ We recommend not to use the `sourceMapContents`, `sourceMapEmbed`,
672
+ * `sourceMapRoot` options because `sass-loader` automatically sets these
673
+ * options.
674
+ *
675
+ * There is a slight difference between the `node-sass` and `sass` (`Dart Sass`)
676
+ * options. Please consult documentation before using them:
677
+ *
678
+ * - [Node Sass documentation](https://github.com/sass/node-sass/#options) for
679
+ * all available `node-sass` options.
680
+ * - [Dart Sass documentation](https://github.com/sass/dart-sass#javascript-api)
681
+ * for all available `sass` options.
682
+ *
683
+ * #### `Object`
684
+ *
685
+ * Use and object for the Sass implementation setup.
686
+ *
687
+ * **webpack.config.js**
688
+ *
689
+ * ```js
690
+ * module.exports = {
691
+ * module: {
692
+ * rules: [
693
+ * {
694
+ * test: /\.s[ac]ss$/i,
695
+ * use: [
696
+ * 'style-loader',
697
+ * 'css-loader',
698
+ * {
699
+ * loader: 'sass-loader',
700
+ * options: {
701
+ * sassOptions: {
702
+ * indentWidth: 4,
703
+ * includePaths: ['absolute/path/a', 'absolute/path/b'],
704
+ * },
705
+ * },
706
+ * },
707
+ * ],
708
+ * },
709
+ * ],
710
+ * },
711
+ * };
712
+ * ```
713
+ *
714
+ * #### `Function`
715
+ *
716
+ * Allows to setup the Sass implementation by setting different options based on
717
+ * the loader context.
718
+ *
719
+ * ```js
720
+ * module.exports = {
721
+ * module: {
722
+ * rules: [
723
+ * {
724
+ * test: /\.s[ac]ss$/i,
725
+ * use: [
726
+ * 'style-loader',
727
+ * 'css-loader',
728
+ * {
729
+ * loader: 'sass-loader',
730
+ * options: {
731
+ * sassOptions: (loaderContext) => {
732
+ * // More information about available properties https://webpack.js.org/api/loaders/
733
+ * const { resourcePath, rootContext } = loaderContext;
734
+ * const relativePath = path.relative(rootContext, resourcePath);
735
+ *
736
+ * if (relativePath === 'styles/foo.scss') {
737
+ * return {
738
+ * includePaths: ['absolute/path/c', 'absolute/path/d'],
739
+ * };
740
+ * }
741
+ *
742
+ * return {
743
+ * includePaths: ['absolute/path/a', 'absolute/path/b'],
744
+ * };
745
+ * },
746
+ * },
747
+ * },
748
+ * ],
749
+ * },
750
+ * ],
751
+ * },
752
+ * };
753
+ * ```
754
+ */
755
+ sassOptions?: LoaderOptions.SassOptions | LoaderOptions.Callback<LoaderOptions.SassOptions> | undefined;
756
+
757
+ /**
758
+ * Prepends `Sass`/`SCSS` code before the actual entry file. In this case, the
759
+ * `sass-loader` will not override the `data` option but just append the entry's
760
+ * content.
761
+ *
762
+ * This is especially useful when some of your Sass variables depend on the
763
+ * environment:
764
+ *
765
+ * > ℹ Since you're injecting code, this will break the source mappings in your
766
+ * entry file. Often there's a simpler solution than this, like multiple Sass
767
+ * entry files.
768
+ *
769
+ * #### `String`
770
+ *
771
+ * ```js
772
+ * module.exports = {
773
+ * module: {
774
+ * rules: [
775
+ * {
776
+ * test: /\.s[ac]ss$/i,
777
+ * use: [
778
+ * 'style-loader',
779
+ * 'css-loader',
780
+ * {
781
+ * loader: 'sass-loader',
782
+ * options: {
783
+ * prependData: '$env: ' + process.env.NODE_ENV + ';',
784
+ * },
785
+ * },
786
+ * ],
787
+ * },
788
+ * ],
789
+ * },
790
+ * };
791
+ * ```
792
+ *
793
+ * #### `Function`
794
+ *
795
+ * ```js
796
+ * module.exports = {
797
+ * module: {
798
+ * rules: [
799
+ * {
800
+ * test: /\.s[ac]ss$/i,
801
+ * use: [
802
+ * 'style-loader',
803
+ * 'css-loader',
804
+ * {
805
+ * loader: 'sass-loader',
806
+ * options: {
807
+ * prependData: (loaderContext) => {
808
+ * // More information about available properties https://webpack.js.org/api/loaders/
809
+ * const { resourcePath, rootContext } = loaderContext;
810
+ * const relativePath = path.relative(rootContext, resourcePath);
811
+ *
812
+ * if (relativePath === 'styles/foo.scss') {
813
+ * return '$value: 100px;';
814
+ * }
815
+ *
816
+ * return '$value: 200px;';
817
+ * },
818
+ * },
819
+ * },
820
+ * ],
821
+ * },
822
+ * ],
823
+ * },
824
+ * };
825
+ * ```
826
+ *
827
+ * @default
828
+ * undefined
829
+ */
830
+ additionalData?: string | LoaderOptions.Callback<string> | undefined;
831
+
832
+ /**
833
+ * Enables/Disables generation of source maps.
834
+ *
835
+ * By default generation of source maps depends on the [`devtool`](https://webpack.js.org/configuration/devtool/)
836
+ * option. All values enable source map generation except `eval` and `false`
837
+ * value.
838
+ *
839
+ * **webpack.config.js**
840
+ *
841
+ * ```js
842
+ * module.exports = {
843
+ * module: {
844
+ * rules: [
845
+ * {
846
+ * test: /\.s[ac]ss$/i,
847
+ * use: [
848
+ * 'style-loader',
849
+ * {
850
+ * loader: 'css-loader',
851
+ * options: {
852
+ * sourceMap: true,
853
+ * },
854
+ * },
855
+ * {
856
+ * loader: 'sass-loader',
857
+ * options: {
858
+ * sourceMap: true,
859
+ * },
860
+ * },
861
+ * ],
862
+ * },
863
+ * ],
864
+ * },
865
+ * };
866
+ * ```
867
+ *
868
+ * > ℹ In some rare cases `node-sass` can output invalid source maps (it is a
869
+ * `node-sass` bug). In order to avoid this, you can try to update `node-sass`
870
+ * to latest version or you can try to set within `sassOptions` the
871
+ * `outputStyle` option to `compressed`.
872
+ *
873
+ * @default
874
+ * Depends on the `compiler.devtool` value.
875
+ */
876
+ sourceMap?: boolean | undefined;
877
+
878
+ /**
879
+ * Enables/Disables the default Webpack importer.
880
+ *
881
+ * This can improve performance in some cases. Use it with caution because
882
+ * aliases and `@import` at-rules starting with `~` will not work. You can pass
883
+ * own `importer` to solve this (see [`importer docs`](https://github.com/sass/node-sass#importer--v200---experimental)).
884
+ *
885
+ * **webpack.config.js**
886
+ *
887
+ * ```js
888
+ * module.exports = {
889
+ * module: {
890
+ * rules: [
891
+ * {
892
+ * test: /\.s[ac]ss$/i,
893
+ * use: [
894
+ * 'style-loader',
895
+ * 'css-loader',
896
+ * {
897
+ * loader: 'sass-loader',
898
+ * options: {
899
+ * webpackImporter: false,
900
+ * },
901
+ * },
902
+ * ],
903
+ * },
904
+ * ],
905
+ * },
906
+ * };
907
+ * ```
908
+ *
909
+ * @default
910
+ * true
911
+ */
912
+ webpackImporter?: boolean | undefined;
913
+ /**
914
+ * Treats the @warn rule as a webpack warning.
915
+ *
916
+ * Note: It will be true by default in the next major release.
917
+ *
918
+ * **webpack.config.js**
919
+ *
920
+ * ```js
921
+ * module.exports = {
922
+ * module: {
923
+ * rules: [
924
+ * {
925
+ * test: /\.s[ac]ss$/i,
926
+ * use: [
927
+ * 'style-loader',
928
+ * 'css-loader',
929
+ * {
930
+ * loader: 'sass-loader',
931
+ * options: {
932
+ * warnRuleAsWarning: false,
933
+ * },
934
+ * },
935
+ * ],
936
+ * },
937
+ * ],
938
+ * },
939
+ * };
940
+ * ```
941
+ */
942
+ warnRuleAsWarning?: boolean | undefined;
943
+ }
944
+
945
+ declare namespace LoaderOptions {
946
+ type Callback<T> = (content: string | Buffer, loaderContext: Rspack.LoaderContext) => T;
947
+
948
+ type SassOptions = Options | Sass.LegacyOptions<"sync">;
949
+ }
950
+
951
+ declare function loader(content: string): void;
952
+
953
+ declare namespace loader {
954
+ type Options = LoaderOptions;
955
+ }
956
+
957
+ export { loader as default, LoaderOptions };
@@ -2,13 +2,13 @@ import type { AliasOption } from '@modern-js/utils';
2
2
  import type { ConfigChain, ConfigChainWithContext, DevConfig, DistPathConfig, EnvironmentConfig, HtmlConfig, OutputConfig, Polyfill, RsbuildConfig, RsbuildPluginAPI, RsbuildPlugins, RsbuildTarget, Rspack, SecurityConfig, ServerConfig, SourceConfig, ToolsConfig } from '@rsbuild/core';
3
3
  import type { PluginAssetsRetryOptions } from '@rsbuild/plugin-assets-retry';
4
4
  import type { PluginCheckSyntaxOptions } from '@rsbuild/plugin-check-syntax';
5
- import type { PluginCssMinimizerOptions } from '@rsbuild/plugin-css-minimizer';
5
+ import type { PluginCssMinimizerOptions } from './css-minimizer/index.js';
6
6
  import type { PluginLessOptions } from '@rsbuild/plugin-less';
7
7
  import type { PluginReactOptions } from '@rsbuild/plugin-react';
8
8
  import type { PluginRemOptions } from '@rsbuild/plugin-rem';
9
- import type { PluginSassOptions } from '@rsbuild/plugin-sass';
9
+ import type { PluginSassOptions } from './sass/index.js';
10
10
  import type { PluginSourceBuildOptions } from '@rsbuild/plugin-source-build';
11
- import type { SvgDefaultExport } from '@rsbuild/plugin-svgr';
11
+ type SvgDefaultExport = 'component' | 'url';
12
12
  import type { PluginTypeCheckerOptions } from '@rsbuild/plugin-type-check';
13
13
  import type { Options as AutoprefixerOptions } from 'autoprefixer';
14
14
  export type CacheGroup = Rspack.OptimizationSplitChunksCacheGroup;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bleedingdev/modern-js-builder",
3
- "version": "3.9.0-ultramodern.2",
3
+ "version": "3.9.0-ultramodern.3",
4
4
  "description": "A builder for Modern.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,7 +26,8 @@
26
26
  "dist"
27
27
  ],
28
28
  "dependencies": {
29
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.2",
29
+ "@jridgewell/trace-mapping": "^0.3.31",
30
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.0-ultramodern.3",
30
31
  "@rsbuild/core": "2.2.3",
31
32
  "@rsbuild/plugin-assets-retry": "2.0.2",
32
33
  "@rsbuild/plugin-check-syntax": "2.0.1",
@@ -56,10 +57,11 @@
56
57
  "postcss-nesting": "14.0.1",
57
58
  "postcss-page-break": "3.0.4",
58
59
  "rspack-manifest-plugin": "5.2.2",
60
+ "sass-embedded": "1.100.0",
59
61
  "ts-deepmerge": "8.0.0"
60
62
  },
61
63
  "devDependencies": {
62
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.2",
64
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.0-ultramodern.3",
63
65
  "@rsdoctor/rspack-plugin": "^1.6.3",
64
66
  "@rslib/core": "1.0.0",
65
67
  "@scripts/rstest-config": "2.66.0",