@@ -108,10 +108,10 @@ describe('native definePlugin', () => {
108108 __APP_VERSION__ : JSON . stringify ( '1.0' ) ,
109109 } )
110110 expect ( await transform ( 'export const version = __APP_VERSION__;' ) ) . toBe (
111- 'const version = "1.0";\n\ nexport { version };' ,
111+ 'const version = "1.0";\nexport { version };\n ' ,
112112 )
113113 expect ( await transform ( 'export const version = __APP_VERSION__ ;' ) ) . toBe (
114- 'const version = "1.0";\n\ nexport { version };' ,
114+ 'const version = "1.0";\nexport { version };\n ' ,
115115 )
116116 } )
117117
@@ -120,55 +120,55 @@ describe('native definePlugin', () => {
120120 __APP_VERSION__ : JSON . stringify ( '1.0' ) ,
121121 } )
122122 expect ( await transform ( 'export const version = "1.0";' ) ) . toBe (
123- 'const version = "1.0";\n\ nexport { version };' ,
123+ 'const version = "1.0";\nexport { version };\n ' ,
124124 )
125125 expect (
126126 await transform ( 'export const version = import.meta.SOMETHING' ) ,
127- ) . toBe ( 'const version = import.meta.SOMETHING;\n\ nexport { version };' )
127+ ) . toBe ( 'const version = import.meta.SOMETHING;\nexport { version };\n ' )
128128 } )
129129
130130 test ( 'replaces import.meta.env.SSR with false' , async ( ) => {
131131 const transform = await createDefinePluginTransform ( )
132132 expect ( await transform ( 'export const isSSR = import.meta.env.SSR;' ) ) . toBe (
133- 'const isSSR = false;\n\ nexport { isSSR };' ,
133+ 'const isSSR = false;\nexport { isSSR };\n ' ,
134134 )
135135 } )
136136
137137 test ( 'preserve import.meta.hot with override' , async ( ) => {
138138 // assert that the default behavior is to replace import.meta.hot with undefined
139139 const transform = await createDefinePluginTransform ( )
140140 expect ( await transform ( 'export const hot = import.meta.hot;' ) ) . toBe (
141- 'const hot = void 0;\n\ nexport { hot };' ,
141+ 'const hot = void 0;\nexport { hot };\n ' ,
142142 )
143143 // assert that we can specify a user define to preserve import.meta.hot
144144 const overrideTransform = await createDefinePluginTransform ( {
145145 'import.meta.hot' : 'import.meta.hot' ,
146146 } )
147147 expect ( await overrideTransform ( 'export const hot = import.meta.hot;' ) ) . toBe (
148- 'const hot = import.meta.hot;\n\ nexport { hot };' ,
148+ 'const hot = import.meta.hot;\nexport { hot };\n ' ,
149149 )
150150 } )
151151
152152 test ( 'replace import.meta.env.UNKNOWN with undefined' , async ( ) => {
153153 const transform = await createDefinePluginTransform ( )
154154 expect ( await transform ( 'export const foo = import.meta.env.UNKNOWN;' ) ) . toBe (
155- 'const foo = void 0;\n\ nexport { foo };' ,
155+ 'const foo = void 0;\nexport { foo };\n ' ,
156156 )
157157 } )
158158
159159 test ( 'leave import.meta.env["UNKNOWN"] to runtime' , async ( ) => {
160160 const transform = await createDefinePluginTransform ( )
161161 expect (
162162 await transform ( 'export const foo = import.meta.env["UNKNOWN"];' ) ,
163- ) . toMatch ( / c o n s t f o o = .* \[ " U N K N O W N " \] ; \n \ ne x p o r t \{ f o o \} ; / s)
163+ ) . toMatch ( / c o n s t f o o = .* \[ " U N K N O W N " \] ; \n e x p o r t \{ f o o \} ; \n / s)
164164 } )
165165
166166 test ( 'preserve import.meta.env.UNKNOWN with override' , async ( ) => {
167167 const transform = await createDefinePluginTransform ( {
168168 'import.meta.env.UNKNOWN' : 'import.meta.env.UNKNOWN' ,
169169 } )
170170 expect ( await transform ( 'export const foo = import.meta.env.UNKNOWN;' ) ) . toBe (
171- 'const foo = import.meta.env.UNKNOWN;\n\ nexport { foo };' ,
171+ 'const foo = import.meta.env.UNKNOWN;\nexport { foo };\n ' ,
172172 )
173173 } )
174174
@@ -182,14 +182,14 @@ describe('native definePlugin', () => {
182182 'export const isLegacy = import.meta.env.LEGACY;\nimport.meta.env.UNDEFINED && console.log(import.meta.env.UNDEFINED);' ,
183183 ) ,
184184 ) . toMatchInlineSnapshot (
185- `"const isLegacy = __VITE_IS_LEGACY__;\n\ nexport { isLegacy };"` ,
185+ `"const isLegacy = __VITE_IS_LEGACY__;\nexport { isLegacy };\n "` ,
186186 )
187187 } )
188188
189189 test ( 'replace bare import.meta.env' , async ( ) => {
190190 const transform = await createDefinePluginTransform ( )
191191 expect ( await transform ( 'export const env = import.meta.env;' ) ) . toMatch (
192- / c o n s t e n v = .* ; \n \ ne x p o r t \{ e n v \} ; / s,
192+ / c o n s t e n v = .* ; \n e x p o r t \{ e n v \} ; \n / s,
193193 )
194194 } )
195195} )
0 commit comments