Skip to content

Fix loading ESM-style shared config file in Node.js 23#16857

Merged
sosukesuzuki merged 3 commits intoprettier:mainfrom
sosukesuzuki:fix-16812
Nov 25, 2024
Merged

Fix loading ESM-style shared config file in Node.js 23#16857
sosukesuzuki merged 3 commits intoprettier:mainfrom
sosukesuzuki:fix-16812

Conversation

@sosukesuzuki
Copy link
Contributor

@sosukesuzuki sosukesuzuki commented Nov 24, 2024

Description

Fixes #16812

I don't add tests for this change due to jestjs/jest#15363, but I was able to test it locally.

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

@sosukesuzuki sosukesuzuki marked this pull request as ready for review November 24, 2024 11:06
@fisker
Copy link
Member

fisker commented Nov 24, 2024

Have you tried esm module with TLA? It should broken too.

return required.default;
}
return required;
} catch (/** @type {any} */ error) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe simply use required?.default ?? required? babel/babel#16441

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I prefer the current code. Because if the option had a default field, it would be used. I know that such a case rarely happens, but it's not that complicated code, so I prefer to be conservative.

@sosukesuzuki
Copy link
Contributor Author

Have you tried esm module with TLA? It should broken too.

Thanks, 3244020 addresses the case.

@sosukesuzuki sosukesuzuki requested a review from fisker November 25, 2024 06:59
@sosukesuzuki sosukesuzuki mentioned this pull request Nov 25, 2024
11 tasks
@sosukesuzuki sosukesuzuki merged commit a3ba537 into prettier:main Nov 25, 2024
fisker added a commit to fisker/prettier that referenced this pull request Dec 16, 2024
sosukesuzuki pushed a commit that referenced this pull request Dec 21, 2024
* Add tests for #16857

* Update comment
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.

ESM Shared Configurations Incompatible with Node v23

2 participants