File tree 3 files changed +9
-7
lines changed
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -41,17 +41,17 @@ describe('definePlugin', () => {
41
41
} )
42
42
43
43
test ( 'preserve import.meta.hot with override' , async ( ) => {
44
- // assert that the default behavior is to replace import.meta.hot with false
44
+ // assert that the default behavior is to replace import.meta.hot with undefined
45
45
const transform = await createDefinePluginTransform ( )
46
- expect ( await transform ( 'const isHot = import.meta.hot;' ) ) . toBe (
47
- 'const isHot = false ;' ,
46
+ expect ( await transform ( 'const hot = import.meta.hot;' ) ) . toBe (
47
+ 'const hot = undefined ;' ,
48
48
)
49
49
// assert that we can specify a user define to preserve import.meta.hot
50
50
const overrideTransform = await createDefinePluginTransform ( {
51
51
'import.meta.hot' : 'import.meta.hot' ,
52
52
} )
53
- expect ( await overrideTransform ( 'const isHot = import.meta.hot;' ) ) . toBe (
54
- 'const isHot = import.meta.hot;' ,
53
+ expect ( await overrideTransform ( 'const hot = import.meta.hot;' ) ) . toBe (
54
+ 'const hot = import.meta.hot;' ,
55
55
)
56
56
} )
57
57
} )
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ export function definePlugin(config: ResolvedConfig): Plugin {
46
46
SSR : ! ! config . build . ssr ,
47
47
}
48
48
// set here to allow override with config.define
49
- importMetaKeys [ 'import.meta.hot' ] = `false `
49
+ importMetaKeys [ 'import.meta.hot' ] = `undefined `
50
50
for ( const key in env ) {
51
51
importMetaKeys [ `import.meta.env.${ key } ` ] = JSON . stringify ( env [ key ] )
52
52
}
Original file line number Diff line number Diff line change 1
1
// This file is never loaded
2
- import . meta. hot . accept ( ( ) => { } )
2
+ if ( import . meta. hot ) {
3
+ import . meta. hot . accept ( ( ) => { } )
4
+ }
You can’t perform that action at this time.
0 commit comments