Modules with [<AutoOpen>] does not require open
to use.
build/
... build scriptsBindingUpdater.fs
... a utility to update bindings inlib/Bindings/
build.fs
... the main build script
lib/
... target-agnostic part of the tool (will be separated to a different repo in near future)Bindings/
... bindings to JS libraries (typescript, browser-or-node)Extensions.fs
... [<AutoOpen>] extensions for standard library and JS librariesDataTypes/
... common data structures and algorithmText.fs
... efficient rope withO(1)
concat &O(n)
stringifyTrie.fs
... trie based on immutable mapGraph.fs
... graph based on immutable map & graph algorithms
Common.fs
... global interfacesSyntax.fs
... AST for parsed TypeScAript codeNaming.fs
... naming helpersJsHelper.fs
... helper functions for JavaScript-related things e.g. NPM packages and ES6 module names.TypeScriptHelper.fs
... helper functions for using TypeScript Compiler APITyper.fs
... functions for resolving and manipulating ASTParser.fs
... functions for converting TS syntax tree to our AST
src/
... target-dependent part of the toolBindings/
... bindings to JS libraries (yargs)Extensions.fs
... [<AutoOpen>] extensions for standard library and JS librariesCommon.fs
... [<AutoOpen>] global command line options, types, and modulesTarget.fs
... generic definitions for each targets (ITarget<_>
)Targets/
... targets should be placed into hereParserTest.fs
... debug target to test parser and typer{Target}/
... target-specific codesCommon.fs
... command line options for the target{Target}Helper.fs
... helper functions to generate code for the target languageWriter.fs
... functions for generating the code from ASTTarget.fs
...ITarget<_>
instance for the target
Main.fs
... entry point
test/
jsoo/
... test for thejs_of_ocaml
targetres/
... test for theReScript
target
dist/
js/
... output directory for NPM packagingjsoo/
... output directory for OPAM packagingjsoo/
... output directory for NPM packaging of the stdlib for ReScript
output/
... temporary output directory for automated testing, etc
-
- Fable is required to build this tool.
- Run
dotnet tool restore
in the root directory of this repo to install it.
-
OCaml 4.08 or higher
- js_of_ocaml should be installed to your opam switch.
- gen_js_api
>= 1.0.9
should also be installed to your opam switch. - Run
opam install . --deps-only
to install all the dependencies.
-
Node 14.0 or higher
- yarn is required.
-
ReScript 11.0.1 or higher
- Installed by
yarn
.
- Installed by
- Run
yarn update --latest typescript
- Run
./fake UpdateBindings
to update the Fable binding (lib/Bindings/TypeScript.fs
) - Run
./fake build
and fix type errors
./fake watch
to live update dist/js/ts2ocaml.js
.
It will be bundled by Webpack with the development
mode.
./fake build
performs the followings:
yarn install
to populatenode_modules
dotnet restore ts2ocaml.sln
to install required F# libraries- Compile F# source files into JS source files (through Fable)
- Bundle the JS files into
dist/js/ts2ocaml.js
(through Webpack)
The resulting dist/js/ts2ocaml.js
is then ready to run through node
.
./fake test
builds the tool and then performs the followings:
Test the tool for js_of_ocaml
target
- Generate bindings for the following packages:
- TypeScript standard libraries (
node_modules/typescript/lib/lib.*.d.ts
) typescript
with thefull
preset (involving a lot of inheritance)react
with thefull
preset (depending on bothfull
packages andsafe
packages)scheduler/tracing
(safe
)csstype
(full
)prop-types
(safe
)
react-modal
with thefull
preset (depending on afull
package)yargs
with thesafe
preset (depending on asafe
package)yargs-parser
(safe
)
- TypeScript standard libraries (
- The bindings will be placed into
output/test_jsoo/
- Copy the bindings to
test/jsoo/src/
- Perform
dune build
intest/jsoo/
Test the tool for ReScript
target
- Generate bindings for the following packages:
- TypeScript standard libraries (
node_modules/typescript/lib/lib.*.d.ts
) typescript
with thefull
preset (involving a lot of inheritance)react
with thefull
preset (depending on bothfull
packages andsafe
packages)scheduler/tracing
(safe
)csstype
(full
)prop-types
(safe
)
react-modal
with thefull
preset (depending on afull
package)yargs
with thesafe
preset (depending on asafe
package)yargs-parser
(safe
)
- TypeScript standard libraries (
- The bindings will be placed into
output/test_res/
- Copy the bindings to
test/res/src/generated/
- Perform
yarn build
intest/res/
Tests for other targets will be added here
./fake publish
builds the tool, runs the tests, and then performs the followings:
Prepare for publishing the standard library for js_of_ocaml
target to the jsoo-stdlib
branch
- Copy
ts2ocaml_*.mli
fromoutput/test_jsoo/
todist/jsoo/src/
- Copy
ts2ocaml_*.ml
fromtest/jsoo/_build/default/src/
todist/jsoo/src/
- Set the correct
version
indist/jsoo/dune-project
- Perform
dune build
indist/jsoo/
to generate.opam
file and check if it compiles
GitHub Action publish.yml
is configured to push the dist/jsoo
directory to the jsoo-stdlib
branch.
- Set the correct
version
inpackage.json
GitHub Action publish.yml
is configured to publish ts2ocaml
to NPM.