Skip to content

Commit

Permalink
Workaround symbol changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesnw committed Nov 21, 2023
1 parent e591fad commit 317ab80
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
3 changes: 2 additions & 1 deletion lib/src/importer-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
import * as proto from './vendor/embedded_sass_pb';
import {catchOr, thenOr, PromiseOr} from './utils';

export const nodePackageImporter: NodePackageImporter = Symbol();
export const nodePackageImporter: NodePackageImporter =
Symbol() as NodePackageImporter;

/**
* A registry of importers defined in the host that can be invoked by the
Expand Down
25 changes: 17 additions & 8 deletions lib/src/legacy/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,9 @@ function convertOptions<sync extends 'sync' | 'async'>(
),
];
}
if (options.pkgImporter === 'node') {
importers = importers
? [nodePackageImporter, ...importers]
: [nodePackageImporter];
}

return {
const convertedOptions = {
functions,
importers,
sourceMap: wasSourceMapRequested(options),
sourceMapIncludeSources: options.sourceMapContents,
loadPaths: importers ? undefined : options.includePaths,
Expand All @@ -177,8 +171,23 @@ function convertOptions<sync extends 'sync' | 'async'>(
verbose: options.verbose,
charset: options.charset,
logger: options.logger,
legacy: true,
legacy: true as const,
};

// Use separate return statements, as applying logic directly to the inclusion
// of `nodePackageImporter` causes the symbol to use its unique flag.
if (options.pkgImporter === 'node') {
importers = importers || [];
return {
...convertedOptions,
importers: [nodePackageImporter, ...importers],
};
} else {
return {
...convertedOptions,
importers,
};
}
}

// Converts `LegacyStringOptions` into new API `StringOptions`.
Expand Down

0 comments on commit 317ab80

Please sign in to comment.