File tree 3 files changed +7
-2
lines changed
packages/vite/src/node/plugins
3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ const debug = createDebugger('vite:esbuild')
29
29
const INJECT_HELPERS_IIFE_RE =
30
30
/ ^ ( .* ?) ( (?: c o n s t | v a r ) \s + \S + \s * = \s * f u n c t i o n \s * \( [ ^ ) ] * \) \s * \{ .* ?" u s e s t r i c t " ; ) / s
31
31
const INJECT_HELPERS_UMD_RE =
32
- / ^ ( .* ?) ( \( f u n c t i o n \( [ ^ ) ] * \) \s * \{ .+ a m d .+ f u n c t i o n \( [ ^ ) ] * \) \s * \{ .* ?" u s e s t r i c t " ; ) / s
32
+ / ^ ( .* ?) ( \( f u n c t i o n \( [ ^ ) ] * \) \s * \{ .+ ? a m d .+ ? f u n c t i o n \( [ ^ ) ] * \) \s * \{ .* ?" u s e s t r i c t " ; ) / s
33
33
34
34
let server : ViteDevServer
35
35
Original file line number Diff line number Diff line change @@ -19,7 +19,9 @@ describe.runIf(isBuild)('build', () => {
19
19
const noMinifyCode = readFile ( 'dist/nominify/my-lib-custom-filename.umd.js' )
20
20
// esbuild helpers are injected inside of the UMD wrapper
21
21
expect ( code ) . toMatch ( / ^ \( f u n c t i o n \( / )
22
- expect ( noMinifyCode ) . toMatch ( / ^ \( f u n c t i o n \( g l o b a l / )
22
+ expect ( noMinifyCode ) . toMatch (
23
+ / ^ \( f u n c t i o n \( g l o b a l .+ ?" u s e s t r i c t " ; v a r .+ ?f u n c t i o n \s m y L i b \( / s,
24
+ )
23
25
} )
24
26
25
27
test ( 'iife' , async ( ) => {
Original file line number Diff line number Diff line change @@ -6,4 +6,7 @@ export default function myLib(sel) {
6
6
7
7
// Env vars should not be replaced
8
8
console . log ( process . env . NODE_ENV )
9
+
10
+ // make sure umd helper has been moved to the right position
11
+ console . log ( `amd function(){ "use strict"; }` )
9
12
}
You can’t perform that action at this time.
0 commit comments