SimonAlling / userscripter

Create userscripts in a breeze!
https://www.npmjs.com/package/userscripter
MIT License
100 stars 10 forks source link

Webpack config can lead to CSP errors #30

Closed jackmac92 closed 3 years ago

jackmac92 commented 3 years ago

I was running into CSP errors on github, realized there were some eval statements in the bundled code. For some reason setting devtool: 'inline-source-map' fixes that. https://github.com/webpack/webpack/issues/4899#issuecomment-609724897

I'll send a PR if you'd like

SimonAlling commented 3 years ago

Thanks for reporting this issue (which I just noticed)! Do you encounter this problem even with USERSCRIPTER_MODE set to production. Example command:

USERSCRIPTER_MODE=production npm run build
jackmac92 commented 3 years ago

@SimonAlling sorry I missed this earlier, setting that env var does fix the problem!

Would it make sense to default to production mode?

SimonAlling commented 3 years ago

@jackmac92: I don't know, but I do know that this has to be fixed somehow; I can easily imagine just how frustrating it would be to have to deal with eval CSP errors when one just wanted to build a userscript. Definitely not acceptable.

SimonAlling commented 3 years ago

Could you perhaps share a sample userscript that I can use to verify that I have found a fix?

EDIT: I created one myself; I believe it suffices!

jackmac92 commented 3 years ago

@SimonAlling awesome! Happy to test it out if that would help verify

SimonAlling commented 3 years ago

I have proposed a fix in #35. Please let me know if it solves the problem, @jackmac92.

SimonAlling commented 3 years ago

I'm going to merge the fix and consider this resolved. Please reopen otherwise. :slightly_smiling_face: