This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-10-11
Channels
- # beginners (57)
- # boot (9)
- # clara (9)
- # cljs-dev (12)
- # clojure (98)
- # clojure-boston (1)
- # clojure-dusseldorf (12)
- # clojure-france (1)
- # clojure-greece (1)
- # clojure-spec (41)
- # clojure-uk (86)
- # clojurescript (60)
- # code-art (2)
- # data-science (5)
- # datomic (5)
- # duct (1)
- # fulcro (14)
- # graphql (2)
- # lein-figwheel (4)
- # luminus (1)
- # midje (1)
- # off-topic (19)
- # om (10)
- # onyx (13)
- # pedestal (5)
- # portkey (59)
- # re-frame (31)
- # reagent (1)
- # ring (14)
- # ring-swagger (1)
- # rum (5)
- # shadow-cljs (90)
- # spacemacs (5)
- # specter (47)
- # sql (9)
- # uncomplicate (95)
- # vim (32)
wondering the best way to handle something like this:
[:browser] Build failure:
errors in file: /Users/MattPro/Documents/sites2017/keys/node_modules/keypress/index.js
{:js-requires ["events" "string_decoder"], :js-imports [], :js-invalid-requires [], :js-language "es3", :js-errors [{:line 374, :column 30, :message "Octal integer literals are not supported in strict mode."} {:line 375, :column 30, :message "Octal integer literals are not supported in strict mode."}], :js-warnings [{:line 36, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 76, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 104, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 117, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"} {:line 130, :column 3, :message "illegal use of unknown JSDoc tag \"api\"; ignoring it"}], :tag :shadow.build.npm/errors}
ExceptionInfo: errors in file: /Users/MattPro/Documents/sites2017/keys/node_modules/keypress/index.js
my current workaround is to include the keypress lib in a <script>
tag and then a :js-option {"keypress": {:target :global :global "keypress"}}
module without entry or suffix: keypress.js
{:package {:package-name "keypress.js", :package-dir #object[java.io.File 0x2e477178 "/Users/MattPro/Documents/sites2017/keys/node_modules/keypress.js"], :package-json {"name" "keypress.js", "version" "2.1.4", "main" "keypress.js", "description" "a robust keyboard input capturing Javascript utility focused on input for games. For details and documentation, please visit ", "devDependencies" {"jasmine" "1.3.0"}, "spm" {"main" "keypress.js", "ignore" ["compiler.jar"]}}, :version "2.1.4", :dependencies #{}}, :entry "keypress.js"}
ExceptionInfo: module without entry or suffix: keypress.js
"main" : "keypress.js",
yet there is no keypress.js
file in the directory, only a keypress.coffee
# Anonymous Module Definition
if typeof define is "function" and define.amd
define [], ->
return keypress
else if exports?
exports.keypress = keypress
else
window.keypress = keypress
https://github.com/dmauro/Keypress/issues/130 5 Dec 2016
still not fixed 😞
so string requires also work with the other cljs build tools - meaning i can switch all my libraries to (:require [“react” as react])?
maybe out of scope, but is there a way to specify a fallback for the dev server? (eg. for pushstate routes, so /whatever/non/file/route returns index.html)
Reading about resolve in #cljs-dev I had the feeling that :type
should default to :npm
most of the time (convention over configuration they say?) - just an idea @thheller
@richiardiandrea :type
? you mean :target
? :resolve
is optional, the default is to look up :npm
. you only specify :resolve
if you want to override something.
(ns my.app (:require ["keypress.js" :refer [keypress]]))
(defonce Keypress (new (.-Listener keypress)))
new $module$node_modules$keypress_js$keypress_2_1_4_min$$.$keypress$.$Listener$;
the referred keypress
as well as Listener
are renamed by the compiler & so it breaks
the only way I currently know how to get this working is pretty ugly:
(ns my.app (:require ["keypress.js" :as KP]
[goog.object :as gobj]))
(defonce Keypress (new (gobj/getValueByKeys KP "keypress" "Listener")))
not sure how one could add hints somewhere here, or write an externs file that references things brought in from node_modules
@thheller cool that's exactly what I would expect 😉
38 | (defonce Keypress (new (.-Listener keypress)))
-----------------------------------------^--------------------------------------
Property keypress never defined on module$node_modules$keypress_js$keypress_2_1_4_min
/**
* @externs
*/
/** @constructor */
var X = function() {};
X.prototype.Listener;
X.prototype.keypress;
i haven’t written externs by hand in awhile.. so X
can be anything, doesn’t have to match module$node_modules$keypress...
X.prototype.keypress
basically tells the compiler that whenever it finds some.keypress
property access and it doesn’t know the type of some
to not rename it
ie. https://github.com/thheller/shadow-cljs/blob/master/src/main/shadow/cljs/npm/externs.js
btw not sure if you know that but shadow-cljs release browser --pseudo-names
enables pseudo names to help debugging issues such as this
also shadow-cljs release browser --debug
but source maps are currently not totally accurate once you use a JS dependency
I totally want to automate externs more … it should be possible to make it work automatically without additional config
are there a lot of cases where externs files do more than list property names of the form you just showed?
the Closure Library is fully typed, CLJS is not. so there are going to be cases where closure will be unable to infer the type of a thing
so in many cases, a sufficient externs
file could be generated from a vector of property strings
say if you have (defn render [] ...)
in CLJS, the render
name would usually be renamed
yeah, and because these things are by definition repetitive, may not have a huge impact after gzip?
still should not be a huge impact, could always let someone write specialized externs