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

Unified React require #306

Merged
merged 14 commits into from
Jul 31, 2017
Merged

Unified React require #306

merged 14 commits into from
Jul 31, 2017

Conversation

Deraen
Copy link
Member

@Deraen Deraen commented Jul 12, 2017

ClojureScript 1.9.854 allows using the same require form for npm-deps, cljsjs packages and Node target.

;; cljs
(ns ... (:require [react-dom :as react-dom]))

(react-dom/render ...)

;; foreign-lib
:global-exports {react-dom ReactDOM}
;; Cljs call is compiled to
var a = window.ReactDOM;
a.render(...)
;; or something similar

;; :target :nodejs
var a = require("react-dom");
a.render(...)

;; npm-deps
module$foo$bar$react$react-dom.render(...)
;; where module$foo$bar$react$react-dom is name for converted Closure module

Version built using :npm-deps is online at https://reagent-project.github.io/reagent-site-npm-deps-test/. In this version the React code is optimized using Closure, which results in a bit smaller output: 463K -> 440K JS, non-gzipped.

@Deraen Deraen changed the title Npm deps Unified React require Jul 29, 2017
@Deraen
Copy link
Member Author

Deraen commented Jul 29, 2017

This should be mostly ready now that Cljs 1.9.854 is out.

Unless someone has comments about this, I plan on merging this to master soon and releasing a SNAPSHOT.

I think next version (0.8) will include only this change, as this change will required the new Cljs version, and it will take some time for everyone to upgrade to that.

project.clj Outdated
:language-out :ecmascript3
:npm-deps {:react "15.6.1"
:react-dom "15.6.1"
:create-react-class "15.5.3"}}}}}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why :create-react-class "15.5.3" when above you have :dependencies [cljsjs/create-react-class "15.6.0-1"]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a mistake.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants