-
-
Notifications
You must be signed in to change notification settings - Fork 631
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ReScript Example #1400
Add ReScript Example #1400
Conversation
Create file to import compiled ReScript components
Add JavaScript dependency required to build for production
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 12 files at r1, all commit messages.
Reviewable status: 11 of 12 files reviewed, 6 unresolved discussions (waiting on @gscarv13 and @justin808)
spec/dummy/package.json, line 63 at r1 (raw file):
"build:clean": "rm -rf public/webpack || true", "re:build": "rescript build", "re:start": "rescript build -w"
- remove these two right here
- update build:XYZ with the
rescript build
- Add "build:production" and set ReactOnRails.configuration.build_production_command
spec/dummy/client/app/packs/client-bundle.js, line 14 at r1 (raw file):
import PureComponentWrappedInFunction from '../components/PureComponentWrappedInFunction'; import { HelloWorldReScript } from './rescript-components';
@pulkitkkr @alexfedoseev is this the right way to integrate?
spec/dummy/client/app/packs/rescript-components.js, line 8 at r1 (raw file):
export { HelloWorldReScript,
@pulkitkkr @alexfedoseev is this the right way to integrate?
spec/dummy/lib/tasks/before_assets_precompile.rake, line 3 at r1 (raw file):
# frozen_string_literal: true task :before_assets_precompile do
Once you merge #1402 then we can remove this whole file.
spec/dummy/lib/tasks/before_assets_precompile.rake, line 5 at r1 (raw file):
task :before_assets_precompile do # clean and build rescript files system("yarn rescript clean && yarn rescript build")
Use sh
https://www.rubydoc.info/gems/rake/FileUtils:sh
https://newbedev.com/how-to-execute-commands-within-rake-tasks
throw if command does not run cleanly.
and don't put script here, put script in package.json
`yarn build:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add test to https://github.com/shakacode/react_on_rails/blob/master/spec/dummy/spec/system/integration_spec.rb
Reviewed 1 of 12 files at r1.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @gscarv13)
f0d1922
to
15baa04
Compare
add files to .prettierignore
15baa04
to
b6179b3
Compare
5c87c07
to
3d367b7
Compare
Remove babel-plugin-transform-react-remove-prop-types
3d367b7
to
f471848
Compare
68acea5
to
95f8b26
Compare
95f8b26
to
f69e21a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 6 files at r2, 2 of 3 files at r5, 1 of 3 files at r6, 6 of 6 files at r7, all commit messages.
Reviewable status: 16 of 17 files reviewed, 13 unresolved discussions (waiting on @alexfedoseev, @gscarv13, and @justin808)
spec/dummy/.gitignore, line 27 at r5 (raw file):
Previously, gscarv13 (Gustavo Carvalho) wrote…
@justin808 The ReScript compiler put the
bs/
insidelib/
. Looking at the documentation I couldn't find a way to change it
Hey @alexfedoseev it's very common to have a /lib directory as part of Rails apps.
@gscarv13 Can ReScript be configured to have the folder called /rescript-lib ?
spec/dummy/package.json, line 14 at r5 (raw file):
Previously, gscarv13 (Gustavo Carvalho) wrote…
I was building the app for the tests and that was being required. I'll check if it is still relevant @justin808
this is for production builds to remove prop types
so yes, good
and not required in this PR.
separate PR would be good, definitely the update to rails/webpacker
spec/dummy/client/app/components/HelloWorldReScript.res, line 4 at r7 (raw file):
// is the same hash passed to react_component method on the view. Log the Props in the compiled JS // and make sure the props passed to the component below match the shape of the prop passed on the view.
Comment on why named default
spec/dummy/client/app/packs/rescript-components.js, line 5 at r7 (raw file):
// and they are generated on the same directory as the .res file import HelloWorldReScript from '../components/HelloWorldReScript.bs';
@alexfedoseev should we import the bs file from the JS file like this?
or maybe
import HelloWorldReScript from '../components/HelloWorldReScript.bs.js';
or configure webpack/babel so this works:
import HelloWorldReScript from '../components/HelloWorldReScript';
and there is a default to look for the .bs.js file?
spec/dummy/spec/system/integration_spec.rb, line 123 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
test changing the text in the input field and observing the output
OK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 12 files at r1, 2 of 6 files at r2, 2 of 3 files at r5, 3 of 6 files at r7, all commit messages.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @alexfedoseev and @gscarv13)
spec/dummy/.gitignore, line 27 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Hey @alexfedoseev it's very common to have a /lib directory as part of Rails apps.
@gscarv13 Can ReScript be configured to have the folder called /rescript-lib ?
I agree that the lib directory is an odd placement.
spec/dummy/bsconfig.json, line 13 at r5 (raw file):
Previously, alexfedoseev (Alex Fedoseev) wrote…
It's not relevant anymore.
@alexfedoseev Should we remove it from here too? https://github.com/shakacode/rescript-on-rails-example/blob/main/bsconfig.json
spec/dummy/app/views/pages/client_side_rescript_hello_world.html.erb, line 4 at r7 (raw file):
<hr/> <h1>React Rails Client Side Only Rendering</h1>
Seems odd to me to mix Rails HTML in a specific view instead of delegating all the front end in the view to ReScript, unless there's a compelling reason. Devs have to bounce between the Rails view and ReScript to decide where to edit the HTML. In my opinion it's cleaner to separate concerns.
spec/dummy/client/app/packs/rescript-components.js, line 5 at r7 (raw file):
Previously, justin808 (Justin Gordon) wrote…
@alexfedoseev should we import the bs file from the JS file like this?
or maybe
import HelloWorldReScript from '../components/HelloWorldReScript.bs.js';or configure webpack/babel so this works:
import HelloWorldReScript from '../components/HelloWorldReScript';and there is a default to look for the .bs.js file?
@justin808 It would be nice if the .bs.js
was implied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 12 files at r1, 2 of 6 files at r2, 3 of 6 files at r7.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @alexfedoseev and @gscarv13)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 3 files at r6.
Reviewable status: all files reviewed, 14 unresolved discussions (waiting on @alexfedoseev and @gscarv13)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 9 of 17 files reviewed, 14 unresolved discussions (waiting on @alexfedoseev, @gscarv13, @justin808, and @mightystrong)
spec/dummy/.gitignore, line 29 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Please note these chars
Done.
spec/dummy/.gitignore, line 27 at r5 (raw file):
Previously, mightystrong (Michael Price) wrote…
I agree that the lib directory is an odd placement.
Sadly there's no way of configuring it in rescript yet rescript-lang/rescript#1124 (comment)
spec/dummy/bsconfig.json, line 13 at r5 (raw file):
Previously, mightystrong (Michael Price) wrote…
@alexfedoseev Should we remove it from here too? https://github.com/shakacode/rescript-on-rails-example/blob/main/bsconfig.json
Done.
spec/dummy/bsconfig.json, line 16 at r5 (raw file):
Previously, alexfedoseev (Alex Fedoseev) wrote…
Useless in the context of the apps.
Done.
spec/dummy/package.json, line 62 at r5 (raw file):
Previously, alexfedoseev (Alex Fedoseev) wrote…
You probably want
-with-deps
flag here.
Done.
spec/dummy/app/views/pages/client_side_rescript_hello_world.html.erb, line 4 at r7 (raw file):
Previously, mightystrong (Michael Price) wrote…
Seems odd to me to mix Rails HTML in a specific view instead of delegating all the front end in the view to ReScript, unless there's a compelling reason. Devs have to bounce between the Rails view and ReScript to decide where to edit the HTML. In my opinion it's cleaner to separate concerns.
Since this is already used in another view, I'll remove it from this one
spec/dummy/client/app/components/HelloWorldReScript.res, line 4 at r7 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Comment on why named
default
Done.
spec/dummy/client/app/packs/rescript-components.js, line 5 at r7 (raw file):
Previously, mightystrong (Michael Price) wrote…
@justin808 It would be nice if the
.bs.js
was implied.
I find it better to be explicit and import as .bs.js';
to make clear it's a rescript component
spec/dummy/lib/tasks/before_assets_precompile.rake, line 3 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Once you merge #1402 then we can remove this whole file.
Done.
spec/dummy/lib/tasks/before_assets_precompile.rake, line 5 at r1 (raw file):
Previously, justin808 (Justin Gordon) wrote…
Use
sh
https://www.rubydoc.info/gems/rake/FileUtils:sh
https://newbedev.com/how-to-execute-commands-within-rake-tasksthrow if command does not run cleanly.
and don't put script here, put script in package.json
`yarn build:
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 9 of 17 files reviewed, 14 unresolved discussions (waiting on @alexfedoseev, @gscarv13, @justin808, and @mightystrong)
spec/dummy/package.json, line 14 at r5 (raw file):
Previously, justin808 (Justin Gordon) wrote…
this is for production builds to remove prop types
so yes, good
and not required in this PR.
separate PR would be good, definitely the update to rails/webpacker
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ready to merge. So long as CI passes, we can merge.
Reviewed 2 of 4 files at r8, 6 of 6 files at r9, all commit messages.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @alexfedoseev, @gscarv13, and @mightystrong)
spec/dummy/client/app/packs/rescript-components.js, line 5 at r7 (raw file):
Previously, gscarv13 (Gustavo Carvalho) wrote…
I find it better to be explicit and import as
.bs.js';
to make clear it's a rescript component
OK
This PR contains:
spec/dummy/
ljuster
at React on Rails ReasonHelloWorld component #1215This change is