Skip to content
Closed
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,6 @@ fsacpath.txt
/out/

build/bin
build/obj
build/obj

!rollup.config.js
61 changes: 36 additions & 25 deletions build/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ module Fable =
| Watch
| Clean

type Webpack =
| WithoutWebpack
| WithWebpack of args: string option
type Rollup =
| WithoutRollup
| WithRollup of args: string option

type Args =
{ Command: Command
Expand All @@ -77,7 +77,7 @@ module Fable =
Defines: string list
SourceMaps: bool
AdditionalFableArgs: string option
Webpack: Webpack }
Rollup: Rollup }

let DefaultArgs =
{ Command = Build
Expand All @@ -88,7 +88,7 @@ module Fable =
Defines = []
AdditionalFableArgs = None
SourceMaps = true
Webpack = WithoutWebpack }
Rollup = WithoutRollup }

let private mkArgs args =
let fableCmd =
Expand Down Expand Up @@ -124,23 +124,34 @@ module Fable =
let fableAdditionalArgs = args.AdditionalFableArgs |> Option.defaultValue ""

let webpackCmd =
match args.Webpack with
| WithoutWebpack -> ""
| WithWebpack webpackArgs ->
sprintf
"--%s webpack %s %s %s"
(match args.Command with
| Watch -> "runWatch"
| _ -> "run")
(if args.Debug then
"--mode=development"
else
"--mode=production")
(if args.Experimental then
"--env.ionideExperimental"
else
"")
(webpackArgs |> Option.defaultValue "")
match args.Rollup with
| WithoutRollup -> ""
| WithRollup rollupArgs ->
let extraArgs = rollupArgs |> Option.defaultValue ""

let env =
let mode =
if args.Debug then
"development"
else
"production"

let experimental =
if args.Experimental then
"true"
else
"false"

$"""--environment IONIDE_MODE:{mode},IONIDE_EXPERIMENTAL:{experimental}"""

let watch = if args.Debug then "--watch" else ""

let cmd =
match args.Command with
| Watch -> "runWatch"
| _ -> "run"

$"--{cmd} rollup --config rollup.config.js {watch} {env} {extraArgs}"

let sourceMaps = if args.SourceMaps then "-s" else ""

Expand Down Expand Up @@ -299,7 +310,7 @@ let initTargets () =
{ Fable.DefaultArgs with
Command = Fable.Watch
Debug = true
Webpack = Fable.WithWebpack None })
Rollup = Fable.WithRollup None })

Target.create "InstallVSCE" (fun _ ->
Process.killAllByName "npm"
Expand All @@ -314,14 +325,14 @@ let initTargets () =
{ Fable.DefaultArgs with
Command = Fable.Build
Debug = false
Webpack = Fable.WithWebpack None })
Rollup = Fable.WithRollup None })

Target.create "RunDevScript" (fun _ ->
Fable.run
{ Fable.DefaultArgs with
Command = Fable.Build
Debug = true
Webpack = Fable.WithWebpack None })
Rollup = Fable.WithRollup None })


Target.create "CopyFSACNetcore" (fun _ ->
Expand Down
18 changes: 10 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
"scripts": {
"gen:semver": "ts2fable node_modules/@types/semver/{classes,functions,internals,ranges}/*.d.ts node_modules/@types/semver/index.d.ts src/Imports/Semver.fs"
},
"type": "module",
"dependencies": {
"bufferutil": "^4.0.6",
"cross-spawn": "^7.0.3",
"htmlparser2": "^4.1.0",
"semver": "^7.3.5"
"showdown": "^1.9.1",
"utf-8-validate": "^5.0.9"
},
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",
"@rollup/plugin-commonjs": "^22.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.3.0",
"@types/semver": "^7.3.8",
"@types/showdown": "^1.9.3",
"@types/vscode": "^1.52.0",
"@types/ws": "^7.2.6",
"axios": "^0.20.0",
"babel-loader": "^8.1.0",
"mocha": "^8.1.3",
"showdown": "^1.9.1",
"rollup": "^2.75.6",
"rollup-plugin-terser": "^7.0.2",
"toml": "^3.0.0",
"ts2fable": "^0.8.0-build.618",
"vscode-debugadapter": "^1.44.0",
"vscode-languageclient": "^7.0.0",
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12",
"ws": "^7.3.1",
"xhr2": "^0.2.0",
"xmldom": "^0.6.0",
Expand Down
28 changes: 28 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import path from "path";
import { cwd, env } from "process";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import rollupJson from "@rollup/plugin-json";
import { terser } from "rollup-plugin-terser";

const resolve = (...paths) => path.join(cwd(), ...paths);
const isProduction = env?.IONIDE_MODE === "production";
const ionideExperimental = env?.IONIDE_EXPERIMENTAL === "true";
const outputPath = ionideExperimental ? "release-exp" : "release";

/**
* @type {import('rollup').RollupOptions}
*/
const config = {
input: "out/fsharp.js",
output: {
file: resolve(outputPath, "fsharp.js"),
format: "cjs",
},
context: "undefined",
treeshake: isProduction,
plugins: [nodeResolve(), commonjs(), rollupJson(), isProduction && terser()],
external: ["vscode"],
};

export default config;
60 changes: 0 additions & 60 deletions webpack.config.js

This file was deleted.

Loading