Skip to content

Commit

Permalink
Release 4.1.0-beta-001
Browse files Browse the repository at this point in the history
  • Loading branch information
alfonsogarciacaro committed Apr 16, 2023
1 parent d9e1b31 commit baa22d1
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 19 deletions.
2 changes: 2 additions & 0 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ let buildLibraryTs() =
copyFiles sourceDir "*.ts" buildDirTs
copyFiles (sourceDir </> "ts") "*.json" buildDirTs
copyDirRecursive (sourceDir </> "lib") (buildDirTs </> "lib")
copyFile (sourceDir </> "package.json") buildDirTs

// runTSLint buildDirTs
runTypeScriptWithArgs buildDirTs ["--outDir " + buildDirJs]
copyFile (buildDirTs </> "lib/big.d.ts") (buildDirJs </> "lib/big.d.ts")
copyFile (buildDirTs </> "package.json") buildDirJs

let buildLibraryTsIfNotExists() =
if not (pathExists (__SOURCE_DIRECTORY__ </> "build/fable-library-ts")) then
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/Fable.Cli/Contributors.fs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ let getRandom() =
"davedawkins"; "njlr"; "steveofficer";
"cannorin"; "thautwarm"; "hensou";
"IanManske"; "entropitor"; "kant2002"
"johannesmols"
|]
Array.length contributors
|> System.Random().Next
Expand Down
15 changes: 11 additions & 4 deletions src/Fable.Cli/Fable.Cli.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<Version>4.0.6</Version>
<PackageVersion>4.0.6</PackageVersion>
<PackageReleaseNotes>* JS Hotfix: Skip compiler generated decls
* TS: Fixes for unions, pattern matching and interface function getters</PackageReleaseNotes>
<Version>4.1.0</Version>
<PackageVersion>4.1.0-beta-001</PackageVersion>
<PackageReleaseNotes>* Fix #3418: Single-Case Union Reflection
* Include declaration .d.ts files in fable-library
* Update FCS
* Python: Implement missing bigint functions @johannesmols
* TS: Fix #3415: ident type of uncurried lambdas
* TS: Don't use const enums to represent union tags
* TS: Fix function type annotation
* TS: Get generic types of generated members
* TS/JS: Sanitize class fields</PackageReleaseNotes>
<!-- Allow users with newer dotnet SDK to run Fable, see #1910 -->
<RollForward>Major</RollForward>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
Expand Down
19 changes: 11 additions & 8 deletions src/Fable.Cli/ProjectCracker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,14 @@ let getSourcesFromFablePkg (opts: CrackerOptions) (projFile: string) =
| path -> [ path ]
|> List.map Path.normalizeFullPath)

let private extractUsefulOptionsAndSources (line: string) (accSources: string list, accOptions: string list) =
let private extractUsefulOptionsAndSources isMainProj (line: string) (accSources: string list, accOptions: string list) =
if line.StartsWith("-") then
// "--warnaserror" // Disable for now to prevent unexpected errors, see #2288
// "--langversion" // See getBasicCompilerArgs
if line.StartsWith("--nowarn") || line.StartsWith("--warnon") then
if line.StartsWith("--langversion:") && isMainProj then
let v = line.Substring("--langversion:".Length).ToLowerInvariant()
if v = "preview" then accSources, line::accOptions
else accSources, accOptions
elif line.StartsWith("--nowarn") || line.StartsWith("--warnon") then
accSources, line::accOptions
elif line.StartsWith("--define:") then
// When parsing the project as .csproj there will be multiple defines in the same line,
Expand Down Expand Up @@ -365,7 +368,7 @@ let excludeProjRef (opts: CrackerOptions) (dllRefs: IDictionary<string,string>)
// Log.always("Couldn't remove project reference " + projName + " from dll references")
Path.normalizeFullPath projRef |> Some

let getCrackedFsproj (opts: CrackerOptions) (projOpts: string[], projRefs, msbuildProps, targetFramework) =
let getCrackedMainFsproj (opts: CrackerOptions) (projOpts: string[], projRefs, msbuildProps, targetFramework) =
// Use case insensitive keys, as package names in .paket.resolved
// may have a different case, see #1227
let dllRefs = Dictionary(StringComparer.OrdinalIgnoreCase)
Expand All @@ -379,7 +382,7 @@ let getCrackedFsproj (opts: CrackerOptions) (projOpts: string[], projRefs, msbui
dllRefs.Add(dllName, line)
src, otherOpts
else
extractUsefulOptionsAndSources line (src, otherOpts))
extractUsefulOptionsAndSources true line (src, otherOpts))

let fablePkgs =
let dllRefs' = dllRefs |> Seq.map (fun (KeyValue(k,v)) -> k,v) |> Seq.toArray
Expand Down Expand Up @@ -411,7 +414,7 @@ let getProjectOptionsFromScript (opts: CrackerOptions): CrackedFsproj =
|> Async.RunSynchronously

let projOpts = Array.append projOpts.OtherOptions projOpts.SourceFiles
getCrackedFsproj opts (projOpts, [||], Dictionary(), "")
getCrackedMainFsproj opts (projOpts, [||], Dictionary(), "")

