Skip to content

Conversation

@fisker
Copy link
Member

@fisker fisker commented Sep 25, 2022

Description

exports for development package.json

{
    ".": {
      "require": "./src/index.cjs",
      "default": "./src/index.js"
    },
    "./*": "./"
}

exports for production package.json

{
    ".": {
      "require": "./index.cjs",
      "default": "./index.mjs"
    },
    "./*": "./",
    "./doc": {
      "require": "./doc.js",
      "default": "./doc.mjs"
    },
    "./standalone": {
      "require": "./standalone.js",
      "default": "./standalone.mjs"
    },
    "./plugins/babel": {
      "require": "./plugins/babel.js",
      "default": "./plugins/babel.mjs"
    },
    "./plugins/flow": {
      "require": "./plugins/flow.js",
      "default": "./plugins/flow.mjs"
    },
    "./plugins/typescript": {
      "require": "./plugins/typescript.js",
      "default": "./plugins/typescript.mjs"
    },
    "./plugins/acorn-and-espree": {
      "require": "./plugins/acorn-and-espree.js",
      "default": "./plugins/acorn-and-espree.mjs"
    },
    "./plugins/meriyah": {
      "require": "./plugins/meriyah.js",
      "default": "./plugins/meriyah.mjs"
    },
    "./plugins/angular": {
      "require": "./plugins/angular.js",
      "default": "./plugins/angular.mjs"
    },
    "./plugins/postcss": {
      "require": "./plugins/postcss.js",
      "default": "./plugins/postcss.mjs"
    },
    "./plugins/graphql": {
      "require": "./plugins/graphql.js",
      "default": "./plugins/graphql.mjs"
    },
    "./plugins/markdown": {
      "require": "./plugins/markdown.js",
      "default": "./plugins/markdown.mjs"
    },
    "./plugins/glimmer": {
      "require": "./plugins/glimmer.js",
      "default": "./plugins/glimmer.mjs"
    },
    "./plugins/html": {
      "require": "./plugins/html.js",
      "default": "./plugins/html.mjs"
    },
    "./plugins/yaml": {
      "require": "./plugins/yaml.js",
      "default": "./plugins/yaml.mjs"
    },

	// legacy entries
    "./esm/standalone.mjs": "./standalone.mjs",
    "./parser-babel": "./plugins/babel.js",
    "./parser-babel.js": "./plugins/babel.js",
    "./esm/parser-babel.mjs": "./plugins/babel.mjs",
    "./parser-flow": "./plugins/flow.js",
    "./parser-flow.js": "./plugins/flow.js",
    "./esm/parser-flow.mjs": "./plugins/flow.mjs",
    "./parser-typescript": "./plugins/typescript.js",
    "./parser-typescript.js": "./plugins/typescript.js",
    "./esm/parser-typescript.mjs": "./plugins/typescript.mjs",
    "./parser-espree": "./plugins/acorn-and-espree.js",
    "./parser-espree.js": "./plugins/acorn-and-espree.js",
    "./esm/parser-espree.mjs": "./plugins/acorn-and-espree.mjs",
    "./parser-meriyah": "./plugins/meriyah.js",
    "./parser-meriyah.js": "./plugins/meriyah.js",
    "./esm/parser-meriyah.mjs": "./plugins/meriyah.mjs",
    "./parser-angular": "./plugins/angular.js",
    "./parser-angular.js": "./plugins/angular.js",
    "./esm/parser-angular.mjs": "./plugins/angular.mjs",
    "./parser-postcss": "./plugins/postcss.js",
    "./parser-postcss.js": "./plugins/postcss.js",
    "./esm/parser-postcss.mjs": "./plugins/postcss.mjs",
    "./parser-graphql": "./plugins/graphql.js",
    "./parser-graphql.js": "./plugins/graphql.js",
    "./esm/parser-graphql.mjs": "./plugins/graphql.mjs",
    "./parser-markdown": "./plugins/markdown.js",
    "./parser-markdown.js": "./plugins/markdown.js",
    "./esm/parser-markdown.mjs": "./plugins/markdown.mjs",
    "./parser-glimmer": "./plugins/glimmer.js",
    "./parser-glimmer.js": "./plugins/glimmer.js",
    "./esm/parser-glimmer.mjs": "./plugins/glimmer.mjs",
    "./parser-html": "./plugins/html.js",
    "./parser-html.js": "./plugins/html.js",
    "./esm/parser-html.mjs": "./plugins/html.mjs",
    "./parser-yaml": "./plugins/yaml.js",
    "./parser-yaml.js": "./plugins/yaml.js",
    "./esm/parser-yaml.mjs": "./plugins/yaml.mjs"
}

Make sense?

Fixes #8772

Checklist

  • I’ve added tests to confirm my change works.
  • (If changing the API or CLI) I’ve documented the changes I’ve made (in the docs/ directory).
  • (If the change is user-facing) I’ve added my changes to changelog_unreleased/*/XXXX.md file following changelog_unreleased/TEMPLATE.md.
  • I’ve read the contributing guidelines.

Try the playground for this PR

@fisker

This comment was marked as outdated.

@fisker

This comment was marked as outdated.

@fisker fisker changed the title Add exports to package.json Restructure package files, add exports Sep 26, 2022
@fisker fisker mentioned this pull request Sep 26, 2022
4 tasks
@fisker fisker marked this pull request as ready for review September 26, 2022 12:48
@sosukesuzuki sosukesuzuki self-requested a review September 26, 2022 14:41
const PRETTIER_DIR = IS_PULL_REQUEST
? DIST_DIR
: path.dirname(require.resolve("prettier"));
: url.fileURLToPath(new URL("../node_modules/prettier", import.meta.url));

This comment was marked as resolved.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem is not about resolve, require.resolve resolves to dev version, don't know why. But it will resolve to stable version if I remove exports.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Co-authored-by: Sosuke Suzuki <[email protected]>
@sosukesuzuki sosukesuzuki mentioned this pull request Sep 27, 2022
23 tasks
@fisker fisker requested a review from thorn0 October 5, 2022 08:44
@fisker fisker merged commit 31a796d into prettier:next Oct 6, 2022
@fisker fisker deleted the exports branch October 6, 2022 07:20
@fisker fisker mentioned this pull request Oct 6, 2022
4 tasks
medikoo pushed a commit to medikoo/prettier-elastic that referenced this pull request Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants