Skip to content

Instantly share code, notes, and snippets.

View trickpattyFH20's full-sized avatar

Patrick trickpattyFH20

View GitHub Profile
@trickpattyFH20
trickpattyFH20 / examples.md
Created February 1, 2023 14:00 — forked from ef4/examples.md
Webpack 5 Node Polyfills Upgrade Cheatsheet

Webpack 5 Node Polyfills Upgrade Cheatsheet

Webpack 4 automatically polyfilled many Node APIs in the browser. This was not a great system, because it could lead to surprisingly giant libraries getting pulled into your app by accident, and it gave you no control over the exact versions of the polyfills you were using.

So Webpack 5 removed this functionality. That means you need to make changes if you were relying on those polyfills. This is a quick reference for how to replace the most common patterns.

List of polyfill packages that were used in webpack 4

For each automatically-polyfilled node package name on the left, this shows the name of the NPM package that was used to polyfill it on the right. Under webpack 5 you can manually install these packages and use them via resolve.fallback.

@trickpattyFH20
trickpattyFH20 / loaders.js
Created September 14, 2017 20:21 — forked from rbellamy/loaders.js
webpack configuration
'use strict';
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const path = require('path');
exports.tslint = {
test: /\.ts$/,
loader: 'tslint',
exclude: [
@trickpattyFH20
trickpattyFH20 / js-observables-binding.md
Created May 17, 2017 23:03 — forked from austinhyde/js-observables-binding.md
Vanilla JavaScript Data Binding

Observables

You don't really need a framework or fancy cutting-edge JavaScript features to do two-way data binding. Let's start basic - first and foremost, you need a way to tell when data changes. Traditionally, this is done via an Observer pattern, but a full-blown implementation of that is a little clunky for nice, lightweight JavaScript. So, if native getters/setters are out, the only mechanism we have are accessors:

var n = 5;
function getN() { return n; }
function setN(newN) { n = newN; }

console.log(getN()); // 5

setN(10);