Commit graph

4271 commits

Author SHA1 Message Date
Donny/강동윤
fd9593542a
Update swc minifier (#31242)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-10 17:39:34 +01:00
Tobias Koppers
9c4c7123b6
run middleware parser handler only for middleware modules (#31219)
## 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-10 15:31:46 +00:00
Donny/강동윤
24f7c21736
Update swc (#31233)
## 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`

This applies

 - https://github.com/swc-project/swc/pull/2699

Fixes https://github.com/vercel/next.js/issues/30839
2021-11-10 09:06:04 +00:00
jj@jjsweb.site
7087adba12
v12.0.4-canary.4 2021-11-09 15:47:35 -06:00
Tobias Koppers
8c8642898f
upgrade webpack (#31034)
* upgrade webpack

* ⚙ Update compiled files

Co-authored-by: sokra <sokra@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-09 22:34:53 +01:00
Genet Schneider
e3135ccde6
Support assetPrefix specific protocol (#31213)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-09 15:26:55 -06:00
Filip Skokan
0985b0b472
share collections in middleware vm context (#31043)
When libraries are required outside of the middleware function context and they do checks such as `a instanceof Uint8Array` since the constructors are different between the two contexts they'll always yield false.

This is a problem for libraries validating user input as well as the WebCryptoAPI polyfill used outside of Edge Functions.

- Fixes #30477
- Fixes #30911

This is only a problem for the sandbox runtime, not when ran inside an Edge Function.
2021-11-09 19:57:19 +00:00
Hiroshi Ogawa
764e29c170
fix(31013): add base path to preflight request url (#31101)
Fixes https://github.com/vercel/next.js/issues/31013

My understanding is that there are currently two functions `Router.change` and `Router.prefetch` leading to `Router._preflightRequest` and they pass `options.as` URL differently regarding base path.
In this PR, such difference will be handled in `Router._preflightRequest` to add base path before actually fetching.
Thanks for the review!

P.S.
Since middleware feature is a relatively new, official maintainers might not want external contributions around this area at this stage.
I totally understand such situation, so please let me know if that's the case. I can look for other issues to investigate instead.


## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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-09 19:03:05 +00:00
Tim Neutkens
3e8b2dcb6c
Disable styled-components displayName in production (#31216)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-11-09 12:24:01 -06:00
Kiko Beats
0bcb7149dc
fix(middleware): expose CryptoKey and globalThis.CryptoKey (#31193)
closes https://github.com/vercel/next.js/issues/30475
2021-11-09 17:39:29 +00:00
JJ Kasper
eb7b40171a
Add initial standalone build handling (#31003)
* Add initial standalone handling

* apply suggestions

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>
2021-11-09 11:03:20 -06:00
Tim Neutkens
31985c5cae v12.0.4-canary.3 2021-11-09 17:18:40 +01:00
Tim Neutkens
b5b315ae04
Add test for styled-components SWC transform disabled (#31214)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-09 17:18:04 +01:00
Tim Neutkens
bcf25289de v12.0.4-canary.2 2021-11-09 15:42:12 +01:00
Tim Neutkens
1941eedd7a Add webpack5 types to right files 2021-11-09 15:40:13 +01:00
Tim Neutkens
14aac0859f
Add all cases where webpack5 type is used (#31206) 2021-11-09 15:18:40 +01:00
Spencer Elliott
a1e76fb966
Use require.resolve to detect "framework" packages (fix pnpm) (#21048)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-09 14:42:23 +01:00
Tim Neutkens
a0a08ae9e5 v12.0.4-canary.1 2021-11-09 12:49:23 +01:00
Donny/강동윤
54ca8f41ce
next-swc: Add displayNameAndId of styled-components (#31189)
## 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`




Related to: https://github.com/vercel/next.js/issues/30802
2021-11-09 10:05:31 +00:00
Javi Velasco
5fc4325aa6
Fix middleware i18n rewrites (#31174)
Fixes #30897

This PR fixes the linked issue where rewrites are not being applied for locale. It adds the corresponding test but also, as it was added in debugging process, it introduces a helper to read/write into the `request` object.

We are currently writing directly into the request by casting to `any` and then using flags like `_nextRewrote`. Instead, this PR puts all of this metadata under a symbol so it is not directly accessible. This also allows to have a single place where all of this metadata is listed so we can add comments describing the purpose of each flag.

In the same way, there is metadata written in the querystring. This is adding some types for it in order to throw some visibility on where is this metadata accessed. In an upcoming PR we can move all of it to the `request` object if possible to simplify the system.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2021-11-09 01:28:39 +00:00
Shu Ding
91a6e3af3a
Do not hide body when concurrentFeatures is enabled (#31187)
When Fizz is enabled, we want to always show the content of body even before it's loaded. Please hide whitespace changes when reviewing this PR.

## 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-09 00:45:44 +00:00
Shu Ding
960298b344
Fix useId mismatches on hydration (#31102)
Fixes #30876.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] 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-08 23:32:06 +00:00
Tim Neutkens
9fe0fda5b4
Add input/output test for 30091 (#31166)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-08 20:40:27 +01:00
Tim Neutkens
9d7900c209
Update reason message for isolatedModules and esModuleInterop (#31150)
This is still required with SWC. The message just wasn't updated.

Fixes #31149



## 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-08 19:16:34 +00:00
Tobias Koppers
283af4e69b
use loader-utils 2 for resolve-url-loader to fix ./data: urls in sass (#31134)
upgrade to loader-utils 3.1.2 for hash fix

fixes #31016
fixes #30998
2021-11-08 18:37:25 +00:00
Furkan MT
58755e6d25
fixes #31060: NullReferenceException (#31061)
* fix(#31060): NullReferenceException

Related Issue: https://github.com/vercel/next.js/issues/31060

* Type 'undefined' is not assignable to type 'Element | null'

Co-authored-by: Steven <steven@ceriously.com>
2021-11-08 12:53:49 -05:00
Othmane KINANE
39ef77cbe6
fix: support --cache-strategy ESLint argument (fixes #29926) (#29928)
* fix: support --cache-strategy ESLint argument

* add integration tests for --cache-strategy

* fix: add cacheStrategy to eslintOptions

* minor adjustments in next lint help message for --cache-strategy

Co-authored-by: Steven <steven@ceriously.com>
2021-11-08 12:17:42 -05:00
Maia Teegarden
bc88831619
Add next-swc jest transform (#30993)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-11-08 17:35:04 +01:00
Steven
83cd45215a
Add warning when image has unused sizes prop (#31064)
- Related to https://twitter.com/jaffathecake/status/1456579637987979265
- Closes #30640
2021-11-08 16:34:30 +00:00
jj@jjsweb.site
2a801809bb
v12.0.4-canary.0 2021-11-08 09:52:15 -06:00
Tim Neutkens
9db80fece5
Add webpack5 namespace to fix type errors (#31140) 2021-11-08 16:19:33 +01:00
Kitty Giraudel
3ceb9c5673
Give priority to document.title over h1 when announcing page change (#31147)
## Improvement

This pull-request should address https://github.com/vercel/next.js/issues/24021, improving the page change announcement for assistive technologies by giving priority to `document.title` over `h1`. Interestingly, it would also improve a potential performance bottleneck by skipping calls to `innerText` on the main `h1` raised in [this comment](https://github.com/vercel/next.js/pull/20428#issuecomment-962537038).
2021-11-08 14:58:21 +00:00
Shu Ding
feed67ee36
Enable code splitting for the web runtime build (#31090)
When using the web runtime with SSR streaming, this PR significantly improves the build speed for large applications when there're large modules shared by most pages.

With another optimization, `react-dom` will now be excluded in the web runtime build if it's imported in the application. It will only take effect in the client bundle.

## 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-08 12:41:49 +00:00
Jiachi Liu
cfb8cc841e
Change .web extension of document page to part of path (#31116)
Fixes: #31104

This effecting users who are using expo with next (`@expo/next-adapter`) since react-native use `.web`, `.ios` and `.android` to identify platform. [Reference](https://docs.expo.dev/guides/using-electron/#%F0%9F%A7%B8-behavior)

Change `document.web.js` to `document-web.js` as fallback page in web runtime
2021-11-07 22:14:50 +00:00
Gerald Monaco
ad981783ab
Add render prop support to <Main> (#30156)
Adds support for render props to the `<Main>` component, when using the [functional custom `Document`](https://github.com/vercel/next.js/pull/28515) style. This allows you to write something like this:

```tsx
export default function Document() {
  const jsxStyleRegistry = createStyleRegistry()
  return (
    <Html>
      <Head />
      <body>
        <Main>
          {content => (
            <StyledJsxWrapper registry={jsxStyleRegistry}>
              {content}
            </StyledJsxWrapper>
          )}
        </Main>
        <NextScript />
      </body>
    </Html>
  )
}
```

In functional document components, this allows the `<App>` to be wrapped, similar to `enhanceApp` (which is only available via `getInitialProps`, which is not supported by functional document components). The primary use for this is for integrating with 3rd party CSS-in-JS libraries, allowing them to attach an `useFlush` handler to [support React 18](https://github.com/reactwg/react-18/discussions/110):

```tsx
import { unstable_useFlush as useFlush } from 'next/document'

export default function StyledJsxWrapper({ children, registry }) {
  useFlush(() => {
    /* ... */
  })
  return (
    <StyleRegistry registry={registry}>
      {children}
    </StyleRegistry>
  )
}
```

Support for `useFlush` will be added in a follow up PR.
2021-11-07 17:36:39 +00:00
Tim Neutkens
f8e66610b6
Change disabled SWC message to Log.info (#31091)
Based on feedback from @flybayer, this changes the `warn - ` to `info -` for the "Disabled SWC" message.



## 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-06 18:37:24 +00:00
Shu Ding
5e185fc5da
Upgrade React alpha and experimental dependencies to latest (#31039)
Ensuring that our tests are not broken with latest React changes.

## 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-06 12:08:03 +00:00
Jiachi Liu
e029ace5ed
Fix custom 404 page when concurrentFeatures is enabled (#31059)
x-ref: https://github.com/vercel/next.js/issues/30424#issuecomment-955615781

This fix the custom 404 is not rendering properly and can’t be built in web runtime when `concurrentFeatures` is enabled. We force 404 page to be rendered outside of middleware ssr. Then it could be the real fallback 404 page in next-server when any routes is not macthed. 
Will check 500 related after #31057 is landed.

## Bug

- [x] Related to #30989
- [x] Integration tests added
2021-11-06 11:27:40 +00:00
Shu Ding
d2c1888a25
update serverless plugin to use webpack 5 apis (#31058)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-11-06 01:19:25 +01:00
JJ Kasper
fab345d952
Ensure decode error in minimal mode responds with 400 not 500 (#31037)
This ensures we handle decode failures in minimal mode as a 400 response (bad request) instead of a 500 (server error). 

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2021-11-05 23:39:52 +00:00
Shu Ding
b75b2f02c9
Improve error handling in the SSR middleware (#31057)
This PR improves error handling in the SSR middleware. Previously the response was sent out synchronously, and and errors were silently swallowed. There was no `.catch` for `renderToHTML`. This changes the middleware to be asynchronous, which waits until the initial Document to be rendered correctly and then starts the streaming. 

With this change we can also send correct status code when there're immediate errors before Fizz.

## 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 22:59:46 +00:00
Shu Ding
0307ba0d1d
Optimize the SSR middleware runtime size (#30906)
By conditionally importing `react-dom/server` under the web runtime and reusing `renderToReadableStream` instead of `renderToStaticMarkup`, we can get rid of the legacy browser React DOM server from the runtime. ~Furthermore we can make the build target `es6` for the SSR middleware, and make some code paths tree-shakable (done in another PR).~

Together this makes the runtime ~32kb smaller.

## 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 21:51:10 +00:00
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
Tim Neutkens
e2506411a1 v12.0.3 2021-11-05 19:04:04 +01:00
Tim Neutkens
4329b7f2b5 v12.0.3-canary.10 2021-11-05 16:05:32 +01:00
Tobias Koppers
177e15b6ba
pass Buffer directly to Rust (#30975) 2021-11-05 15:12:06 +01:00
Shu Ding
bc19c2a564
Fix code splitting and build target for the server-web build (#30972)
- Code splitting should be disabled for the server-web build. Done via `ServerlessPlugin`.
- ~Target can't be `web`, `webworker` is better.~ Using `web` and `es6` for now, still not ideal.
- https://github.com/acornjs/acorn/issues/970

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] 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 03:27:02 +00:00
jj@jjsweb.site
4b6cea2e48
v12.0.3-canary.9 2021-11-04 20:45:02 -05:00
JJ Kasper
bf097f1d0f
Update resolving for node_modules trace pass (#30985)
* Update resolving for node_modules trace pass

* Update test
2021-11-04 20:09:37 -05:00
Tim Neutkens
ad6b9c2d4d
Fix version in trace (#30982)
Noticed the trace can't be imported because the tags are a nested as apparently the type was not restrictive of that.


## 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-04 20:56:30 +00:00