let getProjectOptionsFromProjectFile =
let mutable manager = None
Expand Down Expand Up @@ -509,12 +512,12 @@ let getProjectOptionsFromProjectFile =
/// the references, checking if some .dlls correspond to Fable libraries
let crackMainProject (opts: CrackerOptions): CrackedFsproj =
getProjectOptionsFromProjectFile true opts opts.ProjFile
|> getCrackedFsproj opts
|> getCrackedMainFsproj opts

/// For project references of main project, ignore dll and package references
let crackReferenceProject (opts: CrackerOptions) dllRefs (projFile: string): CrackedFsproj =
let projOpts, projRefs, msbuildProps, targetFramework = getProjectOptionsFromProjectFile false opts projFile
let sourceFiles, otherOpts = Array.foldBack extractUsefulOptionsAndSources projOpts ([], [])
let sourceFiles, otherOpts = Array.foldBack (extractUsefulOptionsAndSources false) projOpts ([], [])
{ ProjectFile = projFile
SourceFiles = sourceFiles
ProjectReferences = projRefs |> Array.choose (excludeProjRef opts dllRefs) |> Array.toList
Expand Down
12 changes: 12 additions & 0 deletions src/Fable.Cli/RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
### 4.1.0-beta-001

* Fix #3418: Single-Case Union Reflection
* Include declaration .d.ts files in fable-library
* Update FCS
* Python: Implement missing bigint functions @johannesmols
* TS: Fix #3415: ident type of uncurried lambdas
* TS: Don't use const enums to represent union tags
* TS: Fix function type annotation
* TS: Get generic types of generated members
* TS/JS: Sanitize class fields

### 4.0.6

* JS Hotfix: Skip compiler generated decls
Expand Down
11 changes: 7 additions & 4 deletions src/Fable.Transforms/Fable2Babel.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1808,14 +1808,17 @@ module Util =
let kind = if var.IsMutable then Let else Const
[| Statement.variableDeclaration(kind, var.Name, ?annotation=ta, typeParameters=tp, init=value) |]

let transformUnionCaseTag (com: IBabelCompiler) typ tag =
let transformUnionCaseTag (com: IBabelCompiler) range typ tag =
let caseName =
match typ with
| Fable.DeclaredType(entRef, _) when com.IsTypeScript ->
let ent = com.GetEntity(entRef)
match List.tryItem tag ent.UnionCases with
| Some case -> Some case.Name
| None -> None
| None ->
$"Unmatched union case tag: {tag} for {ent.FullName}"
|> addWarning com [] range
None
| _ -> None
match caseName with
| Some name -> CommentedExpression(name, ofInt tag)
Expand All @@ -1832,7 +1835,7 @@ module Util =
let expr = libCall com ctx range "List" "isEmpty" [] [expr]
if nonEmpty then Expression.unaryExpression(UnaryNot, expr, ?loc=range) else expr
| Fable.UnionCaseTest tag ->
let expected = transformUnionCaseTag com expr.Type tag
let expected = transformUnionCaseTag com range expr.Type tag
let actual = getUnionExprTag com ctx None expr
Expression.binaryExpression(BinaryEqual, actual, expected, ?loc=range)

Expand All @@ -1842,7 +1845,7 @@ module Util =

let transformGuard = function
| Fable.Test(expr, Fable.UnionCaseTest tag, range) ->
transformUnionCaseTag com expr.Type tag
transformUnionCaseTag com range expr.Type tag
| TransformExpr com ctx e -> e

let cases =
Expand Down
2 changes: 1 addition & 1 deletion src/Fable.Transforms/Global/Compiler.fs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Fable

module Literals =
let [<Literal>] VERSION = "4.0.6"
let [<Literal>] VERSION = "4.1.0-beta-001"

type CompilerOptionsHelper =
static member Make(?language,
Expand Down
6 changes: 6 additions & 0 deletions src/quicktest/QuickTest.fs
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,9 @@ let measureTime (f: unit -> unit): unit = emitJsStatement () """
// to Fable.Tests project. For example:
// testCase "Addition works" <| fun () ->
// 2 + 2 |> equal 4


[<Literal>]
let foo = "FOO%f"

let x = sprintf foo 1.5
1 change: 1 addition & 0 deletions src/quicktest/Quicktest.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<RollForward>Major</RollForward>
<!-- <LangVersion>Preview</LangVersion> -->
</PropertyGroup>
<ItemGroup>
<Compile Include="QuickTest.fs" />
Expand Down
2 changes: 1 addition & 1 deletion tests/Js/Main/NestedAndRecursivePatternTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ open Util.Testing

let tests =
testList "Nested and Recursive Patterns" [
testCase "Nested and Recursive Patterns works" <| fun () ->
testCase "Nested and Recursive Patterns works" <| fun () -> // See #3411
let ctx1 = Position (5, 8) |> CtxtWhile
let ctx2 = Position (78, 2) |> CtxtWhile
undentationLimit true [ctx1; ctx2] |> string |> equal "L5-C18-C28"
Expand Down

0 comments on commit baa22d1

Please sign in to comment.