-
Notifications
You must be signed in to change notification settings - Fork 805
React surrogate #1192
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 surrogate #1192
Conversation
48089e0 to
687379b
Compare
react/build.boot
Outdated
| (comp | ||
| (surrogate :filename (format "cljsjs/%1$s/development/%1$s.inc.js" (name project)) | ||
| :project project) | ||
| (surrogate :filename (format "cljsjs/%1$s/production/%1$s.min.inc.js" (name project)) |
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.
Minified file is not required, so this could be removed to simplify this a bit.
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.
So if :file-min is not set in deps.cljs, :file is used automatically? The reason I left this in was because I wasn't clear on the mechanism by which the minified file is selected.
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.
Yes
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.
@Deraen nice, I've pushed a version that doesn't build a .min variant
|
Maybe document why these packages exist + recommended usage in the package readme as well? |
|
@martinklepsch good point. I think the README could use a overhaul in general. Can this be done in a separate PR? |
|
Sure |
|
I think this is dangerous. Like @pesterhazy said In I think the proper way forward for all this is through: https://dev.clojure.org/jira/browse/CLJS-2061 Creating work arounds for work arounds needs to stop. |
|
This is dangerous because it sets the precedent.
So soon we would have I mentioned |
|
CLJSJS and It shouldn't require another work around to actually be able to use native packages again. |
|
I agree that we should be working on a better solution to the general problem of accessing native packages. But I don't agree that as an interim solution, surrogate react packages are dangerous. This is a workaround of course, but it's significantly less hacky than the existing solution of adding empty namespace. Every cljs react native project uses this hack. The same problem arises today when you use webpack to build a second bundle as explained in this post. It's much better to have all the dependency information in one place, i.e. project.clj or build.boot. I think this is mostly needed for React (which is why this PR only addresses React). |
|
Interim solutions are dangerous since they tend to become permanent or make things significantly more complicated to new users. These things tend to stick around since all this stuff isn't easily discovered and finding 3 different solutions via google without knowing which the "current" one is really sucks for the user. I'd rather just say "don't use IMHO, YMMV. |
|
How about we go forward w/ this, but clearly label it as advanced & link relevant JIRA tickets etc? I see the points @thheller is making and agree. But it's also clear that this is a pain for many (experienced) CLJS devs working with React Native and merging this would ease that pain until we have a more permanent solution. |
|
Opened: https://dev.clojure.org/jira/browse/CLJS-2074 Vote it up if you agree that this is important. |
|
Lets see if/what other solutions we can come up with. This has been an issue for a long while already so I think it is best to not hurry too much. |
|
After https://dev.clojure.org/jira/browse/CLJS-2214, https://dev.clojure.org/jira/browse/CLJS-2213 & co. this has pretty much been solved in ClojureScript compiler now. Libraries can |
|
React packages now use I think these changes will solve the problems of using Reagent/React in different environments. |
This PR adds surrogate packages for cljsjs/react, cljsjs/react-dom and cljsjs/react-dom-server. These packages are like their non-surrogate counterparts, except that the contained javascript file is empty. The packages do contain externs for React.
Libraries like reagent require the
cljsjs.react,cljsjs.react.domandcljsjs.react.dom.servernamespaces. If you use a Rect version provided by some other means, you need to make sure these requires don't fail. A common way to do this is to fauxsrc/cljsjs/react.cljsetc. files containing empty namespaces.With this PR, you can add these coordinates to your project.clj instead:
This is a cleaner solution than adding empty namespaces. Note that you also need to exclude all cljsjs react packages. The best way is to add global exclusions: