Fork me on GitHub
#shadow-cljs
<
2019-09-23
>
Dan11:09:29

I need a specific Babel preset that I have set in a local .babelrc file within a module's folder. I don't want Babel's default transformation of ES6 module syntax to commonjs, so have set it to false (https://babeljs.io/docs/en/6.26.3/babel-preset-env#modules). This doesn't seem to be working. Does shadow-cljs do any other transformation that would effect this?

thheller12:09:33

@studio can you clarify what you are trying to do? "withing a module's folder" can mean many different things? is it in node_modules?

Dan12:09:39

I have decided to persevere with getting Storybook running - after researching it further, the issue is that Storybook is expecting ES Modules and Babel by default is using commonjs so there is a conflict. I have a custom babel config file (https://storybook.js.org/docs/configurations/custom-babel-config/#docs-content) but it doesn't seem to be getting picked up as there are still errors surrounding the use of default

thheller12:09:25

that explains nothing sorry

thheller12:09:53

shadow-cljs does not produce ES Modules. no matter how you configure it, babel isn't even involved in that part

thheller12:09:18

can you setup a sample project for this? maybe I can help if you show me some actual code

thheller12:09:33

but it seems to me you are trying things that'll never work

Dan12:09:16

Sure, I'll set up a quick repo now.

Dan13:09:08

It loads Storybook fine - if you change a string, like the buttons text, then it reloads and errors with can't redefine non-configurable property "default". It also loads "Default" as a story, which is wrong, there should only be one story which is "Normal".

Dan13:09:37

This all seems to be related to how export default is treated.

thheller13:09:11

> added 1084 packages from 869 contributors and audited 36312 packages in 113.036s

thheller13:09:15

isn't npm fun ....

🙂 4
thheller13:09:56

> webpack built efa024dd49af14b30e80 in 70472ms

thheller13:09:06

and they complain that shadow-cljs is slow 😉

thheller13:09:39

@studio I seem to have got it working

Dan13:09:02

:face_with_monocle: How?!

thheller13:09:23

required changing some of the code generated by :npm-module

Dan13:09:08

Was it to do with Babel's modules?

thheller13:09:29

not involved at all

Dan13:09:40

What was the cause?

Dan13:09:16

Doesn't error locally! Let me try on the full prod build with Reagent etc

Dan13:09:41

I'm unsure why it hangs around 69% for so long when building

thheller14:09:17

probably processing the cljs.core. takes forever

Dan14:09:34

Everything seems to work, unless you change the name of the function: (defn ^:export normal [button] "Hello") (defn ^:export normalXXX [button] "Hello") this._data[id] is undefined Do you get that too? Changing anything else, the reload works as expected.

thheller14:09:55

didn't try. no time to look into that sorry

thheller14:09:45

I would recommend staying as far away as possible from this

thheller14:09:54

it is always going to be a hack when used with CLJS

Dan14:09:58

From Storybook?

Dan14:09:36

Not good news!

Dan14:09:13

I will have a think - thank you!

herald09:09:12

Just a tip: there are some clojurescript libs similar to storybook that could be worth checking out. https://github.com/bhauman/devcards https://github.com/nubank/workspaces

mynomoto15:09:50

Does anyone use jest with shadow-cljs? How do you setup the project?

enn18:09:21

What does [:no-worker :app] mean when attempting to start a CLJS REPL for the build :app?

thheller18:09:37

that the watch isnt running

enn18:09:00

thank you

mynomoto18:09:42

Is there some workaround for the dynamic import problem? https://github.com/thheller/shadow-cljs/issues/486

thheller18:09:09

yeah, don't use it 😉

mynomoto18:09:00

Well it comes from a library, so forking it should be the best bet?

thheller18:09:31

can't do much until the closure compiler supports it

mynomoto18:09:45

Ok, thanks. Is this related or is it another kind of problem?

SHADOW import error /home/project/.shadow-cljs/builds/test/dev/out/cljs-runtime/shadow.js.shim.module$react_native.js
/home/project/node_modules/react-native/Libraries/Utilities/warnOnce.js:15
const warnedKeys: {[string]: boolean} = {};
      ^^^^^^^^^^

SyntaxError: Missing initializer in const declaration
    at new Script (vm.js:80:7)
    at createScript (vm.js:274:10)
    at Object.runInThisContext (vm.js:326:10)
    at Module._compile (internal/modules/cjs/loader.js:664:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)

thheller18:09:26

looks to me like you are trying something that isn't supposed to work?

thheller18:09:35

ie. importing react-native without metro?

mynomoto18:09:00

That would explain it, thanks. I wasn't aware that I could not import react-native without metro.

thheller18:09:44

yeah thats typescript or flow

thheller18:09:04

requires preprocessing before you can run it. so metro.

mynomoto18:09:50

I guess that this makes a lot more complicated testing react-native apps using shadow-cljs.

thheller18:09:13

dunno. how are they usually tested? shouldn't be much more complicated than those setups

mynomoto18:09:53

I'm not sure either, I'm coming from the cljs side. For the look of what I read it involves lots of babel.

thheller18:09:04

I didn't look into testing react-native at all. if you have a reference example I can maybe tell you if its possible or not to get this going

mynomoto18:09:12

Ok, thanks. I think I have to do more exploration on the js side of this.