Skip to content

Commit

Permalink
fix: ignore sass deprecation warning
Browse files Browse the repository at this point in the history
Quick fix for now, in the mid term we should add proper support for the new API

fixes #656
  • Loading branch information
dummdidumm committed Sep 26, 2024
1 parent 9d49f3d commit 3bd5116
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 50 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"postcss-load-config": "^3.1.4",
"prettier": "^3.3.2",
"pug": "^3.0.2",
"sass": "^1.56.2",
"sass": "^1.79.3",
"stylus": "^0.55.0",
"sugarss": "^4.0.0",
"svelte": "^4.0.0",
Expand Down
74 changes: 26 additions & 48 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion src/transformers/scss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,24 @@ const tildeImporter: LegacySyncImporter = (url, prev) => {
return { contents };
};

const infoRegex = /dart-sass\s(\d+)\.(\d+)\.(\d+)/;

const transformer: Transformer<Options.Sass> = async ({
content,
filename,
options = {},
}) => {
const { renderSync } = await import('sass');
const { renderSync, info } = await import('sass');

const { prependData, ...restOptions } = options;
const match = info.match(infoRegex) ?? [0, 0, 0, 0];
const [_, major, minor] = match.map(Number);

Check warning on line 47 in src/transformers/scss.ts

View workflow job for this annotation

GitHub Actions / Lint

'_' is assigned a value but never used

Check warning on line 47 in src/transformers/scss.ts

View workflow job for this annotation

GitHub Actions / Lint

'_' is assigned a value but never used
const sassOptions: LegacyStringOptions<'sync'> = {
...restOptions,
silenceDeprecations:
major >= 1 && minor >= 79
? ['legacy-js-api', ...(restOptions.silenceDeprecations || [])]
: undefined,
includePaths: getIncludePaths(filename, options.includePaths),
sourceMap: true,
sourceMapEmbed: false,
Expand Down

0 comments on commit 3bd5116

Please sign in to comment.