This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-03-01
Channels
- # aleph (4)
- # arachne (24)
- # beginners (231)
- # boot (4)
- # cider (63)
- # clara (36)
- # cljs-dev (57)
- # clojure (195)
- # clojure-dev (12)
- # clojure-gamedev (2)
- # clojure-greece (1)
- # clojure-italy (10)
- # clojure-poland (4)
- # clojure-spec (36)
- # clojure-uk (65)
- # clojurescript (133)
- # core-async (8)
- # core-logic (2)
- # cursive (18)
- # data-science (3)
- # datomic (58)
- # defnpodcast (3)
- # duct (2)
- # emacs (2)
- # fulcro (27)
- # graphql (3)
- # hoplon (18)
- # jobs (2)
- # jobs-discuss (10)
- # jobs-rus (1)
- # lumo (1)
- # mount (6)
- # nyc (2)
- # off-topic (27)
- # pedestal (13)
- # re-frame (71)
- # reagent (105)
- # reitit (4)
- # ring (2)
- # ring-swagger (1)
- # rum (10)
- # shadow-cljs (172)
- # spacemacs (24)
- # sql (26)
- # tools-deps (1)
- # uncomplicate (4)
- # unrepl (51)
- # vim (3)
- # yada (11)
For emacs users to try: https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030 the magic is in the function shadow-cljs-jack-in
I can start on my computer browser-repl node-repl and start watch and have cider connect to it without doing anything (like pressing enter twice). Only problem being the possibility of creating these ghost java processes. Deleteing .shadow-cljs directory most often fixes it. Assumes shadow-cljs v2.2.20+, the emacs package edn
(melpa/elpa) and cider/cider-nrepl
as declared dependency within shadow-cljs.edn.
Thanks @hlolli - do you have sample shadow-cljs / project.clj / .dir-local.el files to share? I’m just ramping up on all these - would be helpful. Some people have been using .dir-local.el to kick off shadow-cljs - I’m assuming using this gist would replace that. Also - I’ve run into CIDER not loading cider/cider-nrepl — and think I’m not putting it in the right place. Where specifically should that reference live?
no but I can set up one, just need to be in a buffer where a shadow-cljs.edn file is in the root. This does script does not take leiningen into account, and no need to .dir-local.el/projectile like I saw here recently. If you have cider-nrepl in :dependencies within shadow-cljs.el, it should fire the nrepl connection automatically.
{:dependencies
[[cider/cider-nrepl "0.17.0-SNAPSHOT"]
:nrepl {:port 9000
:middleware []}
...}
This I have on top level.Got it - thanks @hlolli. For cljs/clj dev (with clj repl for server side) - do you just use regular cider-jack-in or cider-connect for that?
yup, I just start a ring handler to serve the cljs-output directory and do my server side stuff with cider-jack-in, which picks up the project.cljs. (and in terminal I have shadow-cljs watch .. running) But I guess this could be simplified as well, there is to say get the autocompletions from both clj and cljs, thinking about it I didn’t test two nrepl connections, so things may get strange. I’ll try adding lein function tonight and let you know!
Ring handler as in, this typical commented section at the bottom of the main ring handler file (comment (defonce server (run-jetty … etc…)))
The node-repl had stupid bug there, which I fixed https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030 plan to move this to a git...
Hi, I defined a SomeGlobalObj
in a.js
and use SomeGlobalObj
in b.js
, I generated a a-externs.js
file for *a.js*
and add to shadow-cljs.edn
:compiler-options
, but when do advanced compilation, there is a warning says variable SomeGlobalObj is undeclared for b.js
. How to fix this?
👋 I’m using the :target :node-library
to get a UMD api that works in both node and the browser
for example, var Foo = require("foo")
in node, or just window.Foo
in the browser if you’re just including the JS file in a script tag without a build system
but currently, I have to use window.returnExports
instead of window.<my-lib-name>
because this is hard-coded into the UMD template that shadow uses here: https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/build/targets/umd_exports.txt#L7
@thheller this should probably be a build option, maybe under :umd-root-name "Foo"
?
sorry, this should a github issue, i’ll file and link here
@thheller thanks!
@thheller When use emacs cider, people usually quit with cider-quit
command, this is not normal quit behavior for shadow-cljs
.
@doglooksgood can you please dig up the source of cider-quit
so I can look at what it actually does and see if I can do something about it?
it is mentioned: Function: delete-process name This function deletes the process associated with name, killing it with a SIGHUP signal. The argument name may be a process, the name of a process, a buffer, or the name of a buffer. is it possible to handle this signal?
I think one solution would be to add all of the processes https://github.com/thheller/shadow-cljs/blob/b107bafc2c20b07af580e3f7deaa1434f54b0022/src/main/shadow/cljs/npm/cli.cljs#L56 into a atom, and catch the SIGHUP signals, kill these processes, and then exit.
@doglooksgood did you do your own shadow-cljs startup script in emacs? I could have maybe saved one evening by useing yours instead of makeing my own 😛
did you try https://gist.github.com/hlolli/d8a28c88ee90c5a57d15299f21528030 ? I believe we are haveing the same problem.
@hlolli I agree but spawnSync
doesn't return until the process it spawned dies so I need to switch to spawn
first
btw given the state of lein
dependence in most tools such as cider I would probably recommend just running through lein
@thheller I think the source map patch in re-natal
is this: https://github.com/drapanjanas/re-natal/pull/102/files
no need to patch in shadow-cljs
@doglooksgood no it just handles the shadow-cljs boot, cider boot and nrepl-select automatically. I guess with leiningen/shadow-cljs setup you don't need to boot shadow-cljs yourself. But I've never integrated shadow-cljs and leiningen, since they work perfectly seperately (within the same project).
their loader has this OS detection which assumes it is not in a browser so long as there is a global process object
// OS detection
if (typeof process === 'object') {
_isWindows = (process.platform === 'win32');
_isMacintosh = (process.platform === 'darwin');
_isLinux = (process.platform === 'linux');
_isRootUser = !_isWindows && (process.getuid() === 0);
let rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
if (rawNlsConfig) {
try {
let nlsConfig: NLSConfig = JSON.parse(rawNlsConfig);
let resolved = nlsConfig.availableLanguages['*'];
_locale = nlsConfig.locale;
// VSCode's default language is 'en'
_language = resolved ? resolved : LANGUAGE_DEFAULT;
} catch (e) {
}
}
_isNative = true;
} else if (typeof navigator === 'object') {
let userAgent = navigator.userAgent;
_isWindows = userAgent.indexOf('Windows') >= 0;
_isMacintosh = userAgent.indexOf('Macintosh') >= 0;
_isLinux = userAgent.indexOf('Linux') >= 0;
_isWeb = true;
_locale = navigator.language;
_language = _locale;
}
I can get it to work if I include monaco’s loader.js in its own script tag, and (js-delete js/self "process")
before I instantiate it
@mhuebert the last time I tried monaco-editor it wasn't packaged in a way that was usable with any bundler (without heavy config)
I can do something horrible like this:
(defn require [paths cb]
(let [process (.-process js/self)]
(js-delete js/self "process")
(js/require (clj->js paths)
(fn [result]
(set! (.-process js/self) process)
(cb result)))
nil))
if it so happens that no other code attempts to read js/process
during the span of time before require calls its callbacki include it via a separate script tag, eg <script src="/js/monaco/vs/loader.js"></script>
Hi, I define a SomeGlobalObj
in a.js
, use SomeGlobalObj
in b.js
, generate a a-externs.js
file for *a.js*
and add to shadow-cljs.edn
:compiler-options
, but when do advanced compilation, there is a warning says variable SomeGlobalObj is undeclared for b.js
. How to fix this?
yes. At first I got some error because compiler renamed on
and invoke
, then I add the externs and the error not come out again.
function handleFontSize() {
WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
WeixinJSBridge.on('menu:setfont', function() {
WeixinJSBridge.invoke('setFontSizeCallback', { 'fontSize' : 0 });
});
}
here WeixinJSBridge is SomeGlobalObj.shadow-cljs - config: /Users/yuzhao/gits/mobile/cljs/shadow-cljs.edn version: 2.1.4
shadow-cljs - connected to server
[:doumi] Compiling ...
------ WARNING #1 --------------------------------------------------------------
File: com/cognitect/transit.js:649:8
variable module is undeclared
--------------------------------------------------------------------------------
------ WARNING #2 --------------------------------------------------------------
File: com/cognitect/transit/impl/writer.js:256:8
variable isObject is undeclared
--------------------------------------------------------------------------------
------ WARNING #3 --------------------------------------------------------------
File: com/cognitect/transit/types.js:384:70
variable Buffer is undeclared
--------------------------------------------------------------------------------
------ WARNING #4 --------------------------------------------------------------
File: doumi/autorem.js:13:4
variable WeixinJSBridge is undeclared
--------------------------------------------------------------------------------
nil
[:doumi] Build completed. (713 files, 3 compiled, 0 warnings, 28.53s)
my guess is that is complains about the variable because the .js file is not in the global scope
I was a bit curious on some background info on shadow-cljs. Is the goal to just be a divergent “fork” of cljs as it is right now? Are there thoughts or plans around merging compiler fixes/changes into the main cljs etc. I haven’t found a “rationale” sort of discussion on this from waht I’ve seen.
I was just reading a bit through the codebase yesterday and was wondering where it is supposed to be headed. Looks like a cool project though by the way!
@mikerod https://groups.google.com/forum/#!msg/clojurescript/xMQuEmQt7oQ/AWT5RZe_nQQJ
I have no intent of merging any of the build specific stuff into CLJS and neither does have CLJS any interest in doing so.
I can move much faster and try many more things which would otherwise be impossible or reaallly slow when done in official CLJS
when I find things that actually affect the compiler itself I usually submit patches and they usually get accepted
https://dev.clojure.org/jira/browse/CLJS-948 started in shadow-cljs before it came part of standard cljs
hmm ok, maybe I saw this in the wild way back. Never mind, struck me as something new 🙂
@mhuebert [email protected]
doesn't leak the process
global anymore
I'm still in hope that shadow-cljs may get a release page like Webpack's, given that we have so many releases https://github.com/webpack/webpack/releases ╮(╯▽╰)╭
releases is different, when you release a new version, if I'm watching the repo, I would get notified of new releases.
I know a release log would be nice but I just can't currently. got too much other stuff on my list already. I might be up for an automated solution but I don't know any so for now there isn't anything
Click "New Release" button, write version number, a title, add a line or two of descriptions... won't take long.
we don't need release notes as long as Webpack anyway, I guess most of updates, since they are mostly bug fixes, should be less than 5 lines.
some of mine are really short. and GitHub generates a page for commits since last release https://github.com/Respo/respo/compare/0.8.13...master
@jiyinyiyong I understand. Still no.
if you want short messages read the commit log. last commit will almost always reflect what you get with npm install
Concerns on my side might be different from yours. New commits are adding to shadow-cljs. Following the release notes would be the simplest way for me to keep updated with changes in shadow-cljs. In theory by reading messages in this channel I would keep myself updated. But I don't have enough time to read so many messages either.
Thomas, you mentioned few weeks ago that you implemented an experimental feature of require-ing bundled in js jar file. Does it mean that I can do an override like this
:resolve {"mylib" {:target :file
:file "jar:file:/lib/some.jar!/mylib.js}}
bit sorry I didn't try to do this immediately, was stuck with other project and the @logbot hasn't published logs for this channel since last year.