eddyson-de / tapestry-react Goto Github PK
View Code? Open in Web Editor NEWIntegration of Apache Tapestry and React
License: Apache License 2.0
Integration of Apache Tapestry and React
License: Apache License 2.0
To speed things up in production, it is often desirable to to the transformation step during compile time. In some of my projects, I use the Gradle Node Plugin (https://github.com/srs/gradle-node-plugin) and add a custom task that transforms the files and packages the results inside the jar/war task.
I'd like this library to provide some utility code to perform the transformation from outside of a Tapestry webapp.
How would I add dependencies to the project so I could import existing components? Assuming this is possible, it would be great if the sample/test application did this.
For performance reasons, the reactcomponent module should be added as JavaScript, not as CoffeeScript.
As Tapestry uses RequireJS, we should output React resources that use the ECMAScript 6 module system as AMD modules. The babel transpiler supports that, so that isn't a problem.
However, there might be a problem if we start running AMD modules through the AMD formatter: babel/babel#2416
We could try to detect the usage of "define", "import" and "export", use the respective options for babel, and force the user to choose a module system if we find both in a single file, but that's probably going to lead to false alerts if the terms are used with a different meaning or inside comments.
The best solution I can come up with right now is to use different file extensions (maybe .jsx
and .jsx6
) and only run the .jsx6
files through the AMD formatter.
As we always add the unminified assets as modules, the debug code stays in the files in production mode. Unfortunately, there is no unminified production distribution (facebook/react#5242), so if we want to be able to use unminified resources in production, we need to strip the debugging code from the react.js file ourselves. Maybe a global replace of "development" !== 'production'
by "production" !== 'production'
will do the trick.
The problem is in https://github.com/apache/tapestry-5/blob/5.4.1/tapestry-webresources/src/main/java/org/apache/tapestry5/internal/webresources/RhinoExecutorPool.java#L146, which creates a Reader
without specifying a Charset
. This causes trouble on Windows machines when trying to read the browser.js
bundle, which contains unicode characters.
Error message:
017-01-09 14:55:35,224 [pool-3-thread-3] ERROR o.a.t.i.Registry - SyntaxError: Invalid range in character class. (classpath:de/eddyson/tapestry/react/services/browser.js#490)
2017-01-09 14:55:35,224 [pool-3-thread-3] ERROR o.a.t.i.Registry - Operations trace:
2017-01-09 14:55:35,225 [pool-3-thread-3] ERROR o.a.t.i.Registry - [ 1] Compiling classpath:XXX from JSXM to JavaScript
2017-01-09 14:55:35,225 [pool-3-thread-3] ERROR o.a.t.i.Registry - [ 2] Creating Rhino executor for source(s) classpath:de/eddyson/tapestry/react/services/browser.js.
2017-01-09 14:55:35,225 [pool-3-thread-3] ERROR o.a.t.i.Registry - [ 3] Loading script classpath:de/eddyson/tapestry/react/services/browser.js.
2017-01-09 14:55:35,231 [pool-3-thread-3] ERROR d.e.t.m.M.MinificationCacheWarming - Error requesting minified stack XXX for locale XXX
org.apache.tapestry5.ioc.internal.OperationException: SyntaxError: Invalid range in character class. (classpath:de/eddyson/tapestry/react/services/browser.js#490)
If I enable the babel stage 3 transformations ENABLE_STAGE_3_TRANSFORMATIONS
, the transformation throws the following error:
Caused by: java.lang.RuntimeException: Error: Invalid preset specified in Babel options: "stage3"
at de.eddyson.tapestry.react.services.impl.NodeBabelCompiler.compile(NodeBabelCompiler.java:79)
at $BabelCompiler_17eea7322f01a9.compile(Unknown Source)
at de.eddyson.tapestry.react.services.impl.BabelResourceTransformer.transform(BabelResourceTransformer.java:69)
at org.apache.tapestry5.internal.webresources.ResourceTransformerFactoryImpl$1$1.perform(ResourceTransformerFactoryImpl.java:143)
at org.apache.tapestry5.internal.webresources.ResourceTransformerFactoryImpl$1$1.perform(ResourceTransformerFactoryImpl.java:139)
at org.apache.tapestry5.ioc.internal.OperationTrackerImpl.perform(OperationTrackerImpl.java:110)
... 92 more
The reason is a typo in preset name in babel-compiler-wrapper.js
. It has to be stage-3
and not stage3
.
Hi,
in some scenarios when not all symbols are available the ReactModule might crash trying to contribute the application config.
Crashing line:
https://github.com/eddyson-de/tapestry-react/blob/master/src/main/java/de/eddyson/tapestry/react/ReactModule.java#L122
Already working on a pull request.
Java 7 reached EOL more than 2 years ago, we should no longer consider compatibility a requirement.
If you use this library in a Java 7 environment and cannot upgrade, please let us know.
cc @felixgonschorek, @benweidig
CJSX support depends on the deprecated https://github.com/jsdf/coffee-react-transform and we don't use it.
If you use it, this is your chance to chime in.
cc @felixgonschorek, @benweidig
This update isn't trivial as 0.14.0 does not ship the JSX compiler anymore. We'll probably have to use babel (https://babeljs.io/).
When a react component is contained in a Zone and the Zone updates, the component should be unmounted to prevent leaks.
The React addons are not available. I'd prefer having a separate react/addons
module but that is not available (facebook/react#5243). On the other hand, the reactcomponent module depends on the react module, so if we just add a react-with-addons module, we'll probably load all the things twice. We could add a symbol to toggle, whether to add the react.js or the react-with-components.js assets as "react" module. The current workaround would be to override the ModuleManager contribution.
Hi Jochen,
we are currently in the process of upgrading our projects to tapestry 5.8
We wantet to upgrade our dependency on tapestry-react to v0.35.0, but it seems the build in jitpack had a timeout - we can't download the dependency in our projects.
The build for 0.35.0 seems to have been successful, but in the end there is a timeout, we think that has been the deployment container that would have published the artifact.
Thank you if you find the time to look afters this issue!
Cheers
Felix
jitpack log of 0.35.0 build: https://jitpack.io/com/github/eddyson-de/tapestry-react/v0.35.0/build.log
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.