Commit graph

960 commits

Author SHA1 Message Date
Shu Ding
5ddee4494b
Add new target for middleware (#30299)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-10-26 18:50:56 +02:00
Tim Neutkens
08a7f7f31a
Enable SWC by default when there is no custom Babel config (#29811)
Co-authored-by: Tobias Koppers <tobias.koppers@googlemail.com>
Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
Co-authored-by: Maia Teegarden <dev@padmaia.rocks>
Co-authored-by: padmaia <padmaia@users.noreply.github.com>
2021-10-23 10:21:44 +02:00
JJ Kasper
3274efc398
Update to latest caniuse-lite version (#30194) 2021-10-22 20:36:33 -05:00
Tim Neutkens
7e370134fb
Use import() to load next.config.js (#29935)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Steven <steven@ceriously.com>
2021-10-16 14:22:42 +02:00
Steven
fdb2cc80b1
Bump "engines" to node >= 12.22.0 (#29949)
Older versions of Node.js don't have a stable ESM implementation

https://nodejs.org/api/esm.html#esm_modules_ecmascript_modules
2021-10-15 20:55:14 +00:00
Tim Neutkens
aa8a885599
Remove webpack 4 support (#29660)
Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
2021-10-06 17:40:01 +02:00
Tobias Koppers
4f212ee91d
the way towards webpack 5 typings (#29105)
Co-authored-by: sokra <sokra@users.noreply.github.com>
2021-09-21 19:17:16 +02:00
JJ Kasper
8e52126ea6
Migrate prerender tests to new set-up (#29245) 2021-09-21 16:21:05 +02:00
JJ Kasper
7a7cb91e80
Update swc dependencies (#29151)
Updates to the latest `@swc/core` and `@swc/jest` versions that we use for running tests with jest.
2021-09-16 19:34:33 +00:00
Tobias Koppers
d78bb6fe46
upgrade to typescript 4.4.3 (#29112)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-16 18:06:57 +02:00
Tim Neutkens
c1e5f5b260
Make traces in development reliable (#28990)
Co-authored-by: Jiachi Liu <inbox@huozhi.im>
2021-09-13 15:49:29 +02:00
JJ Kasper
a92a5caec2
Update test set-up to leverage playwright when able to (#28634)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-13 14:36:25 +02:00
강동윤
a84389591d
Update swc (#28946)
## 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



I updated rust dependencies and node dependencies.
2021-09-09 09:30:22 +00:00
Adrien HARNAY
2abc4f2d6a
Support node-sass@6 (#28710)
* support node-sass@6

* bump sass-loader

* Update precompiled

Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-09-09 11:00:19 +02:00
Tim Neutkens
9a56fdba82
Use consistent postcss version for all transforms (#28529)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-09-02 08:45:35 +02:00
Hunter Tunnicliff
877f982924
Use recommended pattern in testing example (#28404)
* Use recommended pattern in testing example

Since the official linter for testing library, `eslint-plugin-testing-library` recommends using `screen` to write queries, this MR updates the testing library example to follow the pattern recommended by the linter.

> DOM Testing Library (and other Testing Library frameworks built on top of it) exports a screen object which has every query (and a debug method). This works better with autocomplete and makes each test a little simpler to write and maintain.

> This rule aims to force writing tests using built-in queries directly from screen object rather than destructuring them from render result. Given the screen component does not expose utility methods such as rerender() or the container property, it is correct to use the render returned value in those scenarios.

See the `prefer-screen-queries` rules docs for more info: https://github.com/testing-library/eslint-plugin-testing-library/blob/main/docs/rules/prefer-screen-queries.md

* Update devDependencies

* Install and configure test linting

* Use recommended pattern in test

* Update test names for consistency

* Update docs

* Set jest environment in each file

* Use root true in `with-jest` eslint config

* Ensure nested .eslintrcs are not loaded for repo lint

Co-authored-by: jj@jjsweb.site <jj@jjsweb.site>
2021-08-25 12:33:57 -05:00
JJ Kasper
005b13f1ac
Move unit tests to one folder and migrate them to TypeScript (#28427)
* Move unit tests to one folder

* Migrate unit tests to TypeScript

* add test types to lint

* Ensure ts(x) tests are run with util

* Add tsx extension to jest config

* bump
2021-08-24 07:52:45 -05:00
JJ Kasper
ece79a4e00
Update test config to leverage swc (#28400)
This updates our `jest` configuration to no longer use `babel-jest` and instead uses `@swc/jest` which is much faster. This also updates to the latest version of `jest`, fixes our `tsconfig.json` used for tests (previously types in `node_modules` weren't resolved correctly), and ensures `next/dist` isn't un-necessarily transpiled in `jest`. 

Timings for `yarn testheadless test/unit/` on CI
- before: 3m 30s - 4m ([example run](https://github.com/vercel/next.js/runs/3394701995))
- after: under 1m ([example run](https://github.com/vercel/next.js/pull/28400/checks?check_run_id=3395161621))

Timings for `yarn testheadless test/unit/` locally on m1 mac 
- before: 90.16 seconds
- after: 29.92 seconds
2021-08-23 18:36:56 +00:00
Jesse Jafa
8737ac08fc
feat: upgrade swc/core to 1.2.80 (#28347)
* feat: upgrade swc/core to 1.2.80

* fix: add lock file
2021-08-20 14:54:21 -05:00
Tim Neutkens
2b7d4619ed
Improve jaeger traces (#28168)
Co-authored-by: Harsh Karande <harshskarande@gmail.com>
2021-08-17 09:18:47 +02:00
JJ Kasper
5544adc481
Update to latest babel versions (#28174) 2021-08-17 09:18:08 +02:00
C. Lewis
c9ff4c7989
feat(package.json): add contributor-friendly lifecycle scripts (#27825)
## Feature

I was struggling to get my local dev build working as a local package.json override, and types do not seem to be generated by `yarn dev`, so I had to figure out a cohesive way to build the project start-to-finish (and also clean the project).

Building the project and all types ended up just being `yarn prepublish`, here aliased as `yarn build`, and I added a `yarn clean` script. These two together should make it very difficult for any contributor to be confused how to generate a final build including all type declarations.

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

b2a888c144/contributing.md (building)
2021-08-09 16:21:16 +00:00
JJ Kasper
b24cd1eaba
Use @vercel/fetch for run-tests requests (#27815)
* Use @vercel/fetch for run-tests requests

* update precompileld
2021-08-06 10:20:05 -05:00
Tim Neutkens
d2f43b718f
Add experimental SWC minify and SWC loader options (#27664) 2021-08-06 16:07:36 +02:00
Alex Castle
1b733423d6
Use Sharp if available for Image Optimization (#27346)
* Use sharp for image transformations when available

* Refactor resizeImage and add sharp warning

* only show sharp warning once per instance

* Modify sharp error message

* Add documentation for optional sharp dependency

* Update docs/basic-features/image-optimization.md

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

* Import types for sharp

* Update lockfile

* Add testing against sharp

* use fs-extra for node 12

* Rename test sharp path variable

* Apply suggestions from code review

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

* update squoosh specific test

* Apply suggestions from code review

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

* update tests

* Apply suggestions from code review

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

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2021-07-22 18:11:17 -05:00
Jiachi Liu
41b4fc3688
Upgrade swc for mac m1 compiling issue (#27329)
`@swc/core` will trigger a very rare complication issue on mac m1, it's fixed in version 1.2.66
x-ref: https://github.com/swc-project/swc/pull/1939

cc @kdy1 

## 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
2021-07-20 11:53:48 +00:00
Houssein Djirdeh
6645248d41
[ESLint] Remove error when file patterns are unmatched + ESLint setup changes (#27119)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
2021-07-16 20:19:08 +02:00
Tim Neutkens
fdabeb7098
Use SWC to compile Next.js core server files (#27167)
- Use SWC to compile Next.js core server files
- Ensure only @babel/runtime/helpers/interopRequireDefault helper is used

Just an initial comparison to compare size difference of this change.



## 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
2021-07-14 18:12:04 +00:00
Steven
acd0fabf83
Update publish-canary script to include checkout (#26840)
* Update `publish-canary` script to include checkout

* Update contrib with publishing section
2021-07-01 17:19:14 -05:00
JJ Kasper
612889dfeb
Update repo scripts to separate folder (#26787) 2021-07-01 13:41:27 +02:00
Jiachi Liu
ddc0e793fc
Support new hydrate API in latest react 18 alpha release (#26664)
* fix: react 18 new hydration API

* support react 18

* compat latest react only, fix resolved version

* fix tests

* Some changes based on https://github.com/reactwg/react-18/discussions/5

* fix test

Co-authored-by: Tim Neutkens <timneutkens@me.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-06-30 17:03:32 +02:00
Peter Mekhaeil
005a6e4c85
chore: Add Alex to lint documentation (#26354)
This Pull Request adds [Alex](https://alexjs.com/) to our documentation. It catches insensitive, inconsiderate writing. 

The original PR (https://github.com/vercel/next.js/pull/25821) is too large so I have decided to break it down into smaller PRs. This PR is the first part. Then I will continue to add the rest of the documentation in smaller PRs.

## More Information on Alex:
https://alexjs.com/
https://github.com/get-alex/alex

## Documentation / Examples

- [x] Make sure the linting passes
2021-06-22 16:03:12 +00:00
Tim Neutkens
88ed5269b5
Add runtime to hotUpdateMainFilename (#26256)
Updates the hotUpdateChunk to include `[runtime]` for web workers support.

Fixes #26152
Fixes #19865
Fixes #26144

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-06-18 17:12:20 +00:00
Steven
c35b01a631
Omit svg static imports if custom webpack config is defined (#26281)
This PR does a couple things:

1. Omit svg static imports if the user has defined custom webpack config with svg rule
2. Change TS type to `any` for svg imports to avoid conflicts with other plugins

The idea is that some users want to use `next/image` with static imports for most image types but not for svg and instead inline those images with a plugin.

- Fixes #25950  
- Fixes #26130 
- Fixes #26176 
- Fixes #26196 
- Fixes #26067 


## Bug

- [x] Related issues linked using Fixes #26130 
- [x] Integration tests added
2021-06-18 00:40:22 +00:00
JJ Kasper
76f0b3585f
Update to latest TypeScript version and de-dupe versions (#26285)
* Update to latest TypeScript version and de-dupe versions

* Update version test
2021-06-17 17:43:25 -05:00
Gerald Monaco
a09425f66a
Bump minimum React version to ^17.0.2 (#25788) 2021-06-07 13:11:50 +02:00
Steven
3ae27a87e3
Bump "engines" to node >= 12.0.0 (#25761)
* Bump "engines" to node >= 12.0.0

* Bump next-stats-action

* Rename azure groups
2021-06-03 17:21:16 -05:00
Steven
d836ebb248
Update yarn next script with --enable-source-maps (#25533) 2021-05-28 14:48:32 +02:00
Alexander Kachkaev
e5da204aab
Upgrade browserslist to 4.16.6 (#24692)
## Bug

- [x] Related issue: [CVE-2021-23364](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-23364)
- ~Integration tests added~ (N/A)
2021-05-16 18:30:02 +00:00
JJ Kasper
e6a05ee940
Fix export worker threads options (#25063)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-14 12:50:29 +02:00
Tobias Koppers
4e8fac93fd
cache typechecking with incremental compilation (#24559)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2021-05-07 19:21:20 +02:00
Tim Neutkens
cf4ba8d705
Upgrade eslint to the latest version (#24377)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

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

## Documentation / Examples

- [ ] Make sure the linting passes
2021-04-25 18:34:36 +00:00
Shu Ding
1bf4cf3e76
Upgrade jest-worker (#23077)
This PR upgrades `jest-worker` and `jest-cli` to the latest pre-release version, also removed `jest-circus` which is included in Jest by default. `jest-worker@next` includes a fix for memory leak that we need (https://github.com/facebook/jest/pull/11187). 

Fixes #22925. This will also improve the OOM issue for `next dev` #15855.
2021-03-16 21:08:35 +00:00
Dale Bustad
e27b7e996d
Telemetry-compatible tracing (#22713)
A number of changes here.  I recommend viewing the diff with the <a href="?w=1">whitespace flag enabled</a>.

- OpenTelemetry is replaced with a custom and lightweight tracing solution.
- Three trace targets are currently supported: console, Zipkin, and NextJS.
- Tracing is now governed by environment variables rather than `--require instrument.js`.
  + `TRACE_TARGET`: one of `CONSOLE`, `ZIPKIN`, or `TELEMETRY`; defaults to `TELEMETRY` if unset or invalid.
  + `TRACE_ID`: an 8-byte hex-encoded value used as the Zipkin trace ID; if not provided, this value will be randomly generated and passed down to subprocesses.

Other sundry:

- I'm missing something, probably a setup step, with the Zipkin target.  Traces are captured successfully, but you have to manually enter the Trace ID in order to view the trace - it doesn't show up in queries.
- I'm generally unhappy with [this commit](235cedcb3e).  It is... untidy to provide a telemetry object via `setGlobal`, but I don't have a ready alternative.  Is `distDir` strictly required when creating a new Telemetry object?  I didn't dig too deep here.

As noted, there are a lot of changes, so it'd be great if a reviewer could:

- [ ] pull down the branch and try to break it
- [ ] check the Zipkin traces and identify possible regressions in the functionality

Closes #22570
Fixes #22574
2021-03-10 21:00:20 +00:00
Joe Haddad
99a4ea6e9a
feat(next/image): remove sharp for wasm variant (#22253)
This pull request removes the native `sharp` dependency (which doesn't work on some Linux variants, nor **M1 Mac**) and replaces it with a wasm equivalent.

It also reduces Next.js' installed size by 27.3 MB.

The code is adapted from the [Squoosh CLI](https://github.com/GoogleChromeLabs/squoosh).

This PR still supports:

- Rotation normalization
- Resizing
- PNG
- JPEG
- Webp

However, it (temporarily) removes support for:
- Resizing Gifs
- Resizing Tiff

(these formats still get served and rendered correctly by the image component)

---

Fixes #20456
Closes #20738
Closes #21762
2021-02-18 10:23:24 +00:00
matamatanot
b3aa1d14ff
Upgrade to lerna 4 (#22039)
Co-authored-by: Tim Neutkens <timneutkens@me.com>
2021-02-12 13:34:25 +01:00
Joe Haddad
5f41abda9a
fix(link): cancel idle callback on unmount (#22072)
Co-authored-by: mAAdhaTTah <jamesorodig@gmail.com>
2021-02-11 13:51:41 -05:00
Tim Neutkens
6b99bda3e3
Fix profiling plugin for next build (#21989)
Makes sure `yarn trace build` works.
2021-02-09 23:21:38 +00:00
Tim Neutkens
379ad1b302
Rename package build scripts to dev (#21743)
The top-level script has always been `dev` so this makes the package scripts consistent
2021-02-03 17:02:44 +00:00
Joe Haddad
75c504708b
fix: upgrade pinned deps for tests (#21515) 2021-01-25 12:08:08 -05:00