Skip to content

fix: 2.0.0-exp.0 fails to load on install (undeclared fast-decode-uri-component, removed elysia internals)#110

Open
thupi wants to merge 1 commit into
elysiajs:kianafrom
thupi:fix/exp42-compat
Open

fix: 2.0.0-exp.0 fails to load on install (undeclared fast-decode-uri-component, removed elysia internals)#110
thupi wants to merge 1 commit into
elysiajs:kianafrom
thupi:fix/exp42-compat

Conversation

@thupi

@thupi thupi commented Jul 11, 2026

Copy link
Copy Markdown

This PR fixes two independent issues that make @elysia/static@2.0.0-exp.0 fail at import time on any consumer install:

Cannot find module './node_modules/fast-decode-uri-component/index.mjs'
  from '.../node_modules/@elysia/static/dist/index.mjs'

Reproducible in an empty project with bun i elysia@2.0.0-exp.42 @elysia/static@2.0.0-exp.0 — both the ESM and CJS entries fail the same way.

1. fast-decode-uri-component is only a devDependency

The unbundle: true build externalizes it by relative path (./node_modules/fast-decode-uri-component/...) because it isn't a runtime dependency — that path isn't in the published tarball, and consumers never install the package (1.x wasn't affected because the old build inlined it). Moving it to dependencies makes tsdown externalize it by bare specifier:

- import { require_fast_decode_uri_component } from "./node_modules/fast-decode-uri-component/index.mjs";
+ import fastDecodeURI from "fast-decode-uri-component";

2. Built against elysia internals removed during the exp series

With issue 1 shimmed away, the ESM entry still fails to link against current exp:

Export named 'MethodMap' not found in module '.../elysia/dist/constants.mjs'.

src/index.ts imports MethodMap from elysia/constants and reads app.history, both removed in current 2.0 exp, while the peer range allows >= 2.0.0-exp.23. Replaced with the app.routes declarations, which have the same { method, path } shape across the supported range (verified on exp.23 and exp.42):

app.routes?.find(
    (route) => route.method === 'GET' && route.path === `${prefix}/*`
) === undefined

Validation

  • bun test: 141 pass / 0 fail on this branch (lockfile's exp.23)
  • npm pack of this branch installed into a clean project on elysia@2.0.0-exp.42: the plugin now loads and serves files, with fast-decode-uri-component installed automatically as a regular dependency
  • happy to attach the minimal reproduction (3 scripts, clean directory) if useful

…rop removed elysia internals

The unbundled build externalizes fast-decode-uri-component by path
(./node_modules/...) because it was only a devDependency, and the path is
not shipped — both dist entries fail to load on a consumer install.
Declaring it as a runtime dependency makes tsdown externalize it by bare
specifier and consumers install it.

Also replace the MethodMap import and app.history lookup (both removed in
current 2.0 exp; peer range allows >= exp.23) with the app.routes
declarations, which have the same shape across the supported range.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c663f667-b923-404b-a153-a37b22fd0168

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

1 participant