Skip to content

Commit db81a45

Browse files
authored
Merge pull request #320 from rescript-association/upgrade-deps
Upgrade deps
2 parents 8f54a33 + 879da52 commit db81a45

File tree

144 files changed

+8667
-9604
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

144 files changed

+8667
-9604
lines changed

.github/workflows/pull-request.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ jobs:
99
- uses: actions/setup-node@v2
1010
with:
1111
node-version: 14.x
12-
- run: yarn --frozen-lockfile
13-
- run: yarn run bs:build
14-
- run: yarn test
12+
- run: npm ci
13+
- run: npx rescript
14+
- run: npm test

README.md

+15-7
Original file line numberDiff line numberDiff line change
@@ -15,28 +15,36 @@ This is the official documentation platform for the [ReScript](https://rescript-
1515
- Create an issue to let us know what you are missing
1616
- In case you want to contribute missing docs, please refer to our [Contribution section](#contributing)
1717

18+
## System Requirements
19+
20+
- `[email protected]` or higher (for ES6 module compat)
21+
- `npm@6` (package-lock v1)
22+
1823
## Setup
1924

2025
```sh
2126
# For first time clone / build (install dependencies)
22-
yarn
27+
npm i
28+
29+
# Only needed for initial clone (or content H2 changes)
30+
npm run update-index
2331

2432
# Initial build
25-
yarn bs:build
33+
npm run res:build
2634

2735
# Build the index data
28-
yarn run update-index
36+
npm run update-index
2937

3038
# In a new tab
31-
yarn dev
39+
npm run dev
3240

3341
# then open localhost:3000
3442
```
3543

3644
In case you want to run ReScript in watchmode:
3745

3846
```sh
39-
yarn run bs:start
47+
npm run res:start
4048
```
4149

4250
## Build Index Data
@@ -46,7 +54,7 @@ search terms we need for searching inside the `Belt` docs). You can create your
4654
index by running following command:
4755

4856
```sh
49-
yarn run update-index
57+
npm run update-index
5058
```
5159

5260
All the index data is stored in `index_data`, but will not be tracked by git.
@@ -149,7 +157,7 @@ posts](https://rescript-lang.org/blogpost-guide).
149157
**Quick-takeaways:**
150158

151159
- Blogposts are located in `_blogposts`
152-
- Author metadata is located in `data/blog_authors.json`
160+
- Author metadata is located in `data/blog_authors.mjs`
153161
- Make sure to follow the file naming rules
154162

155163
### Contributing

bsconfig.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"refmt": 3,
99
"bs-dependencies": [
1010
"@rescript/react",
11-
"bs-fetch",
1211
"@glennsl/bs-json",
1312
"@ryyppy/rescript-promise"
1413
],
@@ -31,7 +30,7 @@
3130
"warnings": {
3231
"error": "+8"
3332
},
34-
"suffix": ".js",
33+
"suffix": ".mjs",
3534
"bsc-flags": [
3635
"-bs-super-errors",
3736
"-bs-g"

data/blog_authors.json renamed to data/blog_authors.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[
1+
export default [
22
{
33
"username": "hongbo",
44
"fullname": "Hongbo Zhang",

next.config.js

+51-21
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,78 @@
11
const bsconfig = require("./bsconfig.json");
2-
const withCSS = require("@zeit/next-css");
3-
const withTM = require("next-transpile-modules");
4-
const path = require('path');
5-
const remarkSlug = require('remark-slug');
2+
const path = require("path");
3+
const remarkSlug = require("remark-slug");
4+
const fs = require("fs");
5+
6+
const transpileModules = ["rescript"].concat(bsconfig["bs-dependencies"]);
7+
const withTM = require("next-transpile-modules")(transpileModules);
68

79
const withMdx = require("./plugins/next-mdx")({
810
extension: /\.mdx?$/,
911
options: {
10-
remarkPlugins: [remarkSlug]
11-
}
12+
remarkPlugins: [remarkSlug],
13+
},
1214
});
1315

16+
function patchResDeps() {
17+
["rescript"].concat(bsconfig["bs-dependencies"]).forEach((bsDep) => {
18+
fs.writeFileSync(`./node_modules/${bsDep}/index.js`, "");
19+
const json = require(`./node_modules/${bsDep}/package.json`);
20+
json.main = "index.js";
21+
fs.writeFileSync(
22+
`./node_modules/${bsDep}/package.json`,
23+
JSON.stringify(json, null, 2)
24+
);
25+
});
26+
}
27+
patchResDeps(); // update package.json and create empty `index.js` before transpiling
28+
29+
const isWebpack5 = true;
1430
const config = {
1531
target: "serverless",
16-
pageExtensions: ["jsx", "js", "bs.js", "mdx"],
17-
transpileModules: ["bs-platform"].concat(bsconfig["bs-dependencies"]),
32+
pageExtensions: ["jsx", "js", "bs.js", "mdx", "mjs"],
1833
env: {
1934
ENV: process.env.NODE_ENV,
2035
},
2136
webpack: (config, options) => {
2237
const { isServer } = options;
23-
if (!isServer) {
24-
// We shim fs for things like the blog slugs component
25-
// where we need fs access in the server-side part
26-
config.node = {
27-
fs: 'empty'
38+
if (isWebpack5) {
39+
if (!isServer) {
40+
// We shim fs for things like the blog slugs component
41+
// where we need fs access in the server-side part
42+
config.resolve.fallback = {
43+
fs: false,
44+
path: false,
45+
};
2846
}
47+
config.module.rules.push({
48+
test: /\.m?js$/,
49+
use: options.defaultLoaders.babel,
50+
exclude: /node_modules/,
51+
type: "javascript/auto",
52+
resolve: {
53+
fullySpecified: false,
54+
}
55+
});
2956
}
30-
return config
57+
return config;
3158
},
3259
async redirects() {
3360
return [
3461
{
35-
source: '/community',
36-
destination: '/community/overview',
62+
source: "/community",
63+
destination: "/community/overview",
3764
permanent: true,
3865
},
3966
{
40-
source: '/bucklescript-rebranding',
41-
destination: '/blog/bucklescript-is-rebranding',
67+
source: "/bucklescript-rebranding",
68+
destination: "/blog/bucklescript-is-rebranding",
4269
permanent: true,
43-
}
44-
]
70+
},
71+
];
72+
},
73+
future: {
74+
webpack5: isWebpack5,
4575
},
4676
};
4777

48-
module.exports = withMdx(withTM(withCSS(config)));
78+
module.exports = withMdx(withTM(config));

0 commit comments

Comments
 (0)