Skip to content

Commit 0f82523

Browse files
committed
fix(cli): generating closing </script> tags now works correctly
1 parent 747fe5a commit 0f82523

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

.changeset/wide-geese-smoke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'sv': patch
3+
---
4+
5+
fix(cli): generating closing </script> tags now works correctly

packages/cli/lib/install.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,8 @@ async function runAddon({ addon, multiple, workspace }: RunAddon) {
142142
fileContent = content(fileContent);
143143
if (!fileContent) return fileContent;
144144

145-
writeFile(workspace, path, fileContent);
145+
// TODO: fix https://github.com/rolldown/tsdown/issues/575 to remove the `replaceAll`
146+
writeFile(workspace, path, fileContent.replaceAll('<\\/script>', '</script>'));
146147
files.add(path);
147148
} catch (e) {
148149
if (e instanceof Error) {

packages/core/tests/utils.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,8 @@ describe('yaml', () => {
270270
});
271271
});
272272

273-
test('tsdown escapes script tags in bundled source code', async () => {
273+
// TODO: fix https://github.com/rolldown/tsdown/issues/575 to remove the `skip`
274+
test.skip('tsdown escapes script tags in bundled source code', async () => {
274275
const { execSync } = await import('node:child_process');
275276
const fs = await import('node:fs');
276277
const path = await import('node:path');
@@ -348,6 +349,6 @@ export default defineConfig({
348349
// This test demonstrates the issue: tsdown escapes </script> in the bundled source
349350
// Expected: Bundled code should NOT contain escaped script tags
350351
// Actual: Bundled code contains <\/script> when using dedent`...` syntax
351-
expect(hasEscapedScriptTagLiteral).toBe(true);
352+
expect(hasEscapedScriptTagLiteral).toBe(false);
352353
expect(hasEscapedScriptTagFunction).toBe(false);
353354
}, 30000); // 30s timeout for npm install and build

0 commit comments

Comments
 (0)