apostrophecms / sanitize-html

Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance
MIT License
3.68k stars 349 forks source link

Update sanitize-html from 2.1.0 to 2.12.1 fails. Module parse failed: Unexpected token. #663

Open ricdev opened 2 months ago

ricdev commented 2 months ago

To Reproduce

Step by step instructions to reproduce the behavior:

  1. npm install
  2. npm run build

Expected behavior

Clean build.

Describe the bug

Screen Shot 2024-04-17 at 1 16 33 PM

Details

Version of Node.js:

16.18.1

Server Operating System:

MacOs Monterey 12.5.1. Github Actions script.

Additional context:

Relates to https://github.com/apostrophecms/sanitize-html/issues/592#issuecomment-1374020808 and https://github.com/apostrophecms/sanitize-html/issues/592

BoDonkey commented 2 months ago

Two comments: 1) Node16 is past the EOL - you should upgrade to 18 or 20. This might solve your problem. 2) I'm not sure what the build script is. It isn't part of the core repo. I thought we had done something to pin the version of htmlparser2, but I can't find it in the changelog. My latest version is installing 8.0.1.

BoDonkey commented 2 months ago

Can you provide better steps to replicate the error? Again, there isn't a build script.

Insomniak313 commented 2 months ago

As state here the issue (I'm having the same one) is your webpack version. You should update to v5. However, im not really satisfied with the author's answer and I'm wondering whether htmlparser2 should have a devDependency on webpack ^5

BoDonkey commented 2 months ago

Thanks @Insomniak313! - I thought it was something with the version of htmlparser2.