This repository was archived by the owner on Oct 9, 2025. It is now read-only.
feat: separate entry point for dynamic imports #511
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
This PR introduces a temporary solution to address critical bundler issues with dynamic imports while providing a bridge to
v3. It creates two distinct entry points: a bundler-safe main export and a temporary auto-detection export for Node.js compatibility.What is the current behavior?
The current implementation uses dynamic imports in the main export, causing several critical issues:
Critical dependency: the request of a dependency is an expressionCurrent problematic code in Node.js environments:
What is the new behavior?
🚀 Main Export - Bundler Safe
The main export removes all dynamic imports to eliminate bundler issues:
Inconvenience: Node.js < 22 users must now provide WebSocket transport explicitly.
🔧 Temporary Auto Export - Dynamic Loading
For users who need automatic WebSocket detection (with bundler trade-offs):
Additional information
Browser and Node.js 22+ users**
No changes required.
📦 Package Structure
{ "exports": { ".": { "types": "./dist/module/index.d.ts", "import": "./dist/module/index.js", // No dynamic imports "require": "./dist/main/index.js" // No dynamic imports }, "./auto": { "types": "./dist/module/index.auto.d.ts", "import": "./dist/module/index.auto.js", // Has dynamic imports "require": "./dist/main/index.auto.js" // Has dynamic imports } } }🔍 Technical Details
wsloading🗺️ Roadmap
Why This Is Not a Breaking Change
While the main export behavior changes for Node.js < 22 users, this is not considered a breaking change for the following reasons:
Current Implementation Is Already Broken
The existing dynamic import approach already fails in many production environments:
Production failures include:
We Provide a Compatibility Path
Users who need the previous (problematic) behavior can use the
/autoexport:Impact Analysis
transport/autofor identical behaviorFix Rather Than Break
This change fixes broken functionality rather than breaking working functionality: