Middleware builds are using the package.json browser field
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
(not relevant)
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 20.6.0: Wed Jan 12 22:22:42 PST 2022; root:xnu-7195.141.19~2/RELEASE_X86_64
Binaries:
Node: 16.14.0
npm: 8.3.1
Yarn: 1.22.17
pnpm: N/A
Relevant packages:
next: 12.1.0
react: 17.0.2
react-dom: 17.0.2
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
:
"browser": {
"some-package": false,
}
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
- Add a package entry within the browser field in the project package.json, setting it’s value to false
- Import the package into middleware
- Observe the package is undefined in the middleware runtime
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
browser vs module fields in package.json #4674 - GitHub
When module's package.json contains browser , module & main fields, webpack is bundling browser build by default.
Read more >webpack/webpack - Gitter
Hi guys, I'm new to webpack, and I'm developing an npm chat package. ... I would like to send build progress to browser...
Read more >The 'mode' option has not been set, webpack will fallback to ...
Field 'browser' doesn't contain a valid alias configuration using description file: /home/prithvi/Desktop/socialize/package.json (relative path: ...
Read more >Create React App: A quick setup guide - LogRocket Blog
Our quick tutorial on Create React App covers how to set up a React app and configure some important features.
Read more >Express/Node introduction - Learn web development | MDN
The node package manager (npm) provides access to hundreds of thousands of ... You can use Express middleware to add support for cookies, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Update, this behavior might change in the next
canary
release when this is published: https://github.com/vercel/next.js/pull/35335This 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.