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

npm task #39

Closed
Deraen opened this issue Sep 7, 2016 · 5 comments
Closed

npm task #39

Deraen opened this issue Sep 7, 2016 · 5 comments
Assignees

Comments

@Deraen
Copy link
Member

Deraen commented Sep 7, 2016

From cljsjs/packages#396

A common use case starts to be quite evident:

(deftask build []
  (let [tmp (boot/tmp-dir!)]
    (with-pre-wrap
      fileset
      (doseq [f (boot/input-files fileset)]
        (let [target (io/file tmp (tmpd/path f))]
          (io/make-parents target)
          (io/copy (tmpd/file f) target)))
      (io/copy
       (io/file tmp "webpack.config.js")
       (io/file tmp +lib-folder+ "webpack-cljsjs.config.js"))
      (binding [*sh-dir* (str (io/file tmp +lib-folder+))]
        ((sh "npm" "install"))
        ((sh "npm" "install" "webpack"))
        ((sh "npm" "run" "build"))
        ((sh "./node_modules/.bin/webpack" "--config" "webpack-cljsjs.config.js")))
      (-> fileset (boot/add-resource tmp) boot/commit!))))

We can parametrizize this like this:

(npm :import-files {"webpack-cljsjs.config.js" (str +lib-folder+ "webpack-cljsjs.config.js"}
     :commands [["npm" "install"]
                ["npm" "install" "webpack"]]
                ["npm" "run" "build"]]
                ["./node_modules/.bin/webpack" "--config" "webpack-cljsjs.config.js"]])

Where import-files is map of path in fileset to path in working dir for npm.

@Deraen Deraen self-assigned this Sep 7, 2016
@burn2delete
Copy link

https://github.com/degree9/boot-npm Could be extended to support this, current options are limited but this was the direction I had originally planned for the task.

@Deraen
Copy link
Member Author

Deraen commented Sep 7, 2016

Looking at it. The implementation code (without task options etc.) in boot-npm + boot-exec is only ~40 lines. Currently it has a few options we wouldn't need here and it is missing probably some others. I will probably prefer to implement this completely here as it will be easier for me to maintain.

PS. cache key use looks interesting!

Have you tested how it works if you remove some dependencies? I think one needs to run npm prune to remove removed packages from existing node_modules dir.

@burn2delete
Copy link

I have not tested that functionality specifically. I have just been deleting the cache folder and letting the task recreate it as needed. That is probably something which could be easily added tho. Each project gets its own cache folder so this is identical to having node_modules folder in project dir except it is hidden and managed by the boot task.

Feel free to use any of the code you like all MIT license.

@Deraen
Copy link
Member Author

Deraen commented Sep 19, 2016

@flyboarder This is very low on my todo list as I hope this will not be needed in a few months time. If/when we get proper Closure Module Processing support running Webpack will be unncessary as we can directly consume CommonJS/ES6 etc. modules.

First issue in getting module processing workin is http://dev.clojure.org/jira/browse/CLJS-1762

@Deraen
Copy link
Member Author

Deraen commented Dec 12, 2017

4407531

@Deraen Deraen closed this as completed Dec 12, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants