figwheel-main

figwheel-main http://figwheel.org
bhauman 2020-06-05T15:51:08.159300Z

I’m finally adding --clean option

đź‘Ť 2
🦜 1
bhauman 2020-06-05T15:52:21.160700Z

I’ve been wanting it for sometime, and with the new :bundle option it’s really important that you clean the build on every compile as you are switching over from cljsjs libs to npm based libs

bhauman 2020-06-05T15:52:55.161300Z

also a :clean-outputs true config key that will clean as you are starting up a build

bhauman 2020-06-05T15:53:10.161700Z

they both do the same thing

bhauman 2020-06-05T15:53:33.162200Z

Also adding a -m figwheel.main --clean which will clean all builds

bhauman 2020-06-05T15:53:59.162700Z

and a -m figwheel.main --clean dev to clean a single build

bhauman 2020-06-05T15:55:54.164800Z

--clean is more precise as it cleans files generated for extra-mains and bundles as well

bhauman 2020-06-05T15:59:48.167800Z

considering adding auto-clean that detects fundamental changes, like changes to a project.clj , deps.edn , package.json , package.json.lock , yarn.lock and then cleans, but its going to be hard to enumerate all the files that might trigger a need for clean.

dominicm 2020-06-05T16:15:54.168600Z

Nice. I've been manually doing that for a long time.

2020-06-05T18:33:41.169800Z

Getting this sort of thing:

[Figwheel] Compiling build figwheel-main-option-build to "resources/public/cljs-out/figwheel-main-option-build-main.js"
internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module '@cljs-oss/module-deps'
when using :extra-mains in figwheel-main version tested [com.bhauman/figwheel-main "0.2.7"] and [com.bhauman/figwheel-main "0.2.3"] (older)

2020-06-05T18:33:51.170400Z

The weird part is I have :npm-deps false in my build

2020-06-05T18:34:04.170800Z

it’s looking like it is not merging that into the extra main compiler opts perhaps?

2020-06-05T18:34:08.171Z

I tried to just restate it

2020-06-05T18:34:15.171200Z

but it still has same issue

2020-06-05T18:34:40.171400Z

like

:extra-main-files {:testing {:main my.cljs-test-runner
                             :npm-deps false}}

2020-06-05T18:35:00.171900Z

it also seems to output to it’s own default targets and stuff too instead of the output-dir I had specified (perhaps that is expected?)

2020-06-05T18:35:08.172100Z

Oh, and lastly it opens the browser url

2020-06-05T18:35:18.172300Z

when i do have :open-url false

2020-06-05T18:35:34.172700Z

again, it’s just the extra mains that seem to not participate in any of my configuration

2020-06-05T18:38:32.173Z

(just trying to use async runner for console CI output - no UI)

2020-06-05T18:46:40.173300Z

Then I just pulled it all out into a separate test.cljs.edn instead

2020-06-05T18:47:04.173800Z

and went the route of calling -m figwheel.main -co test.cljs.edn -m my.main.ns

2020-06-05T18:47:26.174400Z

it compiled this way at least and didn’t open the browser - however, it doesn’t finish - just hangs saying “JavaScript environment will not launch automatically when :open-url is false”

2020-06-05T18:48:04.174700Z

with my -main just doing this:

(defn -main [& args]
  (run-tests-async 10000))

2020-06-05T18:48:09.174900Z

as specified in https://figwheel.org/docs/testing.html

2020-06-05T18:48:25.175500Z

maybe this only works with a nodejs target or something?

2020-06-05T19:24:40.175800Z

went down this path instead https://betweentwoparens.com/clojurescript-test-setup with js-dom and can at least run this way it seems

2020-06-05T19:24:52.176300Z

pretty confused still the state of the built-in stuff though I guess.

bhauman 2020-06-05T19:53:43.176900Z

@mikerod you can’t have :npm-deps false in a :bundle build

bhauman 2020-06-05T19:53:50.177100Z

I’ll be back later

bhauman 2020-06-05T19:53:59.177300Z

have to go out for a bit

bhauman 2020-06-05T19:55:50.177400Z

oh and use 0.2.8-SNAPSHOT

2020-06-05T20:08:41.177800Z

I am not using bundle either. Just FYI

bhauman 2020-06-05T22:08:59.179200Z

@mikerod yeah OK so there are a few things here, have you read https://figwheel.org/docs/extra_mains.html

2020-06-05T22:19:50.179800Z

I read al the docs related here. Including that

2020-06-05T22:20:30.180400Z

My main first issue was extra mains seemed to not use my config I had for the normal main dev build

2020-06-05T22:20:55.181200Z

Like it opened browser that I didn’t want, also output in default area, also tried to use npm that I didn’t want

2020-06-05T22:21:08.181700Z

So I moved it fully to its own build setup instead and my config was then honored.

2020-06-05T22:21:20.182200Z

But then I just got it waiting forever with the async handler

2020-06-05T22:21:27.182500Z

Which not sure what is supposed to happen

2020-06-05T22:21:40.183Z

So then I just did the launch js stuff with js-dom and tests run

2020-06-05T22:22:02.183600Z

Perhaps you always have to have a JS launcher if you aren’t using browser UI style testing?

