From c1f6d021e54cf253fc7279df1924fe0064432bf9 Mon Sep 17 00:00:00 2001 From: fisker Cheung Date: Thu, 5 May 2022 15:03:08 +0800 Subject: [PATCH] Use named export instead of default export (#12740) --- .eslintrc.cjs | 6 ++ changelog_unreleased/api/12740.md | 13 +++ docs/browser.md | 6 +- index.js | 2 +- scripts/build-website.mjs | 4 +- scripts/build/config.mjs | 2 + scripts/generate-schema.mjs | 9 +- src/cli/file-info.js | 6 +- src/cli/find-config-path.js | 4 +- src/cli/format.js | 2 +- src/cli/index.js | 2 +- src/cli/options/get-context-options.js | 4 +- src/cli/options/get-options-for-file.js | 4 +- src/cli/prettier-internal.js | 15 +--- src/cli/utils.js | 5 +- src/common/util.js | 9 +- src/index.js | 109 ++++++++++++------------ src/standalone.js | 55 ++++++------ standalone.js | 2 +- tests/config/get-prettier.js | 6 +- tests/format/misc/empty/jsfmt.spec.js | 2 +- tests/integration/__tests__/bundle.js | 4 +- 22 files changed, 136 insertions(+), 135 deletions(-) create mode 100644 changelog_unreleased/api/12740.md diff --git a/.eslintrc.cjs b/.eslintrc.cjs index ccfac8d7d..b8ab17800 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -146,6 +146,12 @@ module.exports = { ], "unicorn/prefer-array-flat-map": "error", "unicorn/prefer-array-some": "error", + "unicorn/prefer-export-from": [ + "error", + { + ignoreUsedVariables: true, + }, + ], "unicorn/prefer-includes": "error", "unicorn/prefer-json-parse-buffer": "error", "unicorn/prefer-module": "error", diff --git a/changelog_unreleased/api/12740.md b/changelog_unreleased/api/12740.md new file mode 100644 index 000000000..47f57bb2b --- /dev/null +++ b/changelog_unreleased/api/12740.md @@ -0,0 +1,13 @@ +#### [Breaking] standalone version export style changed (#12740 by @fisker) + +The `esm/standalone.mjs` entry has changed export style from default export to named export. + +```diff +- import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs"; ++ import * as prettier from "https://unpkg.com/prettier@3.0.0/esm/standalone.mjs"; +``` + +```diff +- import prettier from "https://unpkg.com/prettier@2.6.2/esm/standalone.mjs"; ++ import { format } from "https://unpkg.com/prettier@3.0.0/esm/standalone.mjs"; +``` diff --git a/docs/browser.md b/docs/browser.md index 5e0852d23..1fbfc0156 100644 --- a/docs/browser.md +++ b/docs/browser.md @@ -48,7 +48,7 @@ Note that the [`unpkg` field](https://unpkg.com/#examples) in Prettier’s `pack ```html