From 14c08c65c6980d5763f58dc92553f0f7911677c5 Mon Sep 17 00:00:00 2001 From: Emanuel Rabina Date: Sun, 24 Dec 2023 16:34:44 +1300 Subject: [PATCH] Convert package to ESM w/ fallbacks --- .babelrc | 8 +- .browserslistrc | 2 - .eslintignore | 2 - .eslintrc.json | 6 +- .gitignore | 2 - .npmignore | 3 - README.md | 4 +- index.d.ts | 5 - jest.config.js | 8 +- jest.setup.js | 9 +- package-lock.json | 368 ++++++++++-------- package.json | 40 +- ...config.dist.js => rollup.config.browser.js | 10 +- rollup.config.js | 13 +- 14 files changed, 251 insertions(+), 229 deletions(-) delete mode 100644 .browserslistrc delete mode 100755 .npmignore delete mode 100644 index.d.ts rename rollup.config.dist.js => rollup.config.browser.js (69%) diff --git a/.babelrc b/.babelrc index 48faaa4..11dd396 100755 --- a/.babelrc +++ b/.babelrc @@ -1,9 +1,13 @@ { "presets": [ - "@babel/preset-env" + ["@babel/preset-env", { + "targets": [ + "defaults", + "maintained node versions" + ] + }] ], "plugins": [ - "@babel/plugin-transform-class-properties", "@babel/plugin-transform-runtime" ] } diff --git a/.browserslistrc b/.browserslistrc deleted file mode 100644 index d9ac94d..0000000 --- a/.browserslistrc +++ /dev/null @@ -1,2 +0,0 @@ -defaults -maintained node versions diff --git a/.eslintignore b/.eslintignore index 979235b..22be1f9 100755 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,2 @@ /coverage /dist -/lib -/types diff --git a/.eslintrc.json b/.eslintrc.json index 7b8c17f..b7b5592 100755 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,13 +1,11 @@ { "extends": [ "eslint:recommended", - "plugin:compat/recommended", - "plugin:jsdoc/recommended", "ultraq" ], - "parser": "@babel/eslint-parser", "parserOptions": { - "ecmaVersion": 2020 + "ecmaVersion": 2022, + "sourceType": "module" }, "env": { "browser": true, diff --git a/.gitignore b/.gitignore index 388b3ec..831ce8d 100755 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,4 @@ /.idea /coverage /dist -/lib /node_modules -/types diff --git a/.npmignore b/.npmignore deleted file mode 100755 index b6c6d10..0000000 --- a/.npmignore +++ /dev/null @@ -1,3 +0,0 @@ -/coverage -.* -jest.* diff --git a/README.md b/README.md index 9edf0b8..32d6f5d 100755 --- a/README.md +++ b/README.md @@ -34,11 +34,11 @@ npm install @ultraq/icu-message-formatter ### As a script for the browser via the unpkg CDN: An IIFE version of this library is available at: -https://unpkg.com/@ultraq/icu-message-formatter/dist/icu-message-formatter.min.js +https://unpkg.com/@ultraq/icu-message-formatter/dist/icu-message-formatter.browser.min.js In this form, this module will then be present in the global scope as `IcuMessageFormatter`. An ESM version of this library is available at: -https://unpkg.com/@ultraq/icu-message-formatter/dist/icu-message-formatter.es.min.js +https://unpkg.com/@ultraq/icu-message-formatter/dist/icu-message-formatter.browser.es.min.js That URL can be used directly in ESM scripts made for the browser, and otherwise works like the NPM package. diff --git a/index.d.ts b/index.d.ts deleted file mode 100644 index c70a579..0000000 --- a/index.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './types/IcuMessageFormatter'; -export * from './types/MessageFormatter'; -export * from './types/pluralTypeHandler'; -export * from './types/selectTypeHandler'; -export * from './types/utilities'; diff --git a/jest.config.js b/jest.config.js index 9cb006f..0d72e00 100755 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,5 @@ -/* eslint-env node */ -'use strict'; // eslint-disable-line - -module.exports = { +/** @type {import('jest').Config} */ +const config = { collectCoverage: true, collectCoverageFrom: [ 'source/**/*.js' @@ -23,3 +21,5 @@ module.exports = { './jest.setup.js' ] }; + +export default config; diff --git a/jest.setup.js b/jest.setup.js index bd77608..26782ad 100755 --- a/jest.setup.js +++ b/jest.setup.js @@ -1,8 +1,5 @@ -/* eslint-env node */ -'use strict'; // eslint-disable-line - // Node has an Intl object, but doesn't ship with any locale information, so we // need to patch parts of it to work as it does in the browser. -require('@formatjs/intl-locale/polyfill'); -require('@formatjs/intl-numberformat/polyfill'); -require('@formatjs/intl-numberformat/locale-data/en-NZ'); +import '@formatjs/intl-locale/polyfill'; +import '@formatjs/intl-numberformat/polyfill'; +import '@formatjs/intl-numberformat/locale-data/en-NZ'; diff --git a/package-lock.json b/package-lock.json index f0559f9..19cfa6d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,23 +1,22 @@ { "name": "@ultraq/icu-message-formatter", - "version": "0.13.0", + "version": "0.14.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@ultraq/icu-message-formatter", - "version": "0.13.0", + "version": "0.14.0", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.22.15", - "@ultraq/array-utils": "^3.1.0", - "@ultraq/function-utils": "^0.5.0" + "@ultraq/array-utils": "^3.1.1", + "@ultraq/function-utils": "^0.5.1" }, "devDependencies": { - "@babel/core": "^7.22.15", - "@babel/eslint-parser": "^7.22.15", - "@babel/eslint-plugin": "^7.22.10", + "@babel/cli": "^7.23.4", "@babel/plugin-transform-class-properties": "^7.22.5", + "@babel/plugin-transform-modules-commonjs": "^7.23.3", "@babel/plugin-transform-runtime": "^7.22.15", "@babel/preset-env": "^7.22.15", "@formatjs/intl-locale": "^3.3.2", @@ -29,7 +28,6 @@ "@types/jest": "^29.5.4", "eslint": "^8.48.0", "eslint-config-ultraq": "^3.1.0", - "eslint-plugin-compat": "^4.2.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-jsdoc": "^46.5.1", "jest": "^29.6.4", @@ -62,6 +60,95 @@ "node": ">=6.0.0" } }, + "node_modules/@babel/cli": { + "version": "7.23.4", + "resolved": "https://registry.npmjs.org/@babel/cli/-/cli-7.23.4.tgz", + "integrity": "sha512-j3luA9xGKCXVyCa5R7lJvOMM+Kc2JEnAEIgz2ggtjQ/j5YUVgfsg/WsG95bbsgq7YLHuiCOzMnoSasuY16qiCw==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.17", + "commander": "^4.0.1", + "convert-source-map": "^2.0.0", + "fs-readdir-recursive": "^1.1.0", + "glob": "^7.2.0", + "make-dir": "^2.1.0", + "slash": "^2.0.0" + }, + "bin": { + "babel": "bin/babel.js", + "babel-external-helpers": "bin/babel-external-helpers.js" + }, + "engines": { + "node": ">=6.9.0" + }, + "optionalDependencies": { + "@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3", + "chokidar": "^3.4.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/cli/node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/@babel/cli/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@babel/cli/node_modules/make-dir": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz", + "integrity": "sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==", + "dev": true, + "dependencies": { + "pify": "^4.0.1", + "semver": "^5.6.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@babel/cli/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/@babel/cli/node_modules/slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/@babel/code-frame": { "version": "7.23.5", "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.23.5.tgz", @@ -114,40 +201,6 @@ "url": "https://opencollective.com/babel" } }, - "node_modules/@babel/eslint-parser": { - "version": "7.23.3", - "resolved": "https://registry.npmjs.org/@babel/eslint-parser/-/eslint-parser-7.23.3.tgz", - "integrity": "sha512-9bTuNlyx7oSstodm1cR1bECj4fkiknsDa1YniISkJemMY3DGhJNYBECbe6QD/q54mp2J8VO66jW3/7uP//iFCw==", - "dev": true, - "dependencies": { - "@nicolo-ribaudo/eslint-scope-5-internals": "5.1.1-v1", - "eslint-visitor-keys": "^2.1.0", - "semver": "^6.3.1" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "peerDependencies": { - "@babel/core": "^7.11.0", - "eslint": "^7.5.0 || ^8.0.0" - } - }, - "node_modules/@babel/eslint-plugin": { - "version": "7.23.5", - "resolved": "https://registry.npmjs.org/@babel/eslint-plugin/-/eslint-plugin-7.23.5.tgz", - "integrity": "sha512-03+E/58Hoo/ui69gR+beFdGpplpoVK0BSIdke2iw4/Bz7eGN0ssRenNlnU4nmbkowNQOPCStKSwFr8H6DiY49g==", - "dev": true, - "dependencies": { - "eslint-rule-composer": "^0.3.0" - }, - "engines": { - "node": "^10.13.0 || ^12.13.0 || >=14.0.0" - }, - "peerDependencies": { - "@babel/eslint-parser": "^7.11.0", - "eslint": "^7.5.0 || ^8.0.0" - } - }, "node_modules/@babel/generator": { "version": "7.23.6", "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.6.tgz", @@ -2834,20 +2887,12 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, - "node_modules/@mdn/browser-compat-data": { - "version": "5.5.2", - "resolved": "https://registry.npmjs.org/@mdn/browser-compat-data/-/browser-compat-data-5.5.2.tgz", - "integrity": "sha512-HZX4YUlQXDrtuuyAw3ZrzS3LIlsBVL5AhRTROa9cwn6rUpBgtrMWy63S+ahvYhrJgbLmsrEmYwsd5YJBGk5btg==", - "dev": true - }, - "node_modules/@nicolo-ribaudo/eslint-scope-5-internals": { - "version": "5.1.1-v1", - "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/eslint-scope-5-internals/-/eslint-scope-5-internals-5.1.1-v1.tgz", - "integrity": "sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==", + "node_modules/@nicolo-ribaudo/chokidar-2": { + "version": "2.1.8-no-fsevents.3", + "resolved": "https://registry.npmjs.org/@nicolo-ribaudo/chokidar-2/-/chokidar-2-2.1.8-no-fsevents.3.tgz", + "integrity": "sha512-s88O1aVtXftvp5bCPB7WnmXc5IwOZZ7YPuwNPt+GtOOXpPvad1LfbmjYv+qII7zP6RU2QGnqve27dnLycEnyEQ==", "dev": true, - "dependencies": { - "eslint-scope": "5.1.1" - } + "optional": true }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", @@ -3330,17 +3375,17 @@ "dev": true }, "node_modules/@ultraq/array-utils": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/@ultraq/array-utils/-/array-utils-3.1.0.tgz", - "integrity": "sha512-Ogthxoo8cQ6wRtJaOoN27A+ezp8O6fb8vYOxi8wrGViGSYLaESScNG+WTWg3Z9Avwgmb2BX7KNfNK2KeMO29Dg==", + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@ultraq/array-utils/-/array-utils-3.1.1.tgz", + "integrity": "sha512-CgGmJ82ELQcjrApk/wAtpBKVpq1p/Qazg+XgOeTObrgssr5a3J6lTwi2Ngp7rzajMwf1UE5L4YPbzyccfA2Q8Q==", "engines": { "node": ">=18" } }, "node_modules/@ultraq/function-utils": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/@ultraq/function-utils/-/function-utils-0.5.0.tgz", - "integrity": "sha512-E6iJ9wreAzS+3ken1tGCdju79gPntDXByqctttDoTmcrmUSP+e2/ixIOXRoHsDXD8FzAZPh4ikx3pVZF8aj8xQ==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@ultraq/function-utils/-/function-utils-0.5.1.tgz", + "integrity": "sha512-+I0x2GSrA8zjmR/GQREUEZzcK44cT3K8kj+jI1iuRvX9z/kNp9e7L0tsW612OBz2+O8Yf8iQIkCiX7CB2WhuVw==", "engines": { "node": ">=18" } @@ -3560,15 +3605,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/ast-metadata-inferer": { - "version": "0.8.0", - "resolved": "https://registry.npmjs.org/ast-metadata-inferer/-/ast-metadata-inferer-0.8.0.tgz", - "integrity": "sha512-jOMKcHht9LxYIEQu+RVd22vtgrPaVCtDRQ/16IGmurdzxvYbDd5ynxjnyrzLnieG96eTcAyaoj/wN/4/1FyyeA==", - "dev": true, - "dependencies": { - "@mdn/browser-compat-data": "^5.2.34" - } - }, "node_modules/available-typed-arrays": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", @@ -3803,6 +3839,16 @@ "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, + "node_modules/binary-extensions": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", + "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "dev": true, + "optional": true, + "engines": { + "node": ">=8" + } + }, "node_modules/brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3959,6 +4005,47 @@ "node": ">=10" } }, + "node_modules/chokidar": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz", + "integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==", + "dev": true, + "funding": [ + { + "type": "individual", + "url": "https://paulmillr.com/funding/" + } + ], + "optional": true, + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/chokidar/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "optional": true, + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/ci-info": { "version": "3.9.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.9.0.tgz", @@ -4539,60 +4626,6 @@ "ms": "^2.1.1" } }, - "node_modules/eslint-plugin-compat": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/eslint-plugin-compat/-/eslint-plugin-compat-4.2.0.tgz", - "integrity": "sha512-RDKSYD0maWy5r7zb5cWQS+uSPc26mgOzdORJ8hxILmWM7S/Ncwky7BcAtXVY5iRbKjBdHsWU8Yg7hfoZjtkv7w==", - "dev": true, - "dependencies": { - "@mdn/browser-compat-data": "^5.3.13", - "ast-metadata-inferer": "^0.8.0", - "browserslist": "^4.21.10", - "caniuse-lite": "^1.0.30001524", - "find-up": "^5.0.0", - "lodash.memoize": "^4.1.2", - "semver": "^7.5.4" - }, - "engines": { - "node": ">=14.x" - }, - "peerDependencies": { - "eslint": "^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0" - } - }, - "node_modules/eslint-plugin-compat/node_modules/lru-cache": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", - "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, - "dependencies": { - "yallist": "^4.0.0" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/eslint-plugin-compat/node_modules/semver": { - "version": "7.5.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", - "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", - "dev": true, - "dependencies": { - "lru-cache": "^6.0.0" - }, - "bin": { - "semver": "bin/semver.js" - }, - "engines": { - "node": ">=10" - } - }, - "node_modules/eslint-plugin-compat/node_modules/yallist": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", - "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", - "dev": true - }, "node_modules/eslint-plugin-import": { "version": "2.29.1", "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.29.1.tgz", @@ -4713,37 +4746,6 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "dev": true }, - "node_modules/eslint-rule-composer": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/eslint-rule-composer/-/eslint-rule-composer-0.3.0.tgz", - "integrity": "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg==", - "dev": true, - "engines": { - "node": ">=4.0.0" - } - }, - "node_modules/eslint-scope": { - "version": "5.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", - "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", - "dev": true, - "dependencies": { - "esrecurse": "^4.3.0", - "estraverse": "^4.1.1" - }, - "engines": { - "node": ">=8.0.0" - } - }, - "node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" - } - }, "node_modules/eslint/node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", @@ -4974,15 +4976,6 @@ "node": ">=4.0" } }, - "node_modules/estraverse": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", - "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", - "dev": true, - "engines": { - "node": ">=4.0" - } - }, "node_modules/estree-walker": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", @@ -5151,6 +5144,12 @@ "is-callable": "^1.1.3" } }, + "node_modules/fs-readdir-recursive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", + "integrity": "sha512-GNanXlVr2pf02+sPN40XN8HG+ePaNcvM0q5mZBd668Obwb0yD5GiUbZOFgwn8kGMY6I3mdyDJzieUy3PTYyTRA==", + "dev": true + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -5588,6 +5587,19 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "optional": true, + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/is-boolean-object": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", @@ -7745,12 +7757,6 @@ "integrity": "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==", "dev": true }, - "node_modules/lodash.memoize": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", - "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", - "dev": true - }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -8172,6 +8178,15 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pify": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", + "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==", + "dev": true, + "engines": { + "node": ">=6" + } + }, "node_modules/pirates": { "version": "4.0.6", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", @@ -8353,6 +8368,19 @@ "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", "dev": true }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "optional": true, + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, "node_modules/regenerate": { "version": "1.4.2", "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.2.tgz", diff --git a/package.json b/package.json index ccd48ec..c36d71c 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@ultraq/icu-message-formatter", - "version": "0.13.0", + "version": "0.14.0", "description": "Format ICU message syntax strings from supplied parameters and your own configurable types", "author": "Emanuel Rabina (http://www.ultraq.net.nz/)", "license": "Apache-2.0", @@ -15,30 +15,41 @@ "intl", "i18n" ], - "module": "lib/icu-message-formatter.es.js", - "main": "lib/icu-message-formatter.cjs.js", - "types": "index.d.ts", + "type": "module", + "module": "dist/icu-message-formatter.js", + "main": "dist/icu-message-formatter.cjs", + "types": "dist/icu-message-formatter.d.ts", + "exports": { + "import": { + "default": "./dist/icu-message-formatter.js", + "types": "./dist/icu-message-formatter.d.ts" + }, + "require": { + "default": "./dist/icu-message-formatter.cjs", + "types": "./dist/icu-message-formatter.d.cts" + } + }, + "files": [ + "dist", + "CHANGELOG.md" + ], "sideEffects": false, "scripts": { - "format": "eslint --fix \"**/*.js\"", "lint": "eslint \"**/*.js\"", "test": "jest", - "build": "npm run build:lib && npm run build:dist && npm run build:dts", - "build:lib": "rollup --config --bundleConfigAsCjs", - "build:dist": "rollup --config rollup.config.dist.js --bundleConfigAsCjs", - "build:dts": "tsc source/IcuMessageFormatter.js --allowJs --declaration --emitDeclarationOnly --outDir types", + "build": "npm run build:dist && npm run build:browser && npm run build:dts", + "build:dist": "rollup --config", + "build:browser": "rollup --config rollup.config.browser.js", + "build:dts": "tsc dist/icu-message-formatter.js --allowJs --declaration --emitDeclarationOnly && tsc dist/icu-message-formatter.cjs --allowJs --declaration --emitDeclarationOnly", "prepublishOnly": "npm run build" }, "dependencies": { "@babel/runtime": "^7.22.15", - "@ultraq/array-utils": "^3.1.0", - "@ultraq/function-utils": "^0.5.0" + "@ultraq/array-utils": "^3.1.1", + "@ultraq/function-utils": "^0.5.1" }, "devDependencies": { "@babel/core": "^7.22.15", - "@babel/eslint-parser": "^7.22.15", - "@babel/eslint-plugin": "^7.22.10", - "@babel/plugin-transform-class-properties": "^7.22.5", "@babel/plugin-transform-runtime": "^7.22.15", "@babel/preset-env": "^7.22.15", "@formatjs/intl-locale": "^3.3.2", @@ -50,7 +61,6 @@ "@types/jest": "^29.5.4", "eslint": "^8.48.0", "eslint-config-ultraq": "^3.1.0", - "eslint-plugin-compat": "^4.2.0", "eslint-plugin-import": "^2.28.1", "eslint-plugin-jsdoc": "^46.5.1", "jest": "^29.6.4", diff --git a/rollup.config.dist.js b/rollup.config.browser.js similarity index 69% rename from rollup.config.dist.js rename to rollup.config.browser.js index 498bf1c..6ae8358 100644 --- a/rollup.config.dist.js +++ b/rollup.config.browser.js @@ -1,19 +1,19 @@ -import babel from '@rollup/plugin-babel'; -import commonjs from '@rollup/plugin-commonjs'; +import babel from '@rollup/plugin-babel'; +import commonjs from '@rollup/plugin-commonjs'; import nodeResolve from '@rollup/plugin-node-resolve'; -import terser from '@rollup/plugin-terser'; +import terser from '@rollup/plugin-terser'; export default { input: 'source/IcuMessageFormatter.js', output: [ { - file: 'dist/icu-message-formatter.min.js', + file: 'dist/icu-message-formatter.browser.min.js', format: 'iife', name: 'IcuMessageFormatter', sourcemap: true }, { - file: 'dist/icu-message-formatter.es.min.js', + file: 'dist/icu-message-formatter.browser.es.min.js', format: 'es', name: 'IcuMessageFormatter', sourcemap: true diff --git a/rollup.config.js b/rollup.config.js index deef70b..7d62cc2 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,19 +1,18 @@ - -import babel from '@rollup/plugin-babel'; -import commonjs from '@rollup/plugin-commonjs'; +import babel from '@rollup/plugin-babel'; +import commonjs from '@rollup/plugin-commonjs'; import nodeResolve from '@rollup/plugin-node-resolve'; export default { input: 'source/IcuMessageFormatter.js', output: [ { - file: `lib/icu-message-formatter.cjs.js`, - format: 'cjs', + file: 'dist/icu-message-formatter.js', + format: 'es', sourcemap: true }, { - file: `lib/icu-message-formatter.es.js`, - format: 'es', + file: 'dist/icu-message-formatter.cjs', + format: 'cjs', sourcemap: true } ],