- 22 Sep, 2022 2 commits
-
-
JJ Kasper authored
-
Jiachi Liu authored
For app edge SSR, we don't need any internal pages for it since it's handled by app-renderer. This results around reducing 20KB from app edge SSR # Changes * Strip those internal pages modules when it's in app edge SSR * Minimize edge SSR chunk to see the tree-shake result * Add bundle analyzer with switcher in stats-app for testing. Using `TEST_ANAYLYSE=1` to build stats-app for testing
-
- 21 Sep, 2022 16 commits
-
-
Henrik Wenz authored
## Changes - Updated dependencies - Migrated to Typescript - Added additional router use cases ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
JJ Kasper authored
New scoped packages need to be initialized as public so this adds the `publishConfig` for this. Fixes: https://github.com/vercel/next.js/actions/runs/3101494786/jobs/5023375720
-
Balázs Orbán authored
Closes #40775 <!-- 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 that you're making: --> ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
JJ Kasper authored
-
Hannes Bornö authored
For some context: https://vercel.slack.com/archives/CGU8HUTUH/p1662124179102509 Adds `@next/font` package. `scripts/update-google-fonts.js` generates functions and metadata for all available google fonts. The metadata is used in `loader.ts` to validate font options (from #40221). It then fetches the CSS from google fonts, downloads the font files and emits them as static assets. The actual integration with `packages/next` and integration tests depends on #40221, will follow up with new PR. Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Hannes Bornö authored
For some context: https://vercel.slack.com/archives/CGU8HUTUH/p1662124179102509 Transforms call expressions of imported functions, only affects imports specified in SWC options. Each argument is turned into JSON and appended to the import as a query. The query can be read in a webpack loader, i.e. the call expression is only evaluated at build time ### Transform From ```tsx import { Fn } from "package" const res = Fn(1, "2", { three: true }) ``` To ```tsx import res from 'package?Fn;1;"2";{"three":true}' ``` ### Visitors #### NextFontLoaders (mod.rs) Creates several visitors that updates the state and reports errors. This is where the AST is mutated. After all other visitors are done the call expressions and original imports are removed. The newly generated imports are added instead. #### FontFunctionsCollector Finds imports from the specified packages. Function calls of these imports should be transformed. #### FontImportsGenerator Creates import declarations, call expression arguments are turned into JSON and added to the import as a query. #### FindFunctionsOutsideModuleScope Makes sure that there's no reference of the functions anywhere else but the module scope. Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Shu Ding authored
`config.experimental.serverComponents` is currently required to be enabled or disabled together with `config.experimental.appDir` (which means `serverComponents === appDir` otherwise it will throw) so there is no reason to keep both of them. This PR removes `serverComponents` from Next.js and only rely on `appDir` instead. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Shu Ding authored
This PR changes the external module resolution to eagerly bundle node_modules, and some specific Next.js internal modules, if on the `WEBPACK_LAYERS.server` layer. While resolving corresponding packages, we use the `react-server` export condition (fallbacks to default). A follow-up PR will be adding a Next.js option to opt-out specific packages from being bundled on the server layer. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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` - [x] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
JJ Kasper authored
This adds a test case verifying client transitions to `/404` or `/_error` are working properly. Test deployment with patched reproduction can be seen here https://router-bug-repro-4bozmev4p-ijjk-testing.vercel.app/blocked Closes: https://github.com/vercel/next.js/issues/40667
-
Henrik Wenz authored
## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Henrik Wenz authored
## Changes see commits ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Rishabh Poddar authored
- Updates supertokens-node and supertokens-auth-react dependencies. - Uses separate Email verification recipe instead of using it inside the ThirdPartyEmailPassword recipe (as per the update) - Uses <SessionAuth> guard instead of <ThirdPartyEmailPassword> guard (as per the lib update)
-
Shu Ding authored
I have next-swc compiled locally inside the folder so there're a lot of files there (totally unexpected). And then the `fs.copy` takes 28433 ms... by filtering it out it's only 1s. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Tim Neutkens authored
-
Tim Neutkens authored
-
JJ Kasper authored
Leverages `AsyncLocalStorage` when available for handling static generation context and falls back to requiring render to be isolated when `AsyncLocalStorage` is not available. Note: most changes are spacing so toggling to ignore spacing may make reviewing easier
-
- 20 Sep, 2022 8 commits
-
-
Rostyslav Melnychuk authored
Added support for search params and NEXT_LOCALE cookie if set <!-- 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 that you're making: --> ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by:
JJ Kasper <jj@jjsweb.site>
-
Henrik Wenz authored
## Problem Currently the Next.js infer utility (`InferGetServerSidePropsType` and `InferGetStaticPropsType`) types can lead to a wrong inferred types (`never`). This happens if these functions return something different than: `{props: {}}`. **Example:** `getServerSideProps` ```typescript export async function getServerSideProps({ query }: GetServerSidePropsContext) { if (query.foo) { return { notFound: true, } } return { props: { foo: "bar" }, } } type PageProps = InferGetServerSidePropsType<typeof getServerSideProps> // => type PageProps = never ``` **Example:** `getStaticProps` ```typescript import type { InferGetStaticPropsType, GetStaticPropsContext } from 'next' export async function getStaticProps(context: GetStaticPropsContext) { if (context.params?.bar) { return { notFound: true, } } return { props: { foo: 'bar', }, } } type PageProps = InferGetStaticPropsType<typeof getStaticProps> // => type PageProps = never ``` This is because the first infer condition of the utility type is not satified leading to a never result. ```typescript export type InferGetServerSidePropsType<T> = T extends GetServerSideProps< infer P, // <- NOT SATISFIED any > ? P : T extends ( context?: GetServerSidePropsContext<any> ) => Promise<GetServerSidePropsResult<infer P>> ? P : never // <- NOT SATISFIED ``` ## Solution I have experimented with different solutions ending with a much simpler type, that is faster to execute, easier to read and universally usable for both prop variations. ```typescript /** * Flow: * - Make sure getStaticProps is a function * - Get its return type * - Extract the one that contains {props: any} * - Return the props */ export type InferGetStaticPropsType<T extends (args: any) => any> = Extract< Awaited<ReturnType<T>>, { props: any } >['props'] ``` ## Bug - [x] Related issues: fixes #36615, #15913, https://twitter.com/leeerob/status/1563540593003106306 - [x] Type tests added ## Future thoughts Since `InferGetStaticPropsType` and `InferGetServerSidePropsType` are now the same, it's api could be merged into one utility type (e.g: InferNextProps). I recommend doing this in a different PR. ## Additional info I have tested this approach using the following [external package](https://www.npmjs.com/package/infer-next-props-type) (@timneutkens sorry for the late PR). Since about 12 Month I haven't received any negative feedback (issues) regarding this approach. Co-authored-by:JJ Kasper <jj@jjsweb.site>
-
Henrik Wenz authored
## Changes see commits ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Tim Neutkens authored
-
Tim Neutkens authored
Co-authored-by:
Sebastian Markbåge <sebastian@calyptus.eu> Co-authored-by:
kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
-
Jiachi Liu authored
If there's any resolve alias in webpack config, an aliased resource url will error with `require.resolve` usage in flight manifest plugin, we need to resolve the absolute resource url first then pass down to flight manifest ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md`
-
JJ Kasper authored
As discussed in slack this breaks out the `assetPrefix` tests to a separate suite to speed up the main `app` suite. x-ref: [slack thread](https://vercel.slack.com/archives/C035J346QQL/p1663623560467579)
-
JJ Kasper authored
We can re-enable this after the necessary support has been landed. x-ref: https://github.com/vercel/next.js/actions/runs/3086118218/jobs/4990617168
-
- 19 Sep, 2022 14 commits
-
-
JJ Kasper authored
-
JJ Kasper authored
-
chornos13 authored
When there's an error while connect to mongodb (timeout for example), it will be cached and need to restart next.js, by handling the error correctly (clear cached promise) it will try to reconnect to mongodb if the function is called again ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md) Co-authored-by:
JJ Kasper <22380829+ijjk@users.noreply.github.com>
-
Jiachi Liu authored
Drop the support for `.server.js` and `.client.js` extension in RSC, only consume the pages with configured file extensions as page entry
-
JJ Kasper authored
-
Henrik Wenz authored
## Changes - Migrated missing file to typescript ## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Henrik Wenz authored
## Documentation / Examples - [x] Make sure the linting passes by running `pnpm lint` - [x] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Shu Ding authored
We have heuristic checks in the SWC transform to make sure you are not using client-only APIs such as `useState` inside the Server Components graph. However inside our server graph compilation we also have to import the framework and renderer itself (not just the component), and some utility files import these client APIs (because they can be shared by the SSR or client code). Hence we have errors like https://github.com/vercel/next.js/actions/runs/3083270196/jobs/4984135491. To manually opt-out these errors, you can do `import React from 'react'` and use these APIs via `React.useState`. cc @feedthejim ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
JJ Kasper authored
x-ref: [internal notes](https://www.notion.so/vercel/App-Static-Generation-dc5f1e0916684501b586e56a5b7b9483)
-
Sukka authored
## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` Currently, `link[rel=preload]` inserted by `priority` will not have the `crossOrigin` attribute, which will cause the preloaded response not to be used, since the CORS policy mismatches. The PR fixes that.
-
Jiachi Liu authored
We don't have `next/lib/data`, the entry files and types should be removed
-
Jimmy Lai authored
Fixes build errors related to https://github.com/browserslist/caniuse-lite/issues/102 see https://github.com/vercel/next.js/actions/runs/3082979772/jobs/4983345078 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-
Jiachi Liu authored
Tree share the `typeof window` conditions in styled-jsx for edge runtime. Let swc loader go through the styled-jsx assets under node_modules, applying the optimization as well `test-app/server/edge-ssr.js` -155B
-
Shu Ding authored
As per @sebmarkbage's suggestion, this PR refines the error message to be more readable and friendly: ``` error - ./components/qux.js You're importing a component that needs useEffect. It only works in a Client Component but none of its parents are marked with "client", so they're Server Components by default. ,---- 5 | import { useEffect } from 'react' : ^^^^^^^^^ `---- Maybe one of these should be marked as a "client" entry: ./components/qux.js ./components/baz.js ./components/bar.js ./app/dashboard/index/page.js ``` It's more ideal to put error codes inside the SWC transform and format it in the Next.js logging layer. A future improvement is to tweak the message a bit more for these specific cases: - [ ] The error already happens inside an entry point (page or layout), so itself should have "client" added (or removed), not it parents. - [ ] When importing `"server-only"` inside a client component, we can directly hint to the user which module in the import chain is marked with `"client"`. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a 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 a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
-