shadow-cljs

https://github.com/thheller/shadow-cljs | https://github.com/sponsors/thheller | https://www.patreon.com/thheller
sb 2020-09-16T08:46:33.348600Z

Is that possible compile shadow-cljs project into one single file "js-build" ["run" "-m" "shadow.cljs.devtools.cli" "release" "app"] which command or flag could help me? (that code from project.clj file)

thheller 2020-09-16T08:48:15.349600Z

@sb the question is unclear. you are doing a release build which sounds like what you asked? what is the problem?

sb 2020-09-16T08:49:23.349700Z

I would like to inject into one go project as frontend and for this would be great a single js file (because I need to compile into file, as fs attachment, different like in clojure)

sb 2020-09-16T08:50:07.349900Z

maybe I forget the :advanced flag..

thheller 2020-09-16T08:50:11.350100Z

I do not understand what you are asking here

thheller 2020-09-16T08:50:17.350300Z

release produces an optimized build

thheller 2020-09-16T08:50:22.350500Z

which is a single file

thheller 2020-09-16T08:50:27.350700Z

unless you declared multiples :modules

sb 2020-09-16T08:50:39.350900Z

hmm interesting

sb 2020-09-16T08:50:48.351100Z

ok I check again, thanks!

thheller 2020-09-16T08:50:51.351300Z

(assuming this is a :target :browser) build

sb 2020-09-16T08:51:14.351500Z

Sorry for this question! I check again

thheller 2020-09-16T08:54:02.351700Z

if the cljs-runtime dir confuses you that is from watch or compile builds and is not needed in release builds. you can optionally just clean out the :output-dir before running the release

1👍
sb 2020-09-16T08:55:35.352Z

thanks, yes that was the problem :face_with_rolling_eyes:

thheller 2020-09-16T09:04:28.352300Z

you can also just use a different output-dir for release via :release {:output-dir "somewhere/else"} see https://shadow-cljs.github.io/docs/UsersGuide.html#_release_specific_vs_development_configuration

ikitommi 2020-09-16T09:39:01.356400Z

hi. We have a mixed project of cljs & ts. What needs to be considered on writing reusable react-components with ts? I guess the style-requires on ts need to be handled somehow, getting module errors on those requires with shadow-cljs.

thheller 2020-09-16T09:40:02.356700Z

what are style-requires? CSS I presume?

ikitommi 2020-09-16T09:40:20.356800Z

currently using sass on both sides, but I guess plain css requires (on js/ts -side) don't work either?

thheller 2020-09-16T09:41:02.357Z

shadow-cljs has no support for compiling/handling CSS

thheller 2020-09-16T09:43:07.357200Z

you can either compile the TS to regular ES6 code and include it directly via https://shadow-cljs.github.io/docs/UsersGuide.html#classpath-js

thheller 2020-09-16T09:43:55.357400Z

that way the TS can see all the CLJS code and CLJS all the TS

thheller 2020-09-16T09:44:35.357600Z

any other method will result in either the TS code not seeing CLJS or relying on globals to wire everything together

ikitommi 2020-09-16T11:08:34.357800Z

thanks. got the ts & sass converted into js & css, but still have the css-requires in the react-components. Is there a easy way to strip those away on the js-side? e.g. the components look like this:

const Logo_1 = require("./Logo");
require("../styles/overlay.css");
const { Header, Content, Sider, Footer } = antd_1.Layout;
exports.Overlay = (props) => {
    return (React.createElement(antd_1.Layout, null, ...

ikitommi 2020-09-16T11:09:30.358Z

or is there a way for shadow-cljs not to fail on css requires? (as I can import them in my sass)

ikitommi 2020-09-16T11:12:42.358200Z

my bad, actually a typo. sorry for the extra noice.

thheller 2020-09-16T11:19:18.358400Z

you can let shadow-cljs ignore them via :js-options {:ignore-asset-requires true} but it is better to just avoid them to begin with

1👍
2020-09-16T12:02:04.359800Z

A colleague wired up devcards and shadow-cljs; however I appear to be having some problems with the dependencies… In particlar shadow-cljs reports shadow-cljs - failed to load module$node_modules$highlight_DOT_js$lib$core

2020-09-16T12:02:28.360200Z

Then some exceptions related to that

2020-09-16T12:03:00.360500Z

2020-09-16T12:07:15.361400Z

I think it’s because devcards vendors dependencies on highlight.js and marked

2020-09-16T12:12:52.361600Z

This commit seems relevant: https://github.com/bhauman/devcards/commit/4f02973c75586ad3f9559c044cb98585764e5199

thheller 2020-09-16T12:41:05.362Z

@rickmoynihan which shadow-cljs version and which :target?

2020-09-16T12:41:52.362400Z

@thheller cli version: 2.8.26 node: v13.7.0 with :target :browser

thheller 2020-09-16T12:43:05.363400Z

you can either upgrade or set :compiler-options {:output-feature-set :es6} in your build config

2020-09-16T12:45:48.363800Z

ok I’ll try upgrading to 2.11.4

2020-09-16T12:46:50.364300Z

hmm actually the cli version was different to the one in my deps.edn / package.json

2020-09-16T12:50:21.365100Z

ok did yarn global add shadow-cljs and bumped to 2.11.4 and it seems to have fixed the issue