Skip to content

fix(@nylas/react): correct Connect import paths in README - #94

Merged
nbarraclough merged 2 commits into
mainfrom
fix/react-readme-connect-imports
Sep 1, 2026
Merged

fix(@nylas/react): correct Connect import paths in README#94
nbarraclough merged 2 commits into
mainfrom
fix/react-readme-connect-imports

Conversation

@nbarraclough

@nbarraclough nbarraclough commented Sep 1, 2026

Copy link
Copy Markdown
Member

Problem

Four README snippets tell users to import the Connect symbols from the package root:

import { useNylasConnect } from '@nylas/react';        // line 124
import { NylasConnectButton } from "@nylas/react";     // lines 207, 230, 261

Neither symbol is exported from there, so every one of those snippets fails. Under ESM — the normal case for a React app — it is a hard link-time error before any code runs:

SyntaxError: The requested module '@nylas/react' does not provide an export named 'useNylasConnect'

Via CJS require it instead yields undefined, then a TypeError at call time.

This is a docs-only bug. The library itself is fine — the exports map and build are correct, and @nylas/react/connect has always worked. Only readers copying these snippets are affected.

Why they don't resolve

packages/react/src/index.ts is only:

export * from "./elements";   // -> ./elements/components  (web-elements wrappers)
export * from "./utils";      // -> NylasIdentityRequestWrapper, LANGUAGE_CODE

Neither barrel reaches the Connect symbols. They are defined and exported solely under src/connect/:

  • connect/useNylasConnect.ts:50, connect/NylasConnectButton.tsx:66
  • re-exported by connect/index.ts:5,8

That is reachable only through the ./connect subpath, which is a real build entry — vite.config.ts:14 builds connect from src/connect.ts and emits dist/es/connect.js, matching the ./connect condition in package.json.

Fix

  • The four imports now use @nylas/react/connect.
  • The Exports overview (line 34) claimed the Connect symbols could be imported "from @nylas/react or @nylas/react/connect". The first half is wrong; it now names only the subpath.

The Elements entries are deliberately untouched — NylasSchedulerEditor and NylasScheduling really do resolve from the package root, so line 30 and the import at line 46 are correct as written.

No source changes. Patch changeset included so the corrected README reaches npmjs.com, where the broken snippets are currently published.

🤖 Generated with Claude Code

`useNylasConnect` and `NylasConnectButton` are exported only from the
`@nylas/react/connect` subpath. `src/index.ts` re-exports `./elements`
and `./utils`, neither of which reaches them, so the four README
snippets importing from `@nylas/react` could not resolve.

Also corrects the Exports overview, which claimed the Connect symbols
were importable from `@nylas/react` as well as `@nylas/react/connect`.

The Elements entries are unaffected: `NylasSchedulerEditor` and
`NylasScheduling` genuinely resolve from the package root.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@AaronDDM AaronDDM left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good afternoon!

Checked this against the source and the fix is correct. packages/react/src/index.ts only re-exports ./elements and ./utils, so neither useNylasConnect nor NylasConnectButton is reachable from the package root. ./connect is a real entry in the exports map, so the new paths resolve.

All four snippets plus the exports overview line are covered, and you correctly left the Elements imports alone — those do resolve from the root. Changeset is there.

Approving.

@nbarraclough
nbarraclough merged commit b23827f into main Sep 1, 2026
6 checks passed
@nbarraclough
nbarraclough deleted the fix/react-readme-connect-imports branch September 1, 2026 18:13
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