From e0d593cc3af3a317a6bd20c441191e5bbb136a93 Mon Sep 17 00:00:00 2001 From: Linjie Ding Date: Sun, 21 May 2023 22:53:06 -0400 Subject: [PATCH] feat(@formatjs/intl,@formatjs/fast-memoize,@formatjs/icu-messageformat-parser,@formatjs/intl-displaynames,@formatjs/intl-listformat,intl-messageformat,@formatjs/ecma402-abstract,@formatjs/intl-numberformat,@formatjs/icu-skeleton-parser): esm conditional exports (#4109) Fix #4013 Add `exports` to `@formatjs/intl` and its transitive dependencies to support dual ESM / CJS package distribution. ## Why is this not a breaking change? Anything not exported here never appeared in the documentation and therefore are considered internal implementation of the library. Therefore not exporting them is not a breaking change. --- packages/ecma402-abstract/package.json | 8 +++++ packages/fast-memoize/package.json | 9 +++++ .../icu-messageformat-parser/package.json | 23 ++++++++++++ packages/icu-skeleton-parser/package.json | 8 +++++ packages/intl-datetimeformat/package.json | 36 +++++++++++++++++++ packages/intl-displaynames/package.json | 28 +++++++++++++++ packages/intl-listformat/package.json | 28 +++++++++++++++ packages/intl-localematcher/package.json | 8 +++++ packages/intl-messageformat/package.json | 8 +++++ packages/intl-numberformat/package.json | 28 +++++++++++++++ packages/intl/package.json | 9 +++++ 11 files changed, 193 insertions(+) diff --git a/packages/ecma402-abstract/package.json b/packages/ecma402-abstract/package.json index b846e153b8..9441658b0f 100644 --- a/packages/ecma402-abstract/package.json +++ b/packages/ecma402-abstract/package.json @@ -29,6 +29,14 @@ "main": "index.js", "module": "lib/index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./package.json": "./package.json" + }, "homepage": "https://github.com/formatjs/formatjs", "license": "MIT", "gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c" diff --git a/packages/fast-memoize/package.json b/packages/fast-memoize/package.json index 4048148d30..c8ef7267a4 100644 --- a/packages/fast-memoize/package.json +++ b/packages/fast-memoize/package.json @@ -4,6 +4,15 @@ "description": "fork of fast-memoize and support esm", "main": "index.js", "module": "lib/index.js", + "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "git+ssh://git@github.com/formatjs/formatjs.git" diff --git a/packages/icu-messageformat-parser/package.json b/packages/icu-messageformat-parser/package.json index 9765ed16da..a38bc9fa04 100644 --- a/packages/icu-messageformat-parser/package.json +++ b/packages/icu-messageformat-parser/package.json @@ -4,6 +4,29 @@ "main": "index.js", "module": "lib/index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./no-parser": { + "types": "./no-parser.d.ts", + "import": "./lib/no-parser.js", + "default": "./no-parser.js" + }, + "./printer": { + "types": "./printer.d.ts", + "import": "./lib/printer.js", + "default": "./printer.js" + }, + "./manipulator": { + "types": "./manipulator.d.ts", + "import": "./lib/manipulator.js", + "default": "./manipulator.js" + }, + "./package.json": "./package.json" + }, "license": "MIT", "repository": { "type": "git", diff --git a/packages/icu-skeleton-parser/package.json b/packages/icu-skeleton-parser/package.json index d1a54a204d..1f544dab29 100644 --- a/packages/icu-skeleton-parser/package.json +++ b/packages/icu-skeleton-parser/package.json @@ -4,6 +4,14 @@ "main": "index.js", "module": "lib/index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./package.json": "./package.json" + }, "license": "MIT", "repository": { "type": "git", diff --git a/packages/intl-datetimeformat/package.json b/packages/intl-datetimeformat/package.json index bc2517d827..10a9af23d0 100644 --- a/packages/intl-datetimeformat/package.json +++ b/packages/intl-datetimeformat/package.json @@ -4,6 +4,42 @@ "description": "Intl.DateTimeFormat polyfill", "main": "index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./polyfill": { + "types": "./polyfill.d.ts", + "import": "./lib/polyfill.js", + "default": "./polyfill.js" + }, + "./polyfill-force": { + "types": "./polyfill-force.d.ts", + "import": "./lib/polyfill-force.js", + "default": "./polyfill-force.js" + }, + "./should-polyfill": { + "types": "./should-polyfill.d.ts", + "import": "./lib/should-polyfill.js", + "default": "./should-polyfill.js" + }, + "./locale-data/*": { + "types": "./locale-data/*.d.ts", + "default": "./locale-data/*.js" + }, + "./add-all-tz": { + "types": "./add-all-tz.d.ts", + "default": "./add-all-tz.js" + }, + "./add-golden-tz": { + "types": "./add-golden-tz.d.ts", + "default": "./add-golden-tz.js" + }, + "./polyfill.iife.js": "./polyfill.iife.js", + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "git+https://github.com/formatjs/formatjs.git" diff --git a/packages/intl-displaynames/package.json b/packages/intl-displaynames/package.json index c0951c4537..cf3367744d 100644 --- a/packages/intl-displaynames/package.json +++ b/packages/intl-displaynames/package.json @@ -16,6 +16,34 @@ "license": "MIT", "main": "index.js", "types": "index.d.js", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./polyfill": { + "types": "./polyfill.d.ts", + "import": "./lib/polyfill.js", + "default": "./polyfill.js" + }, + "./polyfill-force": { + "types": "./polyfill-force.d.ts", + "import": "./lib/polyfill-force.js", + "default": "./polyfill-force.js" + }, + "./should-polyfill": { + "types": "./should-polyfill.d.ts", + "import": "./lib/should-polyfill.js", + "default": "./should-polyfill.js" + }, + "./locale-data/*": { + "types": "./locale-data/*.d.ts", + "default": "./locale-data/*.js" + }, + "./polyfill.iife.js": "./polyfill.iife.js", + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "git+https://github.com/formatjs/formatjs.git" diff --git a/packages/intl-listformat/package.json b/packages/intl-listformat/package.json index d03773e791..ed7143e24e 100644 --- a/packages/intl-listformat/package.json +++ b/packages/intl-listformat/package.json @@ -29,6 +29,34 @@ }, "main": "index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./polyfill": { + "types": "./polyfill.d.ts", + "import": "./lib/polyfill.js", + "default": "./polyfill.js" + }, + "./polyfill-force": { + "types": "./polyfill-force.d.ts", + "import": "./lib/polyfill-force.js", + "default": "./polyfill-force.js" + }, + "./should-polyfill": { + "types": "./should-polyfill.d.ts", + "import": "./lib/should-polyfill.js", + "default": "./should-polyfill.js" + }, + "./locale-data/*": { + "types": "./locale-data/*.d.ts", + "default": "./locale-data/*.js" + }, + "./polyfill.iife.js": "./polyfill.iife.js", + "./package.json": "./package.json" + }, "homepage": "https://github.com/formatjs/formatjs", "license": "MIT", "gitHead": "a7842673d8ad205171ad7c8cb8bb2f318b427c0c" diff --git a/packages/intl-localematcher/package.json b/packages/intl-localematcher/package.json index 29f7ca93c6..3362a33928 100644 --- a/packages/intl-localematcher/package.json +++ b/packages/intl-localematcher/package.json @@ -17,6 +17,14 @@ "main": "index.js", "module": "lib/index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "git+https://github.com/formatjs/formatjs.git" diff --git a/packages/intl-messageformat/package.json b/packages/intl-messageformat/package.json index 665990a73c..bbfa329d15 100644 --- a/packages/intl-messageformat/package.json +++ b/packages/intl-messageformat/package.json @@ -30,6 +30,14 @@ "main": "index.js", "module": "lib/index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./package.json": "./package.json" + }, "dependencies": { "@formatjs/ecma402-abstract": "workspace:*", "@formatjs/fast-memoize": "workspace:*", diff --git a/packages/intl-numberformat/package.json b/packages/intl-numberformat/package.json index e278124520..4a7b3b9aab 100644 --- a/packages/intl-numberformat/package.json +++ b/packages/intl-numberformat/package.json @@ -17,6 +17,34 @@ "license": "MIT", "main": "index.js", "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./polyfill": { + "types": "./polyfill.d.ts", + "import": "./lib/polyfill.js", + "default": "./polyfill.js" + }, + "./polyfill-force": { + "types": "./polyfill-force.d.ts", + "import": "./lib/polyfill-force.js", + "default": "./polyfill-force.js" + }, + "./should-polyfill": { + "types": "./should-polyfill.d.ts", + "import": "./lib/should-polyfill.js", + "default": "./should-polyfill.js" + }, + "./locale-data/*": { + "types": "./locale-data/*.d.ts", + "default": "./locale-data/*.js" + }, + "./polyfill.iife.js": "./polyfill.iife.js", + "./package.json": "./package.json" + }, "repository": { "type": "git", "url": "git+https://github.com/formatjs/formatjs.git" diff --git a/packages/intl/package.json b/packages/intl/package.json index ca170a7384..b1df8ed2b6 100644 --- a/packages/intl/package.json +++ b/packages/intl/package.json @@ -27,6 +27,15 @@ }, "main": "index.js", "module": "lib/index.js", + "types": "index.d.ts", + "exports": { + ".": { + "types": "./index.d.ts", + "import": "./lib/index.js", + "default": "./index.js" + }, + "./package.json": "./package.json" + }, "sideEffects": false, "dependencies": { "@formatjs/ecma402-abstract": "workspace:*",