Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vercel/next.js
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v14.2.7
Choose a base ref
...
head repository: vercel/next.js
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v14.2.8
Choose a head ref

Commits on Aug 30, 2024

  1. Copy the full SHA
    a966b83 View commit details
  2. fix missing stylesheets when parallel routes are present (#69507)

    Backports:
    
    - #67436
    
    With test case from:
    
    - #66300
    ztanner authored Aug 30, 2024
    Copy the full SHA
    0e1bad0 View commit details
  3. backport branch: disable unnecessary CI tasks (#69513)

    Frees up some runners and unexpected test failures for features that are
    not expected to be productionized in v14.
    
    Disables:
    
    - Turbopack Build tests
    - PPR dev/prod tests (will throw an error anyway if you attempt to use
    PPR outside of canary)
    - Datadog test reporting (to avoid conflicting with our primary reports
    about test stability)
    - Docs link verification (backport docs are never going to be changed /
    productionized)
    ztanner authored Aug 30, 2024
    Copy the full SHA
    246c6a8 View commit details
  4. Copy the full SHA
    c4f5339 View commit details

Commits on Sep 2, 2024

  1. initialize ALS with cookies in middleware (#65008)

    ### What
    Cookies set/updated/removed in middleware won't be accessible during the
    render in which they were set
    
    ### Why
    Middleware will properly set a `set-cookie` header to inform the client
    of the cookie change, but this means the `AsyncLocalStorage` context
    containing the cookies value wouldn't be updated until the next time the
    request headers were parsed. In other words, on the first request the
    cookie would be sent but wouldn't be available in the `cookies()`
    context. And then the following request would properly have the cookie
    values.
    
    ### How
    This uses a proxy on the `ResponseCookies` used in middleware to add a
    middleware override header with the cookie value. When we instantiate
    the cached cookies, we merge in whatever headers would have been set by
    middleware, so that they're available in the same render that invoked
    middleware.
    
    ### Test Plan
    This changeset adds a test to confirm cookies set/deleted in middleware
    are available in a single pass. Verified with a deployment
    [here](https://vtest314-e2e-tests-ldx7olfl1-ztanner.vercel.app/rsc-cookies).
    
    Fixes #49442
    Closes NEXT-1126
    ztanner authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    d99d229 View commit details
  2. fix middleware cookie initialization (#65820)

    When we provide the `set-cookie` string in `x-middleware-set-cookie`, we
    need to ensure that multiple values are properly delimited.
    
    We also make sure the cookies that get passed into `RequestCookies`
    aren't in `ResponseCookie` form, to prevent something like `Path=/` from
    being part of `cookies()`.
    
    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:
    
    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide
    
    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
    
    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change
    
    Closes NEXT-
    Fixes #
    
    -->
    ztanner authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    196f629 View commit details
  3. ensure cookies set in middleware can be read in a server action (#67924)

    If middleware targets a server action handler and sets or updates a
    cookie, the newly updated cookie would not be reflected in the
    `cookies()` response of the action handler
    
    In #65008 we fixed a bug where cookies set in middleware were not
    reflected in the `cookies()` call in a server component from the same
    request. We did this by introducing a `x-middleware-set-cookie` header,
    that signaled to downstream handlers that middleware had run on the
    request & set a cookie. However this handling was only applied to the
    sealed/read-only cookies. Cookies accessed from a server action use
    `mutableCookies`, since those aren't frozen as a server action is
    allowed to modify cookies.
    
    This pulls the cookie merge handling into a function and applies the
    merge to `mutableCookies`.
    
    Fixes #67814
    Closes NDX-95
    ztanner authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    55cdf2b View commit details
  4. fix: merged middleware cookies should preserve options (#67956)

    This ensures that cookies merged via `x-middleware-set-cookie` preserve
    the options that are passed to them. Currently we're only selectively
    merging in `name` and `value` but really we can just copy the
    `ResponseCookie` in kind rather than enumerating on select properties.
    ztanner authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    61df8bb View commit details
  5. Update create-next-app template (#65803)

    Updates the `create-next-app` template with a new design by @evilrabbit.
    
    ![new —
    light](https://github.com/vercel/next.js/assets/22132822/7abf8ac5-e2c5-4d2d-944a-53616dcae5ed)
    ![new —
    dark](https://github.com/vercel/next.js/assets/22132822/a06a948d-6071-4a44-9c7e-9a5077866b0a)
    
    ![old —
    light](https://github.com/vercel/next.js/assets/22132822/49c97cdf-46ae-4d28-88c7-52fe0e9c995b)
    ![old —
    dark](https://github.com/vercel/next.js/assets/22132822/fb028dda-a38a-443c-ad13-21886b750d7a)
    
    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:
    
    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide
    
    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
    
    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change
    
    Closes NEXT-
    Fixes #
    
    -->
    
    ---------
    
    Co-authored-by: Sam Ko <sam@vercel.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    21f0ac2 View commit details
  6. Update create-next-app template CSS (#66043)

    Updates the `create-next-app` template CSS to:
    - Prevent browsers (e.g. Safari) from using synthetic bold font weights
    - Move CSS variables out of global CSS / Tailwind config, to simplify
    the process of wiping the default template.
    
    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:
    
    ## For Contributors
    
    ### Improving Documentation
    
    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide
    
    ### Adding or Updating Examples
    
    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
    
    ### Fixing a bug
    
    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    ### Adding a feature
    
    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    
    ## For Maintainers
    
    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change
    
    ### What?
    
    ### Why?
    
    ### How?
    
    Closes NEXT-
    Fixes #
    
    -->
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    a1135cd View commit details
  7. Update create-next-app template CSS (#66233)

    Updates `create-next-app` template CSS:
    
    - Declares variable font weights in `localFont` options and removes
    instances of `font-synthesis: none`
    - Removes Geist font variables from Tailwind config files
    - Adds fallback sans typefaces to the `body` CSS
    
    Co-authored-by: Sam Ko <sam@vercel.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    3120328 View commit details
  8. Use classnames to set font family in Tailwind create-next-app templat…

    …es (#66374)
    
    Replaces inline styles in the Tailwind `create-next-app` templates with
    classnames to set the font family.
    
    Co-authored-by: Sam Ko <sam@vercel.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    f06e8c2 View commit details
  9. [lint] Disable linting using project config for tests (#66145)

    During integration testing, previously, calls to `next build` could rely
    on the project (the Next.js project) level ESLint configuration. In
    order to correct this, a new `lint` option was added to `nextBuild` that
    can be passed to enabled linting. If this is `false` or `undefined`, a
    `--no-lint` argument will be passed to `next build` to prevent it from
    running.
    wyattjoh authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    a40bc1f View commit details
  10. Copy the full SHA
    442807b View commit details
  11. feat: enable @typescript-eslint/recommended in create-next-app --type…

    …script (#52845)
    
    Co-authored-by: eps1lon <sebastian.silbermann@vercel.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    c021c2f View commit details
  12. chore(cna): add missing period (#69021)

    ## Why?
    
    I noticed the first `<li>` line is missing a period at the end.
    
    ![CleanShot 2024-08-17 at 16 04 24@2x](https://github.com/user-attachments/assets/714de280-ce1e-47b2-b7c0-2fc85264a5ad)
    samcx authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    f600331 View commit details
  13. Copy the full SHA
    55f05c8 View commit details
  14. fix(create-next-app): link to app dir docs in next-env.d.ts in app di…

    …r templates (#68534)
    
    Fixes #68533
    
    A link to docs in `next-dev.d.ts` linked to the pages router docs in app
    router templates. This was confusing, because some sections on this page
    only work with pages router. This PR fixes that
    
    Backport notes: skipped all templates introduced for `--empty` in #65532
    ---------
    
    Co-authored-by: Sam Ko <sam@vercel.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    aa6ef8f View commit details
  15. docs: Refactor next and create-next-app CLI pages (#68899)

    Closes: https://linear.app/vercel/issue/DOC-3249/cli-reference-pages
    
    Updates the `next` and `create-next-app` CLI pages to follow the
    reference page template. Moves these pages under "CLI" to match new IA.
    
    Backport notes: skipped all templates introduced for `--empty` in #65532
    
    Redirects: #68899
    delbaoliveira authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    1f122b8 View commit details
  16. Move create-next-app public/ assets from local folder→ remote URL (#…

    …66931)
    
    To reduce the number of files cloned during `create-next-app`, this PR
    shifts the SVG assets placed in the `public/` folder to instead by
    consumed from the Next.js site.
    
    Since these are SVG files (vector images), the Image component does
    _not_ optimize them with image optimization. Image optimization only
    applies to raster images (like `.png` or `.jpg`). This means it's
    effectively similar to using the `unoptimized` prop on the `Image`
    component, which means you don't need to add `remotePatterns` to
    `next.config.js` – which would be midly annoying for the
    `create-next-app` starter.
    
    I also renamed `file-text.svg` to `file.svg` so the URL is shorter.
    These assets will be live on .org any minute now.
    leerob authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    6520b7d View commit details
  17. [create-next-app]: add font antialiasing to templates (#67425)

    This PR adds font antialiasing to all the next.js templates (with css or
    tw).
    
    ### Before
    
    ![Screenshot 2024-07-03 at 10 27
    02](https://github.com/vercel/next.js/assets/45767683/65778211-23bd-4d20-b1d1-a2f443f73d4d)
    
    ### After 
    
    ![Screenshot 2024-07-03 at 10 26
    38](https://github.com/vercel/next.js/assets/45767683/922188fd-4406-4d08-9b73-74c699d51913)
    
    Co-authored-by: Jiwon Choi <devjiwonchoi@gmail.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    423e5e6 View commit details
  18. Copy the full SHA
    435780a View commit details
  19. Support esm externals in app router (#65041)

    Support `esmExternals` working in app router
    
    `esmExternals` was disabled for app router that most of the packages are
    picking up the CJS bundles for externals. This PR enables to resolve the
    ESM bundle for external packages.
    
    We have two issues discovered while enabling the flag, any esm external
    packages will fail in client page SSR and server action. We fixed them
    by changing the below bundling logics:
    
    * When a client page having a async dependency, we can await the page
    during in rendering
    * When a server action having a async dependency, we changed the server
    action entry creation with webpack along with the server client entry
    creation together, then webpack can handle the modules async propagation
    properly.
    
    Fixes #60756
    Closes NEXT-2435
    Closes NEXT-2472
    Closes NEXT-3225
    
    ---------
    
    Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    f7d4dbd View commit details
  20. Remove rsc esm client module extra exports (#65519)

    Remove the extra `__esModule` and `$$typeof` export for ESM client
    module
    
    For a client page reference, it changed on server side in renderer:
    
    Previous: `{ __esModule, $$typeof, default }`
    Now: `{ default }`
    
    The Module object itself appears as a client reference but it can't be
    rendered since it's not a real reference. I'm not sure why it was added
    but I think the right thing for an ESM module is to not treat the module
    itself as a client reference but only the objects inside of it. E.g. the
    "default" export. That's what React does upstream for ESM modules.
    
    Closes NEXT-3360
    huozhi authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    a5def42 View commit details
  21. Fix esm property def in flight loader (#66286)

    Remove creating client proxy for each ESM export, instead for ESM we
    create a CJS module proxy for itself and access the property with export
    name as the actual export.
    
    `proxy` is the module proxy that we treat the module as a client
    boundary.
    For ESM, we access the property of the module proxy directly for each
    export.
    This is bit hacky that treating using a CJS like module proxy for ESM's
    exports,
    but this will avoid creating nested proxies for each export. It will be
    improved in the future.
    
    Notice that for `next/dynamic`, if you're doing a dynamic import of
    client component in server component, and trying to access the named
    export directly, it will error. Instead you need to align the dynamic
    import resolved value wrapping with a `default:` property (e.g. `{
    default: resolved }`) like what `React.lazy` accepted.
    
    Revert #57301
    Fixes #66212
    
    x-ref:
    [slack](https://vercel.slack.com/archives/C04DUD7EB1B/p1716897764858829)
    huozhi authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    6b41071 View commit details
  22. Revert "Fix esm property def in flight loader" (#66727)

    This is causing unexpected errors.
    
    Reverts #66286
    ztanner authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    6f1418a View commit details
  23. Copy the full SHA
    9bb06c5 View commit details
  24. Copy the full SHA
    336019b View commit details
  25. Copy the full SHA
    cb8ccd5 View commit details
  26. Warn metadataBase missing in standalone mode or non vercel deployment (

    …#66296)
    
    ### What
    
    Change the metadataBase missing warning for all cases to only warn in
    standalone mode or the non-vercel deployment.
    
    ### Why
    
    In vercel deployments, previous concern was that you might not discover
    you missed that metadataBase when you deploy. But now we have sth
    fallback on production deployments. So we only need to warn in
    non-vercel deployment.
    
    Standalone is usually for self-hoist, we always warn users to set the
    `metadataBase` to make sure the domain can be properly resolved.
    
    
    [x-ref](https://vercel.slack.com/archives/C03S8ED1DKM/p1716926825853389?thread_ts=1716923373.484329&cid=C03S8ED1DKM)
    huozhi authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    503b477 View commit details
  27. Fix favicon merging with customized icons (#67982)

    ### What
    
    Support merging the static metadata file conventions `favicon.ico` with
    other customized metadata icon from the module export.
    
    
    ### Why
    
    `favicon.ico` should be displayed everywhere as it's the icon
    representative of the website for all pages. Any customized `icon` in
    metadata export `export const metadata` or `export function
    generateMetadata()` shouldn't override the `favicon.ico` file
    convention.
    
    
    Fixes #55767
    
    ---------
    
    Co-authored-by: hrmny <8845940+ForsakenHarmony@users.noreply.github.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    ce309b4 View commit details
  28. Always collect static icons for all segments (#68712)

    ### What
    
    Collect static metadata icons from the most leaf node in the component
    tree, and then add them into resolved metadata icons if there's no icons
    presented in exported metadata
    
    ### Why
    
    Previously we collected the icons from the last item from collected
    metadata items as last segment in the tree. But it doesn't act like that
    when there's parallel routes, so we collect the last presented static
    metadata icons from the metadata item list and then merge into the
    resolved metadata at the end.
    
    Fixes #68650
    huozhi authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    26ddcdf View commit details
  29. feat: facebook metadata (#65713)

    Add support for the `fb:app_id` & `fb:admins` meta tag in the
    generateMetaData function
    
    ---------
    
    Co-authored-by: Sam Ko <sam@vercel.com>
    Co-authored-by: Jiachi Liu <inbox@huozhi.im>
    3 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    144aec7 View commit details
  30. Fix next-swc native binary write in tests (#64744)

    ## What?
    
    In the past folks on the team have reported that anytime the SWC /
    Turbopack binary changes they had to suddenly run `pnpm build-native` in
    `packages/next-swc`, even though they didn't build from source before.
    While investigating optimizing packing for tests I found that it's
    copying the native binary into the original repository not the temporary
    repository, which then keeps the file there, even after the tests
    finish. This fixes the path to use the tmp repository instead.
    
    
    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:
    
    ## For Contributors
    
    ### Improving Documentation
    
    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide
    
    ### Adding or Updating Examples
    
    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
    
    ### Fixing a bug
    
    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    ### Adding a feature
    
    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    
    ## For Maintainers
    
    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change
    
    ### What?
    
    ### Why?
    
    ### How?
    
    Closes NEXT-
    Fixes #
    
    -->
    
    
    Closes NEXT-3157
    timneutkens authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    8fe7ec1 View commit details
  31. Speed up createNext test suite isolation (#64909)

    Before: 25.71s
    
    ![CleanShot 2024-04-23 at 12 19
    42@2x](https://github.com/vercel/next.js/assets/6324199/3a0ebb81-ac55-4b0c-8bfc-9a61ce138e6f)
    
    After: 11.05s (-57%)
    
    ![CleanShot 2024-04-23 at 12 16
    35@2x](https://github.com/vercel/next.js/assets/6324199/d7b6cd4c-d1e4-4dc2-a423-20b539186d25)
    
    Currently the system for isolation looks like this:
    
    - Copy `packages` folder to an isolated directory
    - Run `pnpm pack` for all folders in `packages`
    - Collect the pack files, add them as `dependencies` in package.json of
    the isolated application
    - Run `pnpm install`
    
    Because the `next-swc` (Turbopack + SWC, yes we still need to rename the
    package) binary file is quite large in development (900MB+) it means we
    have to copy, then zip (pnpm pack), then unzip (pnpm install) that
    binary, which takes about 3+ seconds in each step.
    
    The change in this PR is to skip the copy/zip/unzip completely by
    providing the folder path for the binary directly to Next.js, as it's a
    binary we don't need the special isolation for this, it's already
    standalone so running it directly allows us to skip 14,6 seconds of work
    that is required for each isolated test in development.
    
    This will likely have little effect on CI times as we already do some
    tricks like only running the packing at the start of the CI process.
    Only thing that could be better and is probably worth doing is adopting
    this change for the time it saves for unzipping, that's almost 4 seconds
    per test still.
    
    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:
    
    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide
    
    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
    
    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change
    
    Closes NEXT-
    Fixes #
    
    -->
    
    Closes NEXT-3200
    
    ---------
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    6ff089f View commit details
  32. Fix swc test path from node_modules (#66047)

    Noticed while testing turbopack version of tests that we weren't loading
    the correct swc binary since this path wasn't absolute and was just the
    relative path in `node_modules`.
    
    ---------
    
    Co-authored-by: Zack Tanner <1939140+ztanner@users.noreply.github.com>
    2 people authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    bbdf06b View commit details
  33. ci(workflow): skip building next-swc with latest turbopack (#66048)

    ### What
    
    this was the way we run ci on turbopack's repo and to get the latest
    test results, which isn't required anymore.
    kwonoj authored and lubieowoce committed Sep 2, 2024
    Copy the full SHA
    0343c0e View commit details

Commits on Sep 3, 2024

  1. Copy the full SHA
    13cd9de View commit details
  2. Copy the full SHA
    8eba600 View commit details
  3. Copy the full SHA
    a4ff132 View commit details
  4. Copy the full SHA
    d8ece3e View commit details
  5. Shared Revalidate Timings (#64370)

    <!-- Thanks for opening a PR! Your contribution is much appreciated.
    To make sure your PR is handled as smoothly as possible we request that
    you follow the checklist sections below.
    Choose the right checklist for the change(s) that you're making:
    
    ## For Contributors
    
    ### Improving Documentation
    
    - Run `pnpm prettier-fix` to fix formatting issues before opening the
    PR.
    - Read the Docs Contribution Guide to ensure your contribution follows
    the docs guidelines:
    https://nextjs.org/docs/community/contribution-guide
    
    ### Adding or Updating Examples
    
    - The "examples guidelines" are followed from our contributing doc
    https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md
    - Make sure the linting passes by running `pnpm build && pnpm lint`. See
    https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md
    
    ### Fixing a bug
    
    - Related issues linked using `fixes #number`
    - Tests added. See:
    https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    ### Adding a feature
    
    - Implements an existing feature request or RFC. Make sure the feature
    request has been accepted for implementation before opening a PR. (A
    discussion must be opened, see
    https://github.com/vercel/next.js/discussions/new?category=ideas)
    - Related issues/discussions are linked using `fixes #number`
    - e2e tests added
    (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs)
    - Documentation added
    - Telemetry added. In case of a feature if it's used or not.
    - Errors have a helpful link attached, see
    https://github.com/vercel/next.js/blob/canary/contributing.md
    
    
    ## For Maintainers
    
    - Minimal description (aim for explaining to someone not on the team to
    understand the PR)
    - When linking to a Slack thread, you might want to share details of the
    conclusion
    - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues
    - Add review comments if necessary to explain to the reviewer the logic
    behind a change
    
    ### What?
    
    ### Why?
    
    ### How?
    
    Closes NEXT-
    Fixes #
    
    -->
    
    ### What?
    
    This creates a new `SharedRevalidateTimings` type that is safe to share
    amongst different points within the framework for sharing revalidation
    timings. This is a precursor to #64313 which freezes loaded manifests.
    
    ### Why?
    
    Using the `SharedRevalidateTimings` type, we no-longer have to modify
    the in-memory instance of the prerender manifest to share the
    revalidation timings for different routes.
    
    Closes NEXT-3083
    wyattjoh authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    a48be87 View commit details
  6. Freeze loaded manifests (#64313)

    Manifests in the runtime should be treated as immutable objects to
    ensure that side effects aren't created that depend on the mutability of
    these shared objects. Instead, mutable references should be used in
    places where this is desirable.
    
    This also introduces the new `DeepReadonly` utility type, which when
    paired with existing manifest types, will modify every field to be read
    only, ensuring that the type system will help catch accidental
    modifications to these loaded manifest values as well.
    
    Future work could eliminate these types by modifying the manifest types
    themselves to be read only, only allowing code that generated them to be
    writable.
    
    Closes NEXT-3069
    wyattjoh authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    01c7c85 View commit details
  7. Ensure edge prerender-manifest is minimal (#64946)

    This ensures we don't include the entire prerender-manifest in edge
    runtime as it's un-necesary and can be very large. We only need the
    preview field in this manifest so this ensures we just include that.
    
    x-ref: [slack
    thread](https://vercel.slack.com/archives/C0289CGVAR2/p1713904966662599?thread_ts=1713798297.067699&cid=C0289CGVAR2)
    
    Closes NEXT-3212
    ijjk authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    d44c1fb View commit details
  8. Re-land build(edge): extract buildId into environment (#65426)

    * Extract `buildId` and server action encryption key into environment
    variables for edge to make code more deterministic
    * Fixed the legacy bad env names from #64108
    * Always sort `routes` in prerender manifest for consistent output
    * Change `environments` to `env` in middleware manifest, confirmed with
    @javivelasco this is a fine change without need to bumping the version
    
    Dynamic variants like `buildId`, SA `encryptionKey` and preview props
    are different per build, which results to the non determinstic edge
    bundles. Once we extracted them into env vars then the bundles become
    deterministic which give us more space for optimization
    
    Closes NEXT-3117
    
    Reverts #65425
    
    Co-authored-by: Jiachi Liu <inbox@huozhi.im>
    2 people authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    df864ec View commit details
  9. fix: unstable_cache should not cache new result in draft mode (#67772)

    ### What?
    In draft mode, as of right now, `unstable_cache` does not read from the
    static store, but still write to it. This leads to the following
    scenario:
    
    1. Content Editor enters draft mode to test his content
    2. Content Editor skips cache and reads preview data
    3. Preview data is written to store
    4. Random user without draft mode receives preview data until cache is
    revalidated again
    
    ### Why?
    There's an early exit before reading from the cache - the new result is
    written to the cache nonetheless though.
    
    ### How?
    New result is only cached if draft mode is disabled.
    
    Co-authored-by: JJ Kasper <jj@jjsweb.site>
    2 people authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    79177b7 View commit details
  10. Add draft mode flag for multi-zone (#68997)

    When an application is running in multi-zone API endpoints can have
    differing draft mode IDs on the same domain so we need to avoid clearing
    the original when we see a mismatch as that can break the current
    applications draft mode. This is behind a flag initially to validate but
    it should be safe to make the default in the future as an invalid draft
    mode ID just gets ignored.
    
    x-ref: [slack
    thread](https://vercel.slack.com/archives/C052BQ8F9EJ/p1723844164102539)
    ijjk authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    1f29987 View commit details
  11. Copy the full SHA
    f11346c View commit details
  12. Fix edge preview props are not matched with cookie (#67779)

    Chnage the way of preview props injection to edge runtime, directly read
    from env vars of preview props instead of writing to and reading from
    prerender manifest.js
    
    Previously we're trying to make these preview props values become
    deterministic that we can replace in edge deployment pipeline in #64521
    
    But the way of serializing process env vars in edge runtime is not
    correct. They'll remain as string "process.env.xxx" in the manifest and
    also after consumed. This PR fixes that behavior, instead of writing it
    into manifest, alwyas consuming from process.env.var directly.
    
    I created a shared util to access the preview props of edge runtime
    across all the templates.
    
    On draft provider side, we still need to handle dev mode case when
    preview id is `development-id`, but we already have the cookie, it
    cannot be aligned with the preview id. So we do a fallback check for dev
    mode if the cookie is present and preview id is `development-id` then we
    still treat it as draft mode is enabled.
    
    Fixes #52080
    Fixes #67075
    
    Closes NEXT-3541
    huozhi authored and lubieowoce committed Sep 3, 2024
    Copy the full SHA
    0ab5239 View commit details
  13. test: fix static GETs

    lubieowoce committed Sep 3, 2024
    Copy the full SHA
    d57b805 View commit details
Showing 501 changed files with 11,128 additions and 8,553 deletions.
322 changes: 179 additions & 143 deletions .github/actions/next-stats-action/src/prepare/repo-setup.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
// @ts-check
const path = require('path')
const fs = require('fs')
const { existsSync } = require('fs')
const exec = require('../util/exec')
const logger = require('../util/logger')
const execa = require('execa')
const mockSpan = require('../util/mock-trace')

/** @typedef {import('../util/mock-trace').Span} Span */

module.exports = (actionInfo) => {
return {
@@ -56,10 +60,14 @@ module.exports = (actionInfo) => {
},
/**
* Runs `pnpm pack` on each package in the `packages` folder of the provided `repoDir`
* @param {{ repoDir: string, nextSwcVersion: null | string }} options Required options
* @param {{ repoDir: string, nextSwcVersion: null | string, parentSpan?: Span }} options Required options
* @returns {Promise<Map<string, string>>} List packages key is the package name, value is the path to the packed tar file.'
*/
async linkPackages({ repoDir, nextSwcVersion }) {
async linkPackages({ repoDir, nextSwcVersion, parentSpan }) {
if (!parentSpan) {
// Not all callers provide a parent span
parentSpan = mockSpan()
}
/** @type {Map<string, string>} */
const pkgPaths = new Map()
/** @type {Map<string, { packageJsonPath: string, packagePath: string, packageJson: any, packedPackageTarPath: string }>} */
@@ -68,9 +76,11 @@ module.exports = (actionInfo) => {
let packageFolders

try {
packageFolders = await fs.promises.readdir(
path.join(repoDir, 'packages')
)
packageFolders = await parentSpan
.traceChild('read-packages-folder')
.traceAsyncFn(() =>
fs.promises.readdir(path.join(repoDir, 'packages'))
)
} catch (err) {
if (err.code === 'ENOENT') {
require('console').log('no packages to link')
@@ -79,162 +89,188 @@ module.exports = (actionInfo) => {
throw err
}

for (const packageFolder of packageFolders) {
const packagePath = path.join(repoDir, 'packages', packageFolder)
const packedPackageTarPath = path.join(
packagePath,
`${packageFolder}-packed.tgz`
)
const packageJsonPath = path.join(packagePath, 'package.json')

if (!existsSync(packageJsonPath)) {
require('console').log(`Skipping ${packageFolder}, no package.json`)
continue
}

const packageJson = JSON.parse(fs.readFileSync(packageJsonPath))
const { name: packageName } = packageJson
parentSpan.traceChild('get-pkgdatas').traceFn(() => {
for (const packageFolder of packageFolders) {
const packagePath = path.join(repoDir, 'packages', packageFolder)
const packedPackageTarPath = path.join(
packagePath,
`${packageFolder}-packed.tgz`
)
const packageJsonPath = path.join(packagePath, 'package.json')

pkgDatas.set(packageName, {
packageJsonPath,
packagePath,
packageJson,
packedPackageTarPath,
})
pkgPaths.set(packageName, packedPackageTarPath)
}
if (!existsSync(packageJsonPath)) {
require('console').log(`Skipping ${packageFolder}, no package.json`)
continue
}

for (const [
packageName,
{ packageJsonPath, packagePath, packageJson },
] of pkgDatas.entries()) {
// This loops through all items to get the packagedPkgPath of each item and add it to pkgData.dependencies
for (const [
packageName,
{ packedPackageTarPath },
] of pkgDatas.entries()) {
if (
!packageJson.dependencies ||
!packageJson.dependencies[packageName]
const packageJson = JSON.parse(
fs.readFileSync(packageJsonPath, 'utf-8')
)
continue
// Edit the pkgData of the current item to point to the packed tgz
packageJson.dependencies[packageName] = packedPackageTarPath
const { name: packageName } = packageJson

pkgDatas.set(packageName, {
packageJsonPath,
packagePath,
packageJson,
packedPackageTarPath,
})
pkgPaths.set(packageName, packedPackageTarPath)
}
})

// make sure native binaries are included in local linking
if (packageName === '@next/swc') {
packageJson.files ||= []
await parentSpan
.traceChild('write-packagejson')
.traceAsyncFn(async () => {
for (const [
packageName,
{ packageJsonPath, packagePath, packageJson },
] of pkgDatas.entries()) {
// This loops through all items to get the packagedPkgPath of each item and add it to pkgData.dependencies
for (const [
packageName,
{ packedPackageTarPath },
] of pkgDatas.entries()) {
if (
!packageJson.dependencies ||
!packageJson.dependencies[packageName]
)
continue
// Edit the pkgData of the current item to point to the packed tgz
packageJson.dependencies[packageName] = packedPackageTarPath
}

packageJson.files.push('native')
// make sure native binaries are included in local linking
if (packageName === '@next/swc') {
packageJson.files ||= []

try {
const swcBinariesDirContents = (
await fs.promises.readdir(path.join(packagePath, 'native'))
).filter((file) => file !== '.gitignore' && file !== 'index.d.ts')
packageJson.files.push('native')

require('console').log(
'using swc binaries: ',
swcBinariesDirContents.join(', ')
)
} catch (err) {
if (err.code === 'ENOENT') {
require('console').log('swc binaries dir is missing!')
}
throw err
}
} else if (packageName === 'next') {
const nextSwcPkg = pkgDatas.get('@next/swc')
try {
const swcBinariesDirContents = (
await fs.promises.readdir(path.join(packagePath, 'native'))
).filter(
(file) => file !== '.gitignore' && file !== 'index.d.ts'
)

console.log('using swc dep', {
nextSwcVersion,
nextSwcPkg,
})
if (nextSwcVersion) {
Object.assign(packageJson.dependencies, {
'@next/swc-linux-x64-gnu': nextSwcVersion,
})
} else {
if (nextSwcPkg) {
packageJson.dependencies['@next/swc'] =
nextSwcPkg.packedPackageTarPath
require('console').log(
'using swc binaries: ',
swcBinariesDirContents.join(', ')
)
} catch (err) {
if (err.code === 'ENOENT') {
require('console').log('swc binaries dir is missing!')
}
throw err
}
} else if (packageName === 'next') {
const nextSwcPkg = pkgDatas.get('@next/swc')

console.log('using swc dep', {
nextSwcVersion,
nextSwcPkg,
})
if (nextSwcVersion) {
Object.assign(packageJson.dependencies, {
'@next/swc-linux-x64-gnu': nextSwcVersion,
})
} else {
}
}

await fs.promises.writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2),
'utf8'
)
}
}
})

await fs.promises.writeFile(
packageJsonPath,
JSON.stringify(packageJson, null, 2),
'utf8'
)
}
await parentSpan
.traceChild('pnpm-packing')
.traceAsyncFn(async (packingSpan) => {
// wait to pack packages until after dependency paths have been updated
// to the correct versions
await Promise.all(
Array.from(pkgDatas.entries()).map(
async ([
packageName,
{ packagePath: pkgPath, packedPackageTarPath: packedPkgPath },
]) => {
return packingSpan
.traceChild('handle-package', { packageName })
.traceAsyncFn(async (handlePackageSpan) => {
/** @type {null | (() => Promise<void>)} */
let cleanup = null

// wait to pack packages until after dependency paths have been updated
// to the correct versions
await Promise.all(
Array.from(pkgDatas.entries()).map(
async ([
packageName,
{ packagePath: pkgPath, packedPackageTarPath: packedPkgPath },
]) => {
/** @type {null | () => Promise<void>} */
let cleanup = null
if (packageName === '@next/swc') {
// next-swc uses a gitignore to prevent the committing of native builds but it doesn't
// use files in package.json because it publishes to individual packages based on architecture.
// When we used yarn to pack these packages the gitignore was ignored so the native builds were packed
// however npm does respect gitignore when packing so we need to remove it in this specific case
// to ensure the native builds are packed for use in gh actions and related scripts

if (packageName === '@next/swc') {
// next-swc uses a gitignore to prevent the committing of native builds but it doesn't
// use files in package.json because it publishes to individual packages based on architecture.
// When we used yarn to pack these packages the gitignore was ignored so the native builds were packed
// however npm does respect gitignore when packing so we need to remove it in this specific case
// to ensure the native builds are packed for use in gh actions and related scripts

const nativeGitignorePath = path.join(
pkgPath,
'native/.gitignore'
)
const renamedGitignorePath = path.join(
pkgPath,
'disabled-native-gitignore'
)
const nativeGitignorePath = path.join(
pkgPath,
'native/.gitignore'
)
const renamedGitignorePath = path.join(
pkgPath,
'disabled-native-gitignore'
)

await fs.promises.rename(
nativeGitignorePath,
renamedGitignorePath
)
cleanup = async () => {
await fs.promises.rename(
renamedGitignorePath,
nativeGitignorePath
)
}
}
await handlePackageSpan
.traceChild('rename-gitignore')
.traceAsyncFn(() =>
fs.promises.rename(
nativeGitignorePath,
renamedGitignorePath
)
)
cleanup = async () => {
await fs.promises.rename(
renamedGitignorePath,
nativeGitignorePath
)
}
}

const options = {
cwd: pkgPath,
env: {
...process.env,
COREPACK_ENABLE_STRICT: '0',
},
}
let execResult
try {
execResult = await execa('pnpm', ['pack'], options)
} catch {
execResult = await execa('pnpm', ['pack'], options)
}
const { stdout } = execResult
const options = {
cwd: pkgPath,
env: {
...process.env,
COREPACK_ENABLE_STRICT: '0',
},
}
let execResult
try {
execResult = await handlePackageSpan
.traceChild('pnpm-pack-try-1')
.traceAsyncFn(() => execa('pnpm', ['pack'], options))
} catch {
execResult = await handlePackageSpan
.traceChild('pnpm-pack-try-2')
.traceAsyncFn(() => execa('pnpm', ['pack'], options))
}
const { stdout } = execResult

const packedFileName = stdout.trim()
const packedFileName = stdout.trim()

await Promise.all([
fs.promises.rename(
path.join(pkgPath, packedFileName),
packedPkgPath
),
cleanup?.(),
])
}
)
)
await handlePackageSpan
.traceChild('rename-packed-tar-and-cleanup')
.traceAsyncFn(() =>
Promise.all([
fs.promises.rename(
path.join(pkgPath, packedFileName),
packedPkgPath
),
cleanup?.(),
])
)
})
}
)
)
})

return pkgPaths
},
14 changes: 14 additions & 0 deletions .github/actions/next-stats-action/src/util/mock-trace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** @returns {Span} */
const createMockSpan = () => ({
traceAsyncFn: (fn) => fn(createMockSpan()),
traceFn: (fn) => fn(createMockSpan()),
traceChild: () => createMockSpan(),
})

/** @typedef {{
* traceAsyncFn: <T>(fn: (span: Span) => Promise<T>) => Promise<T>,
* traceFn: <T>(fn: (span: Span) => T) => T,
* traceChild: (id: string, data?: Record<string, any>) => Span,
* }} Span */

module.exports = createMockSpan
Loading