From f0b1446cb1e9c6cb09b0706437ffd09c992831df Mon Sep 17 00:00:00 2001 From: joneff Date: Wed, 7 Dec 2022 11:31:24 +0200 Subject: [PATCH] fix: legacy import result should include null --- src/importers/cache-importer.ts | 6 +++--- src/importers/package-importer.ts | 2 +- types/sass/sass-importer.d.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/importers/cache-importer.ts b/src/importers/cache-importer.ts index d55808f..e2126e5 100644 --- a/src/importers/cache-importer.ts +++ b/src/importers/cache-importer.ts @@ -1,7 +1,7 @@ import fs from 'fs'; import path from 'path'; -const EMPTY_IMPORT = {}; +const EMPTY_IMPORT_RESULT = {}; export function sassCacheImporter( options: CacheImporterOptions = { cache: true } ) : SassImporter { @@ -10,7 +10,7 @@ export function sassCacheImporter( options: CacheImporterOptions = { cache: true ? cache : new Set(); - function sassCacheImporter( url: string, prev: string ) : null | LegacyImporterResult { + function sassCacheImporter( url: string, prev: string ) : LegacyImporterResult { // If previous file is stdin, then we are importing from a string if (prev === 'stdin') { @@ -26,7 +26,7 @@ export function sassCacheImporter( options: CacheImporterOptions = { cache: true if ( fs.existsSync( file ) ) { if ( cache && imported.has( file ) ) { - return EMPTY_IMPORT; + return EMPTY_IMPORT_RESULT; } imported.add( file ); diff --git a/src/importers/package-importer.ts b/src/importers/package-importer.ts index c4a5cc0..8de41c7 100644 --- a/src/importers/package-importer.ts +++ b/src/importers/package-importer.ts @@ -14,7 +14,7 @@ export function sassPackageImporter( options?: PackageImporterOptions ) : SassIm nodeModules = nodeModules(); } - function sassPackageImporter( url: string ) : null | LegacyImporterResult { + function sassPackageImporter( url: string ) : LegacyImporterResult { if ( !url.startsWith('~') ) { return null; diff --git a/types/sass/sass-importer.d.ts b/types/sass/sass-importer.d.ts index f892fab..b5e75d3 100644 --- a/types/sass/sass-importer.d.ts +++ b/types/sass/sass-importer.d.ts @@ -4,10 +4,10 @@ declare type ModernImporterResult = { syntax?: 'css' | 'scss' | 'indented'; }; -declare type LegacyImporterResult = { file: string } | { contents: string }; +declare type LegacyImporterResult = { file: string } | { contents: string } | null; declare type SassImporter = { - (url: string) : null | LegacyImporterResult; + (url: string) : LegacyImporterResult; name?: string; findFileUrl( url: string ) : null | URL; canonicalize?( url: string ) : null | URL;