Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example of :preprocess given recent updates #179

Open
SevereOverfl0w opened this issue Oct 6, 2017 · 6 comments
Open

Example of :preprocess given recent updates #179

SevereOverfl0w opened this issue Oct 6, 2017 · 6 comments

Comments

@SevereOverfl0w
Copy link

continuation of #151

One annoyance is that :file in :foreign-libs is not prefixed on the classpath automatically to the relevant boot tmp files.

@SevereOverfl0w
Copy link
Author

I think I got close, but got this error: Error: Cannot find module '@cljs-oss/module-deps'

@Deraen
Copy link
Contributor

Deraen commented Oct 6, 2017

You need to run npm install @cljs-oss/module-deps to use module processing.

@SevereOverfl0w
Copy link
Author

I see. That makes sense.

I made some further progress by removing the folder containing the js to compile out of my src directory (which felt a little wonky, is this expected?).

I couldn't manage to require react 15 (from node_modules) from that external js though however. I'd be quite happy to require the cljsjs.React, but that didn't seem possible either.

The error I saw was this:

TypeError: module$home$dominic$src$github_com$juxt$edge$node_modules$react$react.default is undefined[Learn More]

@Deraen
Copy link
Contributor

Deraen commented Oct 7, 2017

Looks like you are trying to require React (CommonJS) from ES6 module. That doesn't work currently: google/closure-compiler#2634

And foreign libs (cljsjs) are Cljs only, so they can't be used from module processing modules.

@SevereOverfl0w
Copy link
Author

Okay, so if I convert the code to be commonjs throughout, that seems to be working. Unless I end up depending on a module which uses ES6 modules, I guess? (I'm not sure if that can happen)

I thought they might be cljs only, but figured I'd ask regardless.


I have this working now, which is great!

Things that seem to be missing:

  1. the input files have to be off the classpath else they conflict & you never get your transformed version. I think boot-cljs should be removing them from the fileset (just a hunch)
  2. As the input files are off the classpath, there's no file reloading. This might be fixed by 1.
  3. the foreign-libs requires the prefix src/ or wherever you keep your code, instead of using the classpath like other properties which are transformed automatically, this has been useful in dodging 1, but is probably not desired behaviour.

Are these things that boot-cljs should/would fix? Shall I open specific issue(s) to track them?

@Deraen
Copy link
Contributor

Deraen commented Oct 7, 2017

You can depend on most ES6 modules, but not on those ES6 modules that use CJS.

CommonJS -> ES6 Works
ES6 -> CommonJS Doesn't

I have only looked into case where using existing Node packages, which are always under node_modules, not sure what happens and should happen with local CJS or ES6 modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants