From 272fea13e71b677c4fa40a0315c89cf97cbd84d7 Mon Sep 17 00:00:00 2001 From: Damian Gryski Date: Thu, 30 May 2024 21:01:50 -0700 Subject: [PATCH] builder: keep un-wasm-opt'd .wasm if -work was passed --- builder/build.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/builder/build.go b/builder/build.go index 940439667..e415781fe 100644 --- a/builder/build.go +++ b/builder/build.go @@ -825,10 +825,18 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe args = append(args, "--asyncify") } + exeunopt := result.Executable + + if config.Options.Work { + // Keep the work direction around => don't overwrite the .wasm binary with the optimized version + exeunopt += ".pre-wasm-opt" + os.Rename(result.Executable, exeunopt) + } + args = append(args, opt, "-g", - result.Executable, + exeunopt, "--output", result.Executable, )