Skip to content

Shorten minified error URL to reduce production bundle size#4677

Merged
kubk merged 4 commits into
mobxjs:mainfrom
kubk:shorten-minified-error-url
Jun 24, 2026
Merged

Shorten minified error URL to reduce production bundle size#4677
kubk merged 4 commits into
mobxjs:mainfrom
kubk:shorten-minified-error-url

Conversation

@kubk

@kubk kubk commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Added a separate documentation page for the production error codes we have. Benefits:

  • Make the error list discoverable for Google / AI agents
  • Allows to use the short url mobx.js.org/errors in the production bundle since gzip does not shorten unique strings

The page will be always up-to-date with the source code

@changeset-bot

changeset-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: ed467aa

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@kubk kubk force-pushed the shorten-minified-error-url branch 2 times, most recently from ecbfe95 to 58358d3 Compare June 24, 2026 06:48
@kubk kubk force-pushed the shorten-minified-error-url branch from 58358d3 to 7f4b968 Compare June 24, 2026 06:56
@kubk kubk force-pushed the shorten-minified-error-url branch from aea90a7 to 620da5b Compare June 24, 2026 07:43
@kubk kubk merged commit 979d267 into mobxjs:main Jun 24, 2026
1 check passed
@github-actions github-actions Bot mentioned this pull request Jun 24, 2026
const { relative, resolve } = require("path")

const repoRoot = resolve(__dirname, "../..")
const errorsPath = resolve(repoRoot, "packages/mobx/src/errors.ts")

@kubk kubk Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@mweststrate the change was merged but it doesn't seem to be deploying to prod. I can’t see the logs, but my suspicion is that the Node version is outdated wherever we build the docs.

Node 24 locally imports the errors.ts correctly. An older version would fail. I'd appreciate if you could update it there!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an always-up-to-date documentation page for MobX production error codes and updates the minified-error message to point to a shorter URL, aiming to reduce the production bundle size.

Changes:

  • Add an error-codes doc page entry to the Docusaurus sidebar + i18n.
  • Generate docs/errors.md automatically before starting/building the website.
  • Shorten the production “minified error” URL in die().

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
website/sidebars.json Adds the new errors doc to the sidebar navigation.
website/scripts/generate-error-docs.js New script intended to generate docs/errors.md from MobX source errors.
website/package.json Runs the generator on prestart and prebuild.
website/i18n/en.json Adds title/sidebar labels for the new errors doc.
packages/mobx/src/internal.ts Stops re-exporting everything from ./errors (exports only die).
packages/mobx/src/errors.ts Exports niceErrors and updates the production minified-error link text.
.gitignore Ignores the generated docs/errors.md.
.changeset/fix-minified-error-link.md Adds a patch changeset entry for the link change.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread website/scripts/generate-error-docs.js
Comment thread packages/mobx/src/errors.ts
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.

2 participants