{"action":"created","issue":{"url":"https://api.github.com/repos/magnars/optimus/issues/38","labels_url":"https://api.github.com/repos/magnars/optimus/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/magnars/optimus/issues/38/comments","events_url":"https://api.github.com/repos/magnars/optimus/issues/38/events","html_url":"https://github.com/magnars/optimus/issues/38","id":75974688,"number":38,"title":"\"Maximum call stack size exceeded\" during Javascript minification","user":{"login":"ocharles","id":20878,"avatar_url":"https://avatars.githubusercontent.com/u/20878?v=3","gravatar_id":"","url":"https://api.github.com/users/ocharles","html_url":"https://github.com/ocharles","followers_url":"https://api.github.com/users/ocharles/followers","following_url":"https://api.github.com/users/ocharles/following{/other_user}","gists_url":"https://api.github.com/users/ocharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ocharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocharles/subscriptions","organizations_url":"https://api.github.com/users/ocharles/orgs","repos_url":"https://api.github.com/users/ocharles/repos","events_url":"https://api.github.com/users/ocharles/events{/privacy}","received_events_url":"https://api.github.com/users/ocharles/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-13T12:54:40Z","updated_at":"2015-05-13T13:31:15Z","closed_at":null,"body":"Not sure what info I can provide, but this is the file that uses Optimus:\r\n\r\n```clojure\r\n(ns fynder.exporter\r\n  (:require [clojure.java.io :as io]\r\n            [clojure.string :refer [replace]]\r\n            [net.cgrand.enlive-html :as enlive :refer [at do-> content html-resource attr= prepend append html emit* transform-content]]\r\n            [fynder.env :refer [config]]\r\n            [optimus.assets :as assets]\r\n            [optimus-less.core]\r\n            [optimus.export]\r\n            [optimus.html :refer [link-to-css-bundles link-to-js-bundles]]\r\n            [optimus.optimizations :as optimizations]\r\n            [stasis.core :as stasis]))\r\n\r\n(defn js-src\r\n  \"Generate a JavaScript src reference.\"\r\n  [src]\r\n  (html [:script {:type \"text/javascript\"\r\n                  :src src}]))\r\n\r\n(defn js-tag\r\n  \"Generate a JavaScript tag that runs the given (JavaScript) code.\"\r\n  [string]\r\n  (html [:script {:type \"text/javascript\"} string]))\r\n\r\n(defn loader-tag\r\n  [page-name]\r\n  (js-tag (format \"fynder.interop.call_on_load(fynder_%s.main.main);\" page-name)))\r\n\r\n(defn rewrite-index-page\r\n  \"Rewrites the main.html page for use in production.\r\n\r\n  This is a single-page app, and that page should be targetted at\r\n  development. It's this function's job to do any writing necessary to\r\n  make it production-ready.\"\r\n  [{:keys [uri page-config]\r\n    :as context}]\r\n  (->> (at (html-resource \"public/main.html\")\r\n\r\n           ;; Remove anything tagged for development with a data-info='dev' attribute.\r\n           [(attr= :data-info \"dev\")]\r\n           nil\r\n\r\n           ;; Remap the Google Analytics tracking code\r\n           [(attr= :data-info \"ga\")]\r\n           (transform-content #(replace % #\"XXXX\" (:tracking-code (page-config uri))))\r\n\r\n           ;; Remap the Heap tracking code\r\n           [(attr= :data-info \"heap\")]\r\n           (transform-content #(replace % #\"XXHEAPXX\" (or (:admin-heap-tracking-code (page-config uri)) \"\")))\r\n\r\n           ;; ;; Add in the compiled CSS.\r\n           [:head]\r\n           (prepend\r\n            (link-to-css-bundles context (:css-files (page-config uri))))\r\n\r\n           ;; Add in the compiled ClojureScript.\r\n           [:span#scripts-above-ie8]\r\n           (do->\r\n            (append (link-to-js-bundles context (:js-files (page-config uri))))\r\n            (append (loader-tag (:page-name (page-config uri))))))\r\n\r\n       (emit*)\r\n       (apply str)))\r\n\r\n(defn rewrite-loader-page\r\n  [{:keys [uri page-config]\r\n    :as context}]\r\n  (->> (at (html-resource \"public/loader.html\")\r\n           ;; ;; Add in the compiled CSS.\r\n           [:head]\r\n           (append\r\n            (html (link-to-css-bundles context (:css-files (page-config uri)))))\r\n\r\n           ;; Add in the compiled ClojureScript.\r\n           [:body]\r\n           (append\r\n            (html\r\n              (link-to-js-bundles context (:js-files (page-config uri))))))\r\n\r\n       (emit*)\r\n       (apply str)))\r\n\r\n\r\n(defn get-assets []\r\n  ;; TODO If we were being super-classy, we could pick the JS targets up out of the project.clj file.\r\n  (concat (assets/load-assets  \"public\" [#\"\\.png$\"\r\n                                         #\"\\.jpg$\"])\r\n          (assets/load-bundles \"public\" {\"admin.css\"       [\"/style/admin.less\"]\r\n                                         \"trainer.css\"     [\"/style/trainer.less\"]\r\n                                         \"mobile.css\"      [\"/style/mobile.less\"]\r\n                                         \"sweatybetty.css\" [\"/style/sweatybetty.less\"]\r\n                                         \"loader.css\"      [\"/style/loader.less\"]})\r\n\r\n          (assets/load-bundles \"public\"   {\"preamble.js\" [\"/datatransfer.js\"\r\n                                                          \"/vendor/es5-shim.js\"\r\n                                                          \"/vendor/es5-sham.js\"\r\n                                                          \"/vendor/socket.io-1.2.1.js\"\r\n                                                          \"/vendor/moment.min.js\"\r\n                                                          \"/vendor/fastclick.js\"\r\n                                                          \"/vendor/markdown.min.js\"\r\n                                                          \"/vendor/xss.js\"\r\n                                                          \"/vendor/jquery-1.10.2.min.js\"\r\n                                                          \"/vendor/bootstrap.min.js\"\r\n                                                          \"/vendor/bootstrap-select.min.js\"\r\n                                                          \"/vendor/daterangepicker.js\"\r\n                                                          \"/vendor/colorpicker/js/bootstrap-colorpicker.js\"\r\n                                                          \"/vendor/countdown.js\"\r\n                                                          \"/vendor/papaparse.min.js\"]})\r\n\r\n          (assets/load-bundles \"public\" {\"sweatybetty-extras.js\" [\"/vendor/base32.js\"]})\r\n\r\n          (assets/load-bundles \"assets/js/main\"   {\"cljs.js\"         [\"/cljs.js\"]\r\n                                                   \"admin.js\"        [\"/admin.js\"]\r\n                                                   \"trainer.js\"      [\"/trainer.js\"]\r\n                                                   \"mobile.js\"       [\"/mobile.js\"]\r\n                                                   \"sweatybetty.js\"  [\"/sweatybetty.js\"]})\r\n          (assets/load-bundles \"assets/js/loader\" {\"fynder-loader.js\" [\"/fynder-loader.js\"]})))\r\n\r\n(def app-configs\r\n  {\"/admin.html\" {:page-name \"admin\"\r\n                  :css-files [\"admin.css\"]\r\n                  :tracking-code (config :admin-tracking-code)\r\n                  :admin-heap-tracking-code (config :admin-heap-tracking-code)\r\n                  :js-files [\"preamble.js\" \"cljs.js\" \"admin.js\"]}\r\n\r\n   \"/trainer.html\" {:page-name \"trainer\"\r\n                    :css-files [\"trainer.css\"]\r\n                    :tracking-code (config :trainer-tracking-code)\r\n                    :js-files [\"preamble.js\" \"cljs.js\" \"trainer.js\"]}\r\n\r\n   \"/mobile.html\" {:page-name \"mobile\"\r\n                   :css-files [\"mobile.css\"]\r\n                   :tracking-code (config :widget-tracking-code)\r\n                   :js-files [\"preamble.js\" \"cljs.js\" \"mobile.js\"]}\r\n\r\n   \"/sweatybetty.html\" {:page-name \"sweatybetty\"\r\n                        :css-files [\"sweatybetty.css\"]\r\n                        :tracking-code (config :widget-tracking-code)\r\n                        :js-files [\"preamble.js\" \"cljs.js\" \"sweatybetty-extras.js\" \"sweatybetty.js\"]}})\r\n\r\n(def loader-config\r\n  {\"/loader.html\" {:page-name \"loader\"\r\n                   :css-files [\"loader.css\"]\r\n                   :tracking-code \"\"\r\n                   :js-files [\"fynder-loader.js\"]}})\r\n\r\n(defn my-optimize [assets options]\r\n  (-> assets\r\n      (optimizations/minify-css-assets options)\r\n      (optimizations/inline-css-imports)\r\n      (optimizations/concatenate-bundles)\r\n      (optimizations/add-cache-busted-expires-headers)\r\n      (optimizations/add-last-modified-headers)))\r\n\r\n(defn -main\r\n  []\r\n  (let [app-pages (zipmap (map first app-configs)\r\n                          (repeat rewrite-index-page))\r\n\r\n        loader {\"/loader.html\" rewrite-loader-page}\r\n\r\n        pages (merge loader app-pages)\r\n\r\n        assets (optimizations/all (get-assets) {})\r\n\r\n        target-dir \"target/site\"\r\n        config {:page-config (merge loader-config app-configs)\r\n                :optimus-assets assets}]\r\n    (optimus.export/save-assets assets target-dir)\r\n    (stasis/export-pages pages target-dir config)))\r\n```\r\n\r\nAnd this is the stack trace:\r\n\r\n```\r\nException in thread \"main\" java.lang.Exception: Exception in /fynder-loader.js: Maximum call stack size exceeded (line undefined, col undefined), compiling:(/tmp/form-init1279519951643400366.clj:1:73)\r\n\tat clojure.lang.Compiler.load(Compiler.java:7249)\r\n\tat clojure.lang.Compiler.loadFile(Compiler.java:7175)\r\n\tat clojure.main$load_script.invoke(main.clj:275)\r\n\tat clojure.main$init_opt.invoke(main.clj:280)\r\n\tat clojure.main$initialize.invoke(main.clj:308)\r\n\tat clojure.main$null_opt.invoke(main.clj:343)\r\n\tat clojure.main$main.doInvoke(main.clj:421)\r\n\tat clojure.lang.RestFn.invoke(RestFn.java:421)\r\n\tat clojure.lang.Var.invoke(Var.java:383)\r\n\tat clojure.lang.AFn.applyToHelper(AFn.java:156)\r\n\tat clojure.lang.Var.applyTo(Var.java:700)\r\n\tat clojure.main.main(main.java:37)\r\nCaused by: java.lang.Exception: Exception in /fynder-loader.js: Maximum call stack size exceeded (line undefined, col undefined)\r\n\tat optimus.optimizations.minify$throw_v8_exception.invoke(minify.clj:15)\r\n\tat optimus.optimizations.minify$run_script_with_error_handling.invoke(minify.clj:50)\r\n\tat optimus.optimizations.minify$minify_js.invoke(minify.clj:61)\r\n\tat optimus.optimizations.minify$minify_js_asset$fn__1850.invoke(minify.clj:67)\r\n\tat clojure.lang.AFn.applyToHelper(AFn.java:154)\r\n\tat clojure.lang.AFn.applyTo(AFn.java:144)\r\n\tat clojure.core$apply.invoke(core.clj:630)\r\n\tat clojure.core$update_in.doInvoke(core.clj:5919)\r\n\tat clojure.lang.RestFn.invoke(RestFn.java:445)\r\n\tat optimus.optimizations.minify$minify_js_asset.invoke(minify.clj:67)\r\n\tat optimus.optimizations.minify$minify_js_assets$fn__1854.invoke(minify.clj:74)\r\n\tat clojure.core$map$fn__4550.invoke(core.clj:2622)\r\n\tat clojure.lang.LazySeq.sval(LazySeq.java:40)\r\n\tat clojure.lang.LazySeq.seq(LazySeq.java:49)\r\n\tat clojure.lang.RT.seq(RT.java:507)\r\n\tat clojure.core$seq__4125.invoke(core.clj:135)\r\n\tat clojure.core$map$fn__4550.invoke(core.clj:2614)\r\n\tat clojure.lang.LazySeq.sval(LazySeq.java:40)\r\n\tat clojure.lang.LazySeq.seq(LazySeq.java:49)\r\n\tat clojure.lang.RT.seq(RT.java:507)\r\n\tat clojure.core$seq__4125.invoke(core.clj:135)\r\n\tat clojure.core$map$fn__4550.invoke(core.clj:2614)\r\n\tat clojure.lang.LazySeq.sval(LazySeq.java:40)\r\n\tat clojure.lang.LazySeq.seq(LazySeq.java:49)\r\n\tat clojure.lang.Cons.next(Cons.java:39)\r\n\tat clojure.lang.RT.next(RT.java:674)\r\n\tat clojure.core$next__4109.invoke(core.clj:64)\r\n\tat clojure.core.protocols$fn__6517.invoke(protocols.clj:151)\r\n\tat clojure.core.protocols$fn__6474$G__6469__6483.invoke(protocols.clj:19)\r\n\tat clojure.core.protocols$seq_reduce.invoke(protocols.clj:31)\r\n\tat clojure.core.protocols$fn__6500.invoke(protocols.clj:81)\r\n\tat clojure.core.protocols$fn__6448$G__6443__6461.invoke(protocols.clj:13)\r\n\tat clojure.core$reduce.invoke(core.clj:6515)\r\n\tat clojure.core$group_by.invoke(core.clj:6857)\r\n\tat optimus.optimizations.concatenate_bundles$concatenate_bundles.invoke(concatenate_bundles.clj:27)\r\n\tat optimus.optimizations$all.invoke(optimizations.clj:20)\r\n\tat fynder.exporter$_main.invoke(exporter.clj:163)\r\n\tat clojure.lang.Var.invoke(Var.java:375)\r\n\tat user$eval5.invoke(form-init1279519951643400366.clj:1)\r\n\tat clojure.lang.Compiler.eval(Compiler.java:6792)\r\n\tat clojure.lang.Compiler.eval(Compiler.java:6782)\r\n\tat clojure.lang.Compiler.load(Compiler.java:7237)\r\n\t... 11 more\r\n```"},"comment":{"url":"https://api.github.com/repos/magnars/optimus/issues/comments/101664126","html_url":"https://github.com/magnars/optimus/issues/38#issuecomment-101664126","issue_url":"https://api.github.com/repos/magnars/optimus/issues/38","id":101664126,"user":{"login":"ocharles","id":20878,"avatar_url":"https://avatars.githubusercontent.com/u/20878?v=3","gravatar_id":"","url":"https://api.github.com/users/ocharles","html_url":"https://github.com/ocharles","followers_url":"https://api.github.com/users/ocharles/followers","following_url":"https://api.github.com/users/ocharles/following{/other_user}","gists_url":"https://api.github.com/users/ocharles/gists{/gist_id}","starred_url":"https://api.github.com/users/ocharles/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ocharles/subscriptions","organizations_url":"https://api.github.com/users/ocharles/orgs","repos_url":"https://api.github.com/users/ocharles/repos","events_url":"https://api.github.com/users/ocharles/events{/privacy}","received_events_url":"https://api.github.com/users/ocharles/received_events","type":"User","site_admin":false},"created_at":"2015-05-13T13:31:15Z","updated_at":"2015-05-13T13:31:15Z","body":"I tried `./node_modules/.bin/uglifyjs resources/assets/js/loader/fynder-loader.js` and that runs successfully. That's uglifyjs 2.4.0."}}