Fascinating.. it's using `node_modules/shadow-cljs` to do the trick. I can see ClojureScript files are compiled into CommonJS compatible form...
Do you think it's possible that we put all js built from `cjs.core`(also with `goog`) into a single npm package. And then for each ClojureScript file, it is mapped to a JavaScript file by `shadow-cljs` tools, which use `require("./cljs.core.js");` to access it's cljs dependencies(like in your demo), and use `require('package_name/foo/bar')` to require sibling files. For other packages, maybe we can do the some trick, like precompile them with `shadow-cljs` tools and then release them to npm. Seeing from a CoffeeScript user, I think somehow in this way ClojureScript can also fit into npm's ecosystem. Here's an example, we may create a new project in such file structure, where: `src/` is for source code, `target` is for compiled code, `package.json` is copied from `assets/package.json` to `target/package.json`, ``` . ├── assets │ └── package.json ├── project.clj ├── src │ └── demo │ └── main.cljs └── target ├── demo │ └── main.js └── package.json ``` if it's in this way, `target/` can be released on npm as a module and others surely may use `require('package_name/demo/main.js')` to load the package built from ClojureScript. On Wed, May 17, 2017 at 12:15 AM Thomas Heller <th.hel...@gmail.com> wrote: > > > 1. Should we call this "cljs-require"? With the understanding that it > is a bit like a portal to cljs's ":require" form: > > > > require('cljs-require/foo.core') > > The package name must be something you add to your package.json, otherwise > yarn will nuke the directory every time you run "yarn install". "npm" isn't > as strict but still. Using the name of the tool seemed like the obvious > choice. We can however create an empty cljs-require npm package that just > serves as a placeholder. > > I'm totally for this if other tools want to adopt this idiom. I definitely > do not want this to be something you can only do with shadow-cljs. > > > > 2. Is there a way to set the ClojureScript version, or is it tied to > shadow's version? > > You can specify dependencies in package.json, basically like you would in > lein. > > "shadow-cljs: { > "version":"1.0.20170516", > "dependencies": [ > ["org.clojure/clojurescript", "1.9.542"] > ] > } > > where "version" is the version of shadow-devtools, any other dependencies > are resolved using the fantastic pomegrenate lib. (thanks btw for writing > the dep-resolver, I didn't think it would be this simple to do the > dependency loading). > > I'm not sure how the conflict resolution works but you should be able to > use any cljs version you want. The only things written in stone are the > deps of the shadow-cljs uberjar, can't change the clojure version after the > fact. > > See: > > https://github.com/thheller/shadow-devtools/blob/master/npm-package/project.clj > > > > > > 3. Thinking back on Jiyin's question about using cljs in webpack—have > you put any thought into the possibility of this workflow as a webpack > loader? Maybe that's a next step? > > Don't need a loader. It could be a plugin that just calls "shadow-cljs > --once" > before proceeding with the rest of the JS compilation. > > I actually started by writing a plugin but to be honest I do not think it > is super useful. You can achieve the same via npm scripts & co. You'll need > the CLI tool for more advanced tasks (eg. REPL) anyways. > > I want this to be generally useful, not just webpack. No specific webpack > configuration is needed, you just somehow need to compile before calling > webpack. "webpack -w" and "shadow-cljs --dev" side-by-side actually just > works. > > > Awesome job turning this webpack discussion into a real tool we can > explore! 🎉 > > Thanks. > > One issue that needs to be addressed is the widespread use of CLJSJS > packages in popular libs like reagent&co. Can't have cljsjs.react react.js > if you are supposed to use npm react. > > I can easily skip over all foreign-libs but then (:require [cljsjs.react]) > wouldn't have the effect of ensuring that "React" is available on global. > Not yet sure how to best handle that yet. > > Still have a few ideas I want to explore, haven't totally given up on the > Closure Compiler yet but it making life harder than it should be. > > -- > Note that posts from new members are moderated - please be patient with > your first post. > --- > You received this message because you are subscribed to a topic in the > Google Groups "ClojureScript" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/clojurescript/AGXku7Ous0Y/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > clojurescript+unsubscr...@googlegroups.com. > To post to this group, send email to clojurescript@googlegroups.com. > Visit this group at https://groups.google.com/group/clojurescript. > -- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojurescript+unsubscr...@googlegroups.com. To post to this group, send email to clojurescript@googlegroups.com. Visit this group at https://groups.google.com/group/clojurescript.