Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / esm-package.md
Last active July 23, 2024 10:30
Pure ESM package

Pure ESM package

The package that linked you here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. You also need to put "type": "module" in your package.json and more. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@DrSensor
DrSensor / .gitconfig
Last active March 9, 2022 15:53
Git Tricks
[alias]
rescue = !git fsck --full --no-reflogs --unreachable --lost-found | grep commit | cut -d\\ -f3 | xargs -n 1 git log -n 1 --pretty=oneline > .git/lost-found.txt
ignore = !files={$(echo \"$@\" | tr ' ' ,)}.gitignore && echo '<-' github:$files && curl -sL https://raw.githubusercontent.com/github/gitignore/master/$files >> .gitignore && echo '->' .gitignore || echo FAIL && :
license-osi = !curl -sL https://raw.githubusercontent.com/OpenSourceOrg/licenses/master/texts/plain/$1 > LICENSE
license = !curl -sL https://raw.githubusercontent.com/github/choosealicense.com/gh-pages/_licenses/$1.txt > LICENSE
fork = !git clone $1 $3 --depth 1 && pushd ${3:-$(basename $1 .git)} > /dev/null && git remote add upstream $(git remote get-url origin) && git remote set-url origin $2 && popd > /dev/null && :
modlink = !pushd $1 && repo=$(git remote get-url origin) && popd && git submodule add $repo $2 && rm $2 && ln -s $1 $2 && :
first-commit = !git log $(git rev-list
@paulirish
paulirish / rAF.js
Last active July 19, 2024 19:50
requestAnimationFrame polyfill
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
// requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel
// MIT license
(function() {
var lastTime = 0;
var vendors = ['ms', 'moz', 'webkit', 'o'];