Skip to content

Conversation

@blakeembrey
Copy link
Member

Realized using the same token type strings would improve compression and found some other small byte savings. At this point the next largest size improvement would be moving to ESM so I think this is the last bump available, but I welcome PRs that remove more bytes in the minified output without affecting readability.

Before: 1.93 kB
After: 1.88 kB

@blakeembrey blakeembrey requested a review from a team August 25, 2025 19:36
@codecov
Copy link

codecov bot commented Aug 25, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (2a7f2a4) to head (77d6189).

Additional details and impacted files
@@ Coverage Diff @@ ## master #401 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 1 1 Lines 378 369 -9 Branches 136 132 -4 ========================================= - Hits 378 369 -9 

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
if (next.type !== "CHAR" && next.type !== "ESCAPED") break;
pos++;
path += next.value;
const token = tokens[pos++];
Copy link
Member Author

Choose a reason for hiding this comment

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

Surprised me, but removing destructuring helped.

| "wildcard"
| "param"
| "char"
| "escape"
Copy link
Member Author

Choose a reason for hiding this comment

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

"ESCAPED" -> "escape" arguably reads better in an error (Unexpected escape at index 12). That said, I don't think type would ever show in an error anyway, the only unexpected token is "end".

| "param"
| "char"
| "escape"
| "end"
Copy link
Member Author

Choose a reason for hiding this comment

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

All these types are also internal only, never exposed, so renaming them is safe (only the error changes for "Unexpected END").

@blakeembrey blakeembrey merged commit 9df2448 into master Sep 2, 2025
8 checks passed
@blakeembrey blakeembrey deleted the be/more-shrinking branch September 2, 2025 20:51
Szotkowski added a commit to Selecro/Selecro-backend that referenced this pull request Oct 5, 2025
![snyk-top-banner](https://res.cloudinary.com/snyk/image/upload/r-d/scm-platform/snyk-pull-requests/pr-banner-default.svg) <h3>Snyk has created this PR to upgrade path-to-regexp from 8.2.0 to 8.3.0.</h3> :information_source: Keep your dependencies up-to-date. This makes it easier to fix existing vulnerabilities and to more quickly identify and fix newly disclosed vulnerabilities when they affect your project. <hr/> - The recommended version is **1 version** ahead of your current version. - The recommended version was released **25 days ago**. <details> <summary><b>Release notes</b></summary> <br/> <details> <summary>Package name: <b>path-to-regexp</b></summary> <ul> <li> <b>8.3.0</b> - <a href="https://redirect.github.com/pillarjs/path-to-regexp/releases/tag/v8.3.0">2025-09-02</a></br><p><strong>Changed</strong></p> <ul> <li>Add custom error class (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3332530309" data-permission-text="Title is private" data-url="pillarjs/path-to-regexp#398" data-hovercard-type="pull_request" data-hovercard-url="/pillarjs/path-to-regexp/pull/398/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/pull/398">#398</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/2a7f2a4e9ba42eee41aa9d7a1a69eddb43b79a61/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/2a7f2a4e9ba42eee41aa9d7a1a69eddb43b79a61"><tt>2a7f2a4</tt></a></li> <li>Allow plain objects for <code>TokenData</code> (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3281561483" data-permission-text="Title is private" data-url="pillarjs/path-to-regexp#391" data-hovercard-type="pull_request" data-hovercard-url="/pillarjs/path-to-regexp/pull/391/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/pull/391">#391</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/687a9bbc735245b2688c17db7e9fe86013ea0c77/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/687a9bbc735245b2688c17db7e9fe86013ea0c77"><tt>687a9bb</tt></a></li> <li>Escape text should escape backslash (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3281489414" data-permission-text="Title is private" data-url="pillarjs/path-to-regexp#390" data-hovercard-type="pull_request" data-hovercard-url="/pillarjs/path-to-regexp/pull/390/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/pull/390">#390</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/a4a8552c9fb4449c470fb9ead458df1c89cadb72/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/a4a8552c9fb4449c470fb9ead458df1c89cadb72"><tt>a4a8552</tt></a></li> <li>Improved error messages and stack size (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3054423448" data-permission-text="Title is private" data-url="pillarjs/path-to-regexp#363" data-hovercard-type="pull_request" data-hovercard-url="/pillarjs/path-to-regexp/pull/363/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/pull/363">#363</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/a6bdf4045f369474e4e580bc6fcadb6bd806e62e/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/a6bdf4045f369474e4e580bc6fcadb6bd806e62e"><tt>a6bdf40</tt></a></li> </ul> <p><strong>Other</strong></p> <ul> <li>Minifying the parser <ul> <li>PR (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3352988435" data-permission-text="Title is private" data-url="pillarjs/path-to-regexp#401" data-hovercard-type="pull_request" data-hovercard-url="/pillarjs/path-to-regexp/pull/401/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/pull/401">#401</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/9df2448fdfca9d2957cf47a1777b5deda9be18cf/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/9df2448fdfca9d2957cf47a1777b5deda9be18cf"><tt>9df2448</tt></a></li> <li>PR (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="3301895649" data-permission-text="Title is private" data-url="pillarjs/path-to-regexp#395" data-hovercard-type="pull_request" data-hovercard-url="/pillarjs/path-to-regexp/pull/395/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/pull/395">#395</a>) <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/4a915059a843dfdd122a0c4936837c7fdda2d4ee/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/4a915059a843dfdd122a0c4936837c7fdda2d4ee"><tt>4a91505</tt></a></li> <li>Shaving some bytes <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/d63f44bc54f2c6fe7d35dc77f8515622006bf7cb/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/d63f44bc54f2c6fe7d35dc77f8515622006bf7cb"><tt>d63f44b</tt></a></li> <li>Remove optional operator <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/973d15c262f113c4cb88762971920053fdbd31ff/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/973d15c262f113c4cb88762971920053fdbd31ff"><tt>973d15c</tt></a></li> </ul> </li> </ul> <p><a class="commit-link" href="https://redirect.github.com/pillarjs/path-to-regexp/compare/v8.2.0...v8.3.0"><tt>v8.2.0...v8.3.0</tt></a></p> </li> <li> <b>8.2.0</b> - <a href="https://redirect.github.com/pillarjs/path-to-regexp/releases/tag/v8.2.0">2024-09-26</a></br><p><strong>Fixed</strong></p> <ul> <li>Allowing <code>path-to-regexp</code> to run on older browsers by targeting ES2015 <ul> <li>Target ES2015 <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/59690338f2a089f45505718c94b86dcb2d32f29d/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/59690338f2a089f45505718c94b86dcb2d32f29d"><tt>5969033</tt></a> <ul> <li>Also saved <em>0.22kb</em> (10%!) by removing the private class field down level</li> </ul> </li> <li>Remove <code>s</code> flag from regexp <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pillarjs/path-to-regexp/commit/51dbd45e00043f082e3cf1857861e856c40a32f0/hovercard" href="https://redirect.github.com/pillarjs/path-to-regexp/commit/51dbd45e00043f082e3cf1857861e856c40a32f0"><tt>51dbd45</tt></a></li> </ul> </li> </ul> <p><a class="commit-link" href="https://redirect.github.com/pillarjs/path-to-regexp/compare/v8.1.0...v8.2.0"><tt>v8.1.0...v8.2.0</tt></a></p> </li> </ul> from <a href="https://redirect.github.com/pillarjs/path-to-regexp/releases">path-to-regexp GitHub release notes</a> </details> </details> --- > [!IMPORTANT] > > - Check the changes in this PR to ensure they won't cause issues with your project. > - This PR was automatically created by Snyk using the credentials of a real user. --- **Note:** _You are seeing this because you or someone else with access to this repository has authorized Snyk to open upgrade PRs._ **For more information:** <img src="https://api.segment.io/v1/pixel/track?data=eyJ3cml0ZUtleSI6InJyWmxZcEdHY2RyTHZsb0lYd0dUcVg4WkFRTnNCOUEwIiwiYW5vbnltb3VzSWQiOiI2ZjIyMWFhNS01NDQ4LTQwMDgtODEzNy05NjljNmM0MmJiY2IiLCJldmVudCI6IlBSIHZpZXdlZCIsInByb3BlcnRpZXMiOnsicHJJZCI6IjZmMjIxYWE1LTU0NDgtNDAwOC04MTM3LTk2OWM2YzQyYmJjYiJ9fQ==" width="0" height="0"/> > - 🧐 [View latest project report](https://app.snyk.io/org/szotkowski/project/36f26f5b-e4bf-4cb8-ae5b-087fbc45bf4d?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr) > - 📜 [Customise PR templates](https://docs.snyk.io/scan-using-snyk/pull-requests/snyk-fix-pull-or-merge-requests/customize-pr-templates?utm_source=&utm_content=fix-pr-template) > - 🛠 [Adjust upgrade PR settings](https://app.snyk.io/org/szotkowski/project/36f26f5b-e4bf-4cb8-ae5b-087fbc45bf4d/settings/integration?utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr) > - 🔕 [Ignore this dependency or unsubscribe from future upgrade PRs](https://app.snyk.io/org/szotkowski/project/36f26f5b-e4bf-4cb8-ae5b-087fbc45bf4d/settings/integration?pkg&#x3D;path-to-regexp&amp;utm_source&#x3D;github&amp;utm_medium&#x3D;referral&amp;page&#x3D;upgrade-pr#auto-dep-upgrades) [//]: # 'snyk:metadata:{"breakingChangeRiskLevel":null,"FF_showPullRequestBreakingChanges":null,"FF_showPullRequestBreakingChangesWebSearch":null,"customTemplate":{"variablesUsed":[],"fieldsUsed":[]},"dependencies":[{"name":"path-to-regexp","from":"8.2.0","to":"8.3.0"}],"env":"prod","hasFixes":false,"isBreakingChange":false,"isMajorUpgrade":false,"issuesToFix":[],"prId":"6f221aa5-5448-4008-8137-969c6c42bbcb","prPublicId":"6f221aa5-5448-4008-8137-969c6c42bbcb","packageManager":"npm","priorityScoreList":[],"projectPublicId":"36f26f5b-e4bf-4cb8-ae5b-087fbc45bf4d","projectUrl":"https://app.snyk.io/org/szotkowski/project/36f26f5b-e4bf-4cb8-ae5b-087fbc45bf4d?utm_source=github&utm_medium=referral&page=upgrade-pr","prType":"upgrade","templateFieldSources":{"branchName":"default","commitMessage":"default","description":"default","title":"default"},"templateVariants":[],"type":"auto","upgrade":[],"upgradeInfo":{"versionsDiff":1,"publishedDate":"2025-09-02T21:13:13.739Z"},"vulns":[]}' Co-authored-by: snyk-bot <snyk-bot@snyk.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants