diff --git a/src/Fable.Compiler/ProjectCracker.fs b/src/Fable.Compiler/ProjectCracker.fs index f4b13a0158..0ee43cfa7b 100644 --- a/src/Fable.Compiler/ProjectCracker.fs +++ b/src/Fable.Compiler/ProjectCracker.fs @@ -438,6 +438,9 @@ let private extractUsefulOptionsAndSources // Only forward the nullness flag if it is coming from the main project elif line.StartsWith("--checknulls+", StringComparison.Ordinal) && isMainProj then accSources, line :: accOptions + // Forward pathmap from the main project so CallerFilePath respects / + elif line.StartsWith("--pathmap:", StringComparison.Ordinal) && isMainProj then + accSources, line :: accOptions elif line.StartsWith("--nowarn", StringComparison.Ordinal) || line.StartsWith("--warnon", StringComparison.Ordinal) diff --git a/tests/Integration/Integration/data/pathMap/CallerFilePathTest.fs b/tests/Integration/Integration/data/pathMap/CallerFilePathTest.fs new file mode 100644 index 0000000000..39eecdc8b8 --- /dev/null +++ b/tests/Integration/Integration/data/pathMap/CallerFilePathTest.fs @@ -0,0 +1,14 @@ +module CallerFilePathTest + +open System.Runtime.CompilerServices +open System.Runtime.InteropServices + +type Log = + static member info + ( + message: string, + [] path: string + ) = + printfn "%s: %s" path message + +Log.info "hello" diff --git a/tests/Integration/Integration/data/pathMap/CallerFilePathTest.jsx.expected b/tests/Integration/Integration/data/pathMap/CallerFilePathTest.jsx.expected new file mode 100644 index 0000000000..61f175af95 --- /dev/null +++ b/tests/Integration/Integration/data/pathMap/CallerFilePathTest.jsx.expected @@ -0,0 +1,19 @@ + +import { class_type } from "./fable_modules/fable-library-js/Reflection.js"; +import { printf, toConsole } from "./fable_modules/fable-library-js/String.js"; + +export class Log { + constructor() { + } +} + +export function Log_$reflection() { + return class_type("CallerFilePathTest.Log", undefined, Log); +} + +export function Log_info_Z384F8060(message, path = "") { + toConsole(printf("%s: %s"))(path)(message); +} + +Log_info_Z384F8060("hello", "./CallerFilePathTest.fs"); + diff --git a/tests/Integration/Integration/data/pathMap/pathMap.fsproj b/tests/Integration/Integration/data/pathMap/pathMap.fsproj new file mode 100644 index 0000000000..82be26d96d --- /dev/null +++ b/tests/Integration/Integration/data/pathMap/pathMap.fsproj @@ -0,0 +1,18 @@ + + + + net10.0 + Major + true + $(MSBuildThisFileDirectory)=. + + + + + + + + + + +