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

Better support compile-to-JS languages? #2281

Closed
thheller opened this issue May 20, 2017 · 3 comments
Closed

Better support compile-to-JS languages? #2281

thheller opened this issue May 20, 2017 · 3 comments

Comments

@thheller
Copy link

I'm developing shadow-cljs which is a ClojureScript build tool. The goal is to provide zero-config interop with existing JS tools like this one. It is already zero-config with one exception: File reloading does not work.

ClojureScript organizes code into namespaces, which means that a demo.foo namespace should be in src-cljs/demo/foo.cljs. To make this actually zero config the tool will compile to ./node_modules/shadow-cljs/demo.foo.js which you can then require("shadow-cljs/demo.foo") (or import).

This works nicely, except that yarn start will not reload changes because of this

    watchOptions: {
      ignored: /node_modules/,
    }

I understand why this is there so I'm looking for other ways to still get good interop. One way would be to provide a way to override the watchOptions without eject-ing. I just need a way to getignored: /node_modules\/(?!shadow-cljs)/ in there.

The generate into node_modules "hack" is probably not the recommended way to do things but it just works. Whereas all other solutions I tried required way too much configuration and juggling too many relative paths.

Any thoughts on a solution that doesn't require eject?

@thheller
Copy link
Author

I played with a few different options but each seems to have its own issues.

  • put generated code into node_modules works but won't get reloaded.
  • put generated code into src/cljs and load via relative paths. Causes the code to run through eslint which a bajillion useless warnings and slows down development significantly. .eslintignore doesn't seem to have an effect. Probably also runs through every other babel transform but none are needed.
  • put generated code into compiled and include via ../compiled/demo.foo

Module not found: You attempted to import ../compiled/demo.foo which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project's node_modules/

The only viable option remaining seems to eject and add the modified ignored. 😞

@gaearon
Copy link
Contributor

gaearon commented May 27, 2017

Doesn't symlinking work?

You can either move it inside src/, or add a symlink to it from project's node_modules/

It should still be reloaded in this case.

@thheller
Copy link
Author

Oh, I dismissed that possibility since there already is a node_modules/shadow-cljs from the npm package. If I symlink node_modules/shadow-cljs-gen -> compiled it indeed works.

Not pretty but better than eject for now. Thanks.

@gaearon gaearon closed this as completed Jun 26, 2017
@lock lock bot locked and limited conversation to collaborators Jan 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants