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

Dart Sass v1.80.1 deprecation warning #12961

Open
jmooring opened this issue Oct 17, 2024 · 4 comments · May be fixed by #12966
Open

Dart Sass v1.80.1 deprecation warning #12961

jmooring opened this issue Oct 17, 2024 · 4 comments · May be fixed by #12966
Assignees
Labels
Milestone

Comments

@jmooring
Copy link
Member

jmooring commented Oct 17, 2024

Testing Dart Sass v1.80.1

WARN Dart Sass: hugo:vars:0:17: Global built-in functions are deprecated and will be removed in Dart Sass 3.0.0.
Use string.unquote instead.

Why we're getting this is unclear at the moment.

@bep
Copy link
Member

bep commented Oct 17, 2024

@jmooring
Copy link
Member Author

jmooring commented Oct 17, 2024

This test fails with Dart Sass v1.80.1.

// Issue #12961
func TestDartSassVars(t *testing.T) {
	t.Parallel()

	files := `
-- hugo.toml --
disableKinds = ['page','section','rss','sitemap','taxonomy','term']
-- layouts/index.html --
{{ $opts := dict "transpiler" "dartsass" "outputStyle" "compressed" "vars" (dict "color" "red") }}
{{ with resources.Get "main.scss" | css.Sass $opts }}
  {{ .Content }}
{{ end }}
-- assets/main.scss --
@use "hugo:vars" as v;
body {color: v.$color;}
`

	b := hugolib.Test(t, files, hugolib.TestOptWarn())

	b.AssertFileContent("public/index.html", "body{color:red}")
	b.AssertLogContains("! WARN  Dart Sass: hugo:vars") // failing assertion
}

The warning message generated by the above is:

WARN Dart Sass: hugo:vars:0:8: Global built-in functions are deprecated and will be removed in Dart Sass 3.0.0.\nUse string.unquote instead.

https://sass-lang.com/blog/import-is-deprecated/#built-in-functions

@jmooring
Copy link
Member Author

varsSlice = append(varsSlice, fmt.Sprintf("%s%s: unquote(%q);", prefix, k, v))
}
}
}
sort.Strings(varsSlice)
varsStylesheet = strings.Join(varsSlice, "\n")
return varsStylesheet

This solves the problem when using the Dart Sass transpiler:

				varsSlice = append(varsSlice, fmt.Sprintf("%s%s: string.unquote(%q);", prefix, k, v))
			}
		}
	}
	sort.Strings(varsSlice)
	varsStylesheet = `@use "sass:string";` + "\n" + strings.Join(varsSlice, "\n")
	return varsStylesheet
}

But the containing function (CreateVarsStyleSheet) is called when using either transpiler, so the changes above need to be specific to dart sass, but I haven't found a way to get the transpiler value ("libsass" or "dartsass") within that function.

@bep
Copy link
Member

bep commented Oct 17, 2024

But the containing function (CreateVarsStyleSheet)

I guess adding some kind of identifier as the first arg to CreateVarsStyleSheet would solve it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants