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

Unable to use meta.get-mixin to pass mixin as a value to another mixin, then use it in its content. #2154

Closed
curlykay opened this issue Dec 29, 2023 · 3 comments

Comments

@curlykay
Copy link

Bug report

I get a compilation error when I use the following SCSS code snippet in the project.

@use "sass:meta";

@mixin theme-style($mixin) {
  :root {
    @include meta.apply($mixin);
  }
}

@mixin light() {
    --text-color: #000;
}

@include theme-style(meta.get-mixin("light"));

In fact, this SCSS snippet runs correctly on the SCSS playground. After the issue, @alexander-akait asked me to come here for help. webpack-contrib/sass-loader#1174 (comment)

https://sass-lang.com/playground/#eJxNjcEKwyAQRO9+xWJ70IPFXPXir0i6JILGEDeQEPLvbZem9DYMb950XVgbgmyxNVeQovRChJK2NAGNWNA02jOqO1caDgHgllqJE0BIU5/XJ8Jn+4jznPeL9W/gFOdPl9MwktLfoTGEG5m+5ro4uFlrPbOX7/+c3QOSYZGSbJJa+xdXFTwC

image

PS: This is the smallest complete SCSS snippet I have simplified for verification purposes. If you need the SCSS code from my project, please let me know.

Actual Behavior

print error:

Bad state: Can't access __parent outside of a module.
image

Expected Behavior

Generating CSS Output Correctly:

:root {
  --text-color: #000;
}

How Do We Reproduce?

You can reproduce it just by importing this SCSS snippet into any Webpack project that uses sass-loader.

Please paste the results of npx webpack-cli info here, and mention other relevant information

System:
OS: macOS 13.4.1
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Memory: 12.07 MB / 8.00 GB
Binaries:
Node: 18.18.2 - ~/Library/pnpm/node
Yarn: 1.22.17 - /usr/local/bin/yarn
npm: 8.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 120.0.6099.129
Edge: 120.0.2210.91
Safari: 16.5.1
Packages:
sass: ^1.69.5 => 1.69.5
css-loader: ^6.8.1 => 6.8.1
sass-loader: ^13.3.3 => 13.3.3
style-loader: ^3.3.3 => 3.3.3
webpack: ^5.89.0 => 5.89.0
webpack-cli: ^5.1.4 => 5.1.4

@ntkme
Copy link
Contributor

ntkme commented Dec 29, 2023

This should have been fixed in 1.69.6 released just an hour ago.

@curlykay
Copy link
Author

Incredible efficiency, thank you for your efforts.

@curlykay curlykay closed this as completed Jan 2, 2024
@nex3
Copy link
Contributor

nex3 commented Jan 2, 2024

Thanks to you for the thorough and reproducible bug report!

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

No branches or pull requests

3 participants