@@ -41,7 +41,7 @@ use crate::{
41
41
output:: { OutputAsset , OutputAssets } ,
42
42
package_json:: { read_package_json, PackageJsonIssue } ,
43
43
raw_module:: RawModule ,
44
- reference_type:: { ReferenceType , UrlReferenceSubType } ,
44
+ reference_type:: ReferenceType ,
45
45
resolve:: {
46
46
node:: { node_cjs_resolve_options, node_esm_resolve_options} ,
47
47
parse:: stringify_data_uri,
@@ -1589,14 +1589,10 @@ pub async fn resolve_inline(
1589
1589
handle_before_resolve_plugins ( lookup_path, reference_type. clone ( ) , request, options)
1590
1590
. await ?;
1591
1591
1592
- let retain_data_url = matches ! (
1593
- * reference_type,
1594
- ReferenceType :: Url ( UrlReferenceSubType :: CssUrl )
1595
- ) ;
1596
1592
let raw_result = match before_plugins_result {
1597
1593
Some ( result) => result,
1598
1594
None => {
1599
- resolve_internal ( lookup_path, request, options, retain_data_url )
1595
+ resolve_internal ( lookup_path, request, options)
1600
1596
. resolve ( )
1601
1597
. await ?
1602
1598
}
@@ -1761,16 +1757,14 @@ async fn resolve_internal(
1761
1757
lookup_path : ResolvedVc < FileSystemPath > ,
1762
1758
request : ResolvedVc < Request > ,
1763
1759
options : ResolvedVc < ResolveOptions > ,
1764
- retain_data_url : bool ,
1765
1760
) -> Result < Vc < ResolveResult > > {
1766
- resolve_internal_inline ( * lookup_path, * request, * options, retain_data_url ) . await
1761
+ resolve_internal_inline ( * lookup_path, * request, * options) . await
1767
1762
}
1768
1763
1769
1764
async fn resolve_internal_inline (
1770
1765
lookup_path : Vc < FileSystemPath > ,
1771
1766
request : Vc < Request > ,
1772
1767
options : Vc < ResolveOptions > ,
1773
- retain_data_url : bool ,
1774
1768
) -> Result < Vc < ResolveResult > > {
1775
1769
let span = {
1776
1770
let lookup_path = lookup_path. to_string ( ) . await ?. to_string ( ) ;
@@ -1825,9 +1819,7 @@ async fn resolve_internal_inline(
1825
1819
Request :: Alternatives { requests } => {
1826
1820
let results = requests
1827
1821
. iter ( )
1828
- . map ( |req| async {
1829
- resolve_internal_inline ( lookup_path, * * req, options, retain_data_url) . await
1830
- } )
1822
+ . map ( |req| async { resolve_internal_inline ( lookup_path, * * req, options) . await } )
1831
1823
. try_join ( )
1832
1824
. await ?;
1833
1825
@@ -1960,7 +1952,6 @@ async fn resolve_internal_inline(
1960
1952
lookup_path. root ( ) ,
1961
1953
relative,
1962
1954
options,
1963
- retain_data_url,
1964
1955
) )
1965
1956
. await ?
1966
1957
}
@@ -2014,26 +2005,33 @@ async fn resolve_internal_inline(
2014
2005
encoding,
2015
2006
data,
2016
2007
} => {
2017
- if !retain_data_url {
2018
- * ResolveResult :: primary ( ResolveResultItem :: Source ( ResolvedVc :: upcast (
2019
- DataUriSource :: new (
2020
- media_type. clone ( ) ,
2021
- encoding. clone ( ) ,
2022
- * * data,
2023
- lookup_path,
2024
- )
2025
- . to_resolved ( )
2026
- . await ?,
2027
- ) ) )
2008
+ // Behave like Request::Uri
2009
+ let uri: RcStr = stringify_data_uri ( media_type, encoding, * data)
2010
+ . await ?
2011
+ . into ( ) ;
2012
+ if options. await ?. parse_data_uris {
2013
+ * ResolveResult :: primary_with_key (
2014
+ RequestKey :: new ( uri. clone ( ) ) ,
2015
+ ResolveResultItem :: Source ( ResolvedVc :: upcast (
2016
+ DataUriSource :: new (
2017
+ media_type. clone ( ) ,
2018
+ encoding. clone ( ) ,
2019
+ * * data,
2020
+ lookup_path,
2021
+ )
2022
+ . to_resolved ( )
2023
+ . await ?,
2024
+ ) ) ,
2025
+ )
2028
2026
} else {
2029
- let uri : RcStr = stringify_data_uri ( media_type , encoding , * data )
2030
- . await ?
2031
- . into ( ) ;
2032
- * ResolveResult :: primary ( ResolveResultItem :: External {
2033
- name : uri ,
2034
- ty : ExternalType :: Url ,
2035
- traced : ExternalTraced :: Untraced ,
2036
- } )
2027
+ * ResolveResult :: primary_with_key (
2028
+ RequestKey :: new ( uri . clone ( ) ) ,
2029
+ ResolveResultItem :: External {
2030
+ name : uri ,
2031
+ ty : ExternalType :: Url ,
2032
+ traced : ExternalTraced :: Untraced ,
2033
+ } ,
2034
+ )
2037
2035
}
2038
2036
}
2039
2037
Request :: Uri {
@@ -2127,10 +2125,9 @@ async fn resolve_into_folder(
2127
2125
} else {
2128
2126
options
2129
2127
} ;
2130
- let result =
2131
- & * resolve_internal_inline ( * package_path, * request, options, false )
2132
- . await ?
2133
- . await ?;
2128
+ let result = & * resolve_internal_inline ( * package_path, * request, options)
2129
+ . await ?
2130
+ . await ?;
2134
2131
// we are not that strict when a main field fails to resolve
2135
2132
// we continue to try other alternatives
2136
2133
if !result. is_unresolvable_ref ( ) {
@@ -2166,11 +2163,9 @@ async fn resolve_into_folder(
2166
2163
2167
2164
let request = Request :: parse ( Value :: new ( pattern) ) ;
2168
2165
2169
- Ok (
2170
- resolve_internal_inline ( * package_path, request, options, false )
2171
- . await ?
2172
- . with_request ( "." . into ( ) ) ,
2173
- )
2166
+ Ok ( resolve_internal_inline ( * package_path, request, options)
2167
+ . await ?
2168
+ . with_request ( "." . into ( ) ) )
2174
2169
}
2175
2170
2176
2171
#[ tracing:: instrument( level = Level :: TRACE , skip_all) ]
@@ -2455,7 +2450,6 @@ async fn apply_in_package(
2455
2450
. with_query ( query)
2456
2451
. with_fragment ( fragment) ,
2457
2452
options,
2458
- false ,
2459
2453
)
2460
2454
. with_replaced_request_key ( value. into ( ) , Value :: new ( request_key) )
2461
2455
. with_affecting_sources ( refs. into_iter ( ) . map ( |src| * src) . collect ( ) ) ,
@@ -2628,13 +2622,8 @@ async fn resolve_module_request(
2628
2622
let relative = Request :: relative ( Value :: new ( pattern) , query, fragment, true )
2629
2623
. to_resolved ( )
2630
2624
. await ?;
2631
- let relative_result = Box :: pin ( resolve_internal_inline (
2632
- lookup_path,
2633
- * relative,
2634
- options,
2635
- false ,
2636
- ) )
2637
- . await ?;
2625
+ let relative_result =
2626
+ Box :: pin ( resolve_internal_inline ( lookup_path, * relative, options) ) . await ?;
2638
2627
let relative_result = relative_result
2639
2628
. with_replaced_request_key ( module_prefix, Value :: new ( RequestKey :: new ( module. into ( ) ) ) ) ;
2640
2629
@@ -2720,7 +2709,7 @@ async fn resolve_into_package(
2720
2709
let relative = Request :: relative ( Value :: new ( new_pat) , query, fragment, true )
2721
2710
. to_resolved ( )
2722
2711
. await ?;
2723
- results. push ( resolve_internal_inline ( * package_path, * relative, * options, false ) . await ?) ;
2712
+ results. push ( resolve_internal_inline ( * package_path, * relative, * options) . await ?) ;
2724
2713
}
2725
2714
2726
2715
Ok ( merge_results ( results) )
@@ -2747,7 +2736,7 @@ async fn resolve_import_map_result(
2747
2736
if request == original_request && lookup_path == original_lookup_path {
2748
2737
None
2749
2738
} else {
2750
- let result = resolve_internal ( lookup_path, request, options, false ) ;
2739
+ let result = resolve_internal ( lookup_path, request, options) ;
2751
2740
Some ( result. with_replaced_request_key_pattern (
2752
2741
request. request_pattern ( ) ,
2753
2742
original_request. request_pattern ( ) ,
@@ -2788,7 +2777,6 @@ async fn resolve_import_map_result(
2788
2777
node_esm_resolve_options ( alias_lookup_path. root ( ) )
2789
2778
}
2790
2779
} ,
2791
- false ,
2792
2780
)
2793
2781
. await ?
2794
2782
. is_unresolvable_ref ( ) ;
@@ -2934,13 +2922,8 @@ async fn handle_exports_imports_field(
2934
2922
. to_resolved ( )
2935
2923
. await ?;
2936
2924
2937
- let resolve_result = Box :: pin ( resolve_internal_inline (
2938
- package_path,
2939
- * request,
2940
- options,
2941
- false ,
2942
- ) )
2943
- . await ?;
2925
+ let resolve_result =
2926
+ Box :: pin ( resolve_internal_inline ( package_path, * request, options) ) . await ?;
2944
2927
if conditions. is_empty ( ) {
2945
2928
resolved_results. push ( resolve_result. with_request ( path. into ( ) ) ) ;
2946
2929
} else {
0 commit comments