File tree Expand file tree Collapse file tree 3 files changed +28
-18
lines changed
examples/create-react-app Expand file tree Collapse file tree 3 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -29,11 +29,6 @@ copy_to_bin(
29
29
],
30
30
)
31
31
32
- copy_to_bin (
33
- name = "copy_test_files" ,
34
- srcs = glob (_TESTS ),
35
- )
36
-
37
32
# react-scripts can only work if the working directory is the root of the application.
38
33
# So we'll need to chdir before it runs.
39
34
write_file (
@@ -42,23 +37,31 @@ write_file(
42
37
content = ["process.chdir(__dirname)" ],
43
38
)
44
39
40
+ _RUNTIME_DEPS = [
41
+ "chdir.js" ,
42
+ "copy_static_files" ,
43
+ "@npm//react" ,
44
+ "@npm//react-dom" ,
45
+ ]
46
+
45
47
react_scripts (
46
48
# Note: this must be named "build" since react-scripts hard-codes that as the output dir
47
49
name = "build" ,
48
50
args = [
49
51
"--node_options=--require=./$(execpath chdir.js)" ,
50
52
"build" ,
51
53
],
52
- data = [
53
- "chdir.js" ,
54
- "copy_static_files" ,
54
+ data = _RUNTIME_DEPS + [
55
55
"@npm//@types" ,
56
- "@npm//react" ,
57
- "@npm//react-dom" ,
58
56
],
59
57
output_dir = True ,
60
58
)
61
59
60
+ copy_to_bin (
61
+ name = "copy_test_files" ,
62
+ srcs = glob (_TESTS ),
63
+ )
64
+
62
65
react_scripts_test (
63
66
name = "test" ,
64
67
args = [
@@ -71,15 +74,20 @@ react_scripts_test(
71
74
"--no-watchman" ,
72
75
"--ci" ,
73
76
],
74
- data = [
75
- "chdir.js" ,
76
- "copy_static_files" ,
77
+ data = _RUNTIME_DEPS + [
77
78
"copy_test_files" ,
78
79
"@npm//@testing-library/dom" ,
79
80
"@npm//@testing-library/jest-dom" ,
80
81
"@npm//@testing-library/react" ,
81
82
"@npm//@testing-library/user-event" ,
82
- "@npm//react" ,
83
- "@npm//react-dom" ,
84
83
],
85
84
)
85
+
86
+ react_scripts (
87
+ name = "start" ,
88
+ args = [
89
+ "--node_options=--require=$(rootpath chdir.js)" ,
90
+ "start" ,
91
+ ],
92
+ data = _RUNTIME_DEPS ,
93
+ )
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ approaches you can take to build and test your React app with Bazel.
6
6
7
7
## Available Scripts
8
8
9
- In the project directory, you can run:
9
+ Just like with stock create-react-app, we have the same developer workflow. In the project directory, you can run:
10
10
11
11
### ` yarn start `
12
12
@@ -19,7 +19,9 @@ You will also see any lint errors in the console.
19
19
### ` yarn test `
20
20
21
21
Launches the test runner in the interactive watch mode.<br />
22
- See the section about [ running tests] ( https://facebook.github.io/create-react-app/docs/running-tests ) for more information.
22
+ Note that it restarts Jest on each change, so there's a large time penalty on each re-run.
23
+ This can be solved by making Jest ibazel-aware as we did with Karma.
24
+ See https://github.com/bazelbuild/rules_nodejs/issues/2028
23
25
24
26
### ` yarn build `
25
27
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ function App() {
8
8
< header className = "App-header" >
9
9
< img src = { logo } className = "App-logo" alt = "logo" />
10
10
< p >
11
- Edit < code > src/App.tsx</ code > and save to reload.
11
+ Edit < code > src/App.tsx</ code > and saverate to reload.
12
12
</ p >
13
13
< a
14
14
className = "App-link"
You can’t perform that action at this time.
0 commit comments