File tree 2 files changed +19
-4
lines changed
2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change 1
1
import { describe , expect , test } from 'vitest'
2
2
import type { ResolvedConfig , UserConfig } from '../../config'
3
- import { resolveEsbuildTranspileOptions } from '../../plugins/esbuild'
3
+ import {
4
+ ESBuildTransformResult ,
5
+ resolveEsbuildTranspileOptions ,
6
+ transformWithEsbuild
7
+ } from '../../plugins/esbuild'
4
8
5
9
describe ( 'resolveEsbuildTranspileOptions' , ( ) => {
6
10
test ( 'resolve default' , ( ) => {
@@ -237,6 +241,16 @@ describe('resolveEsbuildTranspileOptions', () => {
237
241
} )
238
242
} )
239
243
244
+ describe ( 'transformWithEsbuild' , ( ) => {
245
+ test ( 'not throw on inline sourcemap' , async ( ) => {
246
+ const result = await transformWithEsbuild ( `const foo = 'bar'` , '' , {
247
+ sourcemap : 'inline'
248
+ } )
249
+ expect ( result ?. code ) . toBeTruthy ( )
250
+ expect ( result ?. map ) . toBeTruthy ( )
251
+ } )
252
+ } )
253
+
240
254
/**
241
255
* Helper for `resolveEsbuildTranspileOptions` to created resolved config with types.
242
256
* Note: The function only uses `build.target`, `build.minify` and `esbuild` options.
Original file line number Diff line number Diff line change @@ -145,9 +145,10 @@ export async function transformWithEsbuild(
145
145
inMap as RawSourceMap
146
146
] ) as SourceMap
147
147
} else {
148
- map = resolvedOptions . sourcemap
149
- ? JSON . parse ( result . map )
150
- : { mappings : '' }
148
+ map =
149
+ resolvedOptions . sourcemap && resolvedOptions . sourcemap !== 'inline'
150
+ ? JSON . parse ( result . map )
151
+ : { mappings : '' }
151
152
}
152
153
if ( Array . isArray ( map . sources ) ) {
153
154
map . sources = map . sources . map ( ( it ) => toUpperCaseDriveLetter ( it ) )
You can’t perform that action at this time.
0 commit comments