rsnext/packages/next/build/webpack
Javi Velasco 6e081e175f
Update middleware eval checks (#30883)
Co-authored-by: Tobias Koppers <sokra@users.noreply.github.com>

With this PR we are updating the way we check the usage of `eval` and other dynamic code evaluation (like `new Function`) for middleware. Now instead of simply showing a warning it will behave differently depending on if we are building or in development.

- Development: we replace the dynamic code with a wrapper so that we print a warning only when the code is used. We don't fail in this scenario as it is possible that once the application is built the code that uses `eval` is left out.
- Build: we detect with tree shaking if the code that will be bundled into the middleware includes any dynamic code and in such scenario we make the build fail as don't want to allow it for the production environment.

Closes #30674

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2021-11-05 20:48:43 +00:00
..
config Fix code splitting and build target for the server-web build (#30972) 2021-11-05 03:27:02 +00:00
loaders pass Buffer directly to Rust (#30975) 2021-11-05 15:12:06 +01:00
plugins Update middleware eval checks (#30883) 2021-11-05 20:48:43 +00:00
require-hook.ts the way towards webpack 5 typings (#29105) 2021-09-21 19:17:16 +02:00
stringify-request.ts Update loader-utils (#30743) 2021-11-02 16:13:15 +01:00