Commit graph

12216 commits

Author SHA1 Message Date
OJ Kwon
58b920d5ba
feat(next-swc/wasm): export async interfaces (#39231)
* build(cargo): update dependencies

* feat(next-swc/wasm): export async interfaces

* feat(next/swc): use async wasm binding interface

* refactor(next/swc): allow to fallback for non-async published pkg

* Apply suggestions from code review

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-03 20:55:02 -05:00
JJ Kasper
de41597bc8
Fix next/server being required during build (#39310) 2022-08-03 20:18:35 -05:00
Ikko Ashimine
11c9d42643
chore(trace): fix typo in trace-to-event-format.mjs (#39279)
arbitary -> arbitrary
2022-08-03 18:20:52 -05:00
Jiachi Liu
1039dd4602
Enable concurrent mode by default in app-render (#39307) 2022-08-04 00:36:57 +02:00
JJ Kasper
ad687c9304
v12.2.4-canary.11 2022-08-03 16:15:59 -05:00
JJ Kasper
2722876eb5
Add delay before exiting tests for log flushing (#39302) 2022-08-03 15:48:17 -05:00
JJ Kasper
699564b226
Update Android NDK path for swc builds (#39298)
* Update Android NDK path for swc builds

* add debug log

* update paths

* update

* re-add isRelease checks

* update strip util path

* double check

* Revert "double check"
2022-08-03 15:38:09 -05:00
Sukka
45ae757ff5
feat(config): implement a human readable ajv errors (#39291) 2022-08-03 15:12:16 -05:00
Alex Castle
2f49a4f930
Remove default setting for object-fit on future fill images (#39297)
This PR removes the default styling of `object-fit:"contain"` for images using the future image component. This means images will get the default `object-fit` behavior of `"fill"`.

The main reason for this change is that an inline style will take precedence over external CSS, making this default behavior difficult to override with some styling strategies.


Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-08-03 19:22:27 +00:00
hiro
498d1e939a
fix typo: docs/advanced-features/react-18/streaming.md (#39293)
fix typo document.
2022-08-03 18:18:25 +00:00
Jiachi Liu
fc8e0242fb
chore: rename typo middlewares to interceptors in hot reloader (#39292)
rename `middlewares` (typo, shouldn't have ending **s**) to `interceptors` to distinguish from middleware
2022-08-03 17:23:01 +00:00
Josh Parnham
a1895424c5
[docs] Clarify polyfill support (#39272)
Currently next.js polyfills a [subset](https://github.com/vercel/next.js/blob/canary/packages/next-polyfill-nomodule/src/index.js) of APIs for `nomodule` browsers (such as IE 11), however it's not immediately clear to developers which APIs are transparently polyfilled.

For example, currently `Object.entries` is polyfilled and thus is usable in IE 11, but [it was decided](https://github.com/vercel/next.js/pull/15772#discussion_r463984612) that `Object.fromEntries` should not be polyfilled. As a developer, this is a confusing situation until you end up finding the `next-polyfill-nomodule` list of polyfills that are included.

This PR attempts to improve the Supported Browser Features page by:
- linking to the list of polyfills
- clarifying that custom polyfills are required for IE11 (and other old browser) compatibility
- moving the section on Sever-Side polyfills further down the page so all browser polyfill sections are better grouped together

## 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.md#adding-examples)
2022-08-03 16:26:52 +00:00
Jiachi Liu
4d0783d9be
Flush styles effects (#39268)
Use flush effects to custom apply css-in-js solution to app. Re-introduce flush effects to app-render, and remove default support of styled-jsx in `app/`. So that users will choose their own css-in-js solution if they need any customization. styled-jsx won't appear in client bundle if you didn't use it.

For now we have to inject the initial styles before `</head>` to avoid hydration errors. Later on we can remove this once react can handle it.

- [x] inject styles before end of head element
- [x] add tests
2022-08-03 16:21:20 +00:00
JJ Kasper
b7efce6437
v12.2.4-canary.10 2022-08-03 10:54:33 -05:00
JJ Kasper
41ffe97f6b
Fix URLPattern next/server export on deploy (#39290) 2022-08-03 10:13:58 -05:00
Steven
213c42f446
Add section about migrating from next/image to next/future/image (#39270)
This expands on the previous PR #38978 with a section on migrating
2022-08-02 23:23:10 +00:00
Duc Tran
b7997105a0
fix: use if...else in dockerfile (#39263)
* fix: use if-else in dockerfile

* fix: remove typo
2022-08-02 17:01:24 -05:00
JJ Kasper
cd3e054f14
Ensure middleware has single data fetch on query hydration with valid props (#39210)
* Ensure middleware has single data fetch on query hydration with valid props

* re-add check

* fix redirect case
2022-08-01 21:39:58 -05:00
Colin McDonnell
c4e8d7d7a3
Update edgedb.toml (#39243)
Update `with-edgedb` to use `2.0`.
2022-08-02 02:31:04 +00:00
Matt DuLeone
0e5a0ec4e0
Clear up rewrites documentation (#39238)
## Documentation / Examples

This PR specifically calls out in more clear language how the rewrites function behaves. This tripped me up recently as I recently came looking for more information, and the documentation left me with more questions than answers. This is an attempt to clear up the confusion I walked away with for anyone who comes in after me.

- [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.md#adding-examples)
2022-08-02 02:18:21 +00:00
Gal Schlezinger
e3181c2d77
Export URLPattern from next/server (#39219)
This commit allows the users to import URLPattern from `next/server`,
by defining a key that uses `global.URLPattern`.

Why is this any good? or: why don't we add URLPattern to the global namespace?

URLPattern is exposed as global on Edge Runtime _only_. This means that if we define a
constructor in global namespace in our TypeScript definitions, people might
have runtime errors in their Node.js functions.

Importing from `next/server` enables users to get the constructor without
risking in runtime errors and wrong type definitions.

Keep in mind, that with the current implementation, we do not check if the
constructor actually exists, but `next/server` shouldn't be imported in
Node.js functions, AFAIK.

## Related

- Fixes #38131

## Bug

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-08-02 02:04:08 +00:00
JJ Kasper
ad75204b34
v12.2.4-canary.9 2022-08-01 17:51:35 -05:00
JJ Kasper
7c0a504a16
Handle assetPrefix in app (#39236)
This ensures we properly leverage the `assetPrefix` for `app`. Note for reviewing the test changes are mostly spacing so hiding that may help. 

## Bug

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

Fixes: [slack thread](https://vercel.slack.com/archives/C035J346QQL/p1659387244559979)
2022-08-01 22:34:23 +00:00
Steven
d56aadae5b
Update tests to use random directory (#39230)
This PR fixes an issue where tests fail because the generated tmp directory already exists. This is likely caused from two tmp dirs being generated in the same millisecond.

```
Failed to create next instance [Error: EEXIST: file already exists, mkdir '/tmp/next-repo-1659368089063/packages'] {
  errno: -17,
  code: 'EEXIST',
  syscall: 'mkdir',
  path: '/tmp/next-repo-1659368089063/packages'
}
```

https://github.com/vercel/next.js/runs/7615808051?check_suite_focus=true
2022-08-01 19:05:48 +00:00
Alex Castle
cbaaaeb076
Add "fill" mode to next/future/image (#38855)
This PR adds a `fill` attribute to the future image component, that behave similarly to the fill mode on the existing image component.

Functionally, it mainly adds `position: "absolute"` and `object-fit: "contain"` to the image element, along with `height: "100%"` and `width: "100%"` to preserve the image aspect ratio. All of these can be overwritten by the user, except for `position: "absolute"`, which will throw an error. This is because changing that property without height and width is likely to cause layout shift.

Because we no longer have the wrapper element, this new version of `fill` requires that the user set `overflow: "hidden"` on the parent element themself, if they want that behavior.

This PR also includes several runtime checks to catch instances where the fill mode may provide unexpected results. These runtime checks warn if:
* The image doesn't have the `sizes` attribute and loads much smaller than the viewport
* The containing element does not have `position: "relative"`
* The image height value is 0

Co-authored-by: Steven <229881+styfle@users.noreply.github.com>
2022-08-01 18:21:36 +00:00
Jiachi Liu
e9d23d709c
fix: react dev bundle is picked in prod mode (#39221)
When we detect if `reactRoot` rendering should be enabled we `require` the require to check the version. But at that time the `NODE_ENV` isn't set yet. Then the react dev build stays in the `require.cache` that any future require of react will get the wrong build. In that case, React dev bundle is picked in production mode.

Fun fact: if you're using hooks, that seem not to effect you, but context consumer works different then you couldn't get the proper context from provider.

Fixes #38176
Fixes #38765
Fixes #38332

## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-01 14:21:42 +00:00
Jiachi Liu
582cb3766d
Fix: only contain middleware in dev middleware manifest (#39217)
x-ref #39199

The change in #39199 isn't correct. Middleware manifest should only contain middleware route, so that when router navigates, it only try to apply middleware instead of checking all edge routes. This PR also changes the middleware manifest global value from array to object for easier access

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-08-01 13:23:24 +00:00
NikhilNama18
f0df2c274d
Replaces getStaticProps with getStaticPaths (#39218)
In `Generating paths on-demand` section 
It was mentioned that `getStaticProps` allows you to control which pages are generated during the build. 
But `getStaticPaths` will allows us to control which pages are generated during the build.



## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-08-01 12:48:06 +00:00
John Daly
0c734543a6
examples/with-msw-typescript (#39196)
## Documentation / Examples

Updating the `with-msw` example to use TypeScript

- [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.md#adding-examples)
2022-07-31 15:54:30 +00:00
Santi Dalmasso
de6fc1cf35
fix: Update testing.md (#39195)
Update `e2e/example.spec.ts` ([/docs/testing](https://nextjs.org/docs/testing#creating-your-first-playwright-end-to-end-test) page) to fix the failed test. Fixes: #39194
## 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
- [X]  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 pnpm lint
- [ ]  The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md?rgh-link-date=2022-07-13T09%3A09%3A13Z#adding-examples)
2022-07-31 15:30:38 +00:00
Jiachi Liu
e42c88d8a9
Fix missing edge routes in dev middleware manifest (#39199)
## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-07-31 15:20:32 +00:00
Jessica Franco
97ab23fb6f
Add missing @napi-rs/cli devDependency to next-swc (#39164)
Otherwise build-native fails with "napi: command not found.".

Alternatively, this is missing from this package's devDependencies.



## 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.md#adding-examples)

P.S.: local copy fails `pnpm lint` due to the `target` subfolder with intermediate rust build artifacts... should I add a `.prettierignore` update to exclude `/packages/next-swc/target/`?

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-30 22:08:50 +00:00
Jiachi Liu
9a1b756def
refactor: simplify middleware execution (#39192)
* refactor: simplify middleware execution

* remove ssr prop from RoutingItem

* fix build
2022-07-30 16:45:58 -05:00
Severin Ibarluzea
dce8c0ce9d
fix(#11930): rewritten api routes can correctly handle cors in dev mode (#38937)
* fix(#11930): rewritten api routes can correctly handle cors in dev mode

* test that request matches hot reloader middleware instead of api https://github.com/vercel/next.js/pull/38937#pullrequestreview-1055957698

* remove unnecessary imports

* remove unused constant

* remove api route import
2022-07-29 21:39:43 -05:00
Jiachi Liu
960693b920
refactor: return single middleware from getMiddleware in dev server (#39177)
Previous next versions supported nested version of middleware, now we simplify it to one global middleware. This PR clarify the middleware and edge functions usage in dev server
2022-07-29 23:37:59 +00:00
Baris Sayil
801acad17a
Fix typo in with-docker-compose README (#39176)
- [x] Simply fix a typo.
2022-07-29 20:00:18 +00:00
JJ Kasper
9fed522c42
Fix default error style overrides (#39169) 2022-07-29 13:09:41 -05:00
JJ Kasper
860c0281b1
Add exportPathMap config type/schema field (#39171) 2022-07-29 12:59:00 -05:00
Jiachi Liu
b1a5821ee0
Add shared dynamic api (#39163)
Add `next/dist/client/components/shared/dynamic` as shared api which server and client components can both support. 
Dynamic imports will be part of flight on server side.
This pr doesn't contain preloading part for client components.
2022-07-29 11:03:05 +00:00
JJ Kasper
48405e6bd7
v12.2.4-canary.8 2022-07-28 23:34:07 -05:00
JJ Kasper
d12272a6fa
Fix incorrect component cache for middleware cases (#39159) 2022-07-28 23:33:17 -05:00
Donny/강동윤
eb0e161f2e
Update swc minifier (#39158)
This PR applies

 - https://github.com/swc-project/swc/pull/5333
   - Closes https://github.com/vercel/next.js/issues/39090
2022-07-29 03:26:28 +00:00
JJ Kasper
cf729edc9d
Add caveat note about shallow routing with middleware (#39154) 2022-07-28 21:28:34 -05:00
JJ Kasper
d091c818c5
v12.2.4-canary.7 2022-07-28 20:24:34 -05:00
JJ Kasper
a154c15799
Fix middleware + afterFiles SSG rewrite case (#39153) 2022-07-28 20:23:18 -05:00
Tim Neutkens
c567d7d2da
Refactor Flight plugins to use types. (#39136)
Cleans up both Flight plugins and leverages type inference more.
- Rename plugin
- Update name
- Remove note on webpack5
- Add types for Flight manifest
- Use webpack5 type and tapPromise
- Remove any



## 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 `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-28 22:35:52 +00:00
JJ Kasper
a08415be32
v12.2.4-canary.6 2022-07-28 16:03:26 -05:00
JJ Kasper
e3efc030cd
Ensure we hard navigate for failed _next/data with middleware (#39148)
* Ensure we hard navigate for failed _next/data with middleware

* fix-lint
2022-07-28 15:48:26 -05:00
Houssein Djirdeh
a8186065b8
[Script] Adds onReady prop to next/script (#38849)
Closes: #30962

This PR adds a new `onReady` prop to `next/script` to handle shortcomings of the current `onLoad` prop. Some third-party providers and widgets require initialization code to run after the script's `load` event and every time the component is mounted. The `onReady` should solve that use case.

For more details, refer to the discussion in #30962.

CC @janicklas-ralph

## Bug

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


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-07-28 20:42:52 +00:00
Keen Yee Liau
85b00b2cca
Collect telemetry for next/future/image (#39046)
* test: cleanup telemetry integration test

Instead of constantly parsing the console output, parse the output
once, convert the entries in JavaScript objects, then compare them
logically rather than textually.

* Collect telemetry for next/future/image

Track adoption of next/future/image and add relevant test.
2022-07-28 15:03:24 -05:00