Skip to content

Commit

Permalink
Fix path import, legacy importer options.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Dec 20, 2023
1 parent 8964f75 commit a55acff
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
9 changes: 2 additions & 7 deletions lib/src/importer-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -58,14 +57,10 @@ export class ImporterRegistry<sync extends 'sync' | 'async'> {
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.'
Expand Down
2 changes: 1 addition & 1 deletion lib/src/legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ function convertStringOptions<sync extends 'sync' | 'async'>(
// 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<sync> | FileImporter<sync>;

return {
Expand Down

0 comments on commit a55acff

Please sign in to comment.