No description
Find a file
Thomas Knickman 7943ef8ed8
feat(next): trace build dependencies for turborepo (#59553)
### What?

This adds a method to optionally detect disk, network, and env access
access during a build and write this to a file.

### Why?

This will be consumed by Turborepo to determine **if** a build can be
cached, and if so, **how** it should be cached.

### How?

This implements a proxy that can be selectively applied to functions to
watch their access to disk, network, and env. For Turborepo, we only
care about what can alter the build output, to achieve this, we trace
the config load, and the static page generation.

Closes
https://linear.app/vercel/issue/TURBO-1904/support-build-access-tracing-in-nextjs

Performance Testing:

Repo -
https://github.com/tknickman/nextjs-turborepo-build-trace-performance-testing

```
- - - - - - - - - - - - - - - - - Performance - - - - - - - - - - - - - - - - -
pages-single-app:
  44629.53301 ms (+/- 6313.82757 ms) from 5 iterations (223318.53692 ms total)
local-pages-single-app-with-trace:
  45684.00503 ms (+/- 6570.85083 ms) from 5 iterations (228585.01729 ms total)
local-pages-single-app-without-trace:
  45938.76231 ms (+/- 6816.13022 ms) from 5 iterations (229830.15925 ms total)
approuter-single-app:
  49517.23156 ms (+/- 7820.20687 ms) from 5 iterations (247725.16713 ms total)
local-approuter-single-app-with-trace:
  50019.98247 ms (+/- 9443.82537 ms) from 5 iterations (250224.62496 ms total)
local-approuter-single-app-without-trace:
  50124.07092 ms (+/- 9656.22047 ms) from 5 iterations (250726.35688 ms total)
local-large-pages-single-app-without-trace:
  51582.92992 ms (+/- 12179.09895 ms) from 5 iterations (258469.36942 ms total)
local-large-pages-single-app-with-trace:
  51740.25813 ms (+/- 12601.02878 ms) from 5 iterations (259329.50946 ms total)
local-xlarge-pages-single-app-with-trace:
  234111.66735 ms (+/- 74629.30509 ms) from 5 iterations (1191018.63608 ms total)
local-xlarge-pages-single-app-without-trace:
  239621.11837 ms (+/- 84629.16374 ms) from 5 iterations (1218078.41921 ms total)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
```

<details>
<summary>Test case keys</summary>

* `local-xlarge-pages-single-app-without-trace`: this branch, built and
linked to a local project with 5000 SSG pages and trace **disabled**
* `local-xlarge-pages-single-app-with-trace`: this branch, built and
linked to a local project with 5000 SSG pages and trace **enabled**
* `local-large-pages-single-app-with-trace`: this branch, built and
linked to a local project with 100 SSG pages and trace **enabled**
* `local-large-pages-single-app-without-trace`: this branch, built and
linked to a local project with 100 SSG pages and trace **disabled**
* `local-approuter-single-app-without-trace`: this branch, built and
linked to a local default approuter starter and trace **disabled**
* `local-approuter-single-app-with-trace`: this branch, built and linked
to a local default approuter starter and trace **enabled**
* `local-pages-single-app-with-trace`: this branch, built and linked to
a local default pages starter and trace **enabled**
* `local-pages-single-app-without-trace`: this branch, built and linked
to a local default pages starter and trace **disabled**
* `approuter-single-app`: next@latest running on the default approuter
starter
* `pages-single-app`: next@latest running on the default pages starter


</details>


TODO:
- [ ] Telemetry events
2024-01-31 14:18:27 -07:00
.cargo Update rust-toolchain to 2023-11-16 (#58558) 2023-11-18 00:29:50 +00:00
.config Update teamname in codeowners (#57775) 2023-10-31 12:33:13 +00:00
.devcontainer re-enable next-dev-tests (#47087) 2023-03-14 16:05:19 +01:00
.github chore: add resolved label (#61416) 2024-01-31 02:50:23 +01:00
.husky Replace pre-commit with husky (#38350) 2022-07-06 11:14:16 -05:00
.vscode misc: build output rework (#57440) 2023-10-25 13:19:42 -07:00
bench Fix basic-app benchmark application (#60842) 2024-01-20 20:35:20 -06:00
contributing chore: add resolved label (#61416) 2024-01-31 02:50:23 +01:00
docs remove note about updating next.config with hostname as this is not n… (#61458) 2024-01-31 11:12:13 -05:00
errors Deprecation warning for config.analyticsId (#60677) 2024-01-19 14:45:05 +01:00
examples fix: dockerfile npm run build (#61466) 2024-01-31 18:46:33 +00:00
packages feat(next): trace build dependencies for turborepo (#59553) 2024-01-31 14:18:27 -07:00
scripts chore: fix postinstall when using tarball (#60443) 2024-01-09 17:37:49 -05:00
test feat(next): trace build dependencies for turborepo (#59553) 2024-01-31 14:18:27 -07:00
turbo/generators fix(generators): update errors gen (#60233) 2024-01-04 20:22:21 +01:00
.alexignore Integrate next-* crates from Turbopack (#47019) 2023-03-13 14:33:17 +01:00
.alexrc docs: Add "special" to the Alex allowlist (#48021) 2023-04-06 16:32:06 +02:00
.eslintignore ci: report daily turbo integration test results from this repo (#58965) 2023-12-04 16:18:42 +01:00
.eslintrc.json Use new JSX transform (#56294) 2023-12-09 00:17:50 +01:00
.git-blame-ignore-revs chore(git): add .git-blame-ignore-revs (#60582) 2024-01-12 16:09:58 -05:00
.gitattributes chore: update gitattributes with linguist-vendored (#54683) 2023-08-28 21:50:19 +00:00
.gitignore ci: report daily turbo integration test results from this repo (#58965) 2023-12-04 16:18:42 +01:00
.node-version Update .node-version (#56460) 2023-10-05 07:40:12 +00:00
.npmrc fix: npm publish provenance permissions (#48757) 2023-04-24 14:08:55 +00:00
.prettierignore ci: report daily turbo integration test results from this repo (#58965) 2023-12-04 16:18:42 +01:00
.prettierignore_staged chore: replace issue triaing actions with nissuer (#55525) 2023-09-19 11:11:00 +00:00
.prettierrc.json chore(examples): use default prettier for examples/templates (#60530) 2024-01-11 16:01:44 -07:00
.rustfmt.toml build(cargo): move workspaces manifest to top level (#48198) 2023-04-19 18:38:36 +02:00
azure-pipelines.yml chore: lower Node.js version requirement (#56943) 2023-10-17 23:15:31 +02:00
Cargo.lock Update turbopack (#61433) 2024-01-31 19:33:37 +09:00
Cargo.toml Update turbopack (#61433) 2024-01-31 19:33:37 +09:00
CODE_OF_CONDUCT.md updated code of conduct to v2.1 (#34208) 2022-02-10 18:11:42 -06:00
contributing.md chore: improve repo templates (#46629) 2023-03-01 09:25:51 -08:00
jest.config.js test: use replay jest runner to add current test name to recording (#60438) 2024-01-10 10:31:32 +01:00
jest.replay.config.js Add Replay integration for dev e2e tests (#40955) 2022-09-29 14:45:10 -07:00
lerna.json v14.1.1-canary.26 2024-01-31 18:11:07 +00:00
license.md chore: update Copyright time from 2023 to 2024 (#60071) 2024-01-02 11:06:02 -08:00
lint-staged.config.js add cargo fmt to lint staged (#56430) 2023-10-04 17:46:44 +00:00
package.json chore: upgrade webpack to 5.90.0 (#61109) 2024-01-25 20:18:12 +01:00
pnpm-lock.yaml v14.1.1-canary.26 2024-01-31 18:11:07 +00:00
pnpm-workspace.yaml Remove next-dev and its test suite and benchmarks (#55983) 2023-09-26 05:22:39 +02:00
readme.md Monorepo (#5341) 2018-10-01 01:02:10 +02:00
release.js Fix labels for release sections 2021-11-21 13:11:54 +01:00
run-tests.js Fix tests exit race condition (#60757) 2024-01-17 17:09:57 +01:00
rust-toolchain Update rust-toolchain to 2023-11-16 (#58558) 2023-11-18 00:29:50 +00:00
socket.yaml chore(ci): add socket.yaml (#54446) 2023-08-23 18:12:51 +00:00
test-file.txt Add additional file serving tests (#12479) 2020-05-04 11:58:19 -05:00
tsconfig-tsec.json Integrate tsec into the linting process (#33746) 2022-02-24 16:59:18 -08:00
tsconfig.base.json [PPR Nav] Fix flash of loading state during back/forward (#60578) 2024-01-12 14:18:54 -05:00
tsconfig.json chore: extends from shared base tsconfig (#59776) 2023-12-19 18:52:22 +01:00
tsec-exemptions.json Move core files to src folder and move JS files to TypeScript (#44405) 2023-01-03 10:05:50 +01:00
turbo.json refactor(next/core): reorganize next.js custom transforms for next-swc/turbopack (#60400) 2024-01-09 12:23:47 -08:00
UPGRADING.md docs: update broken link in UPGRADING.md (#60342) 2024-01-06 14:46:07 -08:00
vercel.json Silence GH Comments for Preview URLs (#18766) 2020-11-03 21:59:47 +00: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 that have a relatively limited scope. This is a great place to get started, gain experience, and get familiar with our contribution process.

Authors

Security

If you believe you have found a security vulnerability in Next.js, we encourage you to responsibly disclose this and not open a public issue. We will investigate all legitimate reports. Email security@vercel.com to disclose any security vulnerabilities.

https://vercel.com/security