importers don't work with api: 'modern'
KaelWD opened this issue · comments
Bug report
proxyCustomImporters
is only valid for legacy importers as it always returns a function, modern importers need to be an object with methods.
Actual Behavior
Module build failed (from ../node_modules/sass-loader/dist/cjs.js):
SassError: SassError: An importer must have either canonicalize and load methods, or a findFileUrl method.
Expected Behavior
"It should work" is not a helpful explanation
It should tho
How Do We Reproduce?
sassOptions: {
importers: [{
async canonicalize (url) {
return new URL(url)
},
load (url) {
console.log(url)
}
}]
},
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 2.59 GB / 31.29 GB
Binaries:
Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
Browsers:
Chrome: 98.0.4758.102
Firefox: 97.0
Yes, we should remove https://github.com/webpack-contrib/sass-loader/blob/master/src/utils.js#L230, we can't proxy new importer API
Fix here #1052, I tried to implement basic async loader for tests and example, but no luck, looks like new API is broken and tried to use examples, but no luck too, even more no one tool migrate on new API, so I strongly recommend do not use it today
Yeah I've tried to use it without webpack but seems pretty useless because it still looks for the file on disk before calling load, so you can't use it to intercept existing sass files.
Yep, I tried to use it in tests to just load content, importer call my load
, but never finished 😕 Unfortunately, I've already wasted enough time on digging in sass code and you can found a lot of issues and threads here around bugs/unexpected/useless behaviours for importers, I tried to contact with sass team, but every time it was very slow, with long discussions without solutions, I just don’t want to waste time on pretty obvious things again (and hope developers reports these things in sass repo directly), I hope I didn’t offend anyone with my statement, I just share my feelings