diff --git a/.prettierignore b/.prettierignore index 2abbfb6d7f..0bbd3c3b32 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,4 +1,3 @@ -docs/ jscomp/ lib/ vendor/ diff --git a/docs/docson/build-schema.json b/docs/docson/build-schema.json index fb59a6e119..01f67555da 100644 --- a/docs/docson/build-schema.json +++ b/docs/docson/build-schema.json @@ -1,553 +1,532 @@ { - "$schema": "http://json-schema.org/draft-04/schema#", - "definitions": { - "module-format": { - "enum": [ - "commonjs", - "es6", - "es6-global" - ], - "description": "es6-global generate relative `require` paths instead of relying on NodeJS' module resolution. Default: commonjs." - }, - "suffix-spec" : { - "enum" : [ - ".js", - ".bs.js", - ".mjs", - ".cjs" - ], - "description": "suffix of generated js files, default to [.js] " - }, - "module-format-object": { - "type": "object", - "properties": { - "module": { - "$ref": "#/definitions/module-format" - }, - "in-source": { - "type": "boolean", - "description": "Default: false." - }, - "suffix" : { - "$ref" : "#/definitions/suffix-spec" - } - }, - "required": [ - "module" - ] - }, - "package-spec": { - "oneOf": [ - { - "$ref": "#/definitions/module-format" - }, - { - "$ref": "#/definitions/module-format-object" - } - ] - }, - "namespace-spec" : { - "oneOf" : [ - { - "type" : "boolean", - "description": "true to use the package name as namespace, false to not use" - }, - { - "type" : "string", - "description": "provide customized namespace name" - } - ] - }, - "package-specs": { - "oneOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/package-spec" - } - }, - { - "$ref": "#/definitions/package-spec" - } - ] - }, - "reanalyze": { - "type": "object", - "properties": { - "analysis": { - "type": "array", - "items": { - "enum": ["dce", "exception", "termination"] - }, - "description": "The types of analysis to activate. `dce` means dead code analysis, `exception` means exception analysis, and `termination` is to check for infinite loops." - }, - "suppress": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Paths for any folders you'd like to exclude from analysis. Useful for bindings and similar. Example: `[\"src/bindings\"]`." - }, - "unsuppress": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Any specific paths inside suppressed folders that you want to unsuppress. Example: [\"src/bindings/SomeBinding.res\"]." - } - } - }, - "react-jsx-version": { - "title": "jsx-version", - "type": "number", - "description": "backward compatible mode, true means on with the default to be version 1 (the default value is subject to change)" - }, - "ppx-specs": { - "type": "array", - "items": { - "oneOf" : [ - { - "type": "string" - }, - { - "type" : "array", - "items": { - "type" : "string" - } - } - ] - - } + "$schema": "http://json-schema.org/draft-04/schema#", + "definitions": { + "module-format": { + "enum": ["commonjs", "es6", "es6-global"], + "description": "es6-global generate relative `require` paths instead of relying on NodeJS' module resolution. Default: commonjs." + }, + "suffix-spec": { + "enum": [".js", ".bs.js", ".mjs", ".cjs"], + "description": "suffix of generated js files, default to [.js] " + }, + "module-format-object": { + "type": "object", + "properties": { + "module": { + "$ref": "#/definitions/module-format" + }, + "in-source": { + "type": "boolean", + "description": "Default: false." + }, + "suffix": { + "$ref": "#/definitions/suffix-spec" + } + }, + "required": ["module"] + }, + "package-spec": { + "oneOf": [ + { + "$ref": "#/definitions/module-format" }, - "pp-specs": { + { + "$ref": "#/definitions/module-format-object" + } + ] + }, + "namespace-spec": { + "oneOf": [ + { + "type": "boolean", + "description": "true to use the package name as namespace, false to not use" + }, + { + "type": "string", + "description": "provide customized namespace name" + } + ] + }, + "package-specs": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/package-spec" + } + }, + { + "$ref": "#/definitions/package-spec" + } + ] + }, + "reanalyze": { + "type": "object", + "properties": { + "analysis": { + "type": "array", + "items": { + "enum": ["dce", "exception", "termination"] + }, + "description": "The types of analysis to activate. `dce` means dead code analysis, `exception` means exception analysis, and `termination` is to check for infinite loops." + }, + "suppress": { + "type": "array", + "items": { "type": "string" + }, + "description": "Paths for any folders you'd like to exclude from analysis. Useful for bindings and similar. Example: `[\"src/bindings\"]`." }, - "bs-dependency": { - "type": "string", - "title": "dependency" - }, - "dependencies": { + "unsuppress": { + "type": "array", + "items": { + "type": "string" + }, + "description": "Any specific paths inside suppressed folders that you want to unsuppress. Example: [\"src/bindings/SomeBinding.res\"]." + } + } + }, + "react-jsx-version": { + "title": "jsx-version", + "type": "number", + "description": "backward compatible mode, true means on with the default to be version 1 (the default value is subject to change)" + }, + "ppx-specs": { + "type": "array", + "items": { + "oneOf": [ + { + "type": "string" + }, + { "type": "array", "items": { - "$ref": "#/definitions/bs-dependency" + "type": "string" } + } + ] + } + }, + "pp-specs": { + "type": "string" + }, + "bs-dependency": { + "type": "string", + "title": "dependency" + }, + "dependencies": { + "type": "array", + "items": { + "$ref": "#/definitions/bs-dependency" + } + }, + "js-post-build": { + "type": "object", + "properties": { + "cmd": { + "type": "string" + } + } + }, + "rule-generator": { + "type": "object", + "properties": { + "name": { + "type": "string" }, - "js-post-build": { - "type": "object", - "properties": { - "cmd": { - "type": "string" - } - } + "command": { + "type": "string" + } + }, + "description": "The shell command is running in *dev* time, and you generated could should be checked in, the depedency is tracked properly during dev time,example: `{ \"name\" : \"ocamllex\", \"command\" : \"ocamllex.opt $in -o $out\"}`" + }, + "build-generator": { + "type": "object", + "properties": { + "name": { + "type": "string" }, - "rule-generator": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "command": { - "type": "string" - } + "edge": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "description": "Note that we will add the directory path accordingly" + }, + "sourceItem": { + "title": "sourceItem", + "oneOf": [ + { + "type": "object", + "properties": { + "dir": { + "type": "string", + "description": "name of the directory" }, - "description": "The shell command is running in *dev* time, and you generated could should be checked in, the depedency is tracked properly during dev time,example: `{ \"name\" : \"ocamllex\", \"command\" : \"ocamllex.opt $in -o $out\"}`" - }, - "build-generator": { - "type": "object", - "properties": { - "name": { + + "type": { + "enum": ["dev"] + }, + "files": { + "oneOf": [ + { + "type": "array", + "items": { "type": "string" + }, + "description": "if files are empty, the build system will populate it automatically. Useful for initial build" }, - "edge": { - "type": "array", - "items": { + { + "type": "object", + "properties": { + "slow-re": { + "type": "string", + "description": "Regex to glob the patterns, syntax is documented [here](http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html), for better incremental build performance, we'd suggest listing files explicitly" + }, + "excludes": { + "type": "array", + "items": { "type": "string" + }, + "description": "Files to be excluded" } + } } + ] }, - "description": "Note that we will add the directory path accordingly" - }, - "sourceItem": { - "title": "sourceItem", - "oneOf": [ - { - "type": "object", - "properties": { - "dir": { - "type": "string", - "description": "name of the directory" - }, - - "type": { - "enum": [ - "dev" - ] - }, - "files": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string" - }, - "description": "if files are empty, the build system will populate it automatically. Useful for initial build" - }, - { - "type": "object", - "properties": { - "slow-re": { - "type": "string", - "description": "Regex to glob the patterns, syntax is documented [here](http://caml.inria.fr/pub/docs/manual-ocaml/libref/Str.html), for better incremental build performance, we'd suggest listing files explicitly" - }, - "excludes": { - "type": "array", - "items": { - "type": "string" - }, - "description": "Files to be excluded" - } - } - } - ] - }, - "generators": { - "type": "array", - "items": { - "$ref": "#/definitions/build-generator" - }, - "description": "(WIP) Files generated in dev time" - }, - "public": { - "oneOf": [ - { - "type": "array", - "items": { - "type": "string" - }, - "description": "Selected modules, for example, [Module_a, Module_b] " - }, - { - "enum": [ - "all" - ] - } - ], - "description": "Default: export all modules. It is recommended for library developers to hide some files/interfaces" - }, - "resources": { - "type": "array", - "items": { - "type": "string" - } - }, - "subdirs": { - "title": "Sub directories", - "oneOf": [ - { - "$ref": "#/definitions/sources", - "description": "More source directories" - }, - { - "type": "boolean", - "description": "true means traverse to all subdirs" - } - ] - }, - "group": { - "oneOf": [ - { - "type": "string", - "description": "A _unique_ name for each directory to refer as an internal dependency later" - }, - { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "hierachy": { - "type": "boolean", - "description": "When true, all subdirs are considered as a whole as dependency" - } - } - } - ], - "description": "Not implemented yet" - }, - "internal-depends": { - "type": "array", - "items": { - "type": "string", - "description": "internal dependencies, if unspecified, all existing listed source files are considered potential dependencies" - } - } - }, - "required": [ - "dir" - ] - }, + "generators": { + "type": "array", + "items": { + "$ref": "#/definitions/build-generator" + }, + "description": "(WIP) Files generated in dev time" + }, + "public": { + "oneOf": [ { - "title": "Single non-nested directory", + "type": "array", + "items": { "type": "string" - } - ] - }, - "sources": { - "oneOf": [ - { - "type": "array", - "items": { - "$ref": "#/definitions/sourceItem" - }, - "description": "A list of source items" + }, + "description": "Selected modules, for example, [Module_a, Module_b] " }, { - "$ref": "#/definitions/sourceItem", - "description": "A single source item" + "enum": ["all"] } - ], - "description": "Example: `\"src\"` or `[\"src\", \"test\"]` or `[{\"dir\": \"src\", \"subdirs\": [...]}]`" - }, - "targetItems": { - "type": "object", - "properties": { - "kind": { - "enum": [ - "native", - "bytecode", - "js" - ], - "description": "The compiler to use for the target" - }, - "main": { - "type": "string", - "description": "Name of the main module used as entry point for this target. 'entry-point' isn't used when this project is built as a dependency." - } - } - }, - "entries": { - "type": "array", - "items": { - "$ref": "#/definitions/targetItems" + ], + "description": "Default: export all modules. It is recommended for library developers to hide some files/interfaces" }, - "description": "A list of buildable targets" - }, - "gentype-specs" : { - "type" : "object", - "properties": { - "path" : { - "type" : "string" - } + "resources": { + "type": "array", + "items": { + "type": "string" + } }, - "description": "path to gentype, path resolution is similar to ReScript" - }, - "reason-specs": { - "type": "object", - "properties": { - "react-jsx": { - "$ref": "#/definitions/react-jsx-version", - "description": "Whether to apply the [RescriptReact](https://github.com/rescript-lang/rescript-react)-specific JSX PPX transformation." - } - } - }, - "jsx-specs": { - "type": "object", - "properties": { - "version": { - "type": "number", - "enum": [3, 4], - "description": "Whether to apply the specific version of JSX PPX transformation" - }, - "module": { - "type": "string", - "enum": ["react"], - "description": "JSX module, currently only support the React." - }, - "mode": { - "type": "string", - "enum": ["classic", "automatic"], - "description": "JSX transformation mode" - } - } - }, - "refmt-specs": { - "oneOf": [ + "subdirs": { + "title": "Sub directories", + "oneOf": [ { - "type": "number", - "enum": [2, 3], - "description": "Reason syntax version to use. Prefer 3. Default: 2, for backward-compatiblity" + "$ref": "#/definitions/sources", + "description": "More source directories" }, { - "type": "string", - "description": "(Usually not needed) Alternative path to `refmt`, the Reason syntax binary. Default: path to the `refmt.exe` ReScript provides out of the box" + "type": "boolean", + "description": "true means traverse to all subdirs" } - ] - }, - "bsc-flags": { - "oneOf": [ + ] + }, + "group": { + "oneOf": [ { - "type": "array", - "items": { - "type": "string" - }, - "description": "Default: `[\"-no-alias-deps\"]`" + "type": "string", + "description": "A _unique_ name for each directory to refer as an internal dependency later" }, { - "type": "object", - "properties": { - "kind": { - "enum": [ - "reset", - "prefix", - "append" - ] - }, - "flags": { - "type": "array", - "items": { - "type": "string" - } - } + "type": "object", + "properties": { + "name": { + "type": "string" }, - "description": "(Not implemented yet)" + "hierachy": { + "type": "boolean", + "description": "When true, all subdirs are considered as a whole as dependency" + } + } } - ] + ], + "description": "Not implemented yet" + }, + "internal-depends": { + "type": "array", + "items": { + "type": "string", + "description": "internal dependencies, if unspecified, all existing listed source files are considered potential dependencies" + } + } + }, + "required": ["dir"] + }, + { + "title": "Single non-nested directory", + "type": "string" + } + ] + }, + "sources": { + "oneOf": [ + { + "type": "array", + "items": { + "$ref": "#/definitions/sourceItem" + }, + "description": "A list of source items" + }, + { + "$ref": "#/definitions/sourceItem", + "description": "A single source item" } + ], + "description": "Example: `\"src\"` or `[\"src\", \"test\"]` or `[{\"dir\": \"src\", \"subdirs\": [...]}]`" }, - "title": "ReScript build configuration", - "description": "All paths are required to be in **Unix format** (foo/bar), the build system normalizes them for other platforms internally", - "type": "object", - "properties": { + "targetItems": { + "type": "object", + "properties": { + "kind": { + "enum": ["native", "bytecode", "js"], + "description": "The compiler to use for the target" + }, + "main": { + "type": "string", + "description": "Name of the main module used as entry point for this target. 'entry-point' isn't used when this project is built as a dependency." + } + } + }, + "entries": { + "type": "array", + "items": { + "$ref": "#/definitions/targetItems" + }, + "description": "A list of buildable targets" + }, + "gentype-specs": { + "type": "object", + "properties": { + "path": { + "type": "string" + } + }, + "description": "path to gentype, path resolution is similar to ReScript" + }, + "reason-specs": { + "type": "object", + "properties": { + "react-jsx": { + "$ref": "#/definitions/react-jsx-version", + "description": "Whether to apply the [RescriptReact](https://github.com/rescript-lang/rescript-react)-specific JSX PPX transformation." + } + } + }, + "jsx-specs": { + "type": "object", + "properties": { "version": { - "type": "string", - "description": "The semantic version of the ReScript library" - }, - "name": { - "type": "string", - "description": "Package name" - }, - "namespace": { - "$ref": "#/definitions/namespace-spec", - "description": "can be true/false or a customized name" - }, - "sources": { - "$ref": "#/definitions/sources", - "description": "Source code location" - }, - "ignored-dirs" : { - "type" : "array", - "items": { - "type" : "string" - }, - "description": "a list of directories that bsb will not look into" - }, - "bs-dependencies": { - "$ref": "#/definitions/dependencies", - "description": "ReScript dependencies of the library, like in package.json. Currently searches in `node_modules`" - }, - "bs-dev-dependencies": { - "$ref": "#/definitions/dependencies", - "description": "ReScript dev dependencies of the library, like in package.json. Currently searches in `node_modules`" - }, - "pinned-dependencies" : { - "$ref": "#/definitions/dependencies", - "description": "Those dependencies are pinned (since version 8.4)" - }, - "generators": { - "type": "array", - "items": { - "$ref": "#/definitions/rule-generator" - }, - "description": "(WIP) Pre defined rules" - }, - "cut-generators": { - "type": "boolean", - "description": "Ignore generators, cut the dependency on generator tools" - }, - "reason": { - "$ref": "#/definitions/reason-specs", - "description": "ReScript comes with [Reason](http://reasonml.github.io/) by default. Specific configurations here." - }, - "gentypeconfig": { - "$ref" : "#/definitions/gentype-specs", - "description": "gentype config, see cristianoc/genType for more details" - }, - "bsc-flags": { - "$ref": "#/definitions/bsc-flags", - "description": "Flags passed to bsc.exe" - }, - "warnings": { - "type": "object", - "properties": { - "number": { - "type": "string", - "description": "Default: -40+6+7+27+32..39+44+45 [Here](https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec270) for the meanings of the warning flags" - }, - "error": { - "oneOf": [ - { - "type": "boolean", - "description": "True means warn is error(default)" - }, - { - "type": "string", - "description": "Same as warning number but different set" - } - ] - } + "type": "number", + "enum": [3, 4], + "description": "Whether to apply the specific version of JSX PPX transformation" + }, + "module": { + "type": "string", + "enum": ["react"], + "description": "JSX module, currently only support the React." + }, + "mode": { + "type": "string", + "enum": ["classic", "automatic"], + "description": "JSX transformation mode" + }, + "preserve-dependencies": { + "$ref": "#/definitions/dependencies", + "description": "Don't propagate the jsx configuration to these dependencies." + } + } + }, + "refmt-specs": { + "oneOf": [ + { + "type": "number", + "enum": [2, 3], + "description": "Reason syntax version to use. Prefer 3. Default: 2, for backward-compatiblity" + }, + { + "type": "string", + "description": "(Usually not needed) Alternative path to `refmt`, the Reason syntax binary. Default: path to the `refmt.exe` ReScript provides out of the box" + } + ] + }, + "bsc-flags": { + "oneOf": [ + { + "type": "array", + "items": { + "type": "string" + }, + "description": "Default: `[\"-no-alias-deps\"]`" + }, + { + "type": "object", + "properties": { + "kind": { + "enum": ["reset", "prefix", "append"] }, - "description": "warning numbers and whether to turn it into error or not" - }, - "ppx-flags": { - "$ref": "#/definitions/ppx-specs", - "description": "PPX macros to pass to compiler. The syntax is package_name/binary, for example: `reason/reactjs_jsx_ppx_3.native`. Currenly searches in `node_modules`" - }, - "pp-flags": { - "$ref": "#/definitions/pp-specs", - "description": "preprocessors to pass to compiler. The syntax is package_name/binary, for example: `pp/syntax.exe`. Currenly searches in `node_modules`" - }, - "js-post-build": { - "$ref": "#/definitions/js-post-build", - "description": "(Experimental) post-processing hook. bsb will invoke `cmd ${file}` whenever a `${file}` is changed" - }, - "package-specs": { - "$ref": "#/definitions/package-specs", - "description": "ReScript can currently output to [Commonjs](https://en.wikipedia.org/wiki/CommonJS), and [ES6 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)" - }, - "entries": { - "$ref": "#/definitions/entries", - "description": "(internal) Used by bsb to build to different targets: native (ocamlopt), bytecode (ocamlc) or JS (bsc)" - }, - "generate-merlin": { - "type": "boolean", - "description": "Whether to generate the `.merlin` file for [Merlin](https://github.com/ocaml/merlin). Default: true" - }, - "use-stdlib": { - "type": "boolean", - "description": "(Experimental) whether to use the OCaml standard library. Default: true" - }, - "external-stdlib" : { - "type" : "string", - "description": "Use the external stdlib library instead of the one shipped with the compiler package" - }, - "bs-external-includes": { - "type": "array", - "items": { + "flags": { + "type": "array", + "items": { "type": "string" + } + } + }, + "description": "(Not implemented yet)" + } + ] + } + }, + "title": "ReScript build configuration", + "description": "All paths are required to be in **Unix format** (foo/bar), the build system normalizes them for other platforms internally", + "type": "object", + "properties": { + "version": { + "type": "string", + "description": "The semantic version of the ReScript library" + }, + "name": { + "type": "string", + "description": "Package name" + }, + "namespace": { + "$ref": "#/definitions/namespace-spec", + "description": "can be true/false or a customized name" + }, + "sources": { + "$ref": "#/definitions/sources", + "description": "Source code location" + }, + "ignored-dirs": { + "type": "array", + "items": { + "type": "string" + }, + "description": "a list of directories that bsb will not look into" + }, + "bs-dependencies": { + "$ref": "#/definitions/dependencies", + "description": "ReScript dependencies of the library, like in package.json. Currently searches in `node_modules`" + }, + "bs-dev-dependencies": { + "$ref": "#/definitions/dependencies", + "description": "ReScript dev dependencies of the library, like in package.json. Currently searches in `node_modules`" + }, + "pinned-dependencies": { + "$ref": "#/definitions/dependencies", + "description": "Those dependencies are pinned (since version 8.4)" + }, + "generators": { + "type": "array", + "items": { + "$ref": "#/definitions/rule-generator" + }, + "description": "(WIP) Pre defined rules" + }, + "cut-generators": { + "type": "boolean", + "description": "Ignore generators, cut the dependency on generator tools" + }, + "jsx": { + "$ref": "#/definitions/jsx-specs", + "description": "Configuration for the JSX transformation." + }, + "reason": { + "$ref": "#/definitions/reason-specs", + "description": "ReScript comes with [Reason](http://reasonml.github.io/) by default. Specific configurations here." + }, + "gentypeconfig": { + "$ref": "#/definitions/gentype-specs", + "description": "gentype config, see cristianoc/genType for more details" + }, + "bsc-flags": { + "$ref": "#/definitions/bsc-flags", + "description": "Flags passed to bsc.exe" + }, + "warnings": { + "type": "object", + "properties": { + "number": { + "type": "string", + "description": "Default: -40+6+7+27+32..39+44+45 [Here](https://caml.inria.fr/pub/docs/manual-ocaml/comp.html#sec270) for the meanings of the warning flags" + }, + "error": { + "oneOf": [ + { + "type": "boolean", + "description": "True means warn is error(default)" }, - "description": "(Not needed usually) external include directories, which will be applied `-I` to all compilation units" - }, - "suffix" : { - "$ref" : "#/definitions/suffix-spec" - }, - "reanalyze": { - "$ref": "#/definitions/reanalyze", - "description": "Configure reanalyze, a static code analysis tool for ReScript." + { + "type": "string", + "description": "Same as warning number but different set" + } + ] } + }, + "description": "warning numbers and whether to turn it into error or not" + }, + "ppx-flags": { + "$ref": "#/definitions/ppx-specs", + "description": "PPX macros to pass to compiler. The syntax is package_name/binary, for example: `reason/reactjs_jsx_ppx_3.native`. Currenly searches in `node_modules`" + }, + "pp-flags": { + "$ref": "#/definitions/pp-specs", + "description": "preprocessors to pass to compiler. The syntax is package_name/binary, for example: `pp/syntax.exe`. Currenly searches in `node_modules`" + }, + "js-post-build": { + "$ref": "#/definitions/js-post-build", + "description": "(Experimental) post-processing hook. bsb will invoke `cmd ${file}` whenever a `${file}` is changed" + }, + "package-specs": { + "$ref": "#/definitions/package-specs", + "description": "ReScript can currently output to [Commonjs](https://en.wikipedia.org/wiki/CommonJS), and [ES6 modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import)" + }, + "entries": { + "$ref": "#/definitions/entries", + "description": "(internal) Used by bsb to build to different targets: native (ocamlopt), bytecode (ocamlc) or JS (bsc)" + }, + "generate-merlin": { + "type": "boolean", + "description": "Whether to generate the `.merlin` file for [Merlin](https://github.com/ocaml/merlin). Default: true" + }, + "use-stdlib": { + "type": "boolean", + "description": "(Experimental) whether to use the OCaml standard library. Default: true" + }, + "external-stdlib": { + "type": "string", + "description": "Use the external stdlib library instead of the one shipped with the compiler package" + }, + "bs-external-includes": { + "type": "array", + "items": { + "type": "string" + }, + "description": "(Not needed usually) external include directories, which will be applied `-I` to all compilation units" + }, + "suffix": { + "$ref": "#/definitions/suffix-spec" }, - "additionalProperties": false, - "required": [ - "name", - "sources" - ] + "reanalyze": { + "$ref": "#/definitions/reanalyze", + "description": "Configure reanalyze, a static code analysis tool for ReScript." + } + }, + "additionalProperties": false, + "required": ["name", "sources"] } diff --git a/jscomp/bsb/bsb_build_schemas.ml b/jscomp/bsb/bsb_build_schemas.ml index a25e3d4b21..b0288d46a7 100644 --- a/jscomp/bsb/bsb_build_schemas.ml +++ b/jscomp/bsb/bsb_build_schemas.ml @@ -24,110 +24,59 @@ (* let files = "files" *) let version = "version" - let name = "name" (* let ocaml_config = "ocaml-config" *) let bsdep = "bsdep" - let ppx_flags = "ppx-flags" - let pp_flags = "pp-flags" - let bsc = "bsc" - let bs_external_includes = "bs-external-includes" - let bs_lib_dir = "bs-lib-dir" - let bs_dependencies = "bs-dependencies" - let pinned_dependencies = "pinned-dependencies" - let bs_dev_dependencies = "bs-dev-dependencies" - let sources = "sources" - let dir = "dir" - let files = "files" - let subdirs = "subdirs" - let bsc_flags = "bsc-flags" - let excludes = "excludes" - let slow_re = "slow-re" - let resources = "resources" - let public = "public" - let js_post_build = "js-post-build" - let cmd = "cmd" - let ninja = "ninja" - let package_specs = "package-specs" - let generate_merlin = "generate-merlin" - let type_ = "type" - let dev = "dev" - let export_all = "all" - let export_none = "none" - let use_stdlib = "use-stdlib" - let external_stdlib = "external-stdlib" - let reason = "reason" - let react_jsx = "react-jsx" - let jsx = "jsx" - let jsx_version = "version" - let jsx_module = "module" - let jsx_mode = "mode" - +let jsx_preserve_dependencies = "preserve-dependencies" let entries = "entries" - let backend = "backend" - let main_module = "main-module" - let cut_generators = "cut-generators" - let generators = "generators" - let command = "command" - let edge = "edge" - let namespace = "namespace" - let in_source = "in-source" - let warnings = "warnings" - let number = "number" - let error = "error" - let suffix = "suffix" - let gentypeconfig = "gentypeconfig" - let language = "language" - let path = "path" - let ignored_dirs = "ignored-dirs" diff --git a/jscomp/bsb/bsb_clean.ml b/jscomp/bsb/bsb_clean.ml index e49d7a71a4..32c67dc17d 100644 --- a/jscomp/bsb/bsb_clean.ml +++ b/jscomp/bsb/bsb_clean.ml @@ -51,9 +51,7 @@ let clean_bs_garbage proj_dir = Bsb_log.warn "@{Failed@} to clean due to %s" (Printexc.to_string e) let clean_bs_deps proj_dir = - let _, pinned_dependencies = - Bsb_config_parse.package_specs_from_bsconfig () - in + let _, _, pinned_dependencies = Bsb_config_parse.deps_from_bsconfig () in let queue = Bsb_build_util.walk_all_deps proj_dir ~pinned_dependencies in Queue.iter (fun (pkg_cxt : Bsb_build_util.package_context) -> diff --git a/jscomp/bsb/bsb_config_parse.ml b/jscomp/bsb/bsb_config_parse.ml index 3060533691..64d99ee398 100644 --- a/jscomp/bsb/bsb_config_parse.ml +++ b/jscomp/bsb/bsb_config_parse.ml @@ -325,14 +325,19 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string) package_specs = (match package_kind with | Toplevel -> Bsb_package_specs.from_map ~cwd:per_proj_dir map - | Pinned_dependency x | Dependency x -> x); + | Pinned_dependency x | Dependency x -> x.package_specs); file_groups = groups; files_to_install = Queue.create (); built_in_dependency = built_in_package; generate_merlin = extract_boolean map Bsb_build_schemas.generate_merlin false; reason_react_jsx; - jsx = Bsb_jsx.from_map map; + jsx = + (match package_kind with + | (Pinned_dependency x | Dependency x) + when not (List.mem package_name x.jsx.preserve_dependencies) -> + x.jsx + | _ -> Bsb_jsx.from_map map); generators = extract_generators map; cut_generators; } @@ -340,10 +345,11 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string) Bsb_exception.invalid_spec "no sources specified in bsconfig.json") | _ -> Bsb_exception.invalid_spec "bsconfig.json expect a json object {}" -let package_specs_from_bsconfig () = +let deps_from_bsconfig () = let json = Ext_json_parse.parse_json_from_file Literals.bsconfig_json in match json with | Obj { map } -> ( Bsb_package_specs.from_map ~cwd:Bsb_global_paths.cwd map, + Bsb_jsx.from_map map, extract_pinned_dependencies map ) | _ -> assert false diff --git a/jscomp/bsb/bsb_config_parse.mli b/jscomp/bsb/bsb_config_parse.mli index 8b30984de3..c6667e259f 100644 --- a/jscomp/bsb/bsb_config_parse.mli +++ b/jscomp/bsb/bsb_config_parse.mli @@ -22,7 +22,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val package_specs_from_bsconfig : unit -> Bsb_package_specs.t * Set_string.t +val deps_from_bsconfig : unit -> Bsb_package_specs.t * Bsb_jsx.t * Set_string.t val interpret_json : package_kind:Bsb_package_kind.t -> per_proj_dir:string -> Bsb_config_types.t diff --git a/jscomp/bsb/bsb_jsx.ml b/jscomp/bsb/bsb_jsx.ml index ce1e311d7f..f6413cad9e 100644 --- a/jscomp/bsb/bsb_jsx.ml +++ b/jscomp/bsb/bsb_jsx.ml @@ -1,20 +1,41 @@ type version = Jsx_v3 | Jsx_v4 type module_ = React type mode = Classic | Automatic +type dependencies = string list type t = { version : version option; module_ : module_ option; mode : mode option; + preserve_dependencies : dependencies; } +let encode_no_nl jsx = + (match jsx.version with + | None -> "" + | Some Jsx_v3 -> "3" + | Some Jsx_v4 -> "4") + ^ (match jsx.module_ with None -> "" | Some React -> "React") + ^ + match jsx.mode with + | None -> "" + | Some Classic -> "Classic" + | Some Automatic -> "Automatic" + let ( .?() ) = Map_string.find_opt let ( |? ) m (key, cb) = m |> Ext_json.test key cb +let get_list_string_acc (s : Ext_json_types.t array) acc = + Ext_array.to_list_map_acc s acc (fun x -> + match x with Str x -> Some x.str | _ -> None) + +let get_list_string s = get_list_string_acc s [] + let from_map map = let version : version option ref = ref None in let module_ : module_ option ref = ref None in let mode : mode option ref = ref None in + let preserve_dependencies : dependencies ref = ref [] in map |? ( Bsb_build_schemas.jsx, `Obj @@ -24,11 +45,11 @@ let from_map map = match flo with | "3" -> version := Some Jsx_v3 | "4" -> version := Some Jsx_v4 - | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-version %s" flo + | _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo ) | Some x -> Bsb_exception.config_error x - "Unexpected input (expect a version number) for jsx-version" + "Unexpected input (expect a version number) for jsx version" | None -> ()) ) |? ( Bsb_build_schemas.jsx, `Obj @@ -37,10 +58,10 @@ let from_map map = | Some (Str { loc; str }) -> ( match str with | "react" -> module_ := Some React - | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-module %s" str) + | _ -> Bsb_exception.errorf ~loc "Unsupported jsx module %s" str) | Some x -> Bsb_exception.config_error x - "Unexpected input (jsx module name) for jsx-mode" + "Unexpected input (jsx module name) for jsx module" | None -> ()) ) |? ( Bsb_build_schemas.jsx, `Obj @@ -50,10 +71,25 @@ let from_map map = match str with | "classic" -> mode := Some Classic | "automatic" -> mode := Some Automatic - | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-mode %s" str) + | _ -> Bsb_exception.errorf ~loc "Unsupported jsx mode %s" str) + | Some x -> + Bsb_exception.config_error x + "Unexpected input (expect classic or automatic) for jsx mode" + | None -> ()) ) + |? ( Bsb_build_schemas.jsx, + `Obj + (fun m -> + match m.?(Bsb_build_schemas.jsx_preserve_dependencies) with + | Some (Arr { content }) -> + preserve_dependencies := get_list_string content | Some x -> Bsb_exception.config_error x - "Unexpected input (expect classic or automatic) for jsx-mode" + "Unexpected input for jsx preserve-dependencies" | None -> ()) ) |> ignore; - { version = !version; module_ = !module_; mode = !mode } + { + version = !version; + module_ = !module_; + mode = !mode; + preserve_dependencies = !preserve_dependencies; + } diff --git a/jscomp/bsb/bsb_package_kind.ml b/jscomp/bsb/bsb_package_kind.ml index a3e20452ab..0f4f74802e 100644 --- a/jscomp/bsb/bsb_package_kind.ml +++ b/jscomp/bsb/bsb_package_kind.ml @@ -22,10 +22,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type dep_payload = { package_specs : Bsb_package_specs.t; jsx : Bsb_jsx.t } + type t = | Toplevel - | Dependency of Bsb_package_specs.t - | Pinned_dependency of Bsb_package_specs.t + | Dependency of dep_payload + | Pinned_dependency of dep_payload (* This package specs comes from the toplevel to override the current settings *) @@ -34,6 +36,12 @@ let encode_no_nl (x : t) = match x with | Toplevel -> "0" | Dependency x -> - "1" ^ Bsb_package_specs.package_flag_of_package_specs x ~dirname:"." + "1" + ^ Bsb_package_specs.package_flag_of_package_specs x.package_specs + ~dirname:"." + ^ Bsb_jsx.encode_no_nl x.jsx | Pinned_dependency x -> - "2" ^ Bsb_package_specs.package_flag_of_package_specs x ~dirname:"." + "2" + ^ Bsb_package_specs.package_flag_of_package_specs x.package_specs + ~dirname:"." + ^ Bsb_jsx.encode_no_nl x.jsx diff --git a/jscomp/bsb/bsb_world.ml b/jscomp/bsb/bsb_world.ml index f092d1335b..805ed87c0d 100644 --- a/jscomp/bsb/bsb_world.ml +++ b/jscomp/bsb/bsb_world.ml @@ -23,20 +23,20 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) let ( // ) = Ext_path.combine - let vendor_ninja = Bsb_global_paths.vendor_ninja let make_world_deps cwd (config : Bsb_config_types.t option) (ninja_args : string array) = - let deps, pinned_dependencies = + let package_specs, jsx, pinned_dependencies = match config with | None -> (* When this running bsb does not read bsconfig.json, we will read such json file to know which [package-specs] it wants *) - Bsb_config_parse.package_specs_from_bsconfig () - | Some config -> (config.package_specs, config.pinned_dependencies) + Bsb_config_parse.deps_from_bsconfig () + | Some config -> + (config.package_specs, config.jsx, config.pinned_dependencies) in let args = if Ext_array.is_empty ninja_args then [| vendor_ninja |] @@ -68,8 +68,8 @@ let make_world_deps cwd (config : Bsb_config_types.t option) let _config : _ option = Bsb_ninja_regen.regenerate_ninja ~package_kind: - (if is_pinned then Pinned_dependency deps - else Dependency deps) + (if is_pinned then Pinned_dependency { package_specs; jsx } + else Dependency { package_specs; jsx }) ~per_proj_dir:proj_dir ~forced:false in let command = diff --git a/lib/4.06.1/rescript.ml b/lib/4.06.1/rescript.ml index 8c7ba0bd3a..544fb2ee27 100644 --- a/lib/4.06.1/rescript.ml +++ b/lib/4.06.1/rescript.ml @@ -1710,112 +1710,61 @@ module Bsb_build_schemas (* let files = "files" *) let version = "version" - let name = "name" (* let ocaml_config = "ocaml-config" *) let bsdep = "bsdep" - let ppx_flags = "ppx-flags" - let pp_flags = "pp-flags" - let bsc = "bsc" - let bs_external_includes = "bs-external-includes" - let bs_lib_dir = "bs-lib-dir" - let bs_dependencies = "bs-dependencies" - let pinned_dependencies = "pinned-dependencies" - let bs_dev_dependencies = "bs-dev-dependencies" - let sources = "sources" - let dir = "dir" - let files = "files" - let subdirs = "subdirs" - let bsc_flags = "bsc-flags" - let excludes = "excludes" - let slow_re = "slow-re" - let resources = "resources" - let public = "public" - let js_post_build = "js-post-build" - let cmd = "cmd" - let ninja = "ninja" - let package_specs = "package-specs" - let generate_merlin = "generate-merlin" - let type_ = "type" - let dev = "dev" - let export_all = "all" - let export_none = "none" - let use_stdlib = "use-stdlib" - let external_stdlib = "external-stdlib" - let reason = "reason" - let react_jsx = "react-jsx" - let jsx = "jsx" - let jsx_version = "version" - let jsx_module = "module" - let jsx_mode = "mode" - +let jsx_preserve_dependencies = "preserve-dependencies" let entries = "entries" - let backend = "backend" - let main_module = "main-module" - let cut_generators = "cut-generators" - let generators = "generators" - let command = "command" - let edge = "edge" - let namespace = "namespace" - let in_source = "in-source" - let warnings = "warnings" - let number = "number" - let error = "error" - let suffix = "suffix" - let gentypeconfig = "gentypeconfig" - let language = "language" - let path = "path" - let ignored_dirs = "ignored-dirs" end @@ -5173,20 +5122,41 @@ module Bsb_jsx type version = Jsx_v3 | Jsx_v4 type module_ = React type mode = Classic | Automatic +type dependencies = string list type t = { version : version option; module_ : module_ option; mode : mode option; + preserve_dependencies : dependencies; } +let encode_no_nl jsx = + (match jsx.version with + | None -> "" + | Some Jsx_v3 -> "3" + | Some Jsx_v4 -> "4") + ^ (match jsx.module_ with None -> "" | Some React -> "React") + ^ + match jsx.mode with + | None -> "" + | Some Classic -> "Classic" + | Some Automatic -> "Automatic" + let ( .?() ) = Map_string.find_opt let ( |? ) m (key, cb) = m |> Ext_json.test key cb +let get_list_string_acc (s : Ext_json_types.t array) acc = + Ext_array.to_list_map_acc s acc (fun x -> + match x with Str x -> Some x.str | _ -> None) + +let get_list_string s = get_list_string_acc s [] + let from_map map = let version : version option ref = ref None in let module_ : module_ option ref = ref None in let mode : mode option ref = ref None in + let preserve_dependencies : dependencies ref = ref [] in map |? ( Bsb_build_schemas.jsx, `Obj @@ -5196,11 +5166,11 @@ let from_map map = match flo with | "3" -> version := Some Jsx_v3 | "4" -> version := Some Jsx_v4 - | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-version %s" flo + | _ -> Bsb_exception.errorf ~loc "Unsupported jsx version %s" flo ) | Some x -> Bsb_exception.config_error x - "Unexpected input (expect a version number) for jsx-version" + "Unexpected input (expect a version number) for jsx version" | None -> ()) ) |? ( Bsb_build_schemas.jsx, `Obj @@ -5209,10 +5179,10 @@ let from_map map = | Some (Str { loc; str }) -> ( match str with | "react" -> module_ := Some React - | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-module %s" str) + | _ -> Bsb_exception.errorf ~loc "Unsupported jsx module %s" str) | Some x -> Bsb_exception.config_error x - "Unexpected input (jsx module name) for jsx-mode" + "Unexpected input (jsx module name) for jsx module" | None -> ()) ) |? ( Bsb_build_schemas.jsx, `Obj @@ -5222,13 +5192,28 @@ let from_map map = match str with | "classic" -> mode := Some Classic | "automatic" -> mode := Some Automatic - | _ -> Bsb_exception.errorf ~loc "Unsupported jsx-mode %s" str) + | _ -> Bsb_exception.errorf ~loc "Unsupported jsx mode %s" str) + | Some x -> + Bsb_exception.config_error x + "Unexpected input (expect classic or automatic) for jsx mode" + | None -> ()) ) + |? ( Bsb_build_schemas.jsx, + `Obj + (fun m -> + match m.?(Bsb_build_schemas.jsx_preserve_dependencies) with + | Some (Arr { content }) -> + preserve_dependencies := get_list_string content | Some x -> Bsb_exception.config_error x - "Unexpected input (expect classic or automatic) for jsx-mode" + "Unexpected input for jsx preserve-dependencies" | None -> ()) ) |> ignore; - { version = !version; module_ = !module_; mode = !mode } + { + version = !version; + module_ = !module_; + mode = !mode; + preserve_dependencies = !preserve_dependencies; + } end module Ext_module_system @@ -7920,10 +7905,12 @@ module Bsb_package_kind * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) +type dep_payload = { package_specs : Bsb_package_specs.t; jsx : Bsb_jsx.t } + type t = | Toplevel - | Dependency of Bsb_package_specs.t - | Pinned_dependency of Bsb_package_specs.t + | Dependency of dep_payload + | Pinned_dependency of dep_payload (* This package specs comes from the toplevel to override the current settings *) @@ -7932,9 +7919,15 @@ let encode_no_nl (x : t) = match x with | Toplevel -> "0" | Dependency x -> - "1" ^ Bsb_package_specs.package_flag_of_package_specs x ~dirname:"." + "1" + ^ Bsb_package_specs.package_flag_of_package_specs x.package_specs + ~dirname:"." + ^ Bsb_jsx.encode_no_nl x.jsx | Pinned_dependency x -> - "2" ^ Bsb_package_specs.package_flag_of_package_specs x ~dirname:"." + "2" + ^ Bsb_package_specs.package_flag_of_package_specs x.package_specs + ~dirname:"." + ^ Bsb_jsx.encode_no_nl x.jsx end module Bsc_warnings @@ -10293,7 +10286,7 @@ module Bsb_config_parse : sig * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) -val package_specs_from_bsconfig : unit -> Bsb_package_specs.t * Set_string.t +val deps_from_bsconfig : unit -> Bsb_package_specs.t * Bsb_jsx.t * Set_string.t val interpret_json : package_kind:Bsb_package_kind.t -> per_proj_dir:string -> Bsb_config_types.t @@ -10627,14 +10620,19 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string) package_specs = (match package_kind with | Toplevel -> Bsb_package_specs.from_map ~cwd:per_proj_dir map - | Pinned_dependency x | Dependency x -> x); + | Pinned_dependency x | Dependency x -> x.package_specs); file_groups = groups; files_to_install = Queue.create (); built_in_dependency = built_in_package; generate_merlin = extract_boolean map Bsb_build_schemas.generate_merlin false; reason_react_jsx; - jsx = Bsb_jsx.from_map map; + jsx = + (match package_kind with + | (Pinned_dependency x | Dependency x) + when not (List.mem package_name x.jsx.preserve_dependencies) -> + x.jsx + | _ -> Bsb_jsx.from_map map); generators = extract_generators map; cut_generators; } @@ -10642,11 +10640,12 @@ let interpret_json ~(package_kind : Bsb_package_kind.t) ~(per_proj_dir : string) Bsb_exception.invalid_spec "no sources specified in bsconfig.json") | _ -> Bsb_exception.invalid_spec "bsconfig.json expect a json object {}" -let package_specs_from_bsconfig () = +let deps_from_bsconfig () = let json = Ext_json_parse.parse_json_from_file Literals.bsconfig_json in match json with | Obj { map } -> ( Bsb_package_specs.from_map ~cwd:Bsb_global_paths.cwd map, + Bsb_jsx.from_map map, extract_pinned_dependencies map ) | _ -> assert false @@ -10862,9 +10861,7 @@ let clean_bs_garbage proj_dir = Bsb_log.warn "@{Failed@} to clean due to %s" (Printexc.to_string e) let clean_bs_deps proj_dir = - let _, pinned_dependencies = - Bsb_config_parse.package_specs_from_bsconfig () - in + let _, _, pinned_dependencies = Bsb_config_parse.deps_from_bsconfig () in let queue = Bsb_build_util.walk_all_deps proj_dir ~pinned_dependencies in Queue.iter (fun (pkg_cxt : Bsb_build_util.package_context) -> @@ -15085,20 +15082,20 @@ end = struct * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *) let ( // ) = Ext_path.combine - let vendor_ninja = Bsb_global_paths.vendor_ninja let make_world_deps cwd (config : Bsb_config_types.t option) (ninja_args : string array) = - let deps, pinned_dependencies = + let package_specs, jsx, pinned_dependencies = match config with | None -> (* When this running bsb does not read bsconfig.json, we will read such json file to know which [package-specs] it wants *) - Bsb_config_parse.package_specs_from_bsconfig () - | Some config -> (config.package_specs, config.pinned_dependencies) + Bsb_config_parse.deps_from_bsconfig () + | Some config -> + (config.package_specs, config.jsx, config.pinned_dependencies) in let args = if Ext_array.is_empty ninja_args then [| vendor_ninja |] @@ -15130,8 +15127,8 @@ let make_world_deps cwd (config : Bsb_config_types.t option) let _config : _ option = Bsb_ninja_regen.regenerate_ninja ~package_kind: - (if is_pinned then Pinned_dependency deps - else Dependency deps) + (if is_pinned then Pinned_dependency { package_specs; jsx } + else Dependency { package_specs; jsx }) ~per_proj_dir:proj_dir ~forced:false in let command = diff --git a/syntax b/syntax index 60a9dc7a8f..47e1782f0f 160000 --- a/syntax +++ b/syntax @@ -1 +1 @@ -Subproject commit 60a9dc7a8fbfd8bc2892959c6f5a1725ed75ea36 +Subproject commit 47e1782f0f29438b6c9adb53f2e86d0c04f211b3