Skip to content

Commit e37966d

Browse files
kfuledead-claudia
authored andcommitted
bundler: fix mangled strings caused by collision disambiguation in comment lines
This removes the mysterious suffixes in the comments and improves the readability of the bundled mithril.js. There is no impact on the code other than comments, as the processing is limited to lines containing only comments. Trailing comments are not subject to this processing, but there are few trailing comments, and mangling does not seem to occur so far.
1 parent adcfe77 commit e37966d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scripts/_bundler-impl.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ module.exports = async (input) => {
164164
return pre + b.replace(/\d+$/, "") + post
165165
})
166166

167+
// fix comment‑only lines
168+
const commentOnlyLines = /^(?:[ \t]*\/\/[^\r\n]*|[ \t]*\/\*[\s\S]*?\*\/[ \t]*)\r?$/gm
169+
code = code.replace(commentOnlyLines, (comment) =>
170+
comment.replace(variables, (match) => match.replace(/\d+$/, ""))
171+
)
172+
167173
return code
168174
.replace(/("|')use strict\1;?/gm, "") // remove extraneous "use strict"
169175
.replace(/module\.exports\s*=\s*/gm, escapeReplace(rest ? `var _${uuid}` + eq : def + (rest ? "_" : "") + variable + eq)) // export

0 commit comments

Comments
 (0)