Skip to content

Commit

Permalink
fix: legacy import result should include null
Browse files Browse the repository at this point in the history
  • Loading branch information
joneff committed Dec 7, 2022
1 parent 2582f21 commit f0b1446
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/importers/cache-importer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';

const EMPTY_IMPORT = {};
const EMPTY_IMPORT_RESULT = <LegacyImporterResult> {};

export function sassCacheImporter( options: CacheImporterOptions = { cache: true } ) : SassImporter {

Expand All @@ -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') {
Expand All @@ -26,7 +26,7 @@ export function sassCacheImporter( options: CacheImporterOptions = { cache: true
if ( fs.existsSync( file ) ) {

if ( cache && imported.has( file ) ) {
return <LegacyImporterResult> EMPTY_IMPORT;
return EMPTY_IMPORT_RESULT;
}

imported.add( file );
Expand Down
2 changes: 1 addition & 1 deletion src/importers/package-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions types/sass/sass-importer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit f0b1446

Please sign in to comment.