From da8e9b0cbbeb870e5d9d2d3949e3084a9ffe1074 Mon Sep 17 00:00:00 2001 From: Ludwig Magnusson Date: Sun, 3 May 2020 22:17:17 +0200 Subject: [PATCH] add es module file and declaration This adds a main file for es modules. Is is generated in the same way as the ts types from the list of names. --- CONTRIBUTING.md | 1 + index.mjs | 22 ++++++++++++++++++++++ package.json | 3 +++ scripts/generate-es | 4 ++++ scripts/lint | 1 + 5 files changed, 31 insertions(+) create mode 100644 index.mjs create mode 100755 scripts/generate-es diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 5434cf0..6244f5b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -8,4 +8,5 @@ When adding a type class to __README.md__, please update __names__ then run: ```console $ npm run generate-js $ npm run generate-ts +$ npm run generate-es ``` diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..aa7dc53 --- /dev/null +++ b/index.mjs @@ -0,0 +1,22 @@ +export const equals = 'fantasy-land/equals'; +export const lte = 'fantasy-land/lte'; +export const compose = 'fantasy-land/compose'; +export const id = 'fantasy-land/id'; +export const concat = 'fantasy-land/concat'; +export const empty = 'fantasy-land/empty'; +export const invert = 'fantasy-land/invert'; +export const filter = 'fantasy-land/filter'; +export const map = 'fantasy-land/map'; +export const contramap = 'fantasy-land/contramap'; +export const ap = 'fantasy-land/ap'; +export const of = 'fantasy-land/of'; +export const alt = 'fantasy-land/alt'; +export const zero = 'fantasy-land/zero'; +export const reduce = 'fantasy-land/reduce'; +export const traverse = 'fantasy-land/traverse'; +export const chain = 'fantasy-land/chain'; +export const chainRec = 'fantasy-land/chainRec'; +export const extend = 'fantasy-land/extend'; +export const extract = 'fantasy-land/extract'; +export const bimap = 'fantasy-land/bimap'; +export const promap = 'fantasy-land/promap'; diff --git a/package.json b/package.json index bdf518d..1336a38 100644 --- a/package.json +++ b/package.json @@ -31,12 +31,15 @@ "/README.md", "/index.d.ts", "/index.js", + "/index.mjs", "/package.json" ], "main": "index.js", "types": "index.d.ts", + "module": "index.mjs", "scripts": { "doctest": "sanctuary-doctest", + "generate-es": "scripts/generate-es", "generate-js": "scripts/generate-js", "generate-ts": "scripts/generate-ts", "lint": "sanctuary-lint", diff --git a/scripts/generate-es b/scripts/generate-es new file mode 100755 index 0000000..541a716 --- /dev/null +++ b/scripts/generate-es @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +set -euf -o pipefail + +awk '{ print "export const " $0 " = \047fantasy-land/" $0 "\047;" }' names >index.mjs diff --git a/scripts/lint b/scripts/lint index f2c01b8..6292ae7 100755 --- a/scripts/lint +++ b/scripts/lint @@ -5,3 +5,4 @@ node_modules/.bin/sanctuary-lint "$@" scripts/generate-js && git diff --exit-code index.js scripts/generate-ts && git diff --exit-code index.d.ts +scripts/generate-es && git diff --exit-code index.mjs