Skip to content

Commit 113aaf8

Browse files
committed
Local development notes
1 parent 04d4b75 commit 113aaf8

File tree

2 files changed

+49
-5
lines changed

2 files changed

+49
-5
lines changed

CONTRIBUTING.md

+36
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,39 @@ npm run build && npm test
3131
```
3232

3333
Please ensure that the tests are passing when submitting a pull request. If you're adding new features, please include tests.
34+
35+
## Development
36+
37+
Developing react-py locally requires some additional steps.
38+
39+
You'll need to install [Node.js](https://nodejs.org/en/). Once you have Node.js installed, you can install the project's dependencies by running:
40+
41+
```sh
42+
git clone [email protected]:elilambnz/react-py.git
43+
cd react-py
44+
npm install
45+
```
46+
47+
This repo also contains the documentation site, which can be used to test your changes. To get started with the website, run:
48+
49+
```sh
50+
cd website
51+
npm install
52+
npm run docusaurus
53+
```
54+
55+
You will need to link the local version of react-py to the website. To do this, run in the root of the project:
56+
57+
```sh
58+
npm link
59+
```
60+
61+
Then, in the website directory, run:
62+
63+
```sh
64+
npm link react-py
65+
```
66+
67+
Now, you can make changes to the react-py code and see the changes reflected in the website.
68+
69+
NOTE: When using React and `npm link`, this can cause issues with multiple copies of React being loaded. A webpack plugin `resolveReact` has been added to the Docusaurus config to resolve this issue.

website/docusaurus.config.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,22 @@ const config = {
107107
}
108108
},
109109
async function disableUsedExports() {
110+
return {
111+
name: 'disable-used-exports',
112+
configureWebpack() {
113+
return {
114+
optimization: {
115+
usedExports: false
116+
}
117+
}
118+
}
119+
}
120+
},
121+
async function copyPyodide() {
110122
return {
111123
name: 'copy-pyodide',
112124
configureWebpack(config) {
113125
return {
114-
// optimization: {
115-
// usedExports: false,
116-
// },
117126
// externals: {
118127
// pyodide: path.resolve(
119128
// __dirname,
@@ -139,6 +148,7 @@ const config = {
139148
}
140149
}
141150
},
151+
// Fixes the issue where React is loaded twice. Only required for local development.
142152
async function resolveReact() {
143153
return {
144154
name: 'resolve-react',
@@ -155,8 +165,6 @@ const config = {
155165
}
156166
],
157167

158-
// staticDirectories: ['node_modules/pyodide'],
159-
160168
scripts: [
161169
{
162170
src: 'https://plausible.pixellab.nz/js/plausible.js',

0 commit comments

Comments
 (0)