Skip to content

Instantly share code, notes, and snippets.

View olivergeorge's full-sized avatar

Oliver George olivergeorge

  • Tasmania, Australia
View GitHub Profile
@ncochard
ncochard / babel-webpack.md
Last active September 29, 2023 05:15
The correct way to compile ES6 using babel...

When you create a npm package, remember it might be used in a browser or a server, or even a command line utility… For each package you create, please pay attention at what it will be used for:

  1. Is it going to be used as a dependency to a nodejs application that is not bundled? (e.g. command line utilities)
  2. Is it going to be used as a dependency to a nodejs application that is bundled? (e.g. AWS Lambdas)
  3. Is it going to be used as a dependency to a browser application (always bundled)?.
  • In cases 2) and 3) you want to allow for tree shaking.
  • In cases 1) and 2) you want to benefit from the "ES6"/"ES next" features supported natively by nodejs.
  • In case 3) you also want to benefit from the native support of "ES6" from your browser.
@cdbkr
cdbkr / react-testing-library-clojurescript.cljs
Last active February 3, 2023 15:24
React-testing-library and Re-frame clojurescript app
(ns demo.core-test
(:require [cljs.test :refer [deftest
testing
is
use-fixtures]]
[clojure.string :refer [lower-case]]
[demo.components :refer [title-component
counter-component]]
[reagent.core :as r]
["react-testing-library" :as rtl]))
@roman01la
roman01la / re-frame.clj
Last active October 21, 2020 11:32
Debugging re-frame subscriptions
(ns utils.re-frame
(:require [cljs.compiler :as cljsc]))
(defn- anonymous-function-declaration? [form]
(and (list? form)
(= 'fn (first form))
(vector? (second form))))
(defn- query-id->js-fn-name [query-id]
(let [ns-part (when-let [ns-part (namespace query-id)]
@roman01la
roman01la / analyze.clj
Created March 18, 2021 01:42
analyzing unused and undefined re-frame subscriptions via clj-kondo
(ns analyze.core
(:require [clj-kondo.core :as clj-kondo]
[clojure.set :as set]))
;; checks re-frame's :<- syntax
;; to mark dependency subscriptions as used
(def analyze-reg-sub
"(require '[clj-kondo.hooks-api :as api])
(fn [{node :node}]
(let [[_ kw & children] (:children node)