bhauman 2020-06-05T23:22:56.184400Z

@mikerod so there is a big bug in 0.2.7

bhauman 2020-06-05T23:24:27.185400Z

Also extra-mains don’t let you change anything other than:

bhauman 2020-06-05T23:25:05.185700Z

• :main • :output-to • :target • :asset-path • :closure-defines • :preloads

bhauman 2020-06-05T23:25:53.186600Z

another thing is that extra-mains are only to be used during dev and they are supposed to open a browser

2020-06-05T23:26:26.187600Z

Ok. Clears that part up then. Thanks for details

2020-06-05T23:26:42.188400Z

It did make it where I can’t do testing with it. I use older webpack style npm bundle

2020-06-05T23:26:50.188800Z

So the npm issue showed up.

2020-06-05T23:27:04.189300Z

Haven’t upgraded to newer cljs bundle features yet. Cutting edge stuff.

bhauman 2020-06-05T23:27:23.189700Z

@mikerod are you saying that you had a build that worked that stopped working?

2020-06-05T23:27:37.190Z

Nope

2020-06-05T23:27:46.190500Z

First time trying figwheel main modern testing features.

2020-06-05T23:27:59.191500Z

That’s when I discovers this. But it’s not a regression sort of thing

bhauman 2020-06-05T23:28:38.192500Z

so if you have npm-deps false then it should defintely be in the extra-main as well

2020-06-05T23:28:51.192900Z

I can do testing via a completely separate build config though at least

2020-06-05T23:29:04.193500Z

Then I can configure the compiler as needed etc. just wasn’t directly in the docs.

2020-06-05T23:29:15.194100Z

Perhaps somewhat indirectly discoverable though.

2020-06-05T23:29:36.194800Z

Interesting about npm-deps

2020-06-05T23:29:44.195400Z

The error looked like when you don’t have it set

bhauman 2020-06-05T23:30:20.196300Z

this could be a real bug, but again please don’t use 0.2.7 as it overwrites your main file with a test file

2020-06-05T23:30:25.196600Z

I don’t have enough fine grained details I know

2020-06-05T23:30:36.196900Z

Ok.

bhauman 2020-06-05T23:30:56.197700Z

also using the latest ClojureScript 0.10.773 is really important as well

2020-06-05T23:31:00.198100Z

I’ll not use that version. I did see the same npm error with 0.2.3 though

bhauman 2020-06-05T23:31:07.198300Z

oh

2020-06-05T23:31:14.198800Z

I am using latest cljs as well

2020-06-05T23:31:39.199500Z

Oh maybe not

2020-06-05T23:32:18.200700Z

1.10.764

bhauman 2020-06-05T23:32:24.200900Z

yeah that one has some npm-deps issues

2020-06-05T23:32:30.201300Z

Interesting

2020-06-05T23:32:47.202200Z

I think I saw issue with earlier cljs. So jumped to this one. But maybe I need to try again with the even newer.

2020-06-05T23:32:56.202600Z

I am not at laptop to try at the moment.

bhauman 2020-06-05T23:33:11.203200Z

no worries but it sounds like this may be a cljs issue

2020-06-05T23:33:15.203500Z

I appreciate the help too

bhauman 2020-06-05T23:33:21.203800Z

as I haven’t tested this setup

2020-06-05T23:33:29.204100Z

I’ll try 1.10.773 and see if that was related

2020-06-05T23:33:37.204400Z

When I get chance.

bhauman 2020-06-05T23:34:12.205200Z

but you do have :npm-deps false in your build config right?

bhauman 2020-06-05T23:35:05.206200Z

and if you do a --print-config it shows :npm-deps false

2020-06-05T23:35:17.206600Z

Yes. I do have it in dev build config

2020-06-05T23:35:20.206800Z

And my repl works

2020-06-05T23:35:28.207100Z

It’s just when I added extra-mains for testing

2020-06-05T23:35:44.207800Z

It kept failing with that classic npm issue about @oss...

bhauman 2020-06-05T23:35:53.208100Z

yeah that’s weird

2020-06-05T23:36:18.209Z

Maybe I can try to get more output on it later to see what’s going on there.

bhauman 2020-06-05T23:36:26.209400Z

so if I wanted to reproduce this, I just use the figwheel :npm stuff?

bhauman 2020-06-05T23:36:44.210100Z

and set npm-deps false and then add an extra-main

2020-06-05T23:36:56.210500Z

Yeah I think. But I do have foreign-libs

2020-06-05T23:37:04.210800Z

Using the old “double bundle” cljs style

bhauman 2020-06-05T23:37:05.211100Z

yeah that shouldn’t affect it

2020-06-05T23:37:11.211300Z

Didn’t think so

2020-06-05T23:37:34.212100Z

But maybe it matters to have node_modules in the dir of project? Don’t know

bhauman 2020-06-05T23:37:56.212700Z

it sounds like something the new CLJS introduced

2020-06-05T23:38:02.213Z

Because maybe that’s what is being scanned when it shouldn’t be or something

bhauman 2020-06-05T23:41:05.214Z

so I’ll use 0.2.3 and cljs 0.10.764

2020-06-05T23:45:42.214300Z

Yep