diff --git a/lib/src/importer-registry.ts b/lib/src/importer-registry.ts index 4e876aa4..e773b287 100644 --- a/lib/src/importer-registry.ts +++ b/lib/src/importer-registry.ts @@ -12,7 +12,6 @@ import {legacyImporterProtocol} from './legacy/utils'; import {FileImporter, Importer, Options} from './vendor/sass'; import * as proto from './vendor/embedded_sass_pb'; import {catchOr, thenOr, PromiseOr} from './utils'; -import path = require('path'); export class NodePackageImporter { entryPointPath?: string; @@ -58,14 +57,10 @@ export class ImporterRegistry { const message = new proto.InboundMessage_CompileRequest_Importer(); if (importer instanceof NodePackageImporter) { const importerMessage = new proto.NodePackageImporter(); - let entryPointPath = importer.entryPointPath - ? path.resolve(process.cwd(), importer.entryPointPath) + const entryPointPath = importer.entryPointPath + ? p.resolve(process.cwd(), importer.entryPointPath) : require.main?.filename; - if (entryPointPath === legacyImporterProtocol) { - entryPointPath = require.main?.filename; - } - if (!entryPointPath) { throw new Error( 'Node Package Importer requires access to a filesystem.' diff --git a/lib/src/legacy/index.ts b/lib/src/legacy/index.ts index 431f4e77..24489ff3 100644 --- a/lib/src/legacy/index.ts +++ b/lib/src/legacy/index.ts @@ -192,7 +192,7 @@ function convertStringOptions( // Find the first non-NodePackageImporter to pass as legacy `importer` option. // NodePackageImporter will be passed in `modernOptions.importers`. const importer = modernOptions.importers?.find( - _importer => _importer instanceof NodePackageImporter + _importer => !(_importer instanceof NodePackageImporter) ) as Importer | FileImporter; return {