You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Webpack workaround no longer working from 1.4.6 #1071
The workaround for Webpack warnings described in the REAMDE.md no longer seems to be working for projects using html-react-parser version 1.4.6 and later.
(described in #213 )
@remarkablemark not really, I'm not very familiar with ES exports etc.
I'll try to take a look at it in the next couple of days, bit I'm a bit busy so might take a while.
Since nobody reported this earlier I don't think a lot of people encounter this issue so might not have the highest priority.
I encountered a Probably similar issue:
"Cannot read properties of undefined (reading 'default')"
I had to downgrade from version 4.2.5 to 4.2.1 (npm) for it to work again
@MaxTwentythree That's probably an unrelated other issue. My original problem also occurs on 4.2.1 with the same error I described earlier. It's not the same error you're encountering.
Hi @remarkablemark, the issue is definitely related the exports config introduced in #434
When removing the exports config from package.json the warnings dissapear even in 5.0.11 (which has a more advanced exports config).
I'm not very familiar with webpack and module exports etc. so it's a bit hard for me to understand what is really going on here.
I think this is somewhat related, because we do use moduleResolution: node.
@robmaas Thanks for the update. Unfortunately, I can't remove exports from package.json since it will break ESM support. I wonder if there's something that can be done on Webpack side.
@remarkablemark Finally got it.
I was able to reproduce the issue in a small project by gradually adding configuration.
Turns out we have some webpack loader configuration with patterns that incorrectly match for *.mjs files.
For example:
{// anything in node_modules that isn't js,// we load as null - e.g. imported css from a module,// that is not needed for SSRtest: /\.(?!js|html$)[^.]+$/,include: /node_modules/,use: {loader: 'null-loader'}}
This pattern allows *.js, *.jsx etc. but not *.mjs.
Obviously that strips the files completely, so errors start appearing.
Before #434 our solution used the exported index.js file, which was fine.
Bit of a stupid issue after all, but even in our complex solution never ran into this before.
Updating the regex to include *.mjs/*.cjs files seems to fix our issue.
Feel free to close this one. You can consider creating a FAQ for this, but it is not at all related to your package (apart from *.mjs files not being used that much out there).
Amazing @robmaas, thanks for the reproduction! If you'd like, feel free to open a PR to improve the README.md. Otherwise, I can close this issue and convert it to a discussion.
Repository owner locked and limited conversation to collaborators on Jan 10, 2024
Activity
remarkablemark commentedon Oct 6, 2023
Thanks for opening this issue @robmaas! Do you have a suggestion on what the fix would be?
robmaas commentedon Oct 6, 2023
@remarkablemark not really, I'm not very familiar with ES exports etc.
I'll try to take a look at it in the next couple of days, bit I'm a bit busy so might take a while.
Since nobody reported this earlier I don't think a lot of people encounter this issue so might not have the highest priority.
remarkablemark commentedon Oct 6, 2023
@robmaas Thanks for the update! I'll also try to see if I can reproduce this locally in my spare time.
MaxTwentythree commentedon Oct 18, 2023
I encountered a Probably similar issue:
"Cannot read properties of undefined (reading 'default')"
I had to downgrade from version 4.2.5 to 4.2.1 (npm) for it to work again
robmaas commentedon Oct 18, 2023
@MaxTwentythree That's probably an unrelated other issue. My original problem also occurs on
4.2.1with the same error I described earlier. It's not the same error you're encountering.robmaas commentedon Dec 1, 2023
@MaxTwentythree Sorry for the delayed response, been very busy lately.
Will try to take a look at it soon, or ask one of my colleague's to do so.
remarkablemark commentedon Dec 1, 2023
All good @robmaas, thanks for the update
MaxTwentythree commentedon Dec 21, 2023
@robmaas: same :)
Should I open a new issue with the problem I'm encountering?
remarkablemark commentedon Dec 21, 2023
@MaxTwentythree can you provide a reproducible example?
robmaas commentedon Dec 28, 2023
Hi @remarkablemark, the issue is definitely related the
exportsconfig introduced in #434When removing the
exportsconfig frompackage.jsonthe warnings dissapear even in 5.0.11 (which has a more advanced exports config).I'm not very familiar with webpack and module exports etc. so it's a bit hard for me to understand what is really going on here.
I think this is somewhat related, because we do use
moduleResolution: node.remarkablemark commentedon Dec 28, 2023
@robmaas Thanks for the update. Unfortunately, I can't remove
exportsfrompackage.jsonsince it will break ESM support. I wonder if there's something that can be done on Webpack side.robmaas commentedon Jan 5, 2024
@remarkablemark Obviously, just reporting that it is related.
Been struggling a bit to isolate the issue to a reproducible project, but will try again sometime soon (not really a big priority at the moment).
robmaas commentedon Jan 5, 2024
@remarkablemark Finally got it.
I was able to reproduce the issue in a small project by gradually adding configuration.
Turns out we have some webpack loader configuration with patterns that incorrectly match for
*.mjsfiles.For example:
This pattern allows
*.js,*.jsxetc. but not*.mjs.Obviously that strips the files completely, so errors start appearing.
Before #434 our solution used the exported
index.jsfile, which was fine.Bit of a stupid issue after all, but even in our complex solution never ran into this before.
Updating the regex to include
*.mjs/*.cjsfiles seems to fix our issue.Feel free to close this one. You can consider creating a FAQ for this, but it is not at all related to your package (apart from
*.mjsfiles not being used that much out there).Repro
Filename:
package.json{ "name": "html-react-parser-repo-1071", "private": true, "version": "1.0.0", "type": "module", "dependencies": { "html-react-parser": "1.4.6", "null-loader": "4.0.1", "webpack": "5.76.1", "webpack-cli": "5.0.1" }, "scripts": { "build": "webpack --config webpack.config.cjs", "start": "cd src && node index" } }Filename:
webpack.config.cjsFilename:
src/index.jsOutput
remarkablemark commentedon Jan 5, 2024
Amazing @robmaas, thanks for the reproduction! If you'd like, feel free to open a PR to improve the README.md. Otherwise, I can close this issue and convert it to a discussion.