webpack-contrib / sass-loader

Compiles Sass to CSS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

curlykay opened this issue · comments

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"));

Since it gave the right result in the SCSS playground, I don't think it's a bug in sass.
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

Please open an issue in dart-sass repo, it is a bug, we can't fix it here, thank you

Thank you for your response and hint.