Git Product home page Git Product logo

Comments (3)

abhi18av avatar abhi18av commented on July 30, 2024

I've tweaked the cljsbuild section to include the following

         {:id "nodejs"
                :source-paths ["src/cljs" "src/cljc" "dev"]
                :compiler {:main cljs.user
                           :target :nodejs
                           :asset-path "js/compiled/out"
                           :output-to "resources/public/js/compiled/nodejs/nodejs.js"
                           :output-dir "resources/public/js/compiled/nodejs"
                           :source-map-timestamp true}}

from chestnut.

abhi18av avatar abhi18av commented on July 30, 2024

I've started to work on a seperate branch with chestnut/master as base here https://github.com/abhi18av/devnagri-ui-tests/tree/node-repl

I've made progress with the configuration here

            {:id "nodejs"
                :source-paths ["src/nodejs" "src/cljc" ]
                :compiler {:main cljs.user
                           :target :nodejs
                           ;:asset-path "js/compiled/out"
                           :output-to "resources/public/js/compiled/nodejs/nodejs.js"
                           :output-dir "resources/public/js/compiled/nodejs"
                           :pretty-print true
                           :optimizations :simple
                           ;:optimizations :advanced :simple :whitespace :none
                           :parallel-build true
                           :npm-deps {"chalk" "2.1.0"}
                           :install-deps true
                           ;:source-map-timestamp true
                           ;:source-map true 
                           :warnings false}}

And the code in src/nodejs/devnagri_ui_tests/nodejs.cljs is as follows

(ns devnagri-ui-tests.nodejs
  (:require [clojure.string :as str]
            [cljs.nodejs :as nodejs]))

(nodejs/enable-util-print!)

(defn -main [& args]
  (-> (str/join " " args)
      (str/replace #"cker\b" "xor")
      (str/replace #"e|E" "3")
      (str/replace #"i|I" "1")
      (str/replace #"o|O" "0")
      (str/replace #"s|S" "5")
      (str/replace #"a|A" "4")
      (str/replace #"t|T" "7")
      (str/replace #"b|B" "6")
      (str/replace #"c|C" "(")
      println))

(set! *main-cli-fn* -main)

But running the node on the output doesn't print out anything at all

❯ npm test

> [email protected] test /Users/eklavya/Projects/ProjectEklavya/BlueCollar/devnagri-ui-tests
> /Users/eklavya/.nvm/versions/node/v8.1.3/bin/node resources/public/js/compiled/nodejs/nodejs.js

The expected output is as follows

$ l33t I am a leet hacker
1 4m 4 l337 h4x0r

This is taken from blog-post by plexus here https://lambdaisland.com/blog/02-05-2017-nodejs-scripts-clojurescript

from chestnut.

featheredtoast avatar featheredtoast commented on July 30, 2024

Hey there!

The one issue I was running into with your code specifically was that your version of clojurescript didn't seem to like compiling node. The following worked:
[org.clojure/clojurescript "1.9.946" :scope "provided"].

Your cljs main should probably also be devnagri-ui-tests.nodejs:

{:id "nodejs"
                :source-paths ["src/nodejs" "src/cljc" ]
                :compiler {:main devnagri-ui-tests.nodejs
                           :target :nodejs
                           ;:asset-path "js/compiled/out"
                           :output-to "resources/public/js/compiled/nodejs/nodejs.js"
                           :output-dir "resources/public/js/compiled/nodejs"
                           :pretty-print true
                           :optimizations :simple
                           ;:optimizations :advanced :simple :whitespace :none
                           :parallel-build true
                           :npm-deps {"chalk" "2.1.0"}
                           :install-deps true
                           ;:source-map-timestamp true
                           ;:source-map true 
                           :warnings false}}

In the future, this kind of thing would be ideal to bring up in the mailing list or on the clojurian slack, not as an issue here.

from chestnut.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.