diff --git a/lib_dev/process.js b/lib_dev/process.js index 0dbddd4881..cb254d8aae 100644 --- a/lib_dev/process.js +++ b/lib_dev/process.js @@ -160,7 +160,7 @@ export function setup(cwd = process.cwd()) { rescript(command, args = [], options = {}) { const cliPath = path.join( import.meta.dirname, - "../cli/rescript-legacy.js", + "../cli/rescript.js", ); return exec("node", [cliPath, command, ...args].filter(Boolean), options); }, diff --git a/packages/playground/rescript.json b/packages/playground/rescript.json index 917f2c35bb..8c165c9913 100644 --- a/packages/playground/rescript.json +++ b/packages/playground/rescript.json @@ -5,11 +5,6 @@ "dir": "src", "subdirs": true }, - "package-specs": { - "module": "esmodule", - "in-source": false, - "suffix": ".res.js" - }, "dependencies": [ "@rescript/react" ] diff --git a/rescript.json b/rescript.json index 2aa506b7b6..63ae5b7f83 100644 --- a/rescript.json +++ b/rescript.json @@ -1,4 +1,24 @@ { "name": "rescript", - "dependencies": ["@tests/gentype-react-example", "playground"] + "package-specs": [ + { + "module": "esmodule", + "in-source": true, + "suffix": ".res.js" + }, + { + "module": "esmodule", + "in-source": false, + "suffix": ".res.js" + } + ], + "jsx": { + "version": 4 + }, + "dependencies": [ + "@tests/gentype-react-example", + "@tests/docstring-tests", + "playground", + "@utils/scripts" + ] } diff --git a/scripts/format.sh b/scripts/format.sh index 6bab80eed3..2909df005e 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -6,7 +6,7 @@ echo Formatting OCaml code... dune build @fmt --auto-promote echo Formatting ReScript code... -files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*") +files=$(find runtime tests scripts/res -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*") ./cli/rescript.js format $files echo Formatting JS code... diff --git a/scripts/format_check.sh b/scripts/format_check.sh index 2c59497e92..9ce2a19906 100755 --- a/scripts/format_check.sh +++ b/scripts/format_check.sh @@ -17,7 +17,7 @@ case "$(uname -s)" in fi echo "Checking ReScript code formatting..." - files=$(find runtime tests -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*") + files=$(find runtime tests scripts/res -type f \( -name "*.res" -o -name "*.resi" \) ! -name "syntaxErrors*" ! -name "generated_mocha_test.res" ! -path "tests/syntax_tests*" ! -path "tests/analysis_tests/tests*" ! -path "*/node_modules/*") if ./cli/rescript.js format --check $files; then printf "${successGreen}✅ ReScript code formatting ok.${reset}\n" else diff --git a/scripts/res/GenApiDocs.res b/scripts/res/GenApiDocs.res index 99e7184d47..5209213c85 100644 --- a/scripts/res/GenApiDocs.res +++ b/scripts/res/GenApiDocs.res @@ -12,17 +12,16 @@ module Docgen = RescriptTools.Docgen let packagePath = Path.join([Node.dirname, "..", "..", "package.json"]) let version = switch Fs.readFileSync(packagePath, ~encoding="utf8")->JSON.parseOrThrow { - | Object(dict{"version": JSON.String(version)}) => version - | _ => JsError.panic("Invalid package.json format") +| Object(dict{"version": JSON.String(version)}) => version +| _ => JsError.panic("Invalid package.json format") } -let version = Semver.parse(version)->Option.getExn +let version = Semver.parse(version)->Option.getOrThrow let version = Semver.toString({...version, preRelease: None}) // Remove pre-release identifiers for API docs let dirVersion = Path.join([Node.dirname, "apiDocs", version]) if !Fs.existsSync(dirVersion) { Fs.mkdirSync(dirVersion) } - let entryPointFiles = ["Belt.res", "Dom.res", "Js.res", "Stdlib.res"] let hiddenModules = ["Js.Internal", "Js.MapperRt"] @@ -56,9 +55,10 @@ let docsDecoded = entryPointFiles->Array.map(libFile => }, )->Buffer.toString - let docs = output - ->JSON.parseOrThrow - ->Docgen.decodeFromJson + let docs = + output + ->JSON.parseOrThrow + ->Docgen.decodeFromJson Console.log(`Generated docs from ${libFile}`) docs } catch { @@ -257,7 +257,7 @@ let () = { tocTree ->Dict.fromArray ->JSON.stringifyAny - ->Option.getExn, + ->Option.getOrThrow, ) Console.log("Generated toc_tree.json") Console.log(`API docs generated successfully in ${dirVersion}`) diff --git a/scripts/res/package.json b/scripts/res/package.json index cbef5e568b..e650a6892b 100644 --- a/scripts/res/package.json +++ b/scripts/res/package.json @@ -3,9 +3,9 @@ "type": "module", "private": true, "scripts": { - "build": "rescript legacy build", + "build": "rescript build", "clean": "rescript clean", - "dev": "rescript legacy -w", + "dev": "rescript build -w", "apidocs:generate": "yarn build && node GenApiDocs.res.js" }, "dependencies": { diff --git a/scripts/res/rescript.json b/scripts/res/rescript.json index 31f7a5c6c3..612081d8e1 100644 --- a/scripts/res/rescript.json +++ b/scripts/res/rescript.json @@ -6,10 +6,5 @@ "dir": "./" } ], - "dependencies": ["@tests/docstring-tests"], - "package-specs": { - "module": "esmodule", - "in-source": true - }, - "suffix": ".res.js" + "dependencies": ["@tests/docstring-tests"] } diff --git a/tests/docstring_tests/package.json b/tests/docstring_tests/package.json index c7858c0599..dfefbd30be 100644 --- a/tests/docstring_tests/package.json +++ b/tests/docstring_tests/package.json @@ -3,7 +3,7 @@ "type": "module", "private": true, "scripts": { - "build": "rescript legacy build", + "build": "rescript build", "clean": "rescript clean", "dev": "rescript -w" }, diff --git a/tests/docstring_tests/rescript.json b/tests/docstring_tests/rescript.json index 19bad773ee..f258716643 100644 --- a/tests/docstring_tests/rescript.json +++ b/tests/docstring_tests/rescript.json @@ -2,10 +2,5 @@ "name": "@tests/docstring-tests", "sources": { "dir": "." - }, - "package-specs": { - "module": "esmodule", - "in-source": true - }, - "suffix": ".res.js" + } } diff --git a/tests/gentype_tests/typescript-react-example/rescript.json b/tests/gentype_tests/typescript-react-example/rescript.json index bde1f40eb8..42fd4ec0c0 100644 --- a/tests/gentype_tests/typescript-react-example/rescript.json +++ b/tests/gentype_tests/typescript-react-example/rescript.json @@ -25,10 +25,5 @@ "subdirs": true } ], - "uncurried": true, - "package-specs": { - "module": "esmodule", - "in-source": true - }, - "suffix": ".res.js" + "uncurried": true }