Fork me on GitHub
#figwheel-main
<
2020-06-05
>
bhauman15:06:08

I’m finally adding --clean option

parrot 4
👍 8
bhauman15:06:21

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

bhauman15:06:55

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

bhauman15:06:10

they both do the same thing

bhauman15:06:33

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

bhauman15:06:59

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

bhauman15:06:54

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

bhauman15:06:48

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.

dominicm16:06:54

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

mikerod18:06:41

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)

mikerod18:06:51

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

mikerod18:06:04

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

mikerod18:06:08

I tried to just restate it

mikerod18:06:15

but it still has same issue

mikerod18:06:40

like

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

mikerod18:06:00

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?)

mikerod18:06:08

Oh, and lastly it opens the browser url

mikerod18:06:18

when i do have :open-url false

mikerod18:06:34

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

mikerod18:06:32

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

mikerod18:06:40

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

mikerod18:06:04

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

mikerod18:06:26

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”

mikerod18:06:04

with my -main just doing this:

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

mikerod18:06:25

maybe this only works with a nodejs target or something?

mikerod19:06:40

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

mikerod19:06:52

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

bhauman19:06:43

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

bhauman19:06:50

I’ll be back later

bhauman19:06:59

have to go out for a bit

bhauman19:06:50

oh and use 0.2.8-SNAPSHOT

mikerod20:06:41

I am not using bundle either. Just FYI

bhauman22:06:59

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

mikerod22:06:50

I read al the docs related here. Including that

mikerod22:06:30

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

mikerod22:06:55

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

mikerod22:06:08

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

mikerod22:06:20

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

mikerod22:06:27

Which not sure what is supposed to happen

mikerod22:06:40

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

mikerod22:06:02

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

bhauman23:06:56

@mikerod so there is a big bug in 0.2.7

bhauman23:06:27

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

bhauman23:06:05

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

bhauman23:06:53

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

mikerod23:06:26

Ok. Clears that part up then. Thanks for details

mikerod23:06:42

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

mikerod23:06:50

So the npm issue showed up.

mikerod23:06:04

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

bhauman23:06:23

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

mikerod23:06:46

First time trying figwheel main modern testing features.

mikerod23:06:59

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

bhauman23:06:38

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

mikerod23:06:51

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

mikerod23:06:04

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

mikerod23:06:15

Perhaps somewhat indirectly discoverable though.

mikerod23:06:36

Interesting about npm-deps

mikerod23:06:44

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

bhauman23:06:20

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

mikerod23:06:25

I don’t have enough fine grained details I know

bhauman23:06:56

also using the latest ClojureScript 0.10.773 is really important as well

mikerod23:06:00

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

mikerod23:06:14

I am using latest cljs as well

mikerod23:06:39

Oh maybe not

bhauman23:06:24

yeah that one has some npm-deps issues

mikerod23:06:30

Interesting

mikerod23:06:47

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

mikerod23:06:56

I am not at laptop to try at the moment.

bhauman23:06:11

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

mikerod23:06:15

I appreciate the help too

bhauman23:06:21

as I haven’t tested this setup

mikerod23:06:29

I’ll try 1.10.773 and see if that was related

mikerod23:06:37

When I get chance.

bhauman23:06:12

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

bhauman23:06:05

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

mikerod23:06:17

Yes. I do have it in dev build config

mikerod23:06:20

And my repl works

mikerod23:06:28

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

mikerod23:06:44

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

bhauman23:06:53

yeah that’s weird

mikerod23:06:18

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

bhauman23:06:26

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

bhauman23:06:44

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

mikerod23:06:56

Yeah I think. But I do have foreign-libs

mikerod23:06:04

Using the old “double bundle” cljs style

bhauman23:06:05

yeah that shouldn’t affect it

mikerod23:06:11

Didn’t think so

mikerod23:06:34

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

bhauman23:06:56

it sounds like something the new CLJS introduced

mikerod23:06:02

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

bhauman23:06:05

so I’ll use 0.2.3 and cljs 0.10.764