Skip to content

Instantly share code, notes, and snippets.

View a-bronx's full-sized avatar

Andrey Bronnikov a-bronx

  • HID Global
  • Fremont, CA
View GitHub Profile
@a-bronx
a-bronx / immutable-operations.spec.js
Created February 10, 2024 07:08 — forked from elliotlarson/immutable-operations.spec.js
JavaScript Immutable Operations on Arrays and Objects
// This is a Jest spec that explores some of the different ways to alter
// arrays and objects without mutating state. I'm trying different approaches
// available using:
//
// * Vanilla JS
// * Immutable.js
// * Lodash
// * Rambda
//
// The motivation for this is largely to work with a Redux store.
@a-bronx
a-bronx / esm-package.md
Created February 10, 2024 07:08 — forked from sindresorhus/esm-package.md
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.