Skip to content
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

React Renderer: refactor the code, clean it up and make it more generic #859

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bb50f6c
React: bump GraalJS and turn on sandboxing tests.
mikehearn Oct 30, 2024
9ec50d2
React: reactivate on CI now JVM crash is avoided.
mikehearn Oct 30, 2024
382bdaf
ReactJS: Update README.
mikehearn Aug 12, 2024
10f6b56
ReactJS: Refactor file reload handler out of JSContextPool, mark some…
mikehearn Aug 12, 2024
f80af48
ReactJS: Improve the docs for how to enable hot file reload.
mikehearn Aug 12, 2024
4ce83fa
ReactJS: Refactor JSContextPool into BeanPool.
mikehearn Aug 12, 2024
c5d2916
ReactJS: Move BeanPool into a sub-package.
mikehearn Aug 12, 2024
e8ff514
ReactJS: Move OutputStreamToSLF4J into the utils sub-package.
mikehearn Aug 12, 2024
5a7c4c9
ReactJS: Move the JUL2SLF4J adapter into the utils sub-package.
mikehearn Aug 12, 2024
be7f13d
ReactJS: Move and rename the proxy adapter class.
mikehearn Aug 12, 2024
ec77c8d
ReactJS: Make BeanPool optionally close beans when they are cleared o…
mikehearn Aug 12, 2024
9311f33
ReactJS: Fix an obsolete JavaDoc.
mikehearn Aug 12, 2024
c31023e
ReactJS: Refactoring to move Engine creation to a bean factory.
mikehearn Aug 12, 2024
ed7c4d6
ReactJS: Bugfix to the sandbox policy.
mikehearn Aug 12, 2024
42cc120
ReactJS: Rename some classes to make it clear they are React specific…
mikehearn Aug 12, 2024
7e352f4
ReactJS: Refactor more code into the bean factory.
mikehearn Aug 12, 2024
760344a
ReactJS: Use qualifiers to avoid conflicts with other Micronaut code …
mikehearn Aug 12, 2024
db58728
ReactJS: Refactor away the CompiledReactJSBundle class.
mikehearn Aug 12, 2024
0a12180
ReactJS: Use c'tor injection.
mikehearn Aug 12, 2024
a7e057b
ReactJS: Extract source builder method.
mikehearn Aug 12, 2024
c6f7037
ReactJS: Simplify source builder logic.
mikehearn Aug 12, 2024
634315e
ReactJS: Unify more source builder logic and simplify again.
mikehearn Aug 12, 2024
9fd6eaf
ReactJS: checkstyle fixes
mikehearn Aug 12, 2024
3ab630d
ReactJS: javadoc++
mikehearn Aug 15, 2024
65a1cfe
ReactJS: work around a Truffle bug by going back to reading the bundl…
mikehearn Aug 15, 2024
c72f0c0
ReactJS: Extract the qualifier to a constant, mark the ReactJSBeanFac…
mikehearn Aug 26, 2024
65dc9e7
ReactJS: Add a lambda helper to BeanPool.
mikehearn Oct 7, 2024
b2c1d33
ReactJS: Fix BeanPool javadoc.
mikehearn Oct 14, 2024
2b9f9a5
ReactJS: More refactorings.
mikehearn Oct 14, 2024
7de0ffe
ReactJS: Even more refactorings.
dstepanov Oct 15, 2024
443862e
ReactJS: Fix a bean conflict introduced by the merge and some spotles…
mikehearn Oct 16, 2024
cc08fdb
Merge branch '5.6.x' into reactjs/make-it-more-generic
mikehearn Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ IMPORTANT: Watch out for the last property that disables virtual threads. If you
[[react-dev-mode]]
== Development

During development you want the fastest iteration speed possible. Firstly turn off response caching so hot reload works with `npx webpack --watch`. Micronaut Views React will automatically notice the file changed on disk and reload it.
During development you want the fastest iteration speed possible. These property changes will help:

[configuration]
----
Expand All @@ -38,9 +38,15 @@ micronaut:
responses:
file:
cache-seconds: 0
io:
watch:
enabled: true
paths: build/resources/main/views
----

If using Maven turn off Micronaut's automatic restart features so that changes to the compiled bundle JS don't cause the whole server to reboot:
The `paths` property is correct if you're using the default JS compilation setup created for you by Micronaut Starter. If your JS bundle is held in a different directory in your project, make sure to set the path appropriately.

Now you can tell your build system to only recompile the needed files. In a Micronaut Starter based project that uses Gradle, just run `./gradlew --continuous processResources`. This will cause new bundles to be created for both client and server whenever your input JS changes. If using Maven turn off Micronaut's automatic restart features so that changes to the compiled bundle JS don't cause the whole server to reboot, and then make sure to re-run the Maven build when necessary:

[xml]
----
Expand All @@ -61,4 +67,3 @@ If using Maven turn off Micronaut's automatic restart features so that changes t
</configuration>
</plugin>
----

18 changes: 4 additions & 14 deletions views-react/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
# React SSR support for Micronaut

## TODO
This module uses GraalJS to implement server-side rendering for applications using React or similar libraries like Preact.

1. Eliminate all TODOs from the docs.
2. Make HTTP prefetches run in parallel.
3. Reduce the need for config:
1. Work out what `micronaut.views.folder` is supposed to be when run from Maven. Get rid of the need to specify this.
2. Make it configurable and allow the path to the static assets to be configured so it doesn't have to be served from MN itself.
3. Get rid of the blocking of the event loop when prefetching. Pending answer from MN team about why IO pool switch isn't implemented.
4. Write unit tests.
5. Document what you can and cannot do in GraalJS.
6. Find a way to use `renderToPipeableStream`?
7. Replace `__micronaut_prefetch` with Sam's implementation of fetch() for Micronaut?
8. Document how to do debugging?
9. Implement / get implemented TextEncoder/TextDecoder
10. Update the micronaut-spa-app sample.
To get a project that uses it, try Micronaut Starter and request Views React. That will give you a fully functional
frontend project with build system integration (NPM and Webpack integrated with Maven and Gradle). You can then easily
add components and build up your frontend, or connect up an existing frontend codebase.
71 changes: 0 additions & 71 deletions views-react/src/main/java/io/micronaut/views/react/CompiledJS.java

This file was deleted.

This file was deleted.

This file was deleted.

Loading
Loading