build: dont strip single line comments (#14969)

This commit is contained in:
Bjorn Lu 2023-11-13 16:18:30 +08:00 committed by GitHub
parent 55335cc3d9
commit ea9ccb7def
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,7 +31,6 @@ export default defineConfig({
// Taken from https://stackoverflow.com/a/36328890
const multilineCommentsRE = /\/\*[^*]*\*+(?:[^/*][^*]*\*+)*\//g
const singlelineCommentsRE = /\/\/[^/].*/g
const licenseCommentsRE = /MIT License|MIT license|BSD license/
const consecutiveNewlinesRE = /\n{2,}/g
const identifierWithTrailingDollarRE = /\b(\w+)\$\d+\b/g
@ -239,7 +238,6 @@ function removeInternal(s: MagicString, node: any): boolean {
function cleanUnnecessaryComments(code: string) {
return code
.replace(singlelineCommentsRE, '')
.replace(multilineCommentsRE, (m) => {
return licenseCommentsRE.test(m) ? '' : m
})