Skip to content

Instantly share code, notes, and snippets.

View BigAB's full-sized avatar
🇨🇦
JavaScript Loving Canadian

Adam L Barrett BigAB

🇨🇦
JavaScript Loving Canadian
View GitHub Profile
@developit
developit / *cjyes.md
Last active July 25, 2023 12:54
more-or-less instant command-line ESM to CJS transform. Copies from src to dist. `cjyes src/*.js`

cjyes npm version

🔍 see jay, yes! 🎉 / 👨🏻‍💻 see, JS! 👾 / ⚓️ sea JS ⛴

If you're publishing ES Modules, you need to also publish CommonJS versions of those modules.

This isn't to support old browsers or Node versions: even in Node 14, using require() to load a module won't work if it's only available as ESM.

cjyes is the bare minimum fix for this problem. You write ES Modules and fill out a valid package.json, and it'll generate the corresponding CommonJS files pretty much instantly. cjyes takes up 500kb of disk space including its two dependencies.

@bvaughn
bvaughn / updating-subscriptions-when-props-change-example.js
Last active March 27, 2022 09:29
Advanced example for manually updating subscriptions in response to props changes in an async-safe way
// This is an advanced example! It is not typically required for application code.
// If you are using a library like Redux or MobX, use the container component provided by that library.
// If you are authoring such a library, use the technique shown below.
// This example shows how to safely update subscriptions in response to props changes.
// In this case, it is important to wait until `componentDidUpdate` before removing a subscription.
// In the event that a render is cancelled before being committed, this will prevent us from unsubscribing prematurely.
// We also need to be careful about how we handle events that are dispatched in between
// `getDerivedStateFromProps` and `componentDidUpdate` so that we don't put stale values into the `state`.
@phillipskevin
phillipskevin / _Forms with CanJS 2.3 Stache Syntax.md
Last active August 15, 2018 19:28
Forms with New Stache Syntax

Forms with CanJS 2.3 Stache Syntax

This gist shows examples of how to handle different types of form elements with the new stache binding syntax in CanJS 2.3.

@m-mujica
m-mujica / who-imported.html
Created October 12, 2015 13:58 — forked from matthewp/who-imported.html
Who imported me?
<script src="node_modules/steal/steal.js"></script>
<script>
var oldNormalize = System.normalize;
System.normalize = function(name, parentName){
return oldNormalize.apply(this, arguments).then(function(name){
if(name === "my/module") {
console.log(name, "is imported by", parentName);
}
return name;
});
<!DOCTYPE html>
<!-- Helpful things to keep in your <head/>
// Brian Blakely, 360i
// http://twitter.com/brianblakely/
-->
<head>
<!-- Disable automatic DNS prefetching.