Skip to content

Commit 6dc8eee

Browse files
committed
Replace webpack with esbuild.
1 parent 6449bdc commit 6dc8eee

File tree

4 files changed

+184
-3462
lines changed

4 files changed

+184
-3462
lines changed

build/Program.fs

+13-31
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,6 @@ module Fable =
6363
| Watch
6464
| Clean
6565

66-
type Webpack =
67-
| WithoutWebpack
68-
| WithWebpack of args: string option
69-
7066
type Args =
7167
{ Command: Command
7268
Debug: bool
@@ -76,7 +72,7 @@ module Fable =
7672
Defines: string list
7773
SourceMaps: bool
7874
AdditionalFableArgs: string option
79-
Webpack: Webpack }
75+
Bundle: bool }
8076

8177
let DefaultArgs =
8278
{ Command = Build
@@ -87,7 +83,7 @@ module Fable =
8783
Defines = []
8884
AdditionalFableArgs = None
8985
SourceMaps = true
90-
Webpack = WithoutWebpack }
86+
Bundle = false }
9187

9288
let private mkArgs args =
9389
let fableCmd =
@@ -122,24 +118,11 @@ module Fable =
122118

123119
let fableAdditionalArgs = args.AdditionalFableArgs |> Option.defaultValue ""
124120

125-
let webpackCmd =
126-
match args.Webpack with
127-
| WithoutWebpack -> ""
128-
| WithWebpack webpackArgs ->
129-
sprintf
130-
"--%s webpack %s %s %s"
131-
(match args.Command with
132-
| Watch -> "runWatch"
133-
| _ -> "run")
134-
(if args.Debug then
135-
"--mode=development"
136-
else
137-
"--mode=production")
138-
(if args.Experimental then
139-
"--env.ionideExperimental"
140-
else
141-
"")
142-
(webpackArgs |> Option.defaultValue "")
121+
let bundleCmd =
122+
if not args.Bundle then
123+
""
124+
else
125+
"--run npm run esbuild"
143126

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

@@ -154,7 +137,7 @@ module Fable =
154137
fableExperimental
155138
fableDefines
156139
fableAdditionalArgs
157-
webpackCmd
140+
bundleCmd
158141

159142
let run args =
160143
let cmd = mkArgs args
@@ -303,8 +286,7 @@ let initTargets () =
303286
Fable.run
304287
{ Fable.DefaultArgs with
305288
Command = Fable.Watch
306-
Debug = true
307-
Webpack = Fable.WithWebpack None })
289+
Debug = true })
308290

309291
Target.create "InstallVSCE" (fun _ ->
310292
Process.killAllByName "npm"
@@ -319,14 +301,13 @@ let initTargets () =
319301
{ Fable.DefaultArgs with
320302
Command = Fable.Build
321303
Debug = false
322-
Webpack = Fable.WithWebpack None })
304+
Bundle = true })
323305

324306
Target.create "RunDevScript" (fun _ ->
325307
Fable.run
326308
{ Fable.DefaultArgs with
327309
Command = Fable.Build
328-
Debug = true
329-
Webpack = Fable.WithWebpack None })
310+
Debug = true })
330311

331312

332313
Target.create "CopyFSACNetcore" (fun _ ->
@@ -405,7 +386,8 @@ let buildTargetTree () =
405386
"YarnInstall" ==>! "RunScript"
406387
"DotNetRestore" ==>! "RunScript"
407388

408-
"Clean" ==> "Format" ==> "RunScript" ==>! "Default"
389+
"Clean" ==> "Format" ==> "RunScript"
390+
==>! "Default"
409391

410392
"Clean"
411393
==> "RunScript"

package.json

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,32 @@
11
{
22
"scripts": {
3-
"gen:semver": "ts2fable node_modules/@types/semver/{classes,functions,internals,ranges}/*.d.ts node_modules/@types/semver/index.d.ts src/Imports/Semver.fs"
3+
"gen:semver": "ts2fable node_modules/@types/semver/{classes,functions,internals,ranges}/*.d.ts node_modules/@types/semver/index.d.ts src/Imports/Semver.fs",
4+
"esbuild-base": "esbuild ./out/fsharp.js --bundle --outfile=release/fsharp.js --external:vscode --format=cjs --platform=node",
5+
"esbuild": "npm run esbuild-base -- --sourcemap",
6+
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch"
47
},
58
"dependencies": {
69
"htmlparser2": "^4.1.0",
710
"semver": "^7.3.5"
811
},
912
"devDependencies": {
10-
"@babel/core": "^7.11.6",
11-
"@babel/plugin-transform-runtime": "^7.11.5",
12-
"@babel/preset-env": "^7.11.5",
1313
"@types/semver": "^7.3.8",
1414
"@types/showdown": "^1.9.3",
1515
"@types/vscode": "^1.52.0",
1616
"@types/ws": "^7.2.6",
1717
"axios": "^0.20.0",
18-
"babel-loader": "^8.1.0",
18+
"cross-spawn": "^7.0.3",
19+
"esbuild": "^0.14.31",
1920
"mocha": "^8.1.3",
2021
"showdown": "^1.9.1",
2122
"toml": "^3.0.0",
2223
"ts2fable": "^0.8.0-build.618",
2324
"vscode-debugadapter": "^1.44.0",
2425
"vscode-languageclient": "^7.0.0",
25-
"webpack": "^4.44.1",
26-
"webpack-cli": "^3.3.12",
2726
"ws": "^7.3.1",
2827
"xhr2": "^0.2.0"
2928
},
3029
"engines": {
3130
"node": ">=14.0.0"
3231
}
33-
}
32+
}

webpack.config.js

-60
This file was deleted.

0 commit comments

Comments
 (0)