Skip to content

Commit e4d08a0

Browse files
committed
fix #4009
1 parent 9456c3e commit e4d08a0

File tree

9 files changed

+429
-21
lines changed

9 files changed

+429
-21
lines changed

lib/4.06.1/bsb.ml

Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15157,6 +15157,210 @@ let root = OCamlRes.Res.([
1515715157
</body>\n\
1515815158
</html>\n\
1515915159
")]) ;
15160+
Dir ("react-starter", [
15161+
Dir ("src", [
15162+
File ("Index.re",
15163+
"[%bs.raw {|require(\"./index.css\")|}];\n\
15164+
\n\
15165+
ReactDOMRe.renderToElementWithId(<App />, \"root\");\n\
15166+
") ;
15167+
File ("index.css",
15168+
"body {\n\
15169+
\ margin: 0;\n\
15170+
\ font-family: -apple-system, system-ui, \"Segoe UI\", Helvetica, Arial,\n\
15171+
\ sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\";\n\
15172+
}\n\
15173+
\n\
15174+
main {\n\
15175+
\ padding: 20px;\n\
15176+
}\n\
15177+
\n\
15178+
.counter {\n\
15179+
\ padding: 20px;\n\
15180+
\ display: inline-block;\n\
15181+
}\n\
15182+
") ;
15183+
File ("App.re",
15184+
"type state = {count: int};\n\
15185+
\n\
15186+
type action =\n\
15187+
\ | Increment\n\
15188+
\ | Decrement;\n\
15189+
\n\
15190+
let initialState = {count: 0};\n\
15191+
\n\
15192+
let reducer = (state, action) =>\n\
15193+
\ switch (action) {\n\
15194+
\ | Increment => {count: state.count + 1}\n\
15195+
\ | Decrement => {count: state.count - 1}\n\
15196+
\ };\n\
15197+
\n\
15198+
[@react.component]\n\
15199+
let make = () => {\n\
15200+
\ let (state, dispatch) = React.useReducer(reducer, initialState);\n\
15201+
\n\
15202+
\ <main>\n\
15203+
\ {React.string(\"Simple counter with reducer\")}\n\
15204+
\ <div>\n\
15205+
\ <button onClick={_ => dispatch(Decrement)}>\n\
15206+
\ {React.string(\"Decrement\")}\n\
15207+
\ </button>\n\
15208+
\ <span className=\"counter\">\n\
15209+
\ {state.count |> string_of_int |> React.string}\n\
15210+
\ </span>\n\
15211+
\ <button onClick={_ => dispatch(Increment)}>\n\
15212+
\ {React.string(\"Increment\")}\n\
15213+
\ </button>\n\
15214+
\ </div>\n\
15215+
\ </main>;\n\
15216+
};\n\
15217+
") ;
15218+
File ("index.html",
15219+
"<!DOCTYPE html>\n\
15220+
<html lang=\"en\">\n\
15221+
\ <head>\n\
15222+
\ <meta charset=\"UTF-8\" />\n\
15223+
\ <title>Reason react starter</title>\n\
15224+
\ </head>\n\
15225+
\ <body>\n\
15226+
\ <div id=\"root\"></div>\n\
15227+
\ <script src=\"/Index.js\"></script>\n\
15228+
\ </body>\n\
15229+
</html>\n\
15230+
")]) ;
15231+
File ("bsconfig.json",
15232+
"{\n\
15233+
\ \"name\": \"reason-react-starter\",\n\
15234+
\ \"reason\": {\n\
15235+
\ \"react-jsx\": 3\n\
15236+
\ },\n\
15237+
\ \"sources\": {\n\
15238+
\ \"dir\": \"src\",\n\
15239+
\ \"subdirs\": true\n\
15240+
\ },\n\
15241+
\ \"bsc-flags\": [\"-bs-super-errors\", \"-bs-no-version-header\"],\n\
15242+
\ \"package-specs\": [\n\
15243+
\ {\n\
15244+
\ \"module\": \"commonjs\",\n\
15245+
\ \"in-source\": true\n\
15246+
\ }\n\
15247+
\ ],\n\
15248+
\ \"suffix\": \".bs.js\",\n\
15249+
\ \"namespace\": true,\n\
15250+
\ \"bs-dependencies\": [\"reason-react\"],\n\
15251+
\ \"refmt\": 3\n\
15252+
}\n\
15253+
") ;
15254+
File ("package.json",
15255+
"{\n\
15256+
\ \"name\": \"${bsb:name}\",\n\
15257+
\ \"version\": \"${bsb:proj-version}\",\n\
15258+
\ \"scripts\": {\n\
15259+
\ \"build\": \"bsb -make-world\",\n\
15260+
\ \"start\": \"bsb -make-world -w -ws _ \",\n\
15261+
\ \"clean\": \"bsb -clean-world\",\n\
15262+
\ \"webpack\": \"webpack -w\",\n\
15263+
\ \"webpack:production\": \"NODE_ENV=production webpack\",\n\
15264+
\ \"server\": \"webpack-dev-server\",\n\
15265+
\ \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n\
15266+
\ },\n\
15267+
\ \"keywords\": [\n\
15268+
\ \"BuckleScript\",\n\
15269+
\ \"ReasonReact\",\n\
15270+
\ \"reason-react\"\n\
15271+
\ ],\n\
15272+
\ \"author\": \"\",\n\
15273+
\ \"license\": \"MIT\",\n\
15274+
\ \"dependencies\": {\n\
15275+
\ \"react\": \"^16.8.1\",\n\
15276+
\ \"react-dom\": \"^16.8.1\",\n\
15277+
\ \"reason-react\": \">=0.7.0\"\n\
15278+
\ },\n\
15279+
\ \"devDependencies\": {\n\
15280+
\ \"bs-platform\": \"^${bsb:bs-version}\",\n\
15281+
\ \"webpack\": \"^4.0.1\",\n\
15282+
\ \"webpack-cli\": \"^3.1.1\",\n\
15283+
\ \"webpack-dev-server\": \"^3.1.8\",\n\
15284+
\ \"html-webpack-plugin\": \"^3.2.0\",\n\
15285+
\ \"style-loader\": \"^1.0.0\",\n\
15286+
\ \"css-loader\": \"^3.2.0\"\n\
15287+
\ }\n\
15288+
}\n\
15289+
") ;
15290+
File (".gitignore",
15291+
".DS_Store\n\
15292+
.merlin\n\
15293+
.bsb.lock\n\
15294+
npm-debug.log\n\
15295+
/lib/bs/\n\
15296+
/node_modules/\n\
15297+
*.bs.js\n\
15298+
") ;
15299+
File ("README.md",
15300+
"# Reason react starter\n\
15301+
\n\
15302+
## Run Project\n\
15303+
\n\
15304+
```sh\n\
15305+
npm install\n\
15306+
npm start\n\
15307+
# in another tab\n\
15308+
npm run server\n\
15309+
```\n\
15310+
\n\
15311+
View the app in the browser at http://localhost:8000. Running in this environment provides hot reloading and support for routing; just edit and save the file and the browser will automatically refresh.\n\
15312+
\n\
15313+
To use a port other than 8000 set the `PORT` environment variable (`PORT=8080 npm run server`).\n\
15314+
\n\
15315+
## Build for Production\n\
15316+
\n\
15317+
```sh\n\
15318+
npm run clean\n\
15319+
npm run build\n\
15320+
npm run webpack:production\n\
15321+
```\n\
15322+
\n\
15323+
This will replace the development artifact `build/Index.js` for an optimized version as well as copy `src/index.html` into `build/`. You can then deploy the contents of the `build` directory (`index.html` and `Index.js`).\n\
15324+
\n\
15325+
**To enable dead code elimination**, change `bsconfig.json`'s `package-specs` `module` from `\"commonjs\"` to `\"es6\"`. Then re-run the above 2 commands. This will allow Webpack to remove unused code.\n\
15326+
") ;
15327+
File ("webpack.config.js",
15328+
"const path = require(\"path\")\n\
15329+
const HtmlWebpackPlugin = require(\"html-webpack-plugin\")\n\
15330+
const outputDir = path.join(__dirname, \"build/\")\n\
15331+
\n\
15332+
const isProd = process.env.NODE_ENV === \"production\"\n\
15333+
\n\
15334+
module.exports = {\n\
15335+
\ entry: \"./src/Index.bs.js\",\n\
15336+
\ mode: isProd ? \"production\" : \"development\",\n\
15337+
\ devtool: \"source-map\",\n\
15338+
\ output: {\n\
15339+
\ path: outputDir,\n\
15340+
\ filename: \"Index.js\"\n\
15341+
\ },\n\
15342+
\ plugins: [\n\
15343+
\ new HtmlWebpackPlugin({\n\
15344+
\ template: \"src/index.html\",\n\
15345+
\ inject: false\n\
15346+
\ })\n\
15347+
\ ],\n\
15348+
\ devServer: {\n\
15349+
\ compress: true,\n\
15350+
\ contentBase: outputDir,\n\
15351+
\ port: process.env.PORT || 8000,\n\
15352+
\ historyApiFallback: true\n\
15353+
\ },\n\
15354+
\ module: {\n\
15355+
\ rules: [\n\
15356+
\ {\n\
15357+
\ test: /\\.css$/,\n\
15358+
\ use: [\"style-loader\", \"css-loader\"]\n\
15359+
\ }\n\
15360+
\ ]\n\
15361+
\ }\n\
15362+
}\n\
15363+
")]) ;
1516015364
Dir ("tea", [
1516115365
Dir ("src", [
1516215366
File ("main.ml",

lib/4.06.1/bsdep.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32384,7 +32384,7 @@ let file_aux ppf ~tool_name inputfile (type a) parse_fun invariant_fun
3238432384
let ast =
3238532385
Profile.record_call "-ppx" (fun () ->
3238632386
apply_rewriters ~restore:false ~tool_name kind ast) in
32387-
if is_ast_file || !Clflags.all_ppx <> [] then invariant_fun ast;
32387+
if is_ast_file || !Clflags.all_ppx <> [] && not !Clflags.bs_only then invariant_fun ast;
3238832388
ast
3238932389

3239032390
let file ppf ~tool_name inputfile parse_fun ast_kind =
@@ -42189,11 +42189,11 @@ let parse_external_attributes
4218942189
| "bs.new" -> {st with new_name = name_from_payload_or_prim ~loc payload}
4219042190
| "bs.set_index" ->
4219142191
if String.length prim_name_check <> 0 then
42192-
Location.raise_errorf ~loc "[@@bs.set_index] expect external names to be empty string";
42192+
Location.raise_errorf ~loc "[@@bs.set_index] this particular external's name needs to be a placeholder empty string";
4219342193
{st with set_index = true}
4219442194
| "bs.get_index"->
4219542195
if String.length prim_name_check <> 0 then
42196-
Location.raise_errorf ~loc "[@@bs.get_index] expect external names to be empty string";
42196+
Location.raise_errorf ~loc "[@@bs.get_index] this particular external's name needs to be a placeholder empty string";
4219742197
{st with get_index = true}
4219842198
| "bs.obj" -> {st with mk_obj = true}
4219942199
| "bs.return" ->

lib/4.06.1/bsppx.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20471,11 +20471,11 @@ let parse_external_attributes
2047120471
| "bs.new" -> {st with new_name = name_from_payload_or_prim ~loc payload}
2047220472
| "bs.set_index" ->
2047320473
if String.length prim_name_check <> 0 then
20474-
Location.raise_errorf ~loc "[@@bs.set_index] expect external names to be empty string";
20474+
Location.raise_errorf ~loc "[@@bs.set_index] this particular external's name needs to be a placeholder empty string";
2047520475
{st with set_index = true}
2047620476
| "bs.get_index"->
2047720477
if String.length prim_name_check <> 0 then
20478-
Location.raise_errorf ~loc "[@@bs.get_index] expect external names to be empty string";
20478+
Location.raise_errorf ~loc "[@@bs.get_index] this particular external's name needs to be a placeholder empty string";
2047920479
{st with get_index = true}
2048020480
| "bs.obj" -> {st with mk_obj = true}
2048120481
| "bs.return" ->

0 commit comments

Comments
 (0)