@@ -111,39 +111,54 @@ let buildLibraryTs() =
111111 runInDir buildDirTs ( " npx tsc --outDir ../../" + buildDirJs)
112112
113113let quicktest () =
114- runFableWithArgs " src/quicktest" [ " --exclude Fable.Core" ]
114+ runFableWithArgs " src/quicktest" [
115+ " --force-pkgs"
116+ " --exclude Fable.Core"
117+ ]
115118 run " npx tsc src/quicktest/QuickTest.fs.js --allowJs -m commonJs --outDir build/quicktest"
116119 run " node build/quicktest/src/quicktest/QuickTest.fs.js"
117120
118- let buildCompilerJs () =
119- let projectDir = " src/fable-compiler-js"
120- let buildDir = " build/fable-compiler-js"
121- cleanDirs [ buildDir; projectDir </> " dist" ]
122- runFableWithArgs projectDir [ " --outDir " + buildDir + " /out" ]
123- run ( sprintf " npx rollup %s /out/app.js --file %s /dist/app.js --format umd --name Fable" buildDir projectDir)
124- run ( sprintf " npx terser %s /dist/app.js -o %s /dist/app.min.js --mangle --compress" projectDir projectDir)
121+ let compileFcs () =
122+ runFableWithArgs " src/fable-standalone/src" [
123+ " --force-pkgs"
124+ " --typed-arrays"
125+ " --define FX_NO_CORHOST_SIGNER"
126+ " --define FX_NO_LINKEDRESOURCES"
127+ " --define FX_NO_PDB_READER"
128+ " --define FX_NO_PDB_WRITER"
129+ " --define FX_NO_WEAKTABLE"
130+ " --define FX_REDUCED_EXCEPTIONS"
131+ " --define NO_COMPILER_BACKEND"
132+ " --define NO_EXTENSIONTYPING"
133+ " --define NO_INLINE_IL_PARSER"
134+ ]
125135
126136let buildStandalone () =
127137 let buildDir = " build/fable-standalone"
128138 let libraryDir = " build/fable-library"
129- let projectDir = " src/fable-standalone"
139+ let projectDir = " src/fable-standalone/src "
130140 let distDir = " src/fable-standalone/dist"
131141 if pathExists libraryDir |> not then
132142 buildLibrary()
133143
134144 // cleanup
135145 cleanDirs [ buildDir; distDir]
136146 makeDirRecursive distDir
147+
137148 // build
138- runFableWithArgs projectDir [ " --outDir " + buildDir + " /out-bundle" ]
139- runFableWithArgs ( projectDir + " /src/Worker" ) [ " --outDir " + buildDir + " /out-worker" ]
149+ compileFcs()
150+ runFableWithArgs ( projectDir + " /Worker" ) [
151+ " --force-pkgs"
152+ ]
153+
140154 // bundle
141- run ( sprintf " npx rollup %s /out-bundle/Main.js --file %s /bundle.js --format umd --name __FABLE_STANDALONE__" buildDir buildDir)
142- run ( sprintf " npx rollup %s /out-worker/Worker.js --file %s /worker.js --format esm" buildDir buildDir)
155+ run ( sprintf " npx rollup %s /Main.fs.js --file %s /bundle.js --format umd --name __FABLE_STANDALONE__" projectDir buildDir)
156+ run ( sprintf " npx rollup %s /Worker/Worker.fs.js --file %s /worker.js --format esm" projectDir buildDir)
157+
143158 // minimize
144159 run ( sprintf " npx terser %s /bundle.js -o %s /bundle.min.js --mangle --compress" buildDir distDir)
145160 // run (sprintf "npx terser %s/worker.js -o %s/worker.min.js --mangle --compress" buildDir distDir)
146- run ( sprintf " npx webpack --entry ./%s /worker.js --output ./%s /worker.min.js --config ./%s /worker.config.js" buildDir distDir projectDir)
161+ run ( sprintf " npx webpack --entry ./%s /worker.js --output ./%s /worker.min.js --config ./%s /../ worker.config.js" buildDir distDir projectDir)
147162
148163 // print bundle size
149164 fileSizeInBytes ( distDir </> " bundle.min.js" ) / 1000 |> printfn " Bundle size: %i KB"
@@ -153,15 +168,15 @@ let buildStandalone() =
153168 let libraryTarget = distDir </> " fable-library"
154169 copyDirRecursive libraryDir libraryTarget
155170 // These files will be used in the browser, so make sure the import paths include .js extension
156- let reg = Regex( @" ^import (.*"" .*)("" .*)$" , RegexOptions.Multiline)
157- getFullPathsInDirectoryRecursively libraryTarget
158- |> Array.filter ( fun file -> file.EndsWith( " .js" ))
159- |> Array.iter ( fun file ->
160- reg.Replace( readFile file, fun m ->
161- let fst = m.Groups.[ 1 ]. Value
162- if fst.EndsWith( " .js" ) then m.Value
163- else sprintf " import %s .js%s " fst m.Groups.[ 2 ]. Value)
164- |> writeFile file)
171+ // let reg = Regex(@"^import (.*"".*)("".*)$", RegexOptions.Multiline)
172+ // getFullPathsInDirectoryRecursively libraryTarget
173+ // |> Array.filter (fun file -> file.EndsWith(".js"))
174+ // |> Array.iter (fun file ->
175+ // reg.Replace(readFile file, fun m ->
176+ // let fst = m.Groups.[1].Value
177+ // if fst.EndsWith(".js") then m.Value
178+ // else sprintf "import %s.js%s" fst m.Groups.[2].Value)
179+ // |> writeFile file)
165180
166181 // Bump version
167182 // let compilerVersion = Publish.loadReleaseVersion "src/fable-compiler"
@@ -172,43 +187,76 @@ let buildStandalone() =
172187 // (if comMajor > staMajor || comMinor > staMinor then compilerVersion
173188 // else sprintf "%i.%i.%i%s" staMajor staMinor (staPatch + 1) comPrerelease)
174189
175- let testJs () =
190+ let buildCompilerJs () =
191+ compileFcs()
192+
176193 let projectDir = " src/fable-compiler-js"
177- let buildDir = " build/tests-js"
178- if not ( pathExists " build/fable-standalone" ) then
179- buildStandalone()
180- if not ( pathExists " build/fable-compiler-js" ) then
181- buildCompilerJs()
194+ runFableWithArgs ( projectDir </> " src" ) [
195+ " --force-pkgs"
196+ " --exclude Fable.Core"
197+ ]
182198
183- cleanDirs [ buildDir]
199+ cleanDirs [ projectDir </> " dist" ]
200+ // run (sprintf "npx rollup %s/src/app.fs.js --file %s/dist/app.js --format umd --name Fable" projectDir projectDir)
201+ // run (sprintf "npx terser %s/dist/app.js -o %s/dist/app.min.js --mangle --compress" projectDir projectDir)
184202
185- // Link fable-compiler-js to local packages
186- runInDir projectDir " npm link ../fable-metadata"
187- runInDir projectDir " npm link ../fable-standalone"
203+ // Compile to commonjs modules
204+ runTypescript " src/fable-compiler-js"
205+ // Copy fable-library
206+ copyDirRecursive ( " build/fable-library" ) ( projectDir </> " dist/fable-library" )
207+ // Copy fable-metadata
208+ copyDirRecursive ( " src/fable-metadata/lib" ) ( projectDir </> " dist/fable-metadata" )
188209
189- // Test fable-compiler-js locally
190- run ( " node " + projectDir + " tests/Main/Fable.Tests.fsproj " + buildDir + " --commonjs " )
191- run ( " npx mocha " + buildDir + " --reporter dot -t 10000 " )
192- // and another test
193- runInDir " src/fable-compiler-js/test " " node .. test_script.fsx --commonjs "
194- runInDir " src/fable-compiler-js/test " " node bin/test_script.js "
210+ let compileAndRunTests ( compileTests ) =
211+ // TODO: "rm tests/**/*.fs.js"
212+ compileTests ( )
213+ cleanDirs [ " build/tests " ]
214+ runTypescript " tests "
215+ run " npx mocha build/tests/tests/Main --reporter dot -t 10000 "
195216
196- // Unlink local packages after test
197- runInDir projectDir " npm unlink ../fable-metadata && cd ../fable-metadata && npm unlink"
198- runInDir projectDir " npm unlink ../fable-standalone && cd ../fable-standalone && npm unlink"
217+ let testJs () =
218+ buildCompilerJs()
219+ compileAndRunTests( fun () ->
220+ run " node src/fable-compiler-js tests/Main/Fable.Tests.fsproj" )
221+
222+ // let projectDir = "src/fable-compiler-js"
223+ // let buildDir = "build/tests-js"
224+ // if not (pathExists "build/fable-standalone") then
225+ // buildStandalone()
226+ // if not (pathExists "build/fable-compiler-js") then
227+ // buildCompilerJs()
228+
229+ // cleanDirs [buildDir]
230+
231+ // // Link fable-compiler-js to local packages
232+ // runInDir projectDir "npm link ../fable-metadata"
233+ // runInDir projectDir "npm link ../fable-standalone"
234+
235+ // // Test fable-compiler-js locally
236+ // run ("node " + projectDir + " tests/Main/Fable.Tests.fsproj " + buildDir + " --commonjs")
237+ // run ("npx mocha " + buildDir + " --reporter dot -t 10000")
238+ // // and another test
239+ // runInDir "src/fable-compiler-js/test" "node .. test_script.fsx --commonjs"
240+ // runInDir "src/fable-compiler-js/test" "node bin/test_script.js"
241+
242+ // // Unlink local packages after test
243+ // runInDir projectDir "npm unlink ../fable-metadata && cd ../fable-metadata && npm unlink"
244+ // runInDir projectDir "npm unlink ../fable-standalone && cd ../fable-standalone && npm unlink"
199245
200246let test () =
201- if pathExists " build/fable-library" |> not then
202- buildLibrary()
247+ compileAndRunTests( fun () ->
248+ if pathExists " build/fable-library" |> not then
249+ buildLibrary()
203250
204- runFableWithArgs " tests/Main" [ " --exclude Fable.Core" ; " --force-pkgs" ]
205- runTypescript " tests"
206- run " npx mocha build/tests/tests/Main --reporter dot -t 10000"
207- runInDir " tests/Main" " dotnet run"
251+ runFableWithArgs " tests/Main" [
252+ " --force-pkgs"
253+ " --exclude Fable.Core"
254+ ]
255+ )
208256
209- // TODO: Temporarily deactivated to get green builds
210- // if envVarOrNone "APPVEYOR" |> Option.isSome then
211- // testJs()
257+ runInDir " tests/Main " " dotnet run "
258+ if envVarOrNone " APPVEYOR" |> Option.isSome then
259+ testJs()
212260
213261let coverage () =
214262 // report converter
@@ -327,6 +375,7 @@ match argsLower with
327375| ( " fable-library-ts" | " library-ts" )::_ -> buildLibraryTs()
328376| ( " fable-compiler-js" | " compiler-js" )::_ -> buildCompilerJs()
329377| ( " fable-standalone" | " standalone" )::_ -> buildStandalone()
378+ | " fcs" ::_ -> compileFcs()
330379| " download-standalone" ::_ -> downloadStandalone()
331380| " publish" :: restArgs -> publishPackages restArgs
332381| " github-release" ::_ ->
0 commit comments