Skip to content

fix: improve tree-shaking#725

Merged
DMartens merged 2 commits intoeslint:mainfrom
fisker:tree-shake
Feb 17, 2026
Merged

fix: improve tree-shaking#725
DMartens merged 2 commits intoeslint:mainfrom
fisker:tree-shake

Conversation

@fisker
Copy link
Contributor

@fisker fisker commented Jan 31, 2026

Prerequisites checklist

What is the purpose of this pull request?

Currently, Prettier bundles espree, only the parser parts needed, but esbuild can't tree-shake the unused eslint-visitor-keys, we use a script to replace unwanted code https://github.com/prettier/prettier/blob/5017d66ea76a7c513d7499b178794dcb6084b6ee/scripts/build/packages/prettier.js#L510

This PR makes espree tree-shakable.

What changes did you make? (Give an overview)

  • Add sideEffects: false to package.json
  • Add pure notation to function calls

Reduce

echo export{parse}from'./espree.js' | npx esbuild --bundle --format=esm

from 474KB to 469KB

Manually mark acorn and acorn-jsx side effects free, and run

>echo export{version}from'./espree.js' | npx esbuild --bundle --format=esm
// espree.js
var version = "11.1.0";
export {
  version
};

Related Issues

N/A

Is there anything you'd like reviewers to focus on?

N/A

@github-project-automation github-project-automation bot moved this to Needs Triage in Triage Jan 31, 2026
@eslint-github-bot
Copy link

Hi @fisker!, thanks for the Pull Request

The pull request title isn't properly formatted. We ask that you update the pull request title to match this format, as we use it to generate changelogs and automate releases.

  • The commit message tag wasn't recognized. Did you mean "docs", "fix", or "feat"?
  • There should be a space following the initial tag and colon, for example 'feat: Message'.
  • The first letter of the tag should be in lowercase

To Fix: You can fix this problem by clicking 'Edit' next to the pull request title at the top of this page.

Read more about contributing to ESLint here

@fisker fisker changed the title Improve tree-shaking fix: improve tree-shaking Jan 31, 2026
@github-actions
Copy link
Contributor

Hi everyone, it looks like we lost track of this pull request. Please review and see what the next steps are. This pull request will auto-close in 7 days without an update.

@github-actions github-actions bot added the Stale label Feb 10, 2026
@DMartens
Copy link

Apologies for taking a while to get back to you.
The changes make sense to me and generally looks good except two small notes.

@DMartens DMartens moved this from Needs Triage to Implementing in Triage Feb 11, 2026
Copy link
Member

@nzakas nzakas left a comment

Choose a reason for hiding this comment

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

LGTM. Would like @DMartens to verify before merging.

@nzakas nzakas moved this from Implementing to Second Review Needed in Triage Feb 16, 2026
Copy link

@DMartens DMartens left a comment

Choose a reason for hiding this comment

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

Changes LGTM, thanks for working on this.

@DMartens DMartens merged commit b699f32 into eslint:main Feb 17, 2026
19 checks passed
@github-project-automation github-project-automation bot moved this from Second Review Needed to Complete in Triage Feb 17, 2026
@eslintbot eslintbot mentioned this pull request Feb 17, 2026
@fisker fisker deleted the tree-shake branch February 17, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

3 participants