Skip to content

Fix a bug where a double-configuration error wouldn't be emitted #2600

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nex3
Copy link
Contributor

@nex3 nex3 commented Jul 3, 2025

@nex3 nex3 requested a review from jathak July 3, 2025 00:01
@arikorn
Copy link

arikorn commented Jul 3, 2025

I am concerned that this PR would break existing codebases (see @nex3's justification for this PR in #2598). It is possible that my PR #2602 would mitigate these effects.

@nex3 nex3 force-pushed the module-configuration-url branch from 0cf97b8 to 1b3c2f9 Compare July 23, 2025 01:11
@arikorn
Copy link

arikorn commented Jul 29, 2025

Thank you for the update @nex3: this is great! It appears to resolve the examples we've discussed and to accomplish what I intended in PR #2602.

There is a minor issue if the variable is in an @use file instead of @forward . For example:

// App.scss (top-level Sass file)

@use 'scss/coreui2' with (
     $white: #aaa
) ;
// scss/coreui2.scss
@use "variables";
@forward "functions";

with the remaining files are as described in Issue #2598, and in https://github.com/arikorn/sass-bug-demo

The result is:

Error: This variable was not declared with !default in the @used module.
  ╷
9 │       $white: #aaa
  │       ^^^^^^^^^^^^
  ╵
  ..\dart-tests\App2.scss 9:7  root stylesheet

The error message is wrong ($white is declared with !default and it's in _variables.css) and could be probably be avoided if @use was treated similarly to @forward, i.e. don't cause an error if there are no remaining config variables.

Just to be clear: the only change here from the previous examples is that coreui2.scss loads variables.scss with @use instead of @forward

Note, though, that this is not a breaking change, since the same input causes an error when using the main branch as well.

I have other specific comments that I'll attach to the code review, but nothing bigger than this.

@arikorn
Copy link

arikorn commented Jul 29, 2025

Oh drat! It also fails the test you mention here, which can be rephrased as:

 // App.scss (top-level Sass file)

@use 'scss/coreui2' as _;
@use 'scss/coreui2' with (
     $white: #aaa
) ;

(Giving a "variable not declared with !default" error instead of "module was already loaded" error.)

Perhaps the answer is that this is a work-in-progress, and those unused functions will fix it?

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 this pull request may close these issues.

[Bug] This module was already loaded false positive
3 participants