This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-09-03
Channels
- # announcements (3)
- # asami (4)
- # aws (1)
- # babashka (22)
- # beginners (111)
- # calva (3)
- # cider (1)
- # clj-kondo (55)
- # clj-on-windows (9)
- # cljsrn (1)
- # clojure (13)
- # clojure-europe (35)
- # clojure-losangeles (3)
- # clojure-nl (2)
- # clojure-norway (2)
- # clojure-spec (2)
- # clojure-uk (5)
- # clojurescript (51)
- # conjure (5)
- # cursive (5)
- # datascript (1)
- # datomic (27)
- # deps-new (8)
- # depstar (41)
- # emacs (4)
- # fulcro (24)
- # graphql (4)
- # gratitude (8)
- # helix (36)
- # jobs (2)
- # leiningen (2)
- # lsp (11)
- # off-topic (24)
- # pathom (23)
- # pedestal (2)
- # polylith (27)
- # re-frame (12)
- # reagent (7)
- # reitit (1)
- # releases (3)
- # remote-jobs (1)
- # rewrite-clj (4)
- # sci (1)
- # shadow-cljs (27)
- # spacemacs (12)
- # tools-deps (31)
- # web-security (2)
FWIW I strongly recommend NOT running secondary tools in hooks. especially not something that starts processes that keep running
prefer setups like this one https://github.com/jacekschae/shadow-cljs-tailwindcss/blob/main/package.json#L8 using npm-run-all
to run multiple things but in separate processes
running separate processes is not what build-hooks are made for and should be avoided
hmm, I see. this is actually what bb tasks is made for as well. (https://book.babashka.org/#tasks), similar to Make, Just, etc.
I’m seeing [BABEL] Note: The code generator has deoptimised the styling of mydev/node_modules/somelib.js as it exceeds the max of 500KB.
in my builds recently. It is not always printed, but sometimes. Does not seem to affect my build times. Normally appears along with Browserslist: caniuse-lite is outdated. Please run next command npm update
. Switching between shadow 2.12.x and 2.15.x seems to not make a difference. Is this something that needs configuration, or is it not a problem?
Hi, morning is there a way to speed up compilation on ci by maybe reusing some caches from prev builds?
How do I install a local dependency?
is it clj dependency?
probably you need to use tools.deps machinery for this
• https://shadow-cljs.github.io/docs/UsersGuide.html#deps-edn • https://clojure.org/guides/deps_and_cli#_using_local_libraries
I'm trying to configure i18n with shadow-cljs. As a glue code I'm using the following js code:
import React from "react";
import ReactDOM from "react-dom";
import i18n from "i18next";
import { initReactI18next } from "react-i18next";
import LanguageDetector from "i18next-browser-languagedetector";
import { resources } from "./translations";
export function init({onMissingKey}) {
i18n
// passes i18n down to react-i18next
.use(LanguageDetector)
.use(initReactI18next)
.on('missingKey', onMissingKey)
.init({
// order and from where user language should be detected
order: ['querystring', 'cookie', 'localStorage', 'sessionStorage', 'navigator', 'path', 'subdomain'],
defaultNS: ['General'],
// keys or params to lookup language from
lookupQuerystring: 'lng',
lookupCookie: 'i18next',
lookupLocalStorage: 'i18nextLng',
lookupSessionStorage: 'i18nextLng',
lookupFromPathIndex: 0,
lookupFromSubdomainIndex: 0,
// cache user language on
caches: ['localStorage', 'cookie'],
excludeCacheFor: ['cimode'], // languages to not persist (cookie, localStorage)
// optional expire and domain for set cookie
cookieMinutes: 10,
// optional htmlTag with lang attribute, the default is:
htmlTag: document.documentElement,
// optional set cookie options, reference:[MDN Set-Cookie docs]()
cookieOptions: { path: '/', sameSite: 'strict' },
// the translations
// (tip move them in a JSON file and import them,
// or even better, manage them via a UI: )
saveMissing: true,
resources,
fallbackLng: "pl",
interpolation: {
// react already safes from xss =>
escapeValue: false
}
});
}
export function refresh({ onSuccess, onFailure }) {
return i18n.reloadResources().then(onSuccess).catch(onFailure);
}
export function language() {
return i18n.language;
}
export function changeLanguage(lang, {onSuccess, onFailure} ) {
return i18n.changeLanguage(lang).then(onSuccess).catch(onFailure);
}
export function t(key, opts) {
return i18n.t(key, opts);
}
This works perfectly for optimizations: none. However with shadow-cljs release changeLanguage and reloadResources are removed from the prototype 😮
Any hints what potentially I'm doing wrong?The first thing that comes to my mind is: externs?!
Suprisingly shadow renames the resources as well. 😮
const pl = {
};
const en = {
};
export const resources = {pl, en};
After advanced en becomes M1Yep it's about externs. Thank you @U05224H0W for making shadow-cljs predictable! In other tools I would: 1. Don't know what is happening 2. Have trouble with creating the externs. Externs simple rocks
This fixed the issue:
# -----------------------------------------------
# [start] i18n externs [start]
i18n.resources.en
i18n.resources.pl
i18n.changeLanguage
i18n.reloadResources
i18n.appendNamespaceToCIMode
i18n.appendNamespaceToMissingKey
i18n.htmlTag
i18n.excludeCacheFor
i18n.cookieOptions
i18n.cookieMinutes
i18n.lookupFromPathIndex
i18n.lookupFromSubdomainIndex
i18n.t
# [end] i18n externs [end]
# -----------------------------------------------
yeah there is no externs inference when using JS code (since the cljs compiler does that)
hi, how can I define a global js/ReactDOMServer
variable? I'm trying to do
(:require ["react-dom/server" :as ReactDOMServer])
(set! js/ReactDOMServer ReactDOMServer)
I'm using esm
target with Deno and above code throw this error:
error: Uncaught (in promise) ReferenceError: ReactDOMServer is not defined
(ReactDOMServer = module$node_modules$react_dom$server_browser);
the reason why I had to do this is because uix
tries to use js/ReactDOMServer
here: https://github.com/roman01la/uix/blob/0da33eef38a7122be226b9b9a8ae0b5431b6b5d3/dom/src/uix/dom/alpha.cljc#L69Probably better to path the library
Btw what is the output of (println ReactDOMServer)