Skip to content

Commit b037347

Browse files
ncavealfonsogarciacaro
authored andcommitted
Remove glob dependency
1 parent 8441abe commit b037347

File tree

6 files changed

+40
-22
lines changed

6 files changed

+40
-22
lines changed

build.fsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,18 @@ module Util =
5252
let runNpx command args =
5353
run ("npx " + command + " " + (String.concat " " args))
5454

55+
let runNpmScript script args =
56+
run ("npm run " + script + " -- " + (String.concat " " args))
57+
5558
let runNpmScriptAsync script args =
5659
runAsync ("npm run " + script + " -- " + (String.concat " " args))
5760

5861
let runFable projectDir =
5962
runFableWithArgs projectDir []
6063

64+
let runMocha testDir =
65+
runNpmScript "mocha" [$"{testDir} -r esm --reporter dot -t 10000"]
66+
6167
let resolveDir dir =
6268
__SOURCE_DIRECTORY__ </> dir
6369

@@ -180,7 +186,7 @@ let testJsFast() =
180186
let testProj = "tests/Main/Fable.Tests.fsproj"
181187
let buildDir = "build/tests-js"
182188
run $"node --eval \"require('esm')(module)('{fableJs}')\" {fableJs} {testProj} {buildDir}"
183-
run $"npx mocha {buildDir} -r esm --reporter dot -t 10000"
189+
runMocha buildDir
184190

185191

186192
let buildStandalone (opts: {| minify: bool; watch: bool |}) =
@@ -230,19 +236,19 @@ let buildStandalone (opts: {| minify: bool; watch: bool |}) =
230236
]
231237

232238
// make standalone bundle dist
233-
runNpx "rollup" rollupArgs
239+
runNpmScript "rollup" rollupArgs
234240
if opts.minify then
235-
runNpx "terser" [
241+
runNpmScript "terser" [
236242
buildDir </> "bundle.js"
237243
"-o " + distDir </> "bundle.min.js"
238244
"--mangle"
239245
"--compress"
240246
]
241247

242248
// make standalone worker dist
243-
runNpx "rollup" [$"{buildDir}/worker/Worker.js -o {buildDir}/worker.js --format iife"]
249+
runNpmScript "rollup" [$"{buildDir}/worker/Worker.js -o {buildDir}/worker.js --format iife"]
244250
// runNpx "webpack" [sprintf "--entry ./%s/worker.js --output ./%s/worker.min.js --config ./%s/../worker.config.js" buildDir distDir projectDir]
245-
runNpx "terser" [$"{buildDir}/worker.js -o {distDir}/worker.min.js --mangle --compress"]
251+
runNpmScript "terser" [$"{buildDir}/worker.js -o {distDir}/worker.min.js --mangle --compress"]
246252

247253
// print bundle size
248254
fileSizeInBytes (distDir </> "bundle.min.js") / 1000. |> printfn "Bundle size: %fKB"
@@ -312,8 +318,8 @@ let testJs(minify) =
312318
runInDir fableDir "npm link ../fable-standalone"
313319

314320
// Test fable-compiler-js locally
315-
run ("node " + fableDir + " tests/Main/Fable.Tests.fsproj " + buildDir)
316-
run ("npx mocha " + buildDir + " -r esm --reporter dot -t 10000")
321+
run $"node {fableDir} tests/Main/Fable.Tests.fsproj {buildDir}"
322+
runMocha buildDir
317323

318324
// // Another local fable-compiler-js test
319325
// runInDir (fableDir </> "test") "node .. test_script.fsx"
@@ -342,7 +348,7 @@ let test() =
342348
"--exclude Fable.Core"
343349
]
344350

345-
run $"npx mocha {buildDir} -r esm --reporter dot -t 10000"
351+
runMocha buildDir
346352

347353
runInDir projectDir "dotnet run"
348354

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
"private": true,
33
"scripts": {
44
"tsc": "tsc",
5+
"mocha": "mocha",
6+
"rollup": "rollup",
7+
"terser": "terser",
58
"tslint": "tslint",
69
"build": "dotnet fsi build.fsx",
710
"publish": "dotnet fsi build.fsx publish",

src/fable-compiler-js/RELEASE_NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### 3.0.1
2+
3+
* Reduced package dependencies
4+
15
### 3.0.0
26

37
* Nagareyama official release

src/fable-compiler-js/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fable-compiler-js",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"main": "index.js",
55
"bin": {
66
"fable": "index.js"
@@ -23,7 +23,6 @@
2323
"homepage": "https://github.com/fable-compiler/Fable#readme",
2424
"dependencies": {
2525
"fable-metadata": "^2.0.0",
26-
"fable-standalone": "^3.0.0-nagareyama-rc-008",
27-
"glob": "^7.1.6"
26+
"fable-standalone": "^3.0.0"
2827
}
2928
}

src/fable-compiler-js/src/Platform.fs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ module JS =
3434
abstract resolve: string -> string
3535
abstract relative: string * string -> string
3636

37-
type IGlob =
38-
abstract sync: pattern: string * ?options: obj -> array<string>
37+
// type IGlob =
38+
// abstract sync: pattern: string * ?options: obj -> array<string>
3939

4040
type IUtil =
4141
abstract getDirFiles: dir: string -> string[]
@@ -48,7 +48,7 @@ module JS =
4848
let os: IOperSystem = importAll "os"
4949
let proc: IProcess = importAll "process"
5050
let path: IPath = importAll "path"
51-
let glob: IGlob = importAll "glob"
51+
// let glob: IGlob = importAll "glob"
5252
let util: IUtil = importAll "./util.js"
5353

5454
let readAllBytes (filePath: string) = JS.fs.readFileSync(filePath)
@@ -88,8 +88,14 @@ let getDirFiles (path: string) (extension: string) =
8888
|> Array.sort
8989

9090
let getGlobFiles (path: string) =
91-
if path.Contains("*") || path.Contains("?")
92-
then JS.glob.sync(path)
91+
if path.Contains("*") || path.Contains("?") then
92+
// JS.glob.sync(path) // commented to remove dependency
93+
// replaced with fixed globbing pattern (*.fs)
94+
let dirPath =
95+
let normPath = path.Replace('\\', '/')
96+
let i = normPath.LastIndexOf('/')
97+
if i < 0 then "" else normPath.Substring(0, i)
98+
getDirFiles dirPath ".fs"
9399
else [| path |]
94100

95101
module Path =

src/fable-standalone/test/bench-compiler/Platform.fs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ module JS =
8787
abstract resolve: string -> string
8888
abstract relative: string * string -> string
8989

90-
type IGlob =
91-
abstract sync: pattern: string * ?options: obj -> array<string>
90+
// type IGlob =
91+
// abstract sync: pattern: string * ?options: obj -> array<string>
9292

9393
type IUtil =
9494
abstract getDirFiles: dir: string -> string[]
@@ -150,10 +150,10 @@ let getGlobFiles (path: string) =
150150
if path.Contains("*") || path.Contains("?") then
151151
// JS.glob.sync(path) // commented to remove dependency
152152
// replaced with fixed globbing pattern (*.fs)
153-
let normPath = path.Replace('\\', '/')
154-
let i = normPath.LastIndexOf('/')
155-
// let pattern = normPath.Substring(i + 1) // ignored
156-
let dirPath = if i < 0 then "" else normPath.Substring(0, i)
153+
let dirPath =
154+
let normPath = path.Replace('\\', '/')
155+
let i = normPath.LastIndexOf('/')
156+
if i < 0 then "" else normPath.Substring(0, i)
157157
getDirFiles dirPath ".fs"
158158
else [| path |]
159159

0 commit comments

Comments
 (0)