Skip to content

Instantly share code, notes, and snippets.

View MattiasBuelens's full-sized avatar

Mattias Buelens MattiasBuelens

View GitHub Profile
@sindresorhus
sindresorhus / esm-package.md
Last active July 15, 2024 20:29
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.

Adding an ES Module entry point to your node module is potentially a breaking change

If you've published a bunch of node modules to npm like I have, this note is for you.

tl;dr: If you're adding an ES Module entry point to your node module ("module" in package.json), and you previously exported a single thing from the CommonJS entry point (module.exports = …), you need to mark the change as a major version bump in semver, or you'll get a lot of angry webpack users.

Okay, so, recently I've been doing some minor maintainance to my little constellation of node modules, and one of the things I was doing was adding a "module" entry point to package.json, and using microbundle to expose an ES Module alongside CommonJS and UMD bundles. This leads to a bunch of fun benefits linked in the aforementioned blog post.

My gut was that this addition to the modules constituted a minor bump to their versions - I try to follow [semver](https://semver.org/

@mslinn
mslinn / decompile.bat
Last active June 24, 2024 20:26
Decompile JVM class files using IntelliJ IDEA's embedded FernFlower decompiler
java -cp "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 15.0.2\plugins\java-decompiler\lib\java-decompiler.jar" org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler -dgs=true . src
@1lann
1lann / rsa-crypt.lua
Last active April 1, 2024 02:52
RSA encryption and decryption library in pure Lua for ComputerCraft
--
-- RSA Encryption/Decryption Library
-- By 1lann
--
-- Refer to license: http://pastebin.com/9gWSyqQt
--
-- See gists comment at the bottom of the page for FAQ and updates!
--
--
@rafaelloab
rafaelloab / gist:7558002
Last active December 28, 2015 20:29
Steps to generate App Engine Backend in Android Studio
useful links
http://bradabrams.com/2013/06/google-io-2013-demo-android-studio-cloud-endpoints-synchronized-stopwatch-demo/
http://android-developers.blogspot.com.br/2013/06/adding-backend-to-your-app-in-android.html
https://code.google.com/p/gcm/
https://github.com/bradabrams/stopwatchio13
https://developers.google.com/appengine/docs/java/endpoints/getstarted/backend/configure_pom
http://developer.android.com/google/gcm/index.html
https://developers.google.com/events/io/sessions/324893448
Android Studio 0.3.5
@gabrielemariotti
gabrielemariotti / build.gradle
Last active January 12, 2024 17:41
Use signing.properties file which controls which keystore to use to sign the APK with gradle.
android {
signingConfigs {
release
}
buildTypes {
release {
signingConfig signingConfigs.release
}
@Yaffle
Yaffle / URLUtils.js
Last active September 5, 2022 02:19
parse URL + absolutize URL in javascript (URLUtils shim - http://url.spec.whatwg.org/#url)
/*jslint regexp: true, maxerr: 50, indent: 2 */
(function (global) {
"use strict";
function URLUtils(url, baseURL) {
var m = String(url).replace(/^\s+|\s+$/g, "").match(/^([^:\/?#]+:)?(?:\/\/(?:([^:@\/?#]*)(?::([^:@\/?#]*))?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/);
if (!m) {
throw new RangeError();
}