@@ -1288,8 +1288,6 @@ export async function preprocessCSS(
12881288 return await compileCSS ( filename , code , config )
12891289}
12901290
1291- const postcssReturnsVirtualFilesRE = / ^ < .+ > $ /
1292-
12931291export async function formatPostcssSourceMap (
12941292 rawMap : ExistingRawSourceMap ,
12951293 file : string ,
@@ -1299,7 +1297,8 @@ export async function formatPostcssSourceMap(
12991297 const sources = rawMap . sources . map ( ( source ) => {
13001298 const cleanSource = cleanUrl ( decodeURIComponent ( source ) )
13011299
1302- if ( postcssReturnsVirtualFilesRE . test ( cleanSource ) ) {
1300+ // postcss virtual files
1301+ if ( cleanSource [ 0 ] === '<' && cleanSource [ cleanSource . length - 1 ] === '>' ) {
13031302 return `\0${ cleanSource } `
13041303 }
13051304
@@ -1373,7 +1372,7 @@ async function resolvePostcssConfig(
13731372 const searchPath =
13741373 typeof inlineOptions === 'string' ? inlineOptions : config . root
13751374 result = postcssrc ( { } , searchPath ) . catch ( ( e ) => {
1376- if ( ! / N o P o s t C S S C o n f i g f o u n d / . test ( e . message ) ) {
1375+ if ( ! e . message . includes ( ' No PostCSS Config found' ) ) {
13771376 if ( e instanceof Error ) {
13781377 const { name, message, stack } = e
13791378 e . name = 'Failed to load PostCSS config'
@@ -1654,6 +1653,11 @@ function resolveMinifyCssEsbuildOptions(
16541653 }
16551654}
16561655
1656+ const atImportRE =
1657+ / @ i m p o r t (?: \s * (?: u r l \( [ ^ ) ] * \) | " (?: [ ^ " ] | (?< = \\ ) " ) * " | ' (?: [ ^ ' ] | (?< = \\ ) ' ) * ' ) .* ?| [ ^ ; ] * ) ; / g
1658+ const atCharsetRE =
1659+ / @ c h a r s e t (?: \s * (?: " (?: [ ^ " ] | (?< = \\ ) " ) * " | ' (?: [ ^ ' ] | (?< = \\ ) ' ) * ' ) .* ?| [ ^ ; ] * ) ; / g
1660+
16571661export async function hoistAtRules ( css : string ) : Promise < string > {
16581662 const s = new MagicString ( css )
16591663 const cleanCss = emptyCssComments ( css )
@@ -1663,8 +1667,7 @@ export async function hoistAtRules(css: string): Promise<string> {
16631667 // CSS @import can only appear at top of the file. We need to hoist all @import
16641668 // to top when multiple files are concatenated.
16651669 // match until semicolon that's not in quotes
1666- const atImportRE =
1667- / @ i m p o r t (?: \s * (?: u r l \( [ ^ ) ] * \) | " (?: [ ^ " ] | (?< = \\ ) " ) * " | ' (?: [ ^ ' ] | (?< = \\ ) ' ) * ' ) .* ?| [ ^ ; ] * ) ; / g
1670+ atImportRE . lastIndex = 0
16681671 while ( ( match = atImportRE . exec ( cleanCss ) ) ) {
16691672 s . remove ( match . index , match . index + match [ 0 ] . length )
16701673 // Use `appendLeft` instead of `prepend` to preserve original @import order
@@ -1673,8 +1676,7 @@ export async function hoistAtRules(css: string): Promise<string> {
16731676
16741677 // #6333
16751678 // CSS @charset must be the top-first in the file, hoist the first to top
1676- const atCharsetRE =
1677- / @ c h a r s e t (?: \s * (?: " (?: [ ^ " ] | (?< = \\ ) " ) * " | ' (?: [ ^ ' ] | (?< = \\ ) ' ) * ' ) .* ?| [ ^ ; ] * ) ; / g
1679+ atCharsetRE . lastIndex = 0
16781680 let foundCharset = false
16791681 while ( ( match = atCharsetRE . exec ( cleanCss ) ) ) {
16801682 s . remove ( match . index , match . index + match [ 0 ] . length )
@@ -2406,8 +2408,8 @@ export const convertTargets = (
24062408
24072409 for ( const entry of entriesWithoutES ) {
24082410 if ( entry === 'esnext' ) continue
2409- const index = entry . match ( versionRE ) ?. index
2410- if ( index ) {
2411+ const index = entry . search ( versionRE )
2412+ if ( index >= 0 ) {
24112413 const browser = map [ entry . slice ( 0 , index ) ]
24122414 if ( browser === false ) continue // No mapping available
24132415 if ( browser ) {
0 commit comments