Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
"name": ".NET Core Launch (console)",
"type": "coreclr",
"request": "launch",
"program": "${workspaceRoot}/src/Fable.Cli/bin/Debug/netcoreapp2.1/Fable.Cli.dll",
"args": ["fable-splitter", "--args", "-c tests/splitter.config.js"],
"program": "${workspaceRoot}/src/Fable.Cli/bin/Debug/netcoreapp3.1/Fable.Cli.dll",
"args": ["start","--port", "61225"],
"cwd": "${workspaceRoot}",
"stopAtEntry": false,
"console": "internalConsole"
"console": "internalConsole",
},
{
"name": ".NET Core Attach",
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "3.1.300"
"version": "3.1.300",
"rollForward": "minor"
}
}
11 changes: 5 additions & 6 deletions src/Fable.Cli/Main.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,10 @@ let parseArguments args =
match Int32.TryParse portArg with
| true, port -> port
| false, _ ->
printfn "Value for --port is not a valid integer, using default port"
Literals.DEFAULT_PORT
printfn "Value for --port is not a valid integer, using free port"
getFreePort()
| None ->
// Literals.DEFAULT_PORT
getFreePort() // Make free port the default
getFreePort()
let workingDir =
match tryFindArgValue "--cwd" args with
| Some cwd -> Path.GetFullPath(cwd)
Expand Down Expand Up @@ -128,7 +127,7 @@ let setGlobalParams(args: string[]) =
)

let printHelp() =
(Literals.VERSION, Literals.DEFAULT_PORT) ||> printfn """Fable F# to JS compiler (%s)
Literals.VERSION |> printfn """Fable F# to JS compiler (%s)
Usage: dotnet fable [command] [script] [fable arguments] [-- [script arguments]]

Commands:
Expand All @@ -138,7 +137,7 @@ Commands:
yarn-run Run Fable while a yarn script is running
node-run Run Fable while a node script is running
shell-run Run Fable while a shell script is running
start Start Fable as a standalone daemon (default port: %i)
start Start Fable as a standalone daemon
[webpack-cli] Other commands will be assumed to be binaries in `node_modules/.bin`

Fable arguments:
Expand Down
3 changes: 0 additions & 3 deletions src/Fable.Cli/Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type Message =
noRestore: bool
typedArrays: bool
clampByteArrays: bool
classTypes: bool
typescript: bool
extra: IDictionary<string,string> }

Expand Down Expand Up @@ -57,7 +56,6 @@ let private parseDic (key: string) (o: JObject): IDictionary<string,string> =
let toCompilerOptions (msg: Message): CompilerOptions =
{ typedArrays = msg.typedArrays
clampByteArrays = msg.clampByteArrays
classTypes = msg.classTypes
typescript = msg.typescript
debugMode = Array.contains "DEBUG" msg.define
verbosity = GlobalParams.Singleton.Verbosity
Expand All @@ -81,6 +79,5 @@ let parse (msg: string) =
noRestore = parseBoolean false "noRestore" json
typedArrays = parseBoolean false "typedArrays" json
clampByteArrays = parseBoolean false "clampByteArrays" json
classTypes = parseBoolean false "classTypes" json
typescript = parseBoolean false "typescript" json
extra = parseDic "extra" json }
17 changes: 8 additions & 9 deletions src/Fable.Core/Fable.Core.JsInterop.fs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,17 @@ let (==>) (key: string) (v: obj): string*obj = jsNative
let createNew (o: obj) (args: obj): obj = jsNative

/// Destructure a tuple of arguments and applies to literal JS code as with EmitAttribute.
/// E.g. `emitJs "$0 + $1" (arg1, arg2)` in JS becomes `arg1 + arg2`
let emitJs (jsCode: string) (args: obj): 'T = jsNative
/// E.g. `emitJsExpr (arg1, arg2) "$0 + $1"` in JS becomes `arg1 + arg2`
let emitJsExpr<'T> (args: obj) (jsCode: string): 'T = jsNative

/// Same as emitJsExpr but intended for JS code that must appear in a statement position
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements
/// E.g. `emitJsExpr aValue "while($0 < 5) doSomething()"`
let emitJsStatement<'T> (args: obj) (jsCode: string): 'T = jsNative

/// Create a literal JS object from a collection of key-value tuples.
/// E.g. `createObj [ "a" ==> 5 ]` in JS becomes `{ a: 5 }`
let createObj (fields: #seq<string*obj>): obj = jsNative
let createObj (fields: seq<string*obj>): obj = jsNative

/// Create a literal JS object from a collection of union constructors.
/// E.g. `keyValueList CaseRules.LowerFirst [ MyUnion 4 ]` in JS becomes `{ myUnion: 4 }`
Expand Down Expand Up @@ -92,12 +97,6 @@ let importValueDynamic (x: 'T): JS.Promise<'T> = jsNative
/// Used when you need to send an F# record to a JS library accepting only plain JS objects (POJOs)
let toPlainJsObj(o: 'T): obj = jsNative

/// Compiles to JS `this` keyword.
///
/// ## Sample
/// jqueryMethod(fun x y -> jsThis?add(x, y))
let [<Emit("this")>] jsThis<'T> : 'T = jsNative

/// JS `in` operator
let [<Emit("$0 in $1")>] isIn (key: string) (target: obj): bool = jsNative

Expand Down
21 changes: 7 additions & 14 deletions src/Fable.Core/Fable.Core.Types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ type ImportAllAttribute(from: string) =

/// Function calls will be replaced by inlined JS code.
/// More info: http://fable.io/docs/interacting.html#emit-attribute
type EmitAttribute(macro: string) =
inherit Attribute()

/// The declaration value will be replaced with the JS code.
type EmitDeclarationAttribute(macro: string) =
type EmitAttribute(macro: string, isStatement: bool) =
inherit Attribute()
new (macro: string) = EmitAttribute(macro, isStatement=false)

/// Same as `Emit("$0.methodName($1...)")`
type EmitMethodAttribute(methodName: string) =
inherit Attribute()

type TestAttribute(r: System.Text.RegularExpressions.Regex) =
inherit Attribute()

/// Same as `Emit("new $0($1...)")`
type EmitConstructorAttribute() =
inherit Attribute()
Expand All @@ -75,16 +75,9 @@ type EmitPropertyAttribute(propertyName: string) =
/// Compile union types as string literals.
/// More info: http://fable.io/docs/interacting.html#StringEnum-attribute
[<AttributeUsage(AttributeTargets.Class)>]
type StringEnumAttribute() =
type StringEnumAttribute(caseRules: CaseRules) =
inherit Attribute()
new (caseRules: CaseRules) = StringEnumAttribute()

/// Used to spread the last argument. Mainly intended for `React.createElement` binding, not for general use.
[<AttributeUsage(AttributeTargets.Parameter)>]
type ParamSeqAttribute() =
inherit Attribute()

type ParamListAttribute = ParamSeqAttribute
new () = StringEnumAttribute(CaseRules.LowerFirst)

/// Experimental: Currently only intended for some specific libraries
[<AttributeUsage(AttributeTargets.Parameter)>]
Expand Down
Loading