-
Notifications
You must be signed in to change notification settings - Fork 44
Description
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 This doesn't work. All components files eventually import the workos file.Impersonation
, so maybe just remove that export from components/index.js
and export /components/impersonation
path separately?
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.