icelam / html-inline-script-webpack-plugin

A webpack plugin for converting external script files to inline script block. Requires 'html-webpack-plugin' to work.
https://www.npmjs.com/package/html-inline-script-webpack-plugin
MIT License
55 stars 10 forks source link

Comments or strings containing </script> are not escaping the “<” #387

Closed gblakeman closed 2 years ago

gblakeman commented 2 years ago

Environment and package version

Webpack @ 5.73.0, HTML Webpack Plugin @ 5.5.0, HTML Inline Script Plugin @ 3.0.1

Reproduction link / code sample

A comment to test with:

/**
 * Typing this makes it possible for IDEs like VS Code with the Svelte extension
 * to provide intellisense and to use the component like this in a Svelte file
 * with TypeScript:
 * ```svelte
 * <script lang="ts">
 *  import { MyComponent } from "component-library";
 * </script>
 * <MyComponent foo={'bar'} />
 * ```
 */

Steps to reproduce

I am unsure if this is a HTML Webpack Plugin issue or a HTML Inline Script Plugin issue, but I did not have the issue using HTML Webpack Plugin 4.x and a different inlining plugin (HTML Inline Source Plugin).

What is expected?

Comments or strings that contain </script> will have the < escaped to \x3C.

What is actually happening?

Comments or strings that contain </script> are not escaped and appear inline as </script> causing a parse error in browsers.

gblakeman commented 2 years ago

It does look like the previous plugin I was using with Webpack 4.x was handling this scenario for me. Maybe something to add to this one?

icelam commented 2 years ago

@gblakeman Agree this should be supported by this plugin. I will try to work on the feature and make a release within this week.

gblakeman commented 2 years ago

@icelam That would be amazing. Thanks!

icelam commented 2 years ago

@gblakeman This feature has just been released in version 3.1.0. Let me know if it works.

gblakeman commented 2 years ago

@icelam Apologies for the delay. 3.1.0 works! Really appreciate the help. I’ll close the issue.