sveltejs / rollup-plugin-svelte

Compile Svelte components with Rollup
MIT License
502 stars 79 forks source link

Failure to compile when string or comment includes `</script>` #182

Closed kristopherbullinger closed 3 years ago

kristopherbullinger commented 3 years ago

Any comment or string that includes </script> will cause a failure to compile. An example comment: //hello 123 </script> Example string: let foo = "hello123 </script>";

This can be worked around in a comment by simply not using that exact sequence, and in a string by escaping the slash <\/script>, but is rather confusing because the error message will likely point at some other "incomplete" bit of code, such as an un-terminated string. Not to mention that a string or comment with such a sequence is valid javascript.

A minimal reproducible example in the svelte repl: https://svelte.dev/repl/6a58379b1397450481499217ea7c3d9c?version=3.37.0

Conduitry commented 3 years ago

This is a duplicate of https://github.com/sveltejs/svelte/issues/3039 / https://github.com/sveltejs/svelte/issues/3840 / https://github.com/sveltejs/svelte/issues/4406 / https://github.com/sveltejs/svelte/issues/4996 / https://github.com/sveltejs/svelte/issues/5024 / https://github.com/sveltejs/svelte/issues/5237 / https://github.com/sveltejs/rollup-plugin-svelte/issues/133 / https://github.com/sveltejs/svelte/issues/5810 / maybe others, and is not a bug. This is how parsing inline script tags works in HTML.

kristopherbullinger commented 3 years ago

Apologies for posting a dupe -- thanks for the quick response!