Skip to content

Commit

Permalink
'@use .. with' Configs get unique IDs propagated down with @forwards
Browse files Browse the repository at this point in the history
When loading a module multiple times, like when several sources end up
using the modules, it used to be an error but now it's allowed as long
as the configuration is the same according to its ID
  • Loading branch information
Goodwine committed Jul 26, 2022
1 parent 72909c9 commit 6c12f71
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
9 changes: 5 additions & 4 deletions spec/at-rules/forward.md
Expand Up @@ -48,9 +48,10 @@ To execute a `@forward` rule `rule`:

* If `rule` has an `AsClause` with identifier `prefix`:

* Let `rule-config` be an empty [configuration][].
* Let `rule-config` be an empty [configuration] inheriting the opaque ID
from [the current configuration].

* For each variable `variable` in [the current configuration][]:
* For each variable `variable` in the current configuration:

* If `variable`'s name begins with `prefix`:

Expand All @@ -66,7 +67,7 @@ To execute a `@forward` rule `rule`:

* If `rule` has a `WithClause`:

* Set `rule-config` to a copy of itself.
* Set `rule-config` to a copy of itself including its opaque ID.

* For each `ForwardWithArgument` `argument` in this clause:

Expand Down Expand Up @@ -96,7 +97,7 @@ To execute a `@forward` rule `rule`:
* For every member `member` in `forwarded`:

* Let `name` be `member`'s name.

* If `rule` has an `AsClause` `as`, prepend `as`'s identifier to `name` (after
the `$` if `member` is a variable).

Expand Down
18 changes: 12 additions & 6 deletions spec/modules.md
Expand Up @@ -38,7 +38,7 @@ Two members are considered identical if they have the same name, type, source
location, and were defined in or forwarded from the same original module.

> Each member type has its own namespace in Sass, so for example the mixin
> `name` doesn't conflict with the function `name` or the variable `$name`.
> `name` doesn't conflict with the function `name` or the variable `$name`.
### CSS Tree

Expand All @@ -52,21 +52,21 @@ An *empty CSS tree* contains no statements.
### Configuration

A *configuration* is a map from [variable](variables.md) names to SassScript
values. An *empty configuration* contains no entries.
values and an opaque ID. An *empty configuration* contains no entries.

[source file]: syntax.md#source-file
A new *configuration* ID is unique unless otherwise specified.

### Module

A *module* is a collection of various properties:

* A set of [members](#member) that contains at most one member of any given type
and name.

> For example, a module may not have two variables named `$name`, although it
> may contain a function and a mixin with the same name or two functions with
> different names.
> The names (and mixin and function signatures) of a module's members are
> static, and can be determined without executing its associated source file.
> This means that any possible module for a given source file has the same
Expand Down Expand Up @@ -99,6 +99,8 @@ A *module* is a collection of various properties:
> Note that [built-in modules](#built-in-module) *do not* have source files
> associated with them.
[source file]: syntax.md#source-file

* An absolute URL, known as the module's *canonical URL*. If the module has a
source file, this must be the same as the source file's canonical URL.

Expand Down Expand Up @@ -262,7 +264,11 @@ This algorithm takes a string `argument` and [configuration](#configuration)

[executed]: spec.md#executing-a-file

* If `config` is not empty, throw an error.
* If `config` has a different ID than before and is not empty, throw an error.

> An ID may be reused in a new configuration via [`@forwards .. with`].
[`@forwards .. with`]: ../spec/at-rules/forward.md#semantics

* Otherwise, return the module that execution produced.

Expand Down

0 comments on commit 6c12f71

Please sign in to comment.