SAFE-Stack / SAFE-template

dotnet CLI template for SAFE project
MIT License
282 stars 87 forks source link

Bundle fails for v3.1.0 #475

Closed chengh42 closed 2 years ago

chengh42 commented 2 years ago

Issue description

Bundle fails for SAFE template v3.1.0.

Steps to reproduce the issue

Installed SAFE template v3.1.0 with dotnet new --install SAFE.Template::3.1.0.

  1. dotnet new safe
  2. dotnet tool restore
  3. dotnet run -- bundle

Expected result

Target Bundle runs successfully.

Actual result

Target Bundle failed with the following log:

Starting target 'Bundle'
server: C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Server> dotnet publish -c Release -o "C:\mydojo\sandbox\safe-bundle-v3.1.0\deploy"
client: C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Client> dotnet fable --run -s webpack -p
C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Server> "dotnet" publish -c Release -o "C:\mydojo\sandbox\safe-bundle-v3.1.0\deploy" (In: false, Out: true, Err: true)
C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Client> "dotnet" fable --run -s webpack -p (In: false, Out: true, Err: true)
client: Fable: F# to JS compiler 3.2.11
server: Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
server: Copyright (C) Microsoft Corporation. All rights reserved.
client: Thanks to the contributor! @zpodlovics
client: .> cmd /C dotnet restore Client.fsproj
server:   Determining projects to restore...
server:   Paket version 6.0.7
client:   Determining projects to restore...
server:   Starting restore process.
client:   Paket version 6.0.7
server:   Total time taken: 0 milliseconds
client:   Starting restore process.
client:   Total time taken: 0 milliseconds
server:   Restored C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Shared\Shared.fsproj (in 265 ms).
server:   Restored C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Server\Server.fsproj (in 362 ms).
client:   Restored C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Client\Client.fsproj (in 229 ms).
client:   1 of 2 projects are up-to-date for restore.
client: Parsing Client.fsproj...
server:   Paket version 6.0.7
server:   Starting restore process.
server:   Total time taken: 0 milliseconds
client: Initializing F# compiler...
client: Compiling Client.fsproj...
server:   Shared -> C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Shared\bin\Release\net5.0\Shared.dll
server:   Server -> C:\mydojo\sandbox\safe-bundle-v3.1.0\src\Server\bin\Release\net5.0\Server.dll
server:   Server -> C:\mydojo\sandbox\safe-bundle-v3.1.0\deploy\
server: --- END ---
client: F# compilation finished in 9286ms
client: Loaded Feliz.HookAttribute from ..\..\..\..\..\Users\Hsin\.nuget\packages\feliz.compilerplugins\1.5.0\lib\netstandard2.0\Feliz.CompilerPlugins.dll
client: Loaded Feliz.ReactComponentAttribute from ..\..\..\..\..\Users\Hsin\.nuget\packages\feliz.compilerplugins\1.5.0\lib\netstandard2.0\Feliz.CompilerPlugins.dll
client: Fable compilation finished in 1303ms
client: .> cmd /C -s webpack -p
client: '-s' is not recognized as an internal or external command,
client: operable program or batch file.
client: Run process failed
Finished (Failed) 'Bundle' in 00:00:17.1000687

---------------------------------------------------------------------
Build Time Report
---------------------------------------------------------------------
Target          Duration
------          --------
Clean           00:00:00.4832377
InstallClient   00:00:11.8776389
Bundle          00:00:17.0990895   (One or more errors occurred. (Process exit code '1' <> 0. Command Line: dotnet fable --run -s webpack -p))
Total:          00:00:29.5700834
Status:         Failure
---------------------------------------------------------------------
Fake.Core.BuildFailedException: Target 'Bundle' failed.
 ---> System.AggregateException: One or more errors occurred. (One or more errors occurred. (Process exit code '1' <> 0. Command Line: dotnet fable --run -s webpack -p))
 ---> System.AggregateException: One or more errors occurred. (Process exit code '1' <> 0. Command Line: dotnet fable --run -s webpack -p)
 ---> System.Exception: Process exit code '1' <> 0. Command Line: dotnet fable --run -s webpack -p
   at Fake.Core.CreateProcess.ensureExitCode@608.Invoke(a data, Int32 exitCode)
   at Fake.Core.CreateProcess.addOnExited@584-5.Invoke(RawProcessResult _arg2)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 404
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 104
--- End of stack trace from previous location ---
   at Microsoft.FSharp.Control.AsyncResult`1.Commit() in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 339
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronouslyInCurrentThread[a](CancellationToken cancellationToken, FSharpAsync`1 computation) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 870
   at Microsoft.FSharp.Control.AsyncPrimitives.RunSynchronously[T](CancellationToken cancellationToken, FSharpAsync`1 computation, FSharpOption`1 timeout) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 878
   at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T](FSharpAsync`1 computation, FSharpOption`1 timeout, FSharpOption`1 cancellationToken) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 1142
   at Fake.Core.Proc.run[a](CreateProcess`1 c)
   at Helpers.Proc.Parallel.run@67.Invoke(CreateProcess`1 c) in C:\mydojo\sandbox\safe-bundle-v3.1.0\Helpers.fs:line 67
   at Microsoft.FSharp.Collections.ArrayModule.Parallel.Map@1319-2.Invoke(Int32 i) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\array.fs:line 1320
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.<>c__DisplayClass19_0`1.<ForWorker>b__1(RangeWorker& currentWorker, Int32 timeout, Boolean& replicationDelegateYieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica`1.ExecuteAction(Boolean& yieldedBeforeCompletion)
   at System.Threading.Tasks.TaskReplicator.Replica.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.TaskReplicator.Run[TState](ReplicatableUserAction`1 action, ParallelOptions options, Boolean stopOnFirstFailure)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
--- End of stack trace from previous location ---
   at System.Threading.Tasks.Parallel.ThrowSingleCancellationExceptionOrOtherException(ICollection exceptions, CancellationToken cancelToken, Exception otherException)
   at System.Threading.Tasks.Parallel.ForWorker[TLocal](Int32 fromInclusive, Int32 toExclusive, ParallelOptions parallelOptions, Action`1 body, Action`2 bodyWithState, Func`4 bodyWithLocal, Func`1 localInit, Action`1 localFinally)
   at System.Threading.Tasks.Parallel.For(Int32 fromInclusive, Int32 toExclusive, Action`1 body)
   at Microsoft.FSharp.Collections.ArrayModule.Parallel.Map[T,TResult](FSharpFunc`2 mapping, T[] array) in D:\workspace\_work\1\s\src\fsharp\FSharp.Core\array.fs:line 1319
   at Helpers.Proc.Parallel.run[a,b](IEnumerable`1 cs) in C:\mydojo\sandbox\safe-bundle-v3.1.0\Helpers.fs:line 66
   at Helpers.runParallel[a,b](IEnumerable`1 processes) in C:\mydojo\sandbox\safe-bundle-v3.1.0\Helpers.fs:line 92
   at Build.clo@25-2.Invoke(TargetParameter _arg3) in C:\mydojo\sandbox\safe-bundle-v3.1.0\Build.fs:line 26
   at Fake.Core.TargetModule.runSimpleInternal(TargetContext context, Target target)
   --- End of inner exception stack trace ---
   --- End of inner exception stack trace ---
   at Fake.Core.TargetModule.raiseIfError(OptionalTargetContext context)
   at Fake.Core.TargetModule.runOrDefault(String defaultTarget)
   at Helpers.runOrDefault(String[] args) in C:\mydojo\sandbox\safe-bundle-v3.1.0\Helpers.fs:line 99

Additional

Here is my dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   5.0.201
 Commit:    a09bd5c86c

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19043
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.201\

Host (useful for support):
  Version: 5.0.4
  Commit:  f27d337295

.NET SDKs installed:
  3.1.405 [C:\Program Files\dotnet\sdk]
  5.0.100-rc.2.20479.15 [C:\Program Files\dotnet\sdk]
  5.0.201 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0-rc.2.20475.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0-rc.2.20475.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 3.1.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0-rc.2.20475.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
theimowski commented 2 years ago

Hi @chengh42 - thanks for reporting the issue! Indeed I haven't tested the bundle target after recent changes.

The issue was a combination of changing output directory for fable and adding support for source maps - to fix it you must change it to this: dotnet "fable -o output -s --run webpack -p" clientPath

I've released the fix in 3.1.1

chengh42 commented 2 years ago

Thanks for the fix and explanation!