Skip to content

Commit

Permalink
Convert package to ESM w/ fallbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
ultraq committed Dec 24, 2023
1 parent 2d425ad commit 14c08c6
Show file tree
Hide file tree
Showing 14 changed files with 251 additions and 229 deletions.
8 changes: 6 additions & 2 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -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"
]
}
2 changes: 0 additions & 2 deletions .browserslistrc

This file was deleted.

2 changes: 0 additions & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
/coverage
/dist
/lib
/types
6 changes: 2 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -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,
Expand Down
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/.idea
/coverage
/dist
/lib
/node_modules
/types
3 changes: 0 additions & 3 deletions .npmignore

This file was deleted.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
5 changes: 0 additions & 5 deletions index.d.ts

This file was deleted.

8 changes: 4 additions & 4 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -23,3 +21,5 @@ module.exports = {
'./jest.setup.js'
]
};

export default config;
9 changes: 3 additions & 6 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -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';
Loading

0 comments on commit 14c08c6

Please sign in to comment.