Skip to content

The /components exports import Node.js code, which causes errors during next buildΒ #208

@aldeed

Description

@aldeed

Describe the bug
The /components exports import Node.js code, which causes errors during next build.

node:http
Module build failed: UnhandledSchemeError: Reading from "node:http" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.
    at /Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:28:406935
    at Hook.eval [as callAsync] (eval at create (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:13:9218), <anonymous>:6:1)
    at Object.processResource (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:28:406860)
    at processResource (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:5308)
    at iteratePitchingLoaders (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:4667)
    at runLoaders (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/loader-runner/LoaderRunner.js:1:8590)
    at NormalModule._doBuild (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:28:406722)
    at NormalModule.build (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:28:408735)
    at /Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:28:82434
    at NormalModule.needBuild (/Users/eric/Code/qawolf/next-esm-example/node_modules/next/dist/compiled/webpack/bundle5.js:28:412676)

Import trace for requested module:
node:http
./node_modules/@workos-inc/node/lib/common/net/node-client.js
./node_modules/@workos-inc/node/lib/index.js
./node_modules/@workos-inc/authkit-nextjs/dist/esm/workos.js
./node_modules/@workos-inc/authkit-nextjs/dist/esm/actions.js
./node_modules/@workos-inc/authkit-nextjs/dist/esm/components/impersonation.js
./node_modules/@workos-inc/authkit-nextjs/dist/esm/components/index.js

It may be because the pages router is not officially supported (see #85), but it still seems unexpected for browser code to be importing from Node.js code within this package.

To Reproduce
See readme of this reproduction repo.

Expected behavior
Maybe it needs to be made clearer that /components exports only work in server components, and/or maybe there should be a separate "clean" export for use in client components?

I think it is only because of Impersonation, so maybe just remove that export from components/index.js and export /components/impersonation path separately? This doesn't work. All components files eventually import the workos file.

Desktop (please complete the following information):

  • OS: MacOS
  • authkit-nextjs version 2.0.0
  • Next.js version 15.1.7

Additional context
Since I'm exploring using this in a very large existing app that can't be easily converted to app router, I'm very interested in workarounds to make this work with pages router. I might try rewriting it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions