Skip to content

Commit 1d6e6c1

Browse files
authored
Update README.md
1 parent ec4333f commit 1d6e6c1

1 file changed

Lines changed: 32 additions & 65 deletions

File tree

README.md

Lines changed: 32 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,8 @@
44

55
## Reason via `npm`
66

7-
Example project using Reason as an `npm` dependency.
8-
9-
> Note: This example will be rapidly changing. It is not officially supported
10-
> yet. Always reclone the repo each time you try it out (rebasing is not
11-
> sufficient).
7+
Example project using Reason as an `npm` dependency. Use this as a template to
8+
quickly start a new project, or just try out `Reason`.
129

1310
## Get Started:
1411

@@ -19,6 +16,12 @@ npm install
1916
npm start
2017
```
2118

19+
## Make Changes And Rebuild :
20+
```sh
21+
npm run reasonBuild
22+
npm run clean # Clean if you need to!
23+
```
24+
2225
If you are running as `root` already (you probably aren't) then invoke `npm
2326
install --unsafe-perm` instead.
2427

@@ -55,6 +58,25 @@ by commenting out any part in your `bashrc` that sources opam environments.
5558
We will come up with a long term solution at some point.
5659

5760

61+
## Making It Your Project
62+
`ExampleProject` is meant to be the starting point of your own project.
63+
64+
##### Add Another Dependency
65+
66+
**Option `1`:** Install a dependency into the project sandbox, and use `--save`
67+
so that your `package.json` is updated.
68+
69+
```sh
70+
npm install --save @opam-alpha/cstruct
71+
```
72+
73+
**Option `2`:** Edit the `package.json` manually to include your new dependency and run `npm install`.
74+
75+
> Note: Sometimes options `1` and `2` above fail because some *other* dependency that is
76+
rebuilt as a result of the `install` was not designed to build in an idempotent manner.
77+
In that case, just add the new dependency to your `package.json` `"dependencies"`,
78+
`rm -r node_modules`, and then run `npm install`. This installs from a clean slate.
79+
5880
### What's happening
5981
- `npm install` will download and install all your dependencies, and run the
6082
`postinstall` steps for all of those dependencies, and then finally the
@@ -70,7 +92,7 @@ We will come up with a long term solution at some point.
7092
started.
7193

7294

73-
### How to customize
95+
### Add Your Own Scripts
7496
- `npm` allows `scripts` to be specified in your project's `package.json`.
7597
These `scripts` are a named set of commands.
7698
- A few scripts have special meaning, such as the `postinstall` script. The
@@ -82,8 +104,8 @@ We will come up with a long term solution at some point.
82104
- You can add new named scripts in the `package.json` `scripts` field. Once
83105
added, you can then run them via `npm run scriptName` from within the project
84106
root.
85-
- `. dependencyEnv` is commonly used in these `scripts`. The dot `.` sources
86-
`dependencyEnv` which manages the environment, and ensure that important
107+
- `eval $(dependencyEnv)` is commonly used in these `scripts`. The `eval`
108+
manages the environment, and ensures that important
87109
binaries (such as `refmt`) are in the `PATH`. `dependencyEnv` ensures that
88110
the environment is augmented only for the duration of that `script` running,
89111
and only in ways that you or your immediate dependencies decide. When
@@ -96,10 +118,6 @@ We will come up with a long term solution at some point.
96118
packages can publish environment variables in the [dependency-env
97119
repo](https://github.com/npm-ml/dependency-env).
98120

99-
### Recompiling
100-
- To recompile this package (but not your dependencies), remove the local build
101-
artifacts for this package (usually just the `_build` directory) and then run
102-
`npm run postinstall`.
103121

104122
### How to turn this project into a library
105123

@@ -179,58 +197,7 @@ from the top again. This just makes sure you've got everything
179197
nice and clean as if you installed it for the first time.
180198

181199

182-
### Adding Packages
183-
184-
###### Easy
185-
Just add the new dependency in your `package.json` file, `rm` the `node_modules`
186-
directory and re-run `npm install`.
187-
188-
###### Fast
189-
Adding individual packages using the "easy" way above, unfortunately causes the
190-
entire universe to rebuild. If you have several minutes, go for that
191-
approach because it is very reliable. But if you know that rebuilding your
192-
whole project is very slow, and you are pretty sure that the exact package
193-
you want to add will not cause version conflicts, just manually add the
194-
individual packages.
195-
196-
Do a dry run to see which packages will be added:
197-
198-
```sh
199-
npm install --dry-run @opam-alpha/qcheck
200-
201-
202-
> test@1.0.0 /Users/jwalke/Desktop/tmp
203-
> └─┬ @opam-alpha/qcheck@0.4.0
204-
> └── qcheck-actual@0.4.0 (git://github.com/npm-opam/qcheck.git#85bd0e35bec2987b301fa26235b97c1e344462df)
205-
206-
```
207-
208-
Then install the package, without running the build scripts (recall you want to run them
209-
manually so that it doesn't rebuild the whole world) then first download all the new
210-
dependencies (by running `npm install --ignore-scripts`) and pass the `--save` flag
211-
so that it updates your project's `package.json` dependencies.
212-
213-
```sh
214-
npm install --ignore-scripts --save myPackageToAdd
215-
cd node_modules/myPackagetoAdd
216-
npm run postinstall
217-
```
218-
It will report all of the newly downloaded dependencies. Then, `cd` into each
219-
newly downloaded dependency, and run `npm run postinstall` in the right order.
220-
(Take note of what the
221-
result of `npm install` command outputs - those are the new packages you need to
222-
run `npm run postinstall` for).
223-
224-
Again, this manual approach is only for when you
225-
are adding one small new dependency that you know won't bring in a bunch of
226-
other dependencies. For bigger changes, you should be using the Easy approach above.
227-
228-
Now that dependency is installed. If it is a findlib package, your build commands
229-
will be able to see them using `ocamlfind` etc (`rebuild` also uses `ocamlfind`
230-
when you supply the `-pkg findlibpackagename` flag).
231-
232-
233-
### Troubleshooting:
200+
## Troubleshooting:
234201
- Check to make sure everything is installed correctly. There's a `script`
235202
already setup that will help you test the location of where `Reason` has been
236203
compiled into.
@@ -242,7 +209,7 @@ when you supply the `-pkg findlibpackagename` flag).
242209
npm run whereisocamlmerlin
243210
```
244211

245-
### TODO:
212+
## TODO:
246213

247214
- This also installs sandboxed IDE support for Vim/Atom/Emacs. We need to
248215
upgrade all of the plugins to automatically search for IDE plugins inside of

0 commit comments

Comments
 (0)