File tree 6 files changed +18
-14
lines changed
6 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import MagicString from 'magic-string'
3
3
import { stripLiteral } from 'strip-literal'
4
4
import type { Plugin } from '../plugin'
5
5
import type { ResolvedConfig } from '../config'
6
- import { transformResult } from '../utils'
6
+ import { transformStableResult } from '../utils'
7
7
import { fileToUrl } from './asset'
8
8
import { preloadHelperId } from './importAnalysisBuild'
9
9
@@ -81,7 +81,7 @@ export function assetImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
81
81
)
82
82
}
83
83
if ( s ) {
84
- return transformResult ( s , id , config )
84
+ return transformStableResult ( s , id , config )
85
85
}
86
86
}
87
87
return null
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ import {
11
11
normalizePath ,
12
12
parseRequest ,
13
13
requestQuerySplitRE ,
14
- transformResult
14
+ transformStableResult
15
15
} from '../utils'
16
16
17
17
export const dynamicImportHelperId = '/@vite/dynamic-import-helper'
@@ -209,7 +209,7 @@ export function dynamicImportVarsPlugin(config: ResolvedConfig): Plugin {
209
209
`import __variableDynamicImportRuntimeHelper from "${ dynamicImportHelperId } ";`
210
210
)
211
211
}
212
- return transformResult ( s , importer , config )
212
+ return transformStableResult ( s , importer , config )
213
213
}
214
214
}
215
215
}
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ import {
40
40
removeImportQuery ,
41
41
stripBomTag ,
42
42
timeFrom ,
43
- transformResult ,
43
+ transformStableResult ,
44
44
unwrapId
45
45
} from '../utils'
46
46
import type { ResolvedConfig } from '../config'
@@ -711,7 +711,7 @@ export function importAnalysisPlugin(config: ResolvedConfig): Plugin {
711
711
}
712
712
713
713
if ( s ) {
714
- return transformResult ( s , importer , config )
714
+ return transformStableResult ( s , importer , config )
715
715
} else {
716
716
return source
717
717
}
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ import type { Plugin } from '../plugin'
17
17
import type { ViteDevServer } from '../server'
18
18
import type { ModuleNode } from '../server/moduleGraph'
19
19
import type { ResolvedConfig } from '../config'
20
- import { normalizePath , slash , transformResult } from '../utils'
20
+ import { normalizePath , slash , transformStableResult } from '../utils'
21
21
22
22
const { isMatch, scan } = micromatch
23
23
@@ -75,7 +75,7 @@ export function importGlobPlugin(config: ResolvedConfig): Plugin {
75
75
server ! . watcher . add ( dirname ( file ) )
76
76
} )
77
77
}
78
- return transformResult ( result . s , id , config )
78
+ return transformStableResult ( result . s , id , config )
79
79
}
80
80
}
81
81
}
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ import {
10
10
injectQuery ,
11
11
normalizePath ,
12
12
parseRequest ,
13
- transformResult
13
+ transformStableResult
14
14
} from '../utils'
15
15
import { getDepsOptimizer } from '../optimizer'
16
16
import type { WorkerType } from './worker'
@@ -136,7 +136,7 @@ export function workerImportMetaUrlPlugin(config: ResolvedConfig): Plugin {
136
136
}
137
137
138
138
if ( s ) {
139
- return transformResult ( s , id , config )
139
+ return transformStableResult ( s , id , config )
140
140
}
141
141
142
142
return null
Original file line number Diff line number Diff line change @@ -1028,16 +1028,20 @@ function normalizeSingleAlias({
1028
1028
return alias
1029
1029
}
1030
1030
1031
- export function transformResult (
1031
+ /**
1032
+ * Transforms transpiled code result where line numbers aren't altered,
1033
+ * so we can skip sourcemap generation during dev
1034
+ */
1035
+ export function transformStableResult (
1032
1036
s : MagicString ,
1033
1037
id : string ,
1034
1038
config : ResolvedConfig
1035
1039
) : TransformResult {
1036
- const isBuild = config . command === 'build'
1037
- const needSourceMap = ! isBuild || config . build . sourcemap
1038
1040
return {
1039
1041
code : s . toString ( ) ,
1040
- map : needSourceMap ? s . generateMap ( { hires : true , source : id } ) : null
1042
+ map : config . build . sourcemap
1043
+ ? s . generateMap ( { hires : true , source : id } )
1044
+ : null
1041
1045
}
1042
1046
}
1043
1047
You can’t perform that action at this time.
0 commit comments