-
Notifications
You must be signed in to change notification settings - Fork 27.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server actions: Cannot use classes imported from ESM packages included in serverComponentsExternalPackages
option
#60756
Labels
bug
Issue was opened via the bug report template.
linear: next
Confirmed issue that is tracked by the Next.js team.
locked
Module Resolution
Module resolution (CJS / ESM, module resolving).
Comments
github-actions
bot
added
the
Module Resolution
Module resolution (CJS / ESM, module resolving).
label
Jan 17, 2024
Here's the full error by the way:
|
Looks like inlining the import fixes the issue new (await import("oslo/password")).Argon2id(); |
feedthejim
added
the
linear: next
Confirmed issue that is tracked by the Next.js team.
label
Feb 12, 2024
huozhi
added a commit
that referenced
this issue
May 7, 2024
### What Support `esmExternals` working in app router ### Why `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
lubieowoce
pushed a commit
that referenced
this issue
Aug 23, 2024
Support `esmExternals` working in app router `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
lubieowoce
pushed a commit
that referenced
this issue
Aug 23, 2024
Support `esmExternals` working in app router `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
lubieowoce
pushed a commit
that referenced
this issue
Aug 23, 2024
Support `esmExternals` working in app router `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
lubieowoce
pushed a commit
that referenced
this issue
Aug 23, 2024
Support `esmExternals` working in app router `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
lubieowoce
pushed a commit
that referenced
this issue
Aug 28, 2024
Support `esmExternals` working in app router `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
lubieowoce
pushed a commit
that referenced
this issue
Sep 2, 2024
Support `esmExternals` working in app router `esmExternals` was disabled for app router that most of the packages are picking up the CJS bundles for externals. This PR enables to resolve the ESM bundle for external packages. We have two issues discovered while enabling the flag, any esm external packages will fail in client page SSR and server action. We fixed them by changing the below bundling logics: * When a client page having a async dependency, we can await the page during in rendering * When a server action having a async dependency, we changed the server action entry creation with webpack along with the server client entry creation together, then webpack can handle the modules async propagation properly. Fixes #60756 Closes NEXT-2435 Closes NEXT-2472 Closes NEXT-3225 --------- Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
bug
Issue was opened via the bug report template.
linear: next
Confirmed issue that is tracked by the Next.js team.
locked
Module Resolution
Module resolution (CJS / ESM, module resolving).
Link to the code that reproduces this issue
https://github.com/pilcrowOnPaper/next-server-actions-esm-class-repro
To Reproduce
/
)Current vs. Expected behavior
I can't seem to use classes imported from ESM packages included in experimental
serverComponentsExternalPackages
option in server actions, when the action is imported from client components.This works fine when the package is CJS, when the package is not included in
serverComponentsExternalPackages
, or when the action is passed down to the client component as a prop.Verify canary release
Provide environment information
Operating System: Platform: darwin Arch: x64 Version: Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64 Binaries: Node: 20.2.0 npm: 9.6.6 Yarn: 1.22.19 pnpm: 8.10.2 Relevant Packages: next: 14.0.5-canary.60 eslint-config-next: 14.0.4 react: 18.2.0 react-dom: 18.2.0 typescript: 5.3.3 Next.js Config: output: N/A
Which area(s) are affected? (Select all that apply)
App Router, Module resolution (CJS / ESM, module resolving)
Which stage(s) are affected? (Select all that apply)
next dev (local), next build (local)
Additional context
I need to use
serverComponentsExternalPackages
as certain modules (oslo/password
) require Node specific modules (@node-rs/argon2
)NEXT-2435
The text was updated successfully, but these errors were encountered: