Skip to content

rescript.json #747

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion misc_docs/syntax/decorator_react_component.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You will need this decorator whenever you want to use a ReScript / React compone


> **Note**
> The `@react.component` decorator requires the [react-jsx or jsx config](/docs/react/latest/installation) to be set in your `bsconfig.json` to enable the required React transformations.
> The `@react.component` decorator requires the [react-jsx or jsx config](/docs/react/latest/installation) to be set in your `rescript.json` to enable the required React transformations.
### Example

Expand Down
6 changes: 3 additions & 3 deletions pages/docs/gentype/latest/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ npm install gentype --save-dev
npx gentype --help
```

Add a `gentypeconfig` section to your `bsconfig.json` (See [Configuration](#configuration) for details):
Add a `gentypeconfig` section to your `rescript.json` (See [Configuration](#configuration) for details):

```
"gentypeconfig": {
Expand All @@ -35,7 +35,7 @@ Add a `gentypeconfig` section to your `bsconfig.json` (See [Configuration](#conf
## Configuration

Every `genType` powered project requires a configuration item `"gentypeconfig"`
at top level in the project's `bsconfig.json`. The configuration has following
at top level in the project's `rescript.json`. The configuration has following
structure:

```js
Expand Down Expand Up @@ -67,7 +67,7 @@ structure:

A shim is a TS file that provides user-provided definitions for library types.

Configure your shim files within `"gentypeconfig"` in your [`bsconfig.json`](https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/bsconfig.json), and add relevant `.shims.ts` files in a directory which is visible by ReScript e.g. [`src/shims/`](https://github.com/rescript-lang/rescript-compiler/tree/master/jscomp/gentype_tests/typescript-react-example/src/shims). An example shim to export ReactEvent can be found [here](https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/src/shims/ReactEvent.shim.ts).
Configure your shim files within `"gentypeconfig"` in your [`rescript.json`](https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/rescript.json), and add relevant `.shims.ts` files in a directory which is visible by ReScript e.g. [`src/shims/`](https://github.com/rescript-lang/rescript-compiler/tree/master/jscomp/gentype_tests/typescript-react-example/src/shims). An example shim to export ReactEvent can be found [here](https://github.com/rescript-lang/rescript-compiler/blob/master/jscomp/gentype_tests/typescript-react-example/src/shims/ReactEvent.shim.ts).

## Testing the Whole Setup

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/api/belt.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ If you want to open Belt globally for all files in your project instead, you can
"bsc-flags": ["-open Belt"],
```

into your `bsconfig.json`.
into your `rescript.json`.

**Note**: this is the **only** `open` we encourage.

Expand Down
10 changes: 5 additions & 5 deletions pages/docs/manual/latest/build-configuration.mdx
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
---
title: "Configuration"
metaTitle: "Build System Configuration"
description: "Details about the configuration of the ReScript build system (bsconfig.json)"
description: "Details about the configuration of the ReScript build system (rescript.json)"
canonical: "/docs/manual/latest/build-configuration"
---

# Configuration

`bsconfig.json` is the single, mandatory build meta file needed for `rescript`.
`rescript.json` (or `rescript.json` in versions prior ReScript 11) is the single, mandatory build meta file needed for `rescript`.

**The complete configuration schema is [here](./build-configuration-schema)**. We'll _non-exhaustively_ highlight the important parts in prose below.

## name, namespace

`name` is the name of the library, used as its "namespace". You can activate namespacing through `"namespace": true` in your `bsconfig.json`. Namespacing is almost **mandatory**; we haven't turned it on by default yet to preserve backward-compatibility.
`name` is the name of the library, used as its "namespace". You can activate namespacing through `"namespace": true` in your `rescript.json`. Namespacing is almost **mandatory**; we haven't turned it on by default yet to preserve backward-compatibility.

**Explanation**: by default, your files, once used as a third-party dependency, are available globally to the consumer. E.g. if you have an `Util.re` and the consumer also has a file of the same name, they will clash. Turning on `namespace` avoids this by wrapping all your own project's files into an extra module layer; instead of a global `Util` module, the consumer will see you as `MyProject.Util`. **The namespacing affects your consumers, not yourself**.

Aka, in ReScript, "namespace" is just a fancy term for an auto-generated module that wraps all your project's files (efficiently and correctly, of course!) for third-party consumption.

We don't do folder-level namespacing for your own project; all your own file names must be unique. This is a constraint that enables several features such as fast search and easier project reorganization.

**Note**: the `bsconfig.json` `name` should be the same as the `package.json` `name`, to avoid confusing corner-cases. However, this means that you can't use a camelCased names such as `MyProject`, since `package.json` and npm forbid you to do so (some file systems are case-insensitive). To have the namespace/module as `MyProject`, write `"name": "my-project"`. ReScript will turn that into the camelCased name correctly.
**Note**: the `rescript.json` `name` should be the same as the `package.json` `name`, to avoid confusing corner-cases. However, this means that you can't use a camelCased names such as `MyProject`, since `package.json` and npm forbid you to do so (some file systems are case-insensitive). To have the namespace/module as `MyProject`, write `"name": "my-project"`. ReScript will turn that into the camelCased name correctly.

**Note on custom namespacing**: if for some reason, you need a namespace that is different from what your `name` will produce, you can directly send a string to the `namespace` option. For example, if your package is a binding named `bs-some-thing`, you can use `"namespace": "some-thing"` to get `SomeThing` namespace instead of `BsSomeThing`.

Expand Down Expand Up @@ -148,7 +148,7 @@ Output to either CommonJS (the default) or ES6 modules. Example:
- `"module": "es6-global"` resolves `node_modules` using relative paths. Good for development-time usage of ES6 in conjunction with browsers like Safari and Firefox that support ES6 modules today. **No more dev-time bundling**!
- `"in-source": true` generates output alongside source files. If you omit it, it'll generate the artifacts into `lib/js`. The output directory is not configurable otherwise.

This configuration only applies to you, when you develop the project. When the project is used as a third-party library, the consumer's own `bsconfig.json` `package-specs` overrides the configuration here, logically.
This configuration only applies to you, when you develop the project. When the project is used as a third-party library, the consumer's own `rescript.json` `package-specs` overrides the configuration here, logically.

## suffix

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/build-external-stdlib.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ npm install [email protected] --save-dev
npm install @rescript/[email protected]
```

Then add this to `bsconfig.json`:
Then add this to `rescript.json`:

```json
{
Expand Down
4 changes: 2 additions & 2 deletions pages/docs/manual/latest/build-overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ canonical: "/docs/manual/latest/build-overview"

ReScript comes with a build system, [`rescript`](https://www.npmjs.com/package/rescript), that's fast, lean and used as the authoritative build system of the community.

Every ReScript project needs a build description file, `bsconfig.json`.
Every ReScript project needs a build description file, `rescript.json`.

## Options

Expand Down Expand Up @@ -55,7 +55,7 @@ Any new file change will be picked up and the build will re-run.

**Note**: third-party libraries (in `node_modules`, or via `pinned-dependencies`) aren't watched, as doing so may exceed the node.js watcher count limit.

**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`npm` and `yarn` workspaces) where changes in your sub packages should be noticed by the build, you will need to define pinned dependencies in your main project's `bsconfig.json`. More details [here](./build-pinned-dependencies).
**Note 2**: In case you want to set up a project in a JS-monorepo-esque approach (`npm` and `yarn` workspaces) where changes in your sub packages should be noticed by the build, you will need to define pinned dependencies in your main project's `rescript.json`. More details [here](./build-pinned-dependencies).

## Clean Project

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/build-performance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Image from "src/components/Image";

ReScript itself uses a build system under the hood, called [Ninja](https://ninja-build.org). Ninja is like Make, but cross-platform, minimal, focuses in perf and destined to be more of a low-level building block than a full-blown build system. In this regard, Ninja's a great implementation detail for `rescript`.

ReScript reads into `bsconfig.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level compiler commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build.
ReScript reads into `rescript.json` and generates the Ninja build file in `lib/bs`. The file contains the low-level compiler commands, namespacing rules, intermediate artifacts generation & others. It then runs `ninja` for the actual build.

## The JS Wrapper

Expand Down
12 changes: 5 additions & 7 deletions pages/docs/manual/latest/build-pinned-dependencies.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ canonical: "/docs/manual/latest/build-pinned-dependencies"

# Pinned Dependencies

**Since 8.4**

Usually we'd recommend to use ReScript in a single-codebase style by using one `bsconfig.json` file for your whole codebase.
Usually we'd recommend to use ReScript in a single-codebase style by using one `rescript.json` file for your whole codebase.

There are scenarios where you still want to connect and build multiple independent ReScript packages for one main project though (`npm` workspaces-like "monorepos"). This is where `pinned-dependencies` come into play.

Expand Down Expand Up @@ -60,13 +58,13 @@ Let's assume we have a codebase like this:
myproject/
app/
- src/App.res
- bsconfig.json
- rescript.json
common/
- src/Header.res
- bsconfig.json
- rescript.json
myplugin/
- src/MyPlugin.res
- bsconfig.json
- rescript.json
package.json
```

Expand All @@ -87,7 +85,7 @@ Our `package.json` file within our codebase root would look like this:
```


Our `app` folder would be our toplevel package, consuming our `common` and `myplugin` packages as `pinned-dependencies`. The configuration for `app/bsconfig.json` looks like this:
Our `app` folder would be our toplevel package, consuming our `common` and `myplugin` packages as `pinned-dependencies`. The configuration for `app/rescript.json` looks like this:

```json
{
Expand Down
4 changes: 2 additions & 2 deletions pages/docs/manual/latest/converting-from-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ ReScript offers a unique project conversion methodology which:

## Step 1: Install ReScript

Run `npm install rescript` on your project, then imitate our [New Project](installation#new-project) workflow by adding a `bsconfig.json` at the root. Then start `npx rescript build -w`.
Run `npm install rescript` on your project, then imitate our [New Project](installation#new-project) workflow by adding a `rescript.json` at the root. Then start `npx rescript build -w`.

## Step 2: Copy Paste the Entire JS File

Expand Down Expand Up @@ -73,7 +73,7 @@ function queryResult(usePayload, payload) {

</CodeTab>

Add this file to `bsconfig.json`:
Add this file to `rescript.json`:

```json
"sources": {
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/import-from-export-to-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ We support 2 JavaScript import/export formats:
- CommonJS: `require('myFile')` and `module.exports = ...`.
- ES6 modules: `import * from 'MyReScriptFile'` and `export let ...`.

The format is [configurable in via `bsconfig.json`](build-configuration.md#package-specs).
The format is [configurable in via `rescript.json`](build-configuration.md#package-specs).

## Import From JavaScript

Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ If you already have a JavaScript project into which you'd like to add ReScript:
"bs-dependencies": []
}
```
See [Build Configuration](build-configuration) for more details on `bsconfig.json`.
See [Build Configuration](build-configuration) for more details on `rescript.json`.
- Add convenience `npm` scripts to `package.json`:
```json
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion pages/docs/manual/latest/interop-with-js-build-systems.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ For what it's worth, you can also turn `rescript` into an automated step in your

### Tips & Tricks

You can make ReScript JS files look even more idiomatic through the in-source + bs suffix config in `bsconfig.json`:
You can make ReScript JS files look even more idiomatic through the in-source + bs suffix config in `rescript.json`:

```json
{
Expand Down