@@ -4,11 +4,11 @@ import type { ImportSpecifier } from 'es-module-lexer'
4
4
import { init , parse as parseImports } from 'es-module-lexer'
5
5
import type { OutputChunk , SourceMap } from 'rollup'
6
6
import type { RawSourceMap } from '@ampproject/remapping'
7
- import { bareImportRE , combineSourcemaps , isRelativeBase } from '../utils'
7
+ import { combineSourcemaps , isRelativeBase } from '../utils'
8
8
import type { Plugin } from '../plugin'
9
9
import type { ResolvedConfig } from '../config'
10
10
import { genSourceMapUrl } from '../server/sourcemap'
11
- import { isCSSRequest , removedPureCssFilesCache } from './css'
11
+ import { removedPureCssFilesCache } from './css'
12
12
13
13
/**
14
14
* A flag for injected helpers. This flag will be set to `false` if the output
@@ -145,14 +145,7 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
145
145
let needPreloadHelper = false
146
146
147
147
for ( let index = 0 ; index < imports . length ; index ++ ) {
148
- const {
149
- s : start ,
150
- e : end ,
151
- ss : expStart ,
152
- se : expEnd ,
153
- n : specifier ,
154
- d : dynamicIndex
155
- } = imports [ index ]
148
+ const { ss : expStart , se : expEnd , d : dynamicIndex } = imports [ index ]
156
149
157
150
const isDynamic = dynamicIndex > - 1
158
151
@@ -166,27 +159,6 @@ export function buildImportAnalysisPlugin(config: ResolvedConfig): Plugin {
166
159
} )`
167
160
)
168
161
}
169
-
170
- // Differentiate CSS imports that use the default export from those that
171
- // do not by injecting a ?used query - this allows us to avoid including
172
- // the CSS string when unnecessary (esbuild has trouble tree-shaking
173
- // them)
174
- if (
175
- specifier &&
176
- isCSSRequest ( specifier ) &&
177
- // always inject ?used query when it is a dynamic import
178
- // because there is no way to check whether the default export is used
179
- ( source . slice ( expStart , start ) . includes ( 'from' ) || isDynamic ) &&
180
- // already has ?used query (by import.meta.glob)
181
- ! specifier . match ( / \? u s e d ( & | $ ) / ) &&
182
- // edge case for package names ending with .css (e.g normalize.css)
183
- ! ( bareImportRE . test ( specifier ) && ! specifier . includes ( '/' ) )
184
- ) {
185
- const url = specifier . replace ( / \? | $ / , ( m ) => `?used${ m ? '&' : '' } ` )
186
- str ( ) . overwrite ( start , end , isDynamic ? `'${ url } '` : url , {
187
- contentOnly : true
188
- } )
189
- }
190
162
}
191
163
192
164
if (
0 commit comments