* Concatenate JS chunks safely. Goals: * - Each chunk's last statement is terminated, so joining can't introduce ASI * surprises (e.g. `a()` followed by `(b)()` — the second chunk would parse * as a call on the first's return value). * - In the common case (chunk already ends with `;
(chunks: string[])
| 577 | * comment, and the standalone `;` becomes the statement separator. |
| 578 | */ |
| 579 | function joinJsChunks(chunks: string[]): string { |
| 580 | return chunks |
| 581 | .map((chunk) => chunk.trim()) |
| 582 | .filter((chunk) => chunk.length > 0) |
| 583 | .map((chunk) => (chunk.endsWith(";") ? chunk : chunk + "\n;")) |
| 584 | .join("\n"); |
| 585 | } |
| 586 | |
| 587 | function stripJsCommentsParserSafe(source: string): string { |
| 588 | if (!source) return source; |
no outgoing calls
no test coverage detected