Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"comment": "Fix `ignoreDeprecationsInDependencies` option being silently ignored; it is now correctly forwarded to the Sass compiler's `quietDeps` flag.",
"type": "patch",
"packageName": "@rushstack/heft-sass-plugin"
}
],
"packageName": "@rushstack/heft-sass-plugin",
"email": "copilot@users.noreply.github.com"
}
3 changes: 3 additions & 0 deletions heft-plugins/heft-sass-plugin/src/SassPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface ISassConfigurationJson {
exportAsDefault?: boolean;
fileExtensions?: string[];
nonModuleFileExtensions?: string[];
ignoreDeprecationsInDependencies?: boolean;
silenceDeprecations?: string[];
excludeFiles?: string[];
doNotTrimOriginalFileExtension?: boolean;
Expand Down Expand Up @@ -98,6 +99,7 @@ export default class SassPlugin implements IHeftPlugin {
exportAsDefault = true,
fileExtensions,
nonModuleFileExtensions,
ignoreDeprecationsInDependencies,
silenceDeprecations,
excludeFiles,
doNotTrimOriginalFileExtension,
Expand Down Expand Up @@ -129,6 +131,7 @@ export default class SassPlugin implements IHeftPlugin {
};
}),
silenceDeprecations,
ignoreDeprecationsInDependencies,
doNotTrimOriginalFileExtension,
preserveIcssExports,
sourceMap,
Expand Down
13 changes: 12 additions & 1 deletion heft-plugins/heft-sass-plugin/src/SassProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class SassProcessor {
private _configFilePath: string | undefined;

public constructor(options: ISassProcessorOptions) {
const { silenceDeprecations, excludeFiles } = options;
const { silenceDeprecations, excludeFiles, ignoreDeprecationsInDependencies } = options;

const { isFileModule, allFileExtensions } = buildExtensionClassifier(options);

Expand Down Expand Up @@ -261,6 +261,7 @@ export class SassProcessor {
this._resolutions = new Map();
this._options = options;
this._realpathSync = new RealNodeModulePathResolver().realNodeModulePath;
const { terminal } = options.logger;
this._scssOptions = {
style: 'expanded', // leave minification to clean-css
importers: [
Expand All @@ -270,7 +271,17 @@ export class SassProcessor {
load: loadAsync
}
],
logger: {
warn: (message, { deprecation }) => {
if (deprecation) {
terminal.writeWarningLine(`Deprecation Warning: ${message}`);
} else {
terminal.writeWarningLine(`Warning: ${message}`);
}
}
},
silenceDeprecations: deprecationsToSilence,
quietDeps: ignoreDeprecationsInDependencies,
...(options.sourceMap && { sourceMap: true, sourceMapIncludeSources: true })
};
}
Expand Down
19 changes: 19 additions & 0 deletions heft-plugins/heft-sass-plugin/src/test/SassProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type ICreateProcessorOptions = Partial<
| 'dtsOutputFolders'
| 'exportAsDefault'
| 'fileExtensions'
| 'ignoreDeprecationsInDependencies'
| 'nonModuleFileExtensions'
| 'postProcessCssAsync'
| 'preserveIcssExports'
Expand Down Expand Up @@ -596,6 +597,24 @@ describe(SassProcessor.name, () => {
});
});

describe('ignoreDeprecationsInDependencies option', () => {
it('emits deprecation warnings from a dependency partial by default', async () => {
const { processor, logger } = createProcessor(terminalProvider);
await compileFixtureAsync(processor, 'use-partial-with-color-deprecation.module.scss');
expect(logger.errors).toHaveLength(0);
expect(terminalProvider.getWarningOutput()).toContain('Deprecation Warning:');
});

it('suppresses deprecation warnings from a dependency partial when ignoreDeprecationsInDependencies is true', async () => {
const { processor, logger } = createProcessor(terminalProvider, {
ignoreDeprecationsInDependencies: true
});
await compileFixtureAsync(processor, 'use-partial-with-color-deprecation.module.scss');
expect(logger.errors).toHaveLength(0);
expect(terminalProvider.getWarningOutput()).not.toContain('Deprecation Warning:');
});
});

describe('non-module (global) files', () => {
it('emits plain compiled CSS for a .global.scss file', async () => {
const { processor } = createProcessor(terminalProvider, {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This partial intentionally uses darken(), a deprecated Sass global color function.
// It exists only to test the ignoreDeprecationsInDependencies option.
.dep-style {
color: darken(#0078d4, 10%);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This file @use's a partial that contains a deprecated Sass function.
// It exists only to test the ignoreDeprecationsInDependencies option.
@use 'partial-with-color-deprecation';

.container {
color: red;
}