File tree Expand file tree Collapse file tree 13 files changed +176
-11
lines changed
src/raw_options/raw_module
rspack-test-tools/tests/defaultsCases/experiments Expand file tree Collapse file tree 13 files changed +176
-11
lines changed Original file line number Diff line number Diff line change @@ -1621,6 +1621,7 @@ export interface RawCssAutoGeneratorOptions {
1621
1621
1622
1622
export interface RawCssAutoParserOptions {
1623
1623
namedExports ?: boolean
1624
+ url ?: boolean
1624
1625
}
1625
1626
1626
1627
export interface RawCssExtractPluginOption {
@@ -1649,10 +1650,12 @@ export interface RawCssModuleGeneratorOptions {
1649
1650
1650
1651
export interface RawCssModuleParserOptions {
1651
1652
namedExports ?: boolean
1653
+ url ?: boolean
1652
1654
}
1653
1655
1654
1656
export interface RawCssParserOptions {
1655
1657
namedExports ?: boolean
1658
+ url ?: boolean
1656
1659
}
1657
1660
1658
1661
export interface RawDllEntryPluginOptions {
Original file line number Diff line number Diff line change @@ -409,12 +409,14 @@ impl From<RawAssetParserDataUrlOptions> for AssetParserDataUrlOptions {
409
409
#[ napi( object) ]
410
410
pub struct RawCssParserOptions {
411
411
pub named_exports : Option < bool > ,
412
+ pub url : Option < bool > ,
412
413
}
413
414
414
415
impl From < RawCssParserOptions > for CssParserOptions {
415
416
fn from ( value : RawCssParserOptions ) -> Self {
416
417
Self {
417
418
named_exports : value. named_exports ,
419
+ url : value. url ,
418
420
}
419
421
}
420
422
}
@@ -423,12 +425,14 @@ impl From<RawCssParserOptions> for CssParserOptions {
423
425
#[ napi( object) ]
424
426
pub struct RawCssAutoParserOptions {
425
427
pub named_exports : Option < bool > ,
428
+ pub url : Option < bool > ,
426
429
}
427
430
428
431
impl From < RawCssAutoParserOptions > for CssAutoParserOptions {
429
432
fn from ( value : RawCssAutoParserOptions ) -> Self {
430
433
Self {
431
434
named_exports : value. named_exports ,
435
+ url : value. url ,
432
436
}
433
437
}
434
438
}
@@ -437,12 +441,14 @@ impl From<RawCssAutoParserOptions> for CssAutoParserOptions {
437
441
#[ napi( object) ]
438
442
pub struct RawCssModuleParserOptions {
439
443
pub named_exports : Option < bool > ,
444
+ pub url : Option < bool > ,
440
445
}
441
446
442
447
impl From < RawCssModuleParserOptions > for CssModuleParserOptions {
443
448
fn from ( value : RawCssModuleParserOptions ) -> Self {
444
449
Self {
445
450
named_exports : value. named_exports ,
451
+ url : value. url ,
446
452
}
447
453
}
448
454
}
Original file line number Diff line number Diff line change @@ -1731,16 +1731,19 @@ impl ModuleOptionsBuilder {
1731
1731
if css {
1732
1732
let css_parser_options = ParserOptions :: Css ( CssParserOptions {
1733
1733
named_exports : Some ( true ) ,
1734
+ url : Some ( true ) ,
1734
1735
} ) ;
1735
1736
parser. insert ( "css" . to_string ( ) , css_parser_options. clone ( ) ) ;
1736
1737
1737
1738
let css_auto_parser_options = ParserOptions :: CssAuto ( CssAutoParserOptions {
1738
1739
named_exports : Some ( true ) ,
1740
+ url : Some ( true ) ,
1739
1741
} ) ;
1740
1742
parser. insert ( "css/auto" . to_string ( ) , css_auto_parser_options) ;
1741
1743
1742
1744
let css_module_parser_options = ParserOptions :: CssModule ( CssModuleParserOptions {
1743
1745
named_exports : Some ( true ) ,
1746
+ url : Some ( true ) ,
1744
1747
} ) ;
1745
1748
parser. insert ( "css/module" . to_string ( ) , css_module_parser_options) ;
1746
1749
Original file line number Diff line number Diff line change @@ -286,18 +286,21 @@ pub struct AssetParserDataUrlOptions {
286
286
#[ derive( Debug , Clone , MergeFrom ) ]
287
287
pub struct CssParserOptions {
288
288
pub named_exports : Option < bool > ,
289
+ pub url : Option < bool > ,
289
290
}
290
291
291
292
#[ cacheable]
292
293
#[ derive( Debug , Clone , MergeFrom ) ]
293
294
pub struct CssAutoParserOptions {
294
295
pub named_exports : Option < bool > ,
296
+ pub url : Option < bool > ,
295
297
}
296
298
297
299
impl From < CssParserOptions > for CssAutoParserOptions {
298
300
fn from ( value : CssParserOptions ) -> Self {
299
301
Self {
300
302
named_exports : value. named_exports ,
303
+ url : value. url ,
301
304
}
302
305
}
303
306
}
@@ -306,12 +309,14 @@ impl From<CssParserOptions> for CssAutoParserOptions {
306
309
#[ derive( Debug , Clone , MergeFrom ) ]
307
310
pub struct CssModuleParserOptions {
308
311
pub named_exports : Option < bool > ,
312
+ pub url : Option < bool > ,
309
313
}
310
314
311
315
impl From < CssParserOptions > for CssModuleParserOptions {
312
316
fn from ( value : CssParserOptions ) -> Self {
313
317
Self {
314
318
named_exports : value. named_exports ,
319
+ url : value. url ,
315
320
}
316
321
}
317
322
}
Original file line number Diff line number Diff line change @@ -80,6 +80,7 @@ pub struct CssParserAndGenerator {
80
80
pub exports_only : bool ,
81
81
pub named_exports : bool ,
82
82
pub es_module : bool ,
83
+ pub url : bool ,
83
84
#[ cacheable( with=AsOption <AsMap <AsCacheable , AsVec >>) ]
84
85
pub exports : Option < CssExports > ,
85
86
pub local_names : Option < FxHashMap < String , String > > ,
@@ -168,6 +169,10 @@ impl ParserAndGenerator for CssParserAndGenerator {
168
169
if request. trim ( ) . is_empty ( ) {
169
170
continue ;
170
171
}
172
+ if !self . url {
173
+ continue ;
174
+ }
175
+
171
176
let request = replace_module_request_prefix (
172
177
request,
173
178
& mut diagnostics,
Original file line number Diff line number Diff line change @@ -488,6 +488,7 @@ impl Plugin for CssPlugin {
488
488
named_exports : p. named_exports . expect ( "should have named_exports" ) ,
489
489
es_module : g. es_module . expect ( "should have es_module" ) ,
490
490
hot : false ,
491
+ url : p. url . expect ( "should have url" ) ,
491
492
} ) as Box < dyn ParserAndGenerator >
492
493
} ) ,
493
494
) ;
@@ -516,6 +517,7 @@ impl Plugin for CssPlugin {
516
517
named_exports : p. named_exports . expect ( "should have named_exports" ) ,
517
518
es_module : g. es_module . expect ( "should have es_module" ) ,
518
519
hot : false ,
520
+ url : p. url . expect ( "should have url" ) ,
519
521
} ) as Box < dyn ParserAndGenerator >
520
522
} ) ,
521
523
) ;
@@ -544,6 +546,7 @@ impl Plugin for CssPlugin {
544
546
named_exports : p. named_exports . expect ( "should have named_exports" ) ,
545
547
es_module : g. es_module . expect ( "should have es_module" ) ,
546
548
hot : false ,
549
+ url : p. url . expect ( "should have url" ) ,
547
550
} ) as Box < dyn ParserAndGenerator >
548
551
} ) ,
549
552
) ;
Original file line number Diff line number Diff line change @@ -41,15 +41,15 @@ module.exports = {
41
41
+ Object {
42
42
+ "descriptionData": Object {
43
43
+ "type": "module",
44
- + },
44
+ @@ ... @@
45
45
+ "resolve": Object {
46
46
+ "fullySpecified": true,
47
47
+ },
48
48
+ },
49
49
+ ],
50
50
+ "type": "webassembly/async",
51
51
+ },
52
- + Object {
52
+ @@ ... @@
53
53
+ "resolve": Object {
54
54
+ "fullySpecified": true,
55
55
+ "preferRelative": true,
@@ -72,6 +72,8 @@ module.exports = {
72
72
+ "preferRelative": true,
73
73
+ },
74
74
+ "type": "css",
75
+ + },
76
+ + Object {
75
77
@@ ... @@
76
78
+ "css": Object {
77
79
+ "esModule": true,
@@ -94,20 +96,21 @@ module.exports = {
94
96
+ },
95
97
+ "css": Object {
96
98
+ "namedExports": true,
97
- @@ ... @@
99
+ + "url": true,
100
+ + },
98
101
+ "css/auto": Object {
99
102
+ "namedExports": true,
100
- + },
103
+ + "url": true,
104
+ @@ ... @@
101
105
+ "css/module": Object {
102
106
+ "namedExports": true,
107
+ + "url": true,
103
108
@@ ... @@
104
109
+ "css",
105
110
@@ ... @@
106
111
- "charset": true,
107
112
+ "charset": false,
108
113
@@ ... @@
109
- + "...",
110
- + ],
111
114
+ },
112
115
+ "css-import": Object {
113
116
+ "conditionNames": Array [
@@ -120,7 +123,8 @@ module.exports = {
120
123
+ ],
121
124
+ "mainFields": Array [
122
125
+ "style",
123
- @@ ... @@
126
+ + "...",
127
+ + ],
124
128
+ "mainFiles": Array [],
125
129
+ "preferRelative": true,
126
130
` )
Original file line number Diff line number Diff line change @@ -607,7 +607,8 @@ function getRawCssParserOptions(
607
607
parser : CssParserOptions
608
608
) : RawCssParserOptions | RawCssAutoParserOptions | RawCssModuleParserOptions {
609
609
return {
610
- namedExports : parser . namedExports
610
+ namedExports : parser . namedExports ,
611
+ url : parser . url
611
612
} ;
612
613
}
613
614
Original file line number Diff line number Diff line change @@ -344,14 +344,17 @@ const applyModuleDefaults = (
344
344
F ( module . parser , "css" , ( ) => ( { } ) ) ;
345
345
assertNotNill ( module . parser . css ) ;
346
346
D ( module . parser . css , "namedExports" , true ) ;
347
+ D ( module . parser . css , "url" , true ) ;
347
348
348
349
F ( module . parser , "css/auto" , ( ) => ( { } ) ) ;
349
350
assertNotNill ( module . parser [ "css/auto" ] ) ;
350
351
D ( module . parser [ "css/auto" ] , "namedExports" , true ) ;
352
+ D ( module . parser [ "css/auto" ] , "url" , true ) ;
351
353
352
354
F ( module . parser , "css/module" , ( ) => ( { } ) ) ;
353
355
assertNotNill ( module . parser [ "css/module" ] ) ;
354
356
D ( module . parser [ "css/module" ] , "namedExports" , true ) ;
357
+ D ( module . parser [ "css/module" ] , "url" , true ) ;
355
358
356
359
// IGNORE(module.generator): already check to align in 2024.6.27
357
360
F ( module . generator , "css" , ( ) => ( { } ) ) ;
Original file line number Diff line number Diff line change @@ -962,6 +962,7 @@ export type AssetParserOptions = {
962
962
} ;
963
963
964
964
export type CssParserNamedExports = boolean ;
965
+ export type CssParserUrl = boolean ;
965
966
966
967
/** Options object for `css` modules. */
967
968
export type CssParserOptions = {
@@ -970,6 +971,12 @@ export type CssParserOptions = {
970
971
* @default true
971
972
* */
972
973
namedExports ?: CssParserNamedExports ;
974
+
975
+ /**
976
+ * Allow to enable/disables handling the CSS functions url.
977
+ * @default true
978
+ * */
979
+ url ?: CssParserUrl ;
973
980
} ;
974
981
975
982
/** Options object for `css/auto` modules. */
@@ -979,6 +986,12 @@ export type CssAutoParserOptions = {
979
986
* @default true
980
987
* */
981
988
namedExports ?: CssParserNamedExports ;
989
+
990
+ /**
991
+ * Allow to enable/disables handling the CSS functions url.
992
+ * @default true
993
+ * */
994
+ url ?: CssParserUrl ;
982
995
} ;
983
996
984
997
/** Options object for `css/module` modules. */
@@ -988,6 +1001,12 @@ export type CssModuleParserOptions = {
988
1001
* @default true
989
1002
* */
990
1003
namedExports ?: CssParserNamedExports ;
1004
+
1005
+ /**
1006
+ * Allow to enable/disables handling the CSS functions url.
1007
+ * @default true
1008
+ * */
1009
+ url ?: CssParserUrl ;
991
1010
} ;
992
1011
993
1012
type ExportsPresence = "error" | "warn" | "auto" | false ;
You can’t perform that action at this time.
0 commit comments