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
Middleware builds are using the package.json browser field #35370
Comments
Sandbox example: https://codesandbox.io/s/keen-cray-33iz09?file=/pages/_middleware.js |
This is expected, as Middleware uses the Edge Runtime (which builds on the same web standard APIs as browsers), not Node.js. https://nextjs.org/docs/api-reference/edge-runtime#unsupported-apis. |
Update, this behavior might change in the next |
@balazsorban44 The linked article cites middleware runtime constraints, but nothing about how dependencies are built. As a user this overloading of the browser field is surprising -- I would not expect to have the browser field applied to a build that is not executed on the client's browser. User's may want to consume a different library entry point or ensure it doesn't end up in client builds irrespective of any runtime constraints. |
I forwarded your feedback, thank you! |
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
(not relevant)
What browser are you using? (if relevant)
N/A
How are you deploying your application? (if relevant)
N/A
Describe the Bug
Middleware webpack builds are using the "browser" field from package.json, which is surprising because middleware only run s in a server context.
With the following in your
package.json
:some-package
will not be defined in middleware handlers.Expected Behavior
The "browser" field from package.json is not used when building middleware code paths.
To Reproduce
The text was updated successfully, but these errors were encountered: