Skip to content

Commit b76a031

Browse files
committed
fix: build script munching unintended symbols
1 parent 5d9f175 commit b76a031

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

build.cjs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,21 @@ printSizes('index.d.ts', indexDtsBefore, indexDtsAfter)
101101
// ============================================================================
102102

103103
function cleanJavaScript(code) {
104-
// Remove inline // comments while preserving the code and removing trailing whitespace
105-
code = code.replace(/^(.*)\/\/.*$/gm, (match, code) => {
106-
return code.trimEnd()
107-
})
108-
109104
// Replace multi-line JSDoc comment blocks with equivalent blank lines to preserve line numbers
105+
// NOTE: This must run before the inline // comment removal below, because single-line
106+
// /** @see [Name](https://...) */ comments contain // in URLs. If the inline comment
107+
// regex ran first, it would strip everything after the // (including the closing */),
108+
// creating orphaned /** openings that cause the JSDoc regex to swallow subsequent code.
110109
code = code.replace(/^[ \t]*\/\*\*[\s\S]*?\*\/[ \t]*$/gm, (match) => {
111110
const lineCount = (match.match(/\n/g) || []).length
112111
return '\n'.repeat(lineCount)
113112
})
114113

114+
// Remove inline // comments while preserving the code and removing trailing whitespace
115+
code = code.replace(/^(.*)\/\/.*$/gm, (match, code) => {
116+
return code.trimEnd()
117+
})
118+
115119
// Remove coverage ignore directives by replacing them with blank lines
116120
code = code.replace(/^.*\/\*\s*c8\s+ignore\s+next.*$/gm, '')
117121

0 commit comments

Comments
 (0)