rsnext/packages/next
Javi Velasco 0de109baab
Refactor Page Paths utils and Middleware Plugin (#36576)
This PR brings some significant refactoring in preparation for upcoming middleware changes. Each commit can be reviewed independently, here is a summary of what each one does and the reasoning behind it:
- [Move pagesDir to next-dev-server](f2fe154c00) simply moves the `pagesDir` property to the dev server which is the only place where it is needed. Having it for every server is misleading.
- [Move (de)normalize page path utils to a file page-path-utils.ts](27cedf0871) Moves the functions to normalize and denormalize page paths to a single file that is intended to hold every utility function that transforms page paths. Since those are complementary it makes sense to have them together. I also added explanatory comments on why they are not idempotent and examples for input -> output that I find very useful.
- [Extract removePagePathTail](6b121332aa) This extracts a function to remove the tail on a page path (absolute or relative). I'm sure there will be other contexts where we can use it.
- [Extract getPagePaths and refactor findPageFile](cf2c7b842e) This extracts a function `getPagePaths` that is used to generate an array of paths to inspect when looking for a page file from `findPageFile`. Then it refactors such function to use it parallelizing lookups. This will allow us to print every path we look at when looking for a file which can be useful for debugging. It also adds a `flatten` helper. 
- [Refactor onDemandEntryHandler](4be685c37e) I've found this one quite difficult to understand so it is refactored to use some of the previously mentioned functions and make it easier to read.
- [Extract absolutePagePath util](3bc0783474) Extracts yet another util from the `next-dev-server` that transforms an absolute path into a page name. Of course it adds comments, parameters and examples.
- [Refactor MiddlewarePlugin](c595a2cc62) This is the most significant change. The logic here was very hard to understand so it is totally redistributed with comments. This also removes a global variable `ssrEntries` that was deprecated in favour of module metadata added to Webpack from loaders keeping less dependencies. It also adds types and makes a clear distinction between phases where we statically analyze the code, find metadata and generate the manifest file cc @shuding @huozhi 

EDIT: 
- [Split page path utils](158fb002d0) After seeing one of the utils was being used by the client while it was defined originally in the server, with this PR we are splitting the util into multiple files and moving it to `shared/lib` in order to make explicit that those can be also imported from client.
2022-04-30 11:19:27 +00:00
..
bin Hoist the desired ReactDOM import expression (#36552) 2022-04-28 19:17:23 +00:00
build Refactor Page Paths utils and Middleware Plugin (#36576) 2022-04-30 11:19:27 +00:00
bundles update webpack (#35867) 2022-04-07 16:00:26 +00:00
cli chore: clarify CLI network errors (#36567) 2022-04-29 12:39:17 +00:00
client Adds inline script functionality to next/script for worker and beforeInteractive strategies (#36364) 2022-04-29 15:20:31 +00:00
compiled unlock eslint-config-next dependencies (#35781) 2022-04-28 17:15:58 +00:00
export Refactor Page Paths utils and Middleware Plugin (#36576) 2022-04-30 11:19:27 +00:00
image-types Don't import internally from types in next-env.d.ts (#34394) 2022-02-19 04:25:49 +01:00
lib Ensure older lockfile/invalid formats are handled (#36577) 2022-04-29 09:42:48 -05:00
pages Adds inline script functionality to next/script for worker and beforeInteractive strategies (#36364) 2022-04-29 15:20:31 +00:00
server Refactor Page Paths utils and Middleware Plugin (#36576) 2022-04-30 11:19:27 +00:00
shared/lib Refactor Page Paths utils and Middleware Plugin (#36576) 2022-04-30 11:19:27 +00:00
telemetry Add event for swc load failure and attempt patching lockfile (#36527) 2022-04-28 11:31:15 +02:00
trace feat(trace): postprocess trace reporter for datadog (#35032) 2022-03-08 08:15:09 -08:00
types polish isomorphic path module (#36521) 2022-04-27 18:23:26 +00:00
amp.d.ts
amp.js
app.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
app.js
babel.d.ts
babel.js
client.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
client.js
config.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
config.js
constants.d.ts
constants.js
data.d.ts
data.js
data.sqlite
document.d.ts Fix document type import path (#32117) 2021-12-04 10:23:15 +00:00
document.js
dynamic.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
dynamic.js
error.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
error.js
head.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
head.js fix(#36435): apply correct fix (#36464) 2022-04-26 11:15:49 -05:00
image.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
image.js
index.d.ts Include submodules in exported type definition (#28316) 2021-11-26 14:46:56 +01:00
jest.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
jest.js Ensure next/jest is published (#31296) 2021-11-11 11:48:12 +01:00
license.md Update license year 2022-01-13 16:02:34 +01:00
link.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
link.js
package.json v12.1.6-canary.15 2022-04-29 11:54:57 -05:00
README.md
router.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
router.js
script.d.ts Improve exported root definitions (#32077) 2021-12-03 07:16:29 +00:00
script.js
server.d.ts Add TS types for NextMiddleware (#30578) 2021-11-30 20:43:40 +00:00
server.js Convert server.js to module.exports (#35181) 2022-03-09 22:50:07 +00:00
streaming.d.ts Group streaming experimental apis (#33878) 2022-02-02 13:42:14 +00:00
streaming.js Group streaming experimental apis (#33878) 2022-02-02 13:42:14 +00:00
taskfile-ncc.js Update to latest ncc and ensure caniuse-lite data is external (#32064) 2021-12-08 10:41:35 -06:00
taskfile-swc.js Interpolate module.exports as default import (#36082) 2022-04-12 14:32:42 +00:00
taskfile.js fix(#36435): apply correct fix (#36464) 2022-04-26 11:15:49 -05:00
tsconfig.json Integrate tsec into the linting process (#33746) 2022-02-24 16:59:18 -08:00

Next.js

Getting Started

Visit https://nextjs.org/learn to get started with Next.js.

Documentation

Visit https://nextjs.org/docs to view the full documentation.

Who is using Next.js?

Next.js is used by the world's leading companies. Check out the Next.js Showcase to learn more.

Community

The Next.js community can be found on GitHub Discussions, where you can ask questions, voice ideas, and share your projects.

To chat with other community members you can join the Next.js Discord.

Our Code of Conduct applies to all Next.js community channels.

Contributing

Please see our contributing.md.

Good First Issues

We have a list of good first issues that contain bugs which have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

Authors