twolfson / css-validator

Validate CSS via W3C's service
The Unlicense
41 stars 8 forks source link

error "Module not found: Error: Can't resolve 'fs'" when used with webpack #9

Closed jcdufourd closed 7 years ago

jcdufourd commented 7 years ago

I try to use css-validator with webpack and when building, I get: Module not found: Error: Can't resolve 'fs' in both form-data and mime modules.

Complete error log is: ERROR in ./~/form-data/lib/form_data.js Module not found: Error: Can't resolve 'fs' in '/Users/dufourd/IdeaProjects/MPAT-core/web/app/plugins/mpat-explorer/node_modules/form-data/lib' @ ./~/form-data/lib/form_data.js 8:9-22 @ ./~/css-validator/lib/validation-stream.js @ ./~/css-validator/lib/css-validator.js @ ./js/main.js @ multi ./js/main.js ./js/cloneLayout.js

ERROR in ./~/mime/mime.js Module not found: Error: Can't resolve 'fs' in '/Users/dufourd/IdeaProjects/MPAT-core/web/app/plugins/mpat-explorer/node_modules/mime' @ ./~/mime/mime.js 4:9-22 @ ./~/form-data/lib/form_data.js @ ./~/css-validator/lib/validation-stream.js @ ./~/css-validator/lib/css-validator.js @ ./js/main.js @ multi ./js/main.js ./js/cloneLayout.js

The css-validator CLI works. Ideas ? Thanks

jcdufourd commented 7 years ago

obviously, this module was done for node.js and not for use in a page, so webpack cannot work... If it did, the problem would be CORS...

dwjohnston commented 3 years ago

@jcdufourd Does wc3 prevent x-origin? I can't see why they would.

twolfson commented 3 years ago

The issue is not preventing CORS but allowing it. By default, the security model prevents site A from accessing site B content (e.g. Google can't request your Facebook profile).

To counteract that, sites can explicitly allow this via a response header (i.e. Access-Control-Allow-Origin)

https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#the_http_response_headers

That being said, it looks like W3C does respond with a CORS header now (tested with "direct input" method) (as opposed to 2017, when this issue was opened)

Glad to reopen this issue under the title "Add browser support" (preferably a new issue though) or accept a PR for it

Selection_249

jcdufourd commented 3 years ago

Sorry, I am not working on that project any more.