@@ -823,19 +823,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
823823 args = append (args , "--asyncify" )
824824 }
825825
826- exeunopt := result .Executable
827-
828- if config .Options .Work {
829- // Keep the work direction around => don't overwrite the .wasm binary with the optimized version
830- exeunopt += ".pre-wasm-opt"
831- os .Rename (result .Executable , exeunopt )
832- }
833-
826+ inputFile := result .Binary
827+ result .Binary = result .Executable + ".wasmopt"
834828 args = append (args ,
835829 opt ,
836830 "-g" ,
837- exeunopt ,
838- "--output" , result .Executable ,
831+ inputFile ,
832+ "--output" , result .Binary ,
839833 )
840834
841835 wasmopt := goenv .Get ("WASMOPT" )
@@ -865,13 +859,15 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
865859
866860 // wasm-tools component embed -w wasi:cli/command
867861 // $$(tinygo env TINYGOROOT)/lib/wasi-cli/wit/ main.wasm -o embedded.wasm
862+ componentEmbedInputFile := result .Binary
863+ result .Binary = result .Executable + ".wasm-component-embed"
868864 args := []string {
869865 "component" ,
870866 "embed" ,
871867 "-w" , witWorld ,
872868 witPackage ,
873- result . Executable ,
874- "-o" , result .Executable ,
869+ componentEmbedInputFile ,
870+ "-o" , result .Binary ,
875871 }
876872
877873 wasmtools := goenv .Get ("WASMTOOLS" )
@@ -888,11 +884,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
888884 }
889885
890886 // wasm-tools component new embedded.wasm -o component.wasm
887+ componentNewInputFile := result .Binary
888+ result .Binary = result .Executable + ".wasm-component-new"
891889 args = []string {
892890 "component" ,
893891 "new" ,
894- result . Executable ,
895- "-o" , result .Executable ,
892+ componentNewInputFile ,
893+ "-o" , result .Binary ,
896894 }
897895
898896 if config .Options .PrintCommands != nil {
0 commit comments