File tree 3 files changed +14
-7
lines changed
3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,13 @@ async function run() {
5
5
6
6
run ( )
7
7
8
- document . getElementById ( 'env' ) . textContent = `is legacy: ${
9
- import . meta. env . LEGACY
10
- } `
8
+ let isLegacy
9
+
10
+ // make sure that branching works despite esbuild's constant folding (#1999)
11
+ if ( import . meta. env . LEGACY ) {
12
+ if ( import . meta. env . LEGACY === true ) isLegacy = true
13
+ } else {
14
+ if ( import . meta. env . LEGACY === false ) isLegacy = false
15
+ }
16
+
17
+ document . getElementById ( 'env' ) . textContent = `is legacy: ${ isLegacy } `
Original file line number Diff line number Diff line change @@ -189,7 +189,7 @@ function viteLegacyPlugin(options = {}) {
189
189
}
190
190
191
191
if ( raw . includes ( legacyEnvVarMarker ) ) {
192
- const re = new RegExp ( `" ${ legacyEnvVarMarker } "` , 'g' )
192
+ const re = new RegExp ( legacyEnvVarMarker , 'g' )
193
193
if ( config . build . sourcemap ) {
194
194
const s = new MagicString ( raw )
195
195
let match
@@ -550,8 +550,8 @@ function replaceLegacyEnvBabelPlugin() {
550
550
return ( { types : t } ) => ( {
551
551
name : 'vite-replace-env-legacy' ,
552
552
visitor : {
553
- StringLiteral ( path ) {
554
- if ( path . node . value === legacyEnvVarMarker ) {
553
+ Identifier ( path ) {
554
+ if ( path . node . name === legacyEnvVarMarker ) {
555
555
path . replaceWith ( t . booleanLiteral ( true ) )
556
556
}
557
557
}
Original file line number Diff line number Diff line change 32
32
"systemjs" : " ^6.8.3"
33
33
},
34
34
"peerDependencies" : {
35
- "vite" : " ^2.0.0-beta.12 "
35
+ "vite" : " ^2.0.0-beta.70 "
36
36
}
37
37
}
You can’t perform that action at this time.
0 commit comments