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

Q&A: How can i fix waring import sass from 'sass'` is deprecated #2161

Closed
yoyo837 opened this issue Jan 18, 2024 · 4 comments
Closed

Q&A: How can i fix waring import sass from 'sass'` is deprecated #2161

yoyo837 opened this issue Jan 18, 2024 · 4 comments

Comments

@yoyo837
Copy link

yoyo837 commented Jan 18, 2024

When I import sass with code: await import('sass'), it report this:

import sass from 'sass'` is deprecated.
Please use `import * as sass from 'sass'` instead.

How can i fix this waring?

@nex3
Copy link
Contributor

nex3 commented Jan 18, 2024

Can you provide a full reproduction of this? I don't see a warning with the following code with Sass 1.70.0:

async function main() {
  const sass = await import('sass');
  console.log(sass.compileString('a {b: c}'));
}

main();

@yoyo837
Copy link
Author

yoyo837 commented Jan 19, 2024

My code looks like this, So is it wrong?

-- console.log(sass.compileString('a {b: c}'));
++ console.log(sass.default.compileString('a {b: c}'));

@yoyo837
Copy link
Author

yoyo837 commented Jan 19, 2024

It seems I need to treat sass and less differently.

When I load less using the dynamic import method, I need to call the .default, but sass doesn't.
Yeah, I'm writing a postcss plugin.

@nex3
Copy link
Contributor

nex3 commented Jan 19, 2024

Yes, you need to avoid using .default..

@nex3 nex3 closed this as completed Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants