Skip to content

Commit

Permalink
fix: not match \n when injecting esbuild helpers (#8414)
Browse files Browse the repository at this point in the history
  • Loading branch information
ddosakura authored Jun 1, 2022
1 parent 8a68fbd commit 5a57626
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/vite/src/node/plugins/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ import { searchForWorkspaceRoot } from '..'
const debug = createDebugger('vite:esbuild')

const INJECT_HELPERS_IIFE_RE =
/(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)(.*)/
/(.*)((?:const|var) [^\s]+=function\([^)]*?\){"use strict";)(.*)/s
const INJECT_HELPERS_UMD_RE =
/(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)(.*)/
/(.*)(\(function\([^)]*?\){.+amd.+function\([^)]*?\){"use strict";)(.*)/s

let server: ViteDevServer

Expand Down
5 changes: 5 additions & 0 deletions playground/lib/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ const path = require('path')
*/
module.exports = {
build: {
rollupOptions: {
output: {
banner: `/*!\nMayLib\n*/`
}
},
lib: {
entry: path.resolve(__dirname, 'src/main.js'),
name: 'MyLib',
Expand Down

0 comments on commit 5a57626

Please sign in to comment.