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

Support changing of the working directory for the node process #11

Closed
eploko opened this issue Dec 2, 2015 · 2 comments
Closed

Support changing of the working directory for the node process #11

eploko opened this issue Dec 2, 2015 · 2 comments

Comments

@eploko
Copy link
Contributor

eploko commented Dec 2, 2015

I’ve got the following edn in my server-side.cljs.edn:

{:require  [myapp.core]
 :init-fns [myapp.core/main]
 :optimizations :none
 :compiler-options {:target :nodejs
                    :pretty-print true}}

It compiles fine with boot-cljs and there’s the server-side.js file and the corresponding server-side.out folder inside the target folder. The issue I’ve got is when I try to run this with node, it bails out with:

Error: Cannot find module ‘~/projects/myapp/server-side.out/goog/bootstrap/nodejs.js’

It looks like it skips the target folder while trying to locate the module.

The resulting server-side.js file has this inside:

require(path.join(path.resolve("."),"server-side.out","goog","bootstrap","nodejs.js"));

Which, as far as I understand, should be resolved properly, but… the devil is in the fact it doesn’t.

I’ve tried to set :asset-path "target" in the cljs compiler options, but it has no effect, the resulting compiled js is the same.

I run all of this as a part of my boot-clj-based build and as far as I understand the current working directory is the one which is parent to the target directory and where the build.boot file is located. That explains why the path.resolve(".") call returns an incorrect value.

From all this it seems it may be meaningful to add a :working-directory option to the prerenderer.core/start! method, which then would be propagated to a call to the .directory(blahblah) method on the ProcessBuilder instance.

What do you guys think? Will you accept a pull request for this?

@pupeno
Copy link
Owner

pupeno commented Dec 2, 2015

I remember running into an issue similar to what you are describing, so I might have experienced this bug before but I just changed the structure of my project to work with the generated code. If you have a better solution, I'm all for getting the PR. :)

@eploko
Copy link
Contributor Author

eploko commented Dec 2, 2015

@pupeno no worries, you can check the PR out at #12 :)

@eploko eploko closed this as completed Aug 25, 2020
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