Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Enhance sourceMapIncludeSources option
  • Loading branch information
ntkme committed Feb 12, 2026
commit 12da411542b048fd58d3e8626217cdfafa4a9acc
4 changes: 3 additions & 1 deletion lib/src/compiler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ function newCompileRequest(
importers: importers.importers,
globalFunctions: Object.keys(options?.functions ?? {}),
sourceMap: !!options?.sourceMap,
sourceMapIncludeSources: !!options?.sourceMapIncludeSources,
sourceMapIncludeSources: utils.protofySourceMapIncludeSources(
options?.sourceMapIncludeSources ?? 'auto',
),
alertColor: options?.alertColor ?? !!supportsColor.stdout,
alertAscii: !!options?.alertAscii,
quietDeps: !!options?.quietDeps,
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 @@ -303,7 +303,7 @@ function newLegacyResult(
return pathToUrlString(
p.relative(sourceMapDir, fileUrlToPathCrossPlatform(source)),
);
} else if (source.startsWith('data:')) {
} else if (source === '') {
return 'stdin';
} else {
return source;
Expand Down
27 changes: 26 additions & 1 deletion lib/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as p from 'path';
import * as url from 'url';

import * as proto from './vendor/embedded_sass_pb';
import {Syntax} from './vendor/sass';
import {SourceMapIncludeSources, Syntax} from './vendor/sass';

export type PromiseOr<
T,
Expand Down Expand Up @@ -147,6 +147,31 @@ export function protofySyntax(syntax: Syntax): proto.Syntax {
}
}

/** Converts a JS sourceMapIncludeSources value into a protobuf
* sourceMapIncludeSources enum.
*/
export function protofySourceMapIncludeSources(
sourceMapIncludeSources: SourceMapIncludeSources | boolean,
): proto.SourceMapIncludeSources {
switch (sourceMapIncludeSources) {
case 'auto':
return proto.SourceMapIncludeSources.AUTO;

case 'always':
case true:
return proto.SourceMapIncludeSources.ALWAYS;

case 'never':
case false:
return proto.SourceMapIncludeSources.NEVER;

default:
throw new Error(
`Unknown sourceMapIncludeSources: "${sourceMapIncludeSources}"`,
);
}
}

/** Returns whether `error` is a NodeJS-style exception with an error code. */
export function isErrnoException(
error: unknown,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "sass-embedded",
"version": "1.97.3",
"protocol-version": "3.2.0",
"protocol-version": "3.3.0",
"compiler-version": "1.97.3",
"description": "Node.js library that communicates with Embedded Dart Sass using the Embedded Sass protocol",
"repository": "sass/embedded-host-node",
Expand Down