fix(next): split runtime-next into server and client entry points - #4
Merged
Merged
Conversation
The single barrel export mixed @autter/runtime-node (Node OTel SDK) with browser re-exports and the React error boundary, so the documented client component import pulled the OTel SDK into the browser bundle and failed the Next.js build (fs cannot be resolved). - Root / ./server entry: registerAutter, createAutterRelayRoute, captureServerException/Message — server-only code paths. - ./client entry: browser tracker API + AutterErrorBoundary, built with a "use client" banner and no Node imports. - Docs updated to import client pieces from @autter/runtime-next/client. Generated-By: PostHog Code Task-Id: 74ac2be4-ebb7-4ac4-8db4-62b20460f276
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem
Setting up
@autter/runtime-nextin a real Next.js app fails at build time. The package has a single barrel entry that imports@autter/runtime-node(the full Node OpenTelemetry SDK) and re-exports the browser tracker + React error boundary. The documented step 3 (import { initAutterBrowser, AutterErrorBoundary } from "@autter/runtime-next"in a client component) therefore drags the OTel SDK into the client bundle and the build dies on Node built-ins (fscannot be resolved).Fix
Split the package into two entry points — the same shape
@sentry/nextjs/posthog-jsuse:@autter/runtime-next(and alias@autter/runtime-next/server) — server-only:registerAutter,createAutterRelayRoute,captureServerException,captureServerMessage. Used ininstrumentation.tsand route handlers, so the two server snippets in the README keep working unchanged.@autter/runtime-next/client— browser tracker API +AutterErrorBoundary, bundled with a"use client"banner and zero Node imports.Build moves from a one-liner to
tsup.config.tsso the client entry gets its own banner/target. Verified the builtdist/client.jsstarts with"use client";and contains no references to OpenTelemetry,runtime-node, orfs.Breaking change
Client components must now import from
@autter/runtime-next/clientinstead of the root. Since the old root import never actually built in a client component, no working setup breaks. Package README,docs/GETTING-STARTED.md, anddocs/INTEGRATIONS.mdupdated.Created with PostHog Code