Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importers don't work with api: 'modern' #1031

Closed
KaelWD opened this issue Feb 28, 2022 · 4 comments · Fixed by #1052
Closed

importers don't work with api: 'modern' #1031

KaelWD opened this issue Feb 28, 2022 · 4 comments · Fixed by #1052

Comments

@KaelWD
Copy link

KaelWD commented Feb 28, 2022

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
@alexander-akait
Copy link
Member

Yes, we should remove https://github.com/webpack-contrib/sass-loader/blob/master/src/utils.js#L230, we can't proxy new importer API

@alexander-akait
Copy link
Member

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

@KaelWD
Copy link
Author

KaelWD commented May 18, 2022

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.

@alexander-akait
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants