File tree 4 files changed +27
-2
lines changed
packages/vite/src/node/plugins
4 files changed +27
-2
lines changed Original file line number Diff line number Diff line change @@ -27,9 +27,9 @@ import { searchForWorkspaceRoot } from '..'
27
27
const debug = createDebugger ( 'vite:esbuild' )
28
28
29
29
const INJECT_HELPERS_IIFE_RE =
30
- / ^ ( .* ?) ( (?: c o n s t | v a r ) \S + = f u n c t i o n \( [ ^ ) ] * \) \{ " u s e s t r i c t " ; ) / s
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 \( [ ^ ) ] * \) \{ .+ a m d .+ f u n c t i o n \( [ ^ ) ] * \) \{ " 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 @@ -16,15 +16,23 @@ describe.runIf(isBuild)('build', () => {
16
16
test ( 'umd' , async ( ) => {
17
17
expect ( await page . textContent ( '.umd' ) ) . toBe ( 'It works' )
18
18
const code = readFile ( 'dist/my-lib-custom-filename.umd.js' )
19
+ const noMinifyCode = readFile ( 'dist/nominify/my-lib-custom-filename.umd.js' )
19
20
// esbuild helpers are injected inside of the UMD wrapper
20
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 / )
21
23
} )
22
24
23
25
test ( 'iife' , async ( ) => {
24
26
expect ( await page . textContent ( '.iife' ) ) . toBe ( 'It works' )
25
27
const code = readFile ( 'dist/my-lib-custom-filename.iife.js' )
28
+ const noMinifyCode = readFile (
29
+ 'dist/nominify/my-lib-custom-filename.iife.js' ,
30
+ )
26
31
// esbuild helpers are injected inside of the IIFE wrapper
27
32
expect ( code ) . toMatch ( / ^ v a r M y L i b = f u n c t i o n \( \) \{ " u s e s t r i c t " ; / )
33
+ expect ( noMinifyCode ) . toMatch (
34
+ / ^ v a r M y L i b \s * = \s * f u n c t i o n \( \) \s * \{ .* ?" u s e s t r i c t " ; / s,
35
+ )
28
36
} )
29
37
30
38
test ( 'Library mode does not include `preload`' , async ( ) => {
Original file line number Diff line number Diff line change @@ -61,6 +61,12 @@ export async function serve(): Promise<{ close(): Promise<void> }> {
61
61
configFile : path . resolve ( __dirname , '../vite.dyimport.config.js' ) ,
62
62
} )
63
63
64
+ await build ( {
65
+ root : rootDir ,
66
+ logLevel : 'warn' , // output esbuild warns
67
+ configFile : path . resolve ( __dirname , '../vite.nominify.config.js' ) ,
68
+ } )
69
+
64
70
// start static file server
65
71
const serve = sirv ( path . resolve ( rootDir , 'dist' ) )
66
72
const httpServer = http . createServer ( ( req , res ) => {
Original file line number Diff line number Diff line change
1
+ const baseConfig = require ( './vite.config' )
2
+
3
+ module . exports = {
4
+ ...baseConfig ,
5
+ build : {
6
+ ...baseConfig . build ,
7
+ minify : false ,
8
+ outDir : 'dist/nominify' ,
9
+ } ,
10
+ plugins : [ ] ,
11
+ }
You can’t perform that action at this time.
0 commit comments