This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-11
Channels
- # announcements (6)
- # architecture (9)
- # beginners (120)
- # calva (13)
- # cider (28)
- # clj-kondo (8)
- # cljs-dev (7)
- # clojure (113)
- # clojure-europe (13)
- # clojure-italy (7)
- # clojure-nl (9)
- # clojure-spec (44)
- # clojure-uk (7)
- # clojuredesign-podcast (15)
- # clojurescript (18)
- # cursive (9)
- # data-science (3)
- # datomic (32)
- # defnpodcast (1)
- # events (2)
- # fulcro (6)
- # jobs (1)
- # kaocha (5)
- # london-clojurians (2)
- # luminus (2)
- # nyc (2)
- # off-topic (54)
- # ring (6)
- # shadow-cljs (136)
- # sql (1)
- # testing (2)
- # tools-deps (64)
- # vim (83)
How do you handle cache busting & copying the index.html
to the target directory where main.js
file is generated? Eg.
Reference to main.js
without cache busting
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="main.js"></script> <--- no cache busting
</body>
</html>
In webpack there is a plugin where you can add hash main.[hash].js
and define a path where your index.html
template is located, and it will copy it to the target
directory@thheller thank you for link. I got the hash working. However it is still not obvious to me how to put the hashes filename in index.html on every build? Would you mind sharing an example?
you read the manifest.edn
, you read your input index.html
. you str/replace the data or however fancy you want to get
Cool. I think it is enough. I will try to make it work. Then maybe I will send a PR to update docs.
btw, I have an idea. It may not be the scope of shadow-cljs. But I’m interested on your opinion.
What if we tell shadow-cljs where the index.html (lets call it template) is located so that it can copy it in the output-dir
?
Then inside the index.html
template, we can define text
that can be replaced by an actual value later.
For instance any text
that starts with $<NAME>.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>$__DOC_TITLE</title>
</head>
<body>
$__SCRIPTS <-- will include all scripts
</body>
</html>
The naming conventation is just an example. Also, on how to get the value needs further thought.If you think it’s something that can be added as an improvement. I’m interested on doing it
you can already do this via https://shadow-cljs.github.io/docs/UsersGuide.html#clj-run or https://shadow-cljs.github.io/docs/UsersGuide.html#build-hooks
@jaime.sangcap A custom script that spits out the html, reading "manifest.edn" for prod builds
I did shadow-cljs release app
for the first time (in a while at least). Now when I go back to watch
I'm getting loads of errors where it seems the JS objects for the CLJS namespaces don't exist. e.g. Cannot set property 'global' of undefined
, where global
is the first defn
in that namespace. I've tried clearing everything in .shadow-cljs
, and in the js/out
dir, but it's still broken. Any ideas?
I don't think so. I've been right clicking on the reload button (Chrome) and doing "Clear cache and reload"
and you are sure you are loading your actual output files? not some older files from some older directory or so?
Turned source maps off to get the actual path of the JS file, confirmed the timestamp is from 2 minutes ago. Same for main.js
hi all…im running up against something that I don’t understand: basically trying to compile with :react-native target, and am including some .js and getting “ReferenceError: Can’t find variable: shadow$provide”
(the .js in this case is generated by the protoc compiler and imported in cljs with a (:require)…this pattern works in :browser but seems to blow up in :react-native
I can see that shadow-cljs did in fact incorporate the generated .js, but it places a reference to shadow$provide that doesnt seem to be fulfilled
so you have a (:require ["./some.js" :as x])
? with some.js
being some generated code?
https://developers.google.com/protocol-buffers/docs/reference/javascript-generated#closure
but then it becomes a regular namespace, so you import it by whatever name it generated
(though in my current iteration, I have abandoned lein-shadow and dropped back to raw shadow-cljs.edn
but all permuations seem to have the same fundamental problem of the missing shadow$provides call
how does anyone get anything done with react-native ... the last time I ran this project it worked fine
react-native run-android
info Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag.
Jetifier found 855 file(s) to forward-jetify. Using 12 workers...
info JS server already running.
info Installing the app...
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :app:transformClassesWithDexBuilderForDebug FAILED
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See
20 actionable tasks: 2 executed, 18 up-to-date
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Could not read path 'C:\Users\thheller\code\tmp\reagent-react-native\react-native\android\app\build\intermediates\transforms\dexBuilder\debug\288\androidx\arch\core'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at
BUILD FAILED in 31s
error Failed to install the app. Make sure you have the Android development environment set up: . Run CLI with --verbose flag for more details.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformClassesWithDexBuilderForDebug'.
> Could not read path 'C:\Users\thheller\code\tmp\reagent-react-native\react-native\android\app\build\intermediates\transforms\dexBuilder\debug\288\androidx\arch\core'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at
BUILD FAILED in 31s
at checkExecSyncError (child_process.js:621:11)
at execFileSync (child_process.js:639:15)
at runOnAllDevices (C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:74:39)
at buildAndRun (C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:158:41)
at C:\Users\thheller\code\tmp\reagent-react-native\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\index.js:125:12
at processTicksAndRejections (internal/process/task_queues.js:85:5)
at async Command.handleAction (C:\Users\thheller\AppData\Roaming\npm\node_modules\react-native\node_modules\@react-native-community\cli\build\cliEntry.js:160:7)
Is it possible to set goog.DEBUG to true for advanced builds?
ES6 module works though, although I only tested with export const foo = "foo";
. no clue what the protoc generated files look like
Yeah, that’s what I’ve been doing but my marker code isn’t showing up
let me play around a bit more
just wanted to ensure it’s meant to work 🙂
its not really clear what the problem is, but there seems to be an issue with .js transitives now
I tried to build a stripped down use case, and I succeeded though the error is slightly different
in essence, it seems there is some kind of problem referencing something like google-protobuf/google/protobuf/any_pb.js, even though that is included in the “google-protobuf” package
it boils down to this: https://gist.github.com/ghaskins/251954237da2bf03be6a740a51fe3c6a
I give up. this has to be the absolute worst managed package I have ever seen. seriously. I have seen some crazy bad packages but this takes the absolute top rank
@ghaskins I hope this helps a bit https://github.com/thheller/cljs-protobuf
what I cant figure out is this all worked perfectly when I target :browser, but I think I see what you are seeing
if I use commonjs output, :react-native output seems to be missing my generated source….if I use closure output, it cant find the google provided exports
Yeah, I think I ran into a problem which led me to try commonjs…but I no longer recall what the issue was
in any case, I did check my browser apps and it looks like they were using shadow-cljs 2.8.55 (vs 2.6.64 in react-native) so I was wondering if there was a regression
but I updated the browser app to 2.8.64 and it still works fine (even with the basic commonjs flow) so it does seem like there is some kind of difference
it seems like the google-protobuf npm package doesnt get included in the same way, but I dont understand why
if there is something the closureJS stuff can't do that the commonjs variant would be able to let me know
I'm confident that the closureJS variant will be able to do anything, it just might not come pre-packaged in some way
@martinklepsch just tested and it definitely works. only thing that might cause trouble if you are mixing strings and symbols. :closure-defines
should only be symbol keys but in case you have strings also the merge rules might delete one value if there is a conflict
Can I tell shadow-cljs or NPM what to do when there are dependency conflicts? (Something like :exclusions
in Leiningen, perhaps?)
I’m getting this:
NPM version conflict for "react" in deps.cljs (will use A)
A: "16.9.0" from jar:file:/Users/xxxx/.m2/repository/reagent/reagent/0.9.0-rc1/reagent-0.9.0-rc1.jar!/deps.cljs
B: "16.8.6" from jar:file:/Users/xxxx/.m2/repository/re-com/re-com/2.6.0/re-com-2.6.0.jar!/deps.cljs
Hmmm. So, yes, you’re right, I am specifying the version of react
(in package,json).
But I if I had conflicts in the transitive dependencies of my :dependencies
, might I have to specify (as a top-level dependency) which version I want? And live with the warnings?
it likely is fine. CLJS dependencies declaring JS dependencies directly is kind of a new thing so there are some kinks that need to be worked out
I’ve run shadow-cljs check app
and I am seeing a bunch of places that have the following warning:
ShadowJS expressions are not callable
This could totally be because I’m doing some weird shit with npm/cljsjs transition. what exactly does this warning pertain to, though?
here’s an example line it’s calling out:
(-> (js/$ ".floating-scrollbar") (.floatingScroll "destroy"))