Commit graph

5120 commits

Author SHA1 Message Date
Mohsen Azimi
0fd2f3ba98
Add types to nextConfig in default template (#34029)
Enable editors to suggest properties for the config object. Also let TypeScript check for type errors in the configuration when using TypeScript

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 15:13:38 +00:00
Phillip Klawansky
0468a56604
Update font-stylesheet-gathering-plugin.ts (#30709)
* Update font-stylesheet-gathering-plugin.ts

For production build, getting an UnhandledPromiseRejectionWarning: Unhandled promise rejection on line 29. Added rejection handling callback to allow for builds.

This breaks deployments to Vercel.

* ensure font css minimizing errors are caught/logged

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-05 21:46:47 -06:00
Mohsen Azimi
7286bed4cf
Add JSDoc to config options (#32915)
* Add JSDoc to config options

* Add JSDoc for all non-experimental configurations

* Update packages/next/server/config-shared.ts

Co-authored-by: Steven <steven@ceriously.com>

* Add JSDoc for all non-experimental configurations

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>

* updates

* bump

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-05 19:49:52 -06:00
Jiachi Liu
c8fd6d89eb
Detect per page runtime config for functions manifest (#33945)
## Feature

Follow up for #33770

* When page config specify runtime is "nodejs", remove runtime option in functions manifest;
* If user enable `concurrentFeatures` and filesystem api, use `runtime: "web"` for those pages;


- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2022-02-06 01:28:42 +00:00
Hannes Bornö
8aa3620a16
Babel & next-swc: Fix exporting page config with AsExpression (#32702)
fixes #20626

No changes needed in next-swc, see comments from @kdy1 below.

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-05 21:15:49 +00:00
Kara
d7de7deb70
Do not warn when application/ld+json scripts are used with next/head (#34021)
In #33968, a warning was added for script tags inserted through the
next/head component. This change unintentionally included
application/ld+json scripts, which shouldn't be triggering the
warnings (as they were originally intended to catch scripts where
loading order or timing could be important). This change adds an
exception for application/ld+json scripts, so they do not log the
warning if they are included through next/head.
2022-02-05 14:45:02 -06:00
Thibaut SABOT
2ea2c81f52
Don't use yarn if a package-lock.json file is found (#31926)
Fixes https://github.com/vercel/next.js/issues/31755
2022-02-05 20:16:25 +00:00
Gerald Monaco
1aeb230839
Fix suffix ordering while streaming (#34011)
* Fix suffix ordering

* Don't start reading until after resolving

* More yak shaving
2022-02-05 13:17:29 -06:00
Gerald Monaco
7e0b8aa4d1
Use ReadableStream in RenderResult (#34005)
Since we're always using `ReadableStream`, we should just get rid of `ResultPiper`.

This also lets us replace things like `bufferedReadFromReadableStream` with a `TransformStream` that does the same thing, so that it's `TransformStream`s all the way down.

Finally, we can get rid of the one-off call to `renderToReadableStream` and just use `renderToStream` whenever we're rendering a concurrent tree.
2022-02-05 01:13:02 +00:00
JJ Kasper
f322d62639
v12.0.11-canary.6 2022-02-04 17:02:00 -06:00
Kara
24fe279751
Warn in dev mode when stylesheets are added using next/head (#34004)
This commit adds a development mode warning in the console
if you try to include <link rel="stylesheet"> tags in
next/head, e.g.

```
<Head>
  <link ref="stylesheet" href="..." />
</Head>
```

The warning message explains that this pattern will not
work well with Suspense/streaming and recommends using a
custom Document component instead.

## Feature

- [x] 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
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-04 22:48:30 +00:00
Daniel Lindenkreuz
f275fcff7a
Update Terser to v5.10.0, fix minification issues (#33045)
Bumping Terser from v5.7.1 to v5.10.0 fixes some minification issues:
- I specifically encountered this bug, where a boolean condition was flipped when a nullish coalescing operator was involved: https://github.com/terser/terser/pull/1045
- See [Terser's changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md) for more fixes

## 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

- [x] Make sure the linting passes by running `yarn lint`
2022-02-04 21:33:10 +00:00
JJ Kasper
103d3ab4fc
Ensure external middleware rewrite is handled correctly (#33962) 2022-02-04 13:32:30 -06:00
Gerald Monaco
0b1d5e17bc
Use react-dom/server.browser in Node.js (#33950)
Instead of branching rendering based on Node.js and browser/web runtimes, we should just use the web version for now, which can run as-is on versions >=16.5.0 of Node.js, polyfilling `ReadableStream` on older versions when necessary.

There are a few potential downsides to this, as React is less able to optimize flushing and execution. We can revisit that in the future though if desired.
2022-02-04 17:52:53 +00:00
JJ Kasper
502a869a68
v12.0.11-canary.5 2022-02-04 11:15:32 -06:00
JJ Kasper
a65e3612d0
Ensure optional chaining in swc matches babel (#33995)
This ensures we always transpile optional chaining and nullish coalescing with swc the same as we do [with babel](4812e22992/packages/next/build/babel/preset.ts (L97-L98)) since it can cause issues with webpack even when the node target supports these features. 

The specific case this seems to cause issues with webpack is when a value is imported and optional chaining is used on the import value webpack is stripping the optional chaining cc @sokra 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/33915
2022-02-04 17:08:01 +00:00
Kara
61ea8efe42
Warn in dev mode when script tags are added with next/head (#33968)
This commit adds a development mode warning in the console
if you try to include <script> tags in next/head, e.g.

```
<Head>
  <script async src="..." />
</Head>
```

The warning message explains that this pattern will not
work well with Suspense/streaming and recommends using the
next/script component instead.

TODO in follow-up PR: add same warning for stylesheets, etc

## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Integration tests added
- [x] Documentation added
- [x] Errors have helpful link attached, see `contributing.md`
2022-02-04 13:06:55 +00:00
JJ Kasper
06b263021a
Update to latest version of amphtml-validator (#33967)
* Update to latest version of amphtml-validator

* update compiled

* bump compiled
2022-02-03 20:33:38 -06:00
JJ Kasper
740f908aa4
v12.0.11-canary.4 2022-02-03 13:18:41 -06:00
Donny/강동윤
4bd76ff5df
feat(next-swc): Update swc (#33724)
This PR applies

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

which fixes lots of minifier issues.

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

This fixes the regression of evaluatior.

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

This fixes codegen bugs.

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

This improves compression.

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

This fixes some transform bugs.

 - https://github.com/swc-project/swc/pull/3392
 
This implements more terser options.
2022-02-03 17:39:37 +00:00
stefanprobst
49afcd4871
fix: handle jsxspreadattribute in inline-script-id eslint rule (#32421)
fixes #32178

the `inline-script-id` eslint rule crashed when encountering a `JSXSpreadAttribute`. this pr fixes that, and also handles `id` being passed via the spreaded object.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] ~~Integration~~ Unit 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`
2022-02-02 23:04:22 +00:00
Steven
abae663f2b v12.0.11-canary.3 2022-02-02 17:29:18 -05:00
Andrey Lunyov
831d45d73d
Add support for Relay projects without artifactDirectory (#33918)
* update plugin

* Update the test

* remove dbg

* Use pages_dir in Relay

* copy edits

* cargo test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-02 16:00:02 -06:00
Steven
e3e62aa786
Fix image cache race condition (#33883)
- Fixes #33860
2022-02-02 21:27:56 +00:00
JJ Kasper
aae0370d63
v12.0.11-canary.2 2022-02-02 13:32:35 -06:00
JJ Kasper
cdc4ee3615
Ensure browserslist extends works properly (#33890)
* Ensure browserslist extends works properly

* add comment
2022-02-02 13:23:51 -06:00
JJ Kasper
f841307fa0
Fix parsing params for i18n optional route in minimal mode (#33896)
This fixes our parsing of params with i18n for optional catch-all routes and ensures a regression test catches this case.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/30631
2022-02-02 19:02:03 +00:00
JJ Kasper
7b1baceede
Ensure external beforeFiles rewrites are handled with next/link (#33888)
This ensures we properly handle external `beforeFiles` rewrites client-side so that a different result doesn't occur client-side versus on a direct visit. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/32348
2022-02-02 18:31:56 +00:00
zhoulixiang
6dfe02d22f
Optimize offline condition judgment (#33238)
* perf: optimize offline condition judgment

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-02 10:17:29 -06:00
Gerald Monaco
0fa95da53f
Encapsulate routing and initial hydration (#33875)
* Encapsulate initial rendering

* Run dev code before rendering

* Fix call

* Try reverting last change, fixing call
2022-02-02 09:08:16 -06:00
Jiachi Liu
5365f41785
Group streaming experimental apis (#33878)
Move undocumented `next/rsc` and `next/vitals` to `next/streaming`. In the future `next/streaming` can contain streaming SSR related (including react server components) APIs together.
2022-02-02 13:42:14 +00:00
Jim Fisher
965d26eba3
Bug fix: dynamic page should not be interpreted as predefined page (#33808)
Fixes: https://github.com/vercel/next.js/issues/17096
Fixes: https://github.com/vercel/next.js/issues/23824
Closes: https://github.com/vercel/next.js/pull/33765

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added in https://github.com/vercel/next.js/pull/33765
- [x] Errors have helpful link attached (N/A)

Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-02 02:57:04 +00:00
JJ Kasper
39d3210776
v12.0.11-canary.1 2022-02-01 17:01:29 -06:00
Sean Kiefer
5d9310e378
update NextResponse default redirect status to 307 to match docs (#33505)
* fix: update default redirect status to 307 to match docs

* fix: update default redirect status to 307 to match docs

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-02-01 16:45:54 -06:00
Shu Ding
51f0359222
Refactor page component getter in web server (#33759)
Cleans up the code of the middleware SSR loader and the web server. Currently the page components and render options are provided to the server via `globalThis` which is not ideal.

Instead we can inject `extendRenderOpts` and `loadComponent` to the web server. Since this is the the minimal mode and we'll need to handle `?flight` requests, we update the server render opts upon `updateRenderOpts` (In the future this should be changed to be passed to `requestHandler` to avoid race conditions).

Currently, we can't fully get rid of the `__server_context` global as we call `getBuildId` in the base server constructor.

## 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`
2022-02-01 22:36:47 +00:00
Tobias Koppers
a803638da2
fix problem with HMR when middleware and page reference the same node_module (#33873)
fixes https://github.com/vercel/next.js/issues/31827



## 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`
2022-02-01 21:46:07 +00:00
Jiachi Liu
4786557908
Flush buffered vitals metrics on page mount (#33867)
## Bug

fixes #32631

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-02-01 20:48:08 +00:00
JJ Kasper
dd486602b6
v12.0.11-canary.0 2022-02-01 14:05:04 -06:00
Tobias Koppers
3ba3bb8d6d
update webpack (#33831)
https://github.com/webpack/webpack/releases/tag/v5.68.0

fixes https://github.com/vercel/next.js/issues/32360
2022-02-01 19:27:31 +00:00
Stoyan Delev
a7793c7a0c
fix eslint link-passhref rule (#33857) 2022-02-01 12:53:55 -06:00
JJ Kasper
3e60c232a8
Relay Support in Rust Compiler (#33702)
Reverts vercel/next.js#33699

This re-opens the support for relay in swc, although we need to narrow in the causes for the build failures in https://github.com/vercel/next.js/runs/4950448889?check_suite_focus=true

Co-authored-by: Andrey Lunyov <102968+alunyov@users.noreply.github.com>
2022-02-01 18:18:55 +00:00
JJ Kasper
4c28177c15
v12.0.10 2022-01-31 19:52:18 -06:00
Steven
94989461ff v12.0.10-canary.2 2022-01-31 19:14:21 -05:00
Divlo
e0095faf23
fix(next/image): render valid html according to W3C (#33825)
## Bug

- [x] Fixes #33809
- [x] Related to #33218
- [x] Integration tests added: Usage of [html-validator](https://www.npmjs.com/package/html-validator) to validate the HTML.
- [x] Errors have helpful link attached, see `contributing.md` (N/A)
2022-01-31 19:13:46 -05:00
lxy-yz
b00270b1ab
fix typo (#33840)
## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-01-31 22:54:17 +00:00
Tim Neutkens
3bac02e032
Enable jest hoist transform when using next/jest (#33731)
Fixes #32539

Implements what was shared at https://github.com/vercel/next.js/issues/32539#issuecomment-1023139083.



## 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`
2022-01-31 16:15:15 +00:00
Jiachi Liu
5b31c18e76
Generate functions manifest (#33770)
## Feature

Reuse most of the part from manifest plugin to generate similar assets

Resolves #33667

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
2022-01-31 15:46:04 +00:00
Steven
48dee57ff5 v12.0.10-canary.1 2022-01-28 18:51:51 -05:00
Steven
b9c012f49d
Fix duplicate image src causing canceled request (#33776)
In PR #26968, we added Set of loaded images that was removed in #33474 erroneously.

We still need to track loaded images since we can't rely on `img.complete`, especially if the parent uses `react-virtualized`.

Tested on https://nextjs.org/showcase
2022-01-28 23:50:36 +00:00
Tim Neutkens
f104e9105c
Fix encoding error with location and refresh headers (#33763)
Fixes the merge conflicts in #27003

Fixes #24977
Fixes #24047
Closes #27003

Co-Authored-By: Jamie <5964236+jamsinclair@users.noreply.github.com>



## 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`
2022-01-28 16:20:34 +00:00
JJ Kasper
b314c9886c
v12.0.10-canary.0 2022-01-27 16:50:54 -06:00
JJ Kasper
6aef15dc23
Ensure non-error thrown in getStaticPaths shows correctly (#33753) 2022-01-27 16:31:54 -06:00
JJ Kasper
7ec49be7ac
Ensure all CSS files are included for experimental critical CSS (#33752)
* Ensure all CSS files are included for experimental critical CSS

* remove extra import
2022-01-27 16:22:20 -06:00
Gal Schlezinger
7b2ea48745
Allow to delete URL search params in middleware rewrites (#33725)
This allows to have a more streamlined API for rewrites.
Since middlewares are code and not static configurations, we can allow people to
delete query params and not just overwrite them.

**⚠️ Warning ⚠️** this is a breaking change in query parameter behavior with middlewares, but the API will make more sense now. Compare the following:

```diff
  import {NextResponse} from 'next/server'
  export default function middleware({ nextUrl }) {
-   nextUrl.searchParams.set('ignored-query-param', '');
+   nextUrl.searchParams.delete('ignored-query-param'); // 🎉
    return NextResponse.rewrite(nextUrl);
  }
```

Since this is breaking change, we're adding a warning every time we find a query param that is missing, and eventually--the warning will be deleted.
I don't think we need to worry about older versions of Next.js as the current behavior is misleading: merging query parameters make sense for static rewrites, but not for middlewares where you have access to all the query parameters and can manipulate them freely.

Related:
* This is the opposite of #33454
* This supersedes #33574
2022-01-27 22:06:39 +00:00
Steven
16b5bfa78e
Add stale-while-revalidate pattern to Image Optimization API (#33735)
- Resolves #27208
2022-01-27 21:33:23 +00:00
Pieter Bogaerts
662fa6362a
fix: fixes #33314 move is-plain-object for es5 compilation (#33690)
## Bug

- [ ] Related issues linked using `fixes #33314` #33314
- [ ] Moved the `is-plain-object` file to the shared directory since it's emitted to the client and thus needs to be transpiled.

This is just my 2nd PR so if I'm missing something please let me know.
2022-01-27 17:59:42 +00:00
Pepijn Senders
c8a0aac24e
chore: deprecate process.browser (#32862)
This value has been deprecated in favor of `typeof window !== 'undefined'` a long time ago ([ref](https://github.com/vercel/next.js/pull/7651)). We should also deprecate the value in the global types as it might give the wrong assumption that this value should still be used.
2022-01-27 16:55:26 +00:00
Shu Ding
7b524c1b97
Properly support custom 500 page in the web server (#33729)
In the web runtime, currently we use `absolute500Path || absoluteErrorPath` to act like `/_error`. This PR fixes the behavior to use the `/pages/500.js` for 500 errors and `/pages/_error.js` for 500 fallback and other errors.

## 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`
2022-01-27 16:20:16 +00:00
Jiachi Liu
3bda6e66b6
Use swc parse for flight server and client loaders (#33713)
* Add `parse` method for next-swc
* Use shared next-swc to parse rsc components AST
* Remove the invalid case of parsing `ExportAllDecalaration` (we didn't support it well before, so I deleted. need to support later)


Co-authored-by: Donny/강동윤 <29931815+kdy1@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-27 15:48:09 +00:00
Balázs Orbán
7e95e30063
fix: allow certain variable names in development (#33638)
Fixes #24570

A few variable names (listed https://github.com/vercel/next.js/issues/24570#issuecomment-828721019) were causing problems when using `next dev`.

## 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`
2022-01-27 14:22:35 +00:00
Balázs Orbán
0d642f1264
feat: make compress configurable in standalone mode (#33717)
Fixes #33696

## 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`
2022-01-27 02:13:10 +00:00
Keen Yee Liau
c551a329d5
fix: image optimizer hangs when invalid image is requested (#33719)
When an invalid image is requested, the 'finish' event is never triggered,
which ultimately leads to a 504 Gateway Timeout error.

This is fixed by invoking the 'callback' in `_write()`.

fix https://github.com/vercel/next.js/issues/33441



## 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`
2022-01-27 01:41:57 +00:00
JJ Kasper
07431d3e0f
v12.0.9 2022-01-26 16:01:19 -06:00
JJ Kasper
c938e20077
v12.0.9-canary.12 2022-01-26 15:10:58 -06:00
JJ Kasper
865a079923
v12.0.9-canary.11 2022-01-26 10:31:07 -06:00
JJ Kasper
b5d4564cca
Revert "Relay Support in Rust Compiler" (#33699) 2022-01-26 17:26:32 +01:00
Tim Neutkens
65c63c9434 v12.0.9-canary.10 2022-01-26 12:00:50 +01:00
Terence Bezman
b20eb99a4d
Relay Support in Rust Compiler (#33240)
## Feature

Implements feature requested in https://github.com/vercel/next.js/issues/30805. 

A few people including myself have been looking to use Relay with Next.JS and want to use the new Rust Compiler. This is my stab at an implementation. 

### How it works?
Finds all  `graphql` tagged template experssions and replaces them with `require`s to the file generated by Relay.

### Where I need help
- I've only worked with Rust a handful of times so I would appreciate any feedback on my use of language features.
- Is there any performance overhead to many duplicate usages of `require`? I imagine there's a cache in place but I want to be sure.
- I've added some unit tests & integration tests but I might be missing some use cases. Feel free to comment some use cases I'm not thinking about.

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Documentation added
  - I haven't added any docs since this is an experimental API.

## Documentation / Examples

You're expected to be running the Relay Compiler along side Next.JS when you're developing. This is pretty standard. I wouldn't expect people to have any problem with this.

### Usage
In your `next.config.js`
```js
module.exports = {
  experimental: {
    relay: {
      language: 'typescript', // or 'javascript`
      artifactDirectory: 'path/to/you/artifact/directory' // you can leave this undefined if you did not specify one in the `relay.json`
    }
  }
}
```


Co-authored-by: Tim Neutkens <6324199+timneutkens@users.noreply.github.com>
2022-01-26 08:23:57 +00:00
Shu Ding
99d4d6c5a4
Implement web server as the request handler for edge SSR (#33635)
(#31506 for context)

This PR implements the minimum viable web server on top of the Next.js base server, and integrates it into our middleware (edge) SSR runtime to handle all the requests.

This also addresses problems like missing dynamic routes support in our current handler.

Note that this is the initial implementation with the assumption that the web server is running under minimal mode. Also later we can refactor the `__server_context` environment to properly passing the context via the constructor or methods.
2022-01-26 06:22:11 +00:00
Donny/강동윤
f0e31ee842
feat(next-swc): Update swc (#33675)
This PR applies

 - https://github.com/swc-project/swc/pull/3367
2022-01-26 05:46:29 +00:00
JJ Kasper
8d1c58525c
v12.0.9-canary.9 2022-01-25 10:53:28 -06:00
11koukou
7452c0bf1b
Add lazyRoot optional property to next/image component (#33290)
* Added 'rootEl' oprional property to next/Image component resembling 'root' option of the Intersection Observer API

* changed 'rootEl' to 'lazyBoundary' and its type as well

* added test, fixed initial root detection

* Update test/integration/image-component/default/test/index.test.js

Co-authored-by: Steven <steven@ceriously.com>

* prop names changed

* added 'lazyroot' prop to the documentation

* removed unused import

* Apply suggestions from code review

* Update docs with lazyRoot added in 12.0.9

Co-authored-by: Steven <steven@ceriously.com>
2022-01-25 14:54:15 +01:00
Donny/강동윤
9dd0399dd8
feat(next-swc): Update swc (#33628)
This PR applies


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

Closes https://github.com/vercel/next.js/issues/33600
2022-01-25 09:22:22 +00:00
JJ Kasper
f60a480771
v12.0.9-canary.8 2022-01-24 16:30:26 -06:00
JJ Kasper
c13d9a0c78
Update other instances of node-fetch (#33617)
* Update other instances of node-fetch

* update compiled
2022-01-24 16:18:39 -06:00
JJ Kasper
e8c15e5991
Ensure fetch polyfill is loaded in next-server (#33616) 2022-01-24 15:38:54 -06:00
JJ Kasper
3329ac6460
v12.0.9-canary.7 2022-01-24 13:14:25 -06:00
Tobias Koppers
2c6bd1ed1b
upgrade webpack (#33549)
https://github.com/webpack/webpack/releases/tag/v5.67.0
2022-01-24 18:32:47 +00:00
Jiachi Liu
62b63098a2
Fix rsc export component name detection (#33608) 2022-01-24 17:19:57 +01:00
Donny/강동윤
0fb1183973
feat(next-swc): Update swc (#33595)
This PR applies

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

Resolves https://github.com/vercel/next.js/discussions/30237#discussioncomment-2014245

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

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

This fixes `jsc.experimental.keepImportAssertions`.
2022-01-24 13:46:09 +00:00
PØL1
01cd69fbc3
Update deprecation for webpack5 config (#33560)
* Removed the s

Removed the s of
"This option was moved to the top level"
was before: "this options was moved to the top level"

* Update packages/next/server/config-shared.ts

Co-authored-by: JJ Kasper <jj@jjsweb.site>

* Suggestion of @ijjk

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-01-23 13:34:08 -06:00
Steven
f81a6a5f0f
Bump nft to 0.17.4 (#33548)
- Fixes https://github.com/vercel/next.js/issues/33294

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-22 00:14:11 +00:00
JJ Kasper
f5fb18198c
Ensure optional value normalizing is correct for index (#33547)
This fixes a case where optional catch-all route values aren't normalized to an array properly when the `index` value is passed. An additional test case has been added to prevent regressing on this. 

x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1642791113093400)

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-01-21 23:16:24 +00:00
JJ Kasper
2a349c769d
v12.0.9-canary.6 2022-01-21 15:55:00 -06:00
Jiachi Liu
ebe95f4420
Bump styled-jsx (#33546)
Use stable v5 of styled-jsx
2022-01-21 21:27:37 +00:00
JJ Kasper
69524c290d
Fix static file check with i18n (#33503) 2022-01-21 14:38:59 -06:00
Jiachi Liu
557a972568
Simplify getMiddlewareInfo calls (#33542)
Subtask of #31506

* move `serverBuildDir` and getter function of `publicDir` to next-server as only used place
* simplify `getMiddlewareInfo`, remove `distDir` and other params could be accessed from web server itself
2022-01-21 16:24:57 +00:00
Shu Ding
76b9a5497f
Implement abstract methods to get manifest files in the base server (#33537)
Related to #31506, this PR adds `getPrerenderManifest` and `getRoutesManifest` methods to provide manifest files to the base server. In the future, we can consider making these methods async, or provide necessary manifests from the very top.

## 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`
2022-01-21 15:31:47 +00:00
Tim Neutkens
8959292d2b v12.0.9-canary.5 2022-01-21 15:42:22 +01:00
Donny/강동윤
8ff9785d08
Update swc (#33514)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-01-21 12:49:38 +01:00
Shu Ding
1c1a4de0e2
Refactor base server to remove native dependencies (#33499)
Part of #31506, this PR removes `loadEnvConfig` and `chalk` from the base server while keeping the same behavior for the node server.

## 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`
2022-01-20 21:25:44 +00:00
Steven
c879fce0d4
Fix multiple calls to image onLoadingComplete() (#33474)
The image prop `onLoadingComplete()` was unexpectedly called multiple times because it uses a [callback ref](https://reactjs.org/docs/refs-and-the-dom.html#callback-refs).

This could lead to an infinite loop if `onLoadingComplete()` calls `setState()` as demonstrated in the updated test.

The solution is to handle refs with `useRef()` and `useEffect` so `onLoadingComplete()` is called at most once per component instance.

- Fixes #33463
2022-01-20 15:29:34 +00:00
Tim Neutkens
96057c8f67 v12.0.9-canary.4 2022-01-20 09:57:25 +01:00
Donny/강동윤
a54eb376e1
feat(next-swc): Update swc (#33485) 2022-01-20 09:54:56 +01:00
JJ Kasper
2fd17ba1f8
v12.0.9-canary.3 2022-01-19 16:09:37 -06:00
Jiachi Liu
8ca32f15f7
Move static serving to next server (#33475)
Part of #31506

Decouple static serving logic from base-server, let them go to next-server only
2022-01-19 21:54:04 +00:00
Balázs Orbán
1d4f364515
chore(deps): upgrade node-fetch (#33466)
Fixes #33462 

Tried upgrading to v3, but we rely on the `timeout` property:

e5dee17f77/packages/next/telemetry/post-payload.ts (L12)

Which was removed since it's non-standard:

https://github.com/node-fetch/node-fetch/blob/main/docs/v3-UPGRADE-GUIDE.md#the-timeout-option-was-removed

I wanted to keep this PR minimal, so I did not try to work around the above.

## 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`
2022-01-19 16:48:11 +00:00
JJ Kasper
818f6b3258
Update main field for nccd jest-worker (#33465) 2022-01-19 10:11:14 -06:00
Donny/강동윤
3574b91b48
feat(next-swc): Update swc (#33461)
This PR applies

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

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

Fixes https://github.com/vercel/next.js/issues/31077
2022-01-19 15:57:39 +00:00
Javi Velasco
e5dee17f77
Enforce absolute URLs in Edge Functions runtime (#33410)
We currently have inconsistencies when working with URLs in the Edge Functions runtime, this PR addresses them introducing a warning for inconsistent usage that will break in the future. Here is the reasoning.

### The Browser

When we are in a browser environment there is a fixed location stored at `globalThis.location`. Then, if one tries to build a request with a relative URL it will work using that location global hostname as _base_ to construct its URL. For example:

```typescript
// https://nextjs.org
new Request('/test').url; // https://nextjs.org/test
Response.redirect('/test').headers.get('Location'); // https://nextjs.org/test
```

However, if we attempt to run the same code from `about:blank` it would not work because the global to use as a base `String(globalThis.location)` is not a valid URL. Therefore a call to `Response.redirect('/test')` or `new Response('/test')` would fail.

### Edge Functions Runtime

In Next.js Edge Functions runtime the situation is slightly different from a browser. Say that we have a root middleware (`pages/_middleware`) that gets invoked for every page. In the middleware file we expose the handler function and also define a global variable that we mutate on every request:

```typescript
// pages/_middleware

let count = 0;

export function middleware(req: NextRequest) {
  console.log(req.url);
  count += 1;
}
```

Currently we cache the module scope in the runtime so subsequent invocations would hold the same globals and the module would not be evaluated again. This would make the counter to increment for each request that the middleware handles. It is for this reason that we **can't have a global location** that changes across different invocations. Each invocation of the same function uses the same global which also holds primitives like `URL` or `Request` so changing an hypothetical `globalThis.location` per request would affect concurrent requests being handled.

Then, it is not possible to use relative URLs in the same way the browser does because we don't have a global to rely on to use its host to compose a URL from a relative path.

### Why it works today

We are **not** validating what is provided to, for example, `NextResponse.rewrite()` nor `NextResponse.redirect()`. We simply create a `Response` instance that adds the corresponding header for the rewrite or the redirect. Then it is **the consumer** the one that composes the final destination based on the request. Theoretically you can pass any value and it would fail on redirect but won't validate the input.

Of course this is inconsistent because it doesn't make sense that `NextResponse.rewrite('/test')` works but `fetch(new NextRequest('/test'))` does not. Also we should validate what is provided. Finally, we want to be consistent with the way a browser behaves so `new Request('/test')` _should_ not work if there is no global location which we lack.

### What this PR does

We will have to deprecate the usage of relative URLs in the previously mentioned scenarios. In preparation for it, this PR adds a validation function in those places where it will break in the future, printing a warning with a link that points to a Next.js page with an explanation of the issue and ways to fix it.

Although middleware changes are not covered by semver, we will roll this for some time to make people aware that this change is coming. Then after a reasonable period of time we can remove the warning and make the code fail when using relative URLs in the previously exposed scenarios.
2022-01-19 15:10:25 +00:00
Shu Ding
4d3b2ea426
Move middleware handling to node server (#33448)
Part of #31506, this PR moves the code of middleware handling from the base server to the node server.

## 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`
2022-01-19 12:36:06 +00:00
Tim Neutkens
82f3233c0c v12.0.9-canary.2 2022-01-19 09:16:10 +01:00
Donny/강동윤
b111ba159a
fix(next-swc): Update swc (#33427)
This PR applies lots of patches, including

 - https://github.com/swc-project/swc/pull/3303
 - https://github.com/swc-project/swc/pull/3301
 - https://github.com/swc-project/swc/pull/3287
 - https://github.com/swc-project/swc/pull/3286
 - https://github.com/swc-project/swc/pull/3289

  - https://github.com/swc-project/swc/pull/3302
    - Fixes https://github.com/vercel/next.js/issues/33265

(Verified)

I'll undraft this after verifying
2022-01-19 08:15:45 +00:00
JJ Kasper
3220bbaba3
Fix pre-compiled check from copying react-refresh-utils (#33442)
This updates to not commit the copied `react-refresh-utils` files as they will change anytime a new version is published. 

Fixes: https://github.com/vercel/next.js/runs/4855748491?check_suite_focus=true
2022-01-18 18:49:26 +00:00
Jiachi Liu
c367c72d28
Disable cache for rsc pages (#33438)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-01-18 17:56:08 +01:00
Tim Neutkens
45eb137a89 v12.0.9-canary.1 2022-01-18 16:42:03 +01:00
Jiachi Liu
41614e52d7
Fix broken html on streaming render for error page (#33399)
## Bug

Fixes: #32515

Previously, we render the `suffix` after consuming 1st chunk, instead we should render it after stream finished

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`
2022-01-17 20:27:12 +00:00
Oleg Zuev
8dc46705f2
Replace regexp to plain string for optimization render HTML (#33306)
## Bug

Line `const [renderTargetPrefix, renderTargetSuffix] = documentHTML.split(*)` with RegExp almost 80 times slower than a plain string.

Before:
![telegram-cloud-photo-size-2-5409140542421448593-y](https://user-images.githubusercontent.com/22259080/149506024-84365840-5b0f-481f-b05f-1381d839c579.jpg)


After:
![telegram-cloud-photo-size-2-5409140542421448594-y](https://user-images.githubusercontent.com/22259080/149506036-0df69ae7-e265-40da-a865-73c84496aa58.jpg)
2022-01-17 16:22:44 +00:00
Jiachi Liu
f4d2938503
Remove node fetch polyfill from base server (#33395)
* keep fetch polyfill only in dev-server, next-server (polyfilled in next.ts)
* also export worker, static paths worker since they also requires it
2022-01-17 15:50:36 +00:00
JJ Kasper
25d064f812
Pre-compile more dependencies (#32742)
This ncc's some remaining dependencies bringing us under 20 install time dependencies (including nested dependencies), this also reduces install size by another `2.75 MB`. A follow-up PR will investigate a custom install script for our swc packages to allow us to remove the `optionalDependencies` which is slowing down install time as well. 

x-ref: https://github.com/vercel/next.js/pull/32679
x-ref: https://github.com/vercel/next.js/pull/32627
x-ref: https://github.com/vercel/next.js/issues/31887
x-ref: https://github.com/vercel/styled-jsx/pull/770
2022-01-17 15:17:22 +00:00
JJ Kasper
389432048c
Update check for fallback pages during export (#33323)
This fixes our check for fallback pages during `next export` as we are currently erroring even when the erroneous pages are not included in the `exportPathMap`. This also adds additional tests to certify the expected behavior for the error. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/29135
2022-01-17 14:44:45 +00:00
Donny/강동윤
aaa77dd73f
Update swc (#33342) 2022-01-17 15:09:55 +01:00
JJ Kasper
02405e2247
Fix getServerSideProps hanging in dev on early end (#33366)
This fixes the case where calling `res.end()` is `getServerSideProps` would cause the request to hang in development due to our `Proxy` around `res` causing internal `ServerResponse` fields to not be available ([related post](https://javascript.info/proxy#built-in-objects-internal-slots)). I also migrated our `getServerSideProps` test suite to an e2e suite with a test for this case. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/15118
Fixes: https://github.com/vercel/next.js/issues/32824
Closes: https://github.com/vercel/next.js/pull/33129
2022-01-16 16:14:21 +00:00
George Karagkiaouris
3e00a81ede
Base Http for BaseServer (#32999)
Adds base http classes, along with Node + Web (partial) implementations
Removes usage of IncomingMessage and ServerResponse from base server

Co-authored-by: Shu Ding <3676859+shuding@users.noreply.github.com>
2022-01-14 21:01:35 +00:00
JJ Kasper
613e4c91e3
Update yarn PnP tests and disable swc file reading for PnP (#33236)
* Update yarn PnP tests and disable swc file reading for PnP

* update job

* Update test

* add env variable

* update destory

* test one

* bump timeout

* update pnp install command

* only run pnp test

* add more logs

* handle exit signal

* dont inherit stdio for install

* update server start

* re-add test type

* add build log

* additional logging

* update build command

* remove separate timeout

* update install command

* install separate for better time info

* add cache pre-warming

* update yarn config

* enable other pnp tests

* Separate out tests

* fix-lint

* update path

* update test concurrency for isolated tests

* update retries

* Revert "update test concurrency for isolated tests"

This reverts commit 3a6e924df8ec61d55d3ee8a58d24cd50f0141195.

* re-enable production tests

* apply suggestions
2022-01-14 09:43:30 -06:00
Jiachi Liu
00a843280d
Custom app for server components (#33149)
## Feature

Resolves #30996

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] 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 helpful link attached, see `contributing.md`
2022-01-14 13:01:00 +00:00
Tobias Koppers
30ca6b38ca
improve full refresh overlay (#33301)
include a few lines of stack trace in the full refresh overlay
error is not necessary webpack related



## 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`
2022-01-14 12:32:01 +00:00
Donny/강동윤
fd231a68bf
Update swc (#33201)
This PR is a bit big because AST definitions are modified recently because previous AST defs were too error-prone.
It will prevent plugin authors from making some common mistakes.


 - Closes #33088
 - Closes #31084
 - Closes #33283
2022-01-14 11:54:01 +00:00
JJ Kasper
7db6aa2fde
v12.0.9-canary.0 2022-01-13 15:19:42 -06:00
Gal Schlezinger
338307cd83
Fix global process testing for the process polyfill (#33220)
When there is a DOM element with id of `process`, the DOM marks it as a global, so `window.process` would exist. We should check for `process.env` to make sure it is available too.
2022-01-13 16:44:55 +00:00
Balázs Orbán
1dd053f9fa
chore(deps): upgrade postcss (#33142)
Fixes #33135

I also tried reducing the number of variants.

## 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`
2022-01-13 16:06:38 +00:00
Tim Neutkens
ca19860684 Update license year 2022-01-13 16:02:34 +01:00
Tobias Koppers
628e6aca97
use text data url instead of base64 for shorter encoding (#33218)
and text is easier to gzip

and it avoid the reference to `Buffer` from next

## 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`
2022-01-12 19:51:38 +00:00
Shu Ding
5572eb3988
Abstract out native filesystem usage from the base server (#33226)
This PR moves `require` and `fs` usage from the base server to the node server. Closes #32322.

## 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`
2022-01-12 18:12:36 +00:00
Tobias Koppers
3ee3ec30d9
update webpack (#33207)
https://github.com/webpack/webpack/releases/tag/v5.66.0
2022-01-12 16:46:59 +00:00
Gal Schlezinger
e69500462d
middlewares: limit process.env to inferred usage (#33186)
Production middlewares will only expose env vars that are statically analyzable, as mentioned here: https://nextjs.org/docs/api-reference/next/server#how-do-i-access-environment-variables

This creates some incompatibility with `next dev` and `next start`, where all `process.env` data is shared and can lead to unexpected behavior in runtime.

This PR fixes it by limiting the data in `process.env` with the inferred env vars from the code usage. I believe the test speaks for itself 🕺 

<!--
## 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`
-->
2022-01-12 13:09:24 +00:00
Tim Neutkens
d7a96d22be v12.0.8 2022-01-12 09:14:02 +01:00
Tim Neutkens
df0e89984e v12.0.8-canary.22 2022-01-12 09:09:32 +01:00
Manny Becerra
36eba95227
Fixes #33153: Updating cross-references from master to main + canary (#33198)
* copy cleanup in env. variables docs

* copy cleanup in fast refresh docs

* Supplements #33153 - updating existing cross-references to `master` branch to renamed default branch of `main`

* Supplements #33153 - updating existing cross-references to `master` branch to renamed default branch of `main`

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2022-01-12 02:55:35 +01:00
JJ Kasper
0de84472eb
v12.0.8-canary.21 2022-01-11 15:00:27 -06:00
JJ Kasper
57a87050e7
Add util for normalizing errors (#33159)
* JSON.stringify generic errors

* Add util for normalizing errors

* lint-fix

* Add better error for null case as well

Co-authored-by: Michael Ozeryansky <mozeryansky@users.noreply.github.com>
2022-01-11 14:40:03 -06:00
kaykdm
2d0fd341a3
Fix broken yarn pnp (#32867)
x-ref [#31552 ](https://github.com/vercel/next.js/issues/31552)
x-ref https://github.com/vercel/next.js/issues/32115
x-ref https://github.com/vercel/next.js/issues/32546
x-ref https://github.com/vercel/next.js/issues/32721

Since this PR https://github.com/vercel/next.js/pull/31455 is merged, `enhanced-resolve` dependency's resolved field is changed which caused broken yarn pnp.
I am not sure how this field has been changed or this is intentional or not 
When I install webpack locally, `enhanced-resolve`'s resolved field in lock file is always `registry.yarnpkg.com` not `codeload.github.com`

## Bug

- [x] 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`


Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-11 19:46:18 +00:00
Tobias Koppers
9836429bee
drop dynamic import with ssr: false on server-side (#32606) 2022-01-11 14:46:28 +01:00
Fatih Kalifa
600f113358
next-swc: fix ssg code elimination when used in render (#32709)
* next-swc: fix ssg code elimination when used in render

* simplify logic and add more thorough tests

* comment

* remove fold_export_default and fix JSX member expression
2022-01-11 14:02:24 +01:00
JJ Kasper
3eabb7f4c7
v12.0.8-canary.20 2022-01-10 14:59:41 -06:00
Gal Schlezinger
4aa9879dcc
Allow dependencies to use environment variables in middlewares (#33141)
After discussing with @sokra, seems that the proposed solution is split in two:

* We need to make sure that the `process` polyfill uses `global.process` if available. This is because middlewares are bundled using `browser` target and therefore `process.env.MY_ENV` gets shimmed into `require('process').env.MY_ENV`.

* Allow `process.env` to be statically analyzed for dependencies so they will be exported to the manifest.

Related issues:

* should fix #33043.
2022-01-10 18:45:00 +00:00
Tobias Koppers
f0ad19aef6
use a separate webpack runtime for middleware (#33134)
it should not leak into the client runtime

cc @javivelasco 



## 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`
2022-01-10 17:41:53 +00:00
Donny/강동윤
87dbd03eb0
Update swc (#33063) 2022-01-10 11:37:32 +01:00
David Babel
320986a2b8
Update next.config.js (#33091)
## Feature

We are in a Typescript context, but the `next.config.js` cannot be parsed as is, since it fails on `File is a CommonJS module; it may be converted to an ES module.ts(80001)` so it does not parse the rest of the file :


![image](https://user-images.githubusercontent.com/5599375/148612812-de50b5d9-609e-4273-9892-5b3a4ad0b282.png)

Here we should have an error because the type is not the expected one.

With a little trick, it's possible to enable the check by : 
- adding `// @ts-check` at first line
- moving the export at the end of the file

And then it works like a charm :

![image](https://user-images.githubusercontent.com/5599375/148612666-ae5350d8-f16e-45e0-84e4-b31faf07fcca.png)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-08 01:47:22 +00:00
JJ Kasper
aeb67cc28d
v12.0.8-canary.19 2022-01-06 11:09:32 -06:00
Simon Kirsten
6f5bfc1b40
Fix middleware at root in standalone mode (#33053)
Fixes [a small bug](https://github.com/vercel/next.js/pull/32967#issuecomment-1006277236) that caused the build to crash if a _middleware is present at the root of the project and standalone mode is enabled.
2022-01-06 16:20:43 +00:00
JJ Kasper
efabf81e23
Add util for generating new tests/error documents (#33001)
* Add util for generating new tests/error documents

* update compiled

* lint-fix

* apply suggestions

* update wording

* update compiled
2022-01-06 09:45:04 -06:00
Steven
62227ee9aa
Bump @vercel/nft to 0.17.2 (#33048)
This bumps `@vercel/nft` to the latest version and consequently bumps `graceful-fs` to the latest version.

- Fixes #33003
- Related to https://github.com/vercel/nft/pull/258
- Related to https://github.com/browserify/resolve/issues/264

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-06 00:01:37 +00:00
JJ Kasper
5680007fa2
v12.0.8-canary.18 2022-01-05 13:49:39 -06:00
Balázs Orbán
626955d61c
fix: ensure revalidation error is logged from response-cache (#32657)
Something [between `11.0.2-canary.5` and `11.0.2-canary.6`](https://github.com/vercel/next.js/compare/v11.0.2-canary.5...v11.0.2-canary.6) changed the behavior that logged any runtime errors in `getStaticProps` to stderr. This is only observable if `getStaticProps` has a `revalidate` value, and the build did not fail. The error has to happen in a subsequent revalidation step.


This PR reverts the change and fixes #30375.

## 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`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-01-05 19:40:04 +00:00
JJ Kasper
1ee13baf00
Ensure NODE_ENV is not inlined for next/jest (#33032) 2022-01-05 09:22:22 -06:00
JJ Kasper
cfa8ab9cbf
v12.0.8-canary.17 2022-01-04 15:29:37 -06:00
Balázs Orbán
3ad2035ae6
feat(cli): introduce next info CLI command (#32972)
This PR adds a new command to the `next` CLI.

Running `next info` will print useful information to the terminal about how/where Next.js is run. This information can be added to the Bug report when opening an issue in the repository.

This makes reporting issues more accurate and doesn't require the user to guess certain details, the command will retrieve it on their behalf.

Example output:

```sh
$ npx --no-install next info

    Operating System:
      Platform: linux
      Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021
    Binaries:
      Node: 16.13.0
      npm: 8.1.0
      Yarn: 1.22.17
      pnpm: 6.24.2
    Relevant packages:
      next: 12.0.8-canary.14
      react: 17.0.2
      react-dom: 17.0.2


```

The idea is based on #32858

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [x] 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`


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-01-04 15:35:32 +00:00
JJ Kasper
69a56759ee
v12.0.8-canary.16 2022-01-03 18:58:27 -06:00
Steven
6f10d94d90
Revert "Reduce install size for linux glibc/musl (#32850)" (#32973)
This reverts commit a5fab84840.

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-01-03 18:47:48 -06:00