Commit graph

1376 commits

Author SHA1 Message Date
Jan Karres
3b3d20f729 Check if 'formatAmpMessages' returns a none empty string in Next.js build process (#8924) 2019-10-29 23:49:40 -04:00
Jason Miller
5f203b8342 Improve serverless build performance (#9155)
* Improve serverless build performance

Next's serverless build uses a custom resolver, injected the via Webpack's `externals` option that delegates out to `resolve-request` to more aggressively pull node modules into the serverless bundles.

When profiling a large Next.js application, I noticed an excessive number of filesystem calls near the end of the build. I narrowed this down to the serverless compiler pass, and eventually the custom resolver function that is the subject of this PR.  As it turns out, around half of the calls to the `externals` custom resolver function are for a `request` path that is a relative import. Next doesn't have any specific logic to apply to relative imports - it only needs to special-case bare module resolution.

Adding a simple bypass for relative module resolution reduces the number of blocking filesystem-bound `resolveRequest()` calls by 50% on a certain well-known Next.js website. This also results in a 30% reduction in production build times for incremental builds.

* Explain more in the comment
2019-10-29 23:36:22 -04:00
Christoph Tavan
17d7544f45 Remove concurrency option from next export (#9197)
Usage of this option was removed in
61b8b7323e but the cli was not updated.
2019-10-29 23:07:42 -04:00
JJ Kasper
c4bef164ce Add unique identifier to router instance (#9015)
* Update to use a historyId to track invalid popstates

* Remove log from debugging

* Use Math.random instead of Date.getTime to avoid mocks
2019-10-29 22:50:16 -04:00
Janicklas Ralph
d3293f7cd6 Dynamic granular chunking (#9090)
* Enable granular chunks config for all chunk types

Adding comment

Bug fix

* Update index.test.js

* Update index.test.js

* Fix test cases. Adding next/link to not trigger a different bug

* Removing obsolete comment
2019-10-29 21:27:41 -04:00
Joe Haddad
acf7d0ad3b
v9.1.2 2019-10-29 16:56:45 -04:00
Joe Haddad
cb7a184cd9
v9.1.2-canary.10 2019-10-29 11:14:39 -04:00
Joe Haddad
4dbd267c6a
Split TypeScript Flag Docs (#9231)
* Split TypeScript Flag Docs

* reword
2019-10-28 22:44:10 -04:00
Christoph Tavan
14ed867537 Disable worker_threads by default for firebase compatibility (#9199)
* Pass config.experimental.cpus to export during build

Currently, there is no way of specifying the number of worker threads of
`next export` when run as part of `next build`.

I suggest a sane default should be to just use the same amount of
workers that were used during the build process which currently seems to
be configured through `config.experimental.cpus`.

This setting is already respected in the two other places where
jest-workers are in use: The TerserPlugin and the staticCheckWorkers in
`next build`.

* Only enable worker threads if there is more than 1 worker

Multiple worker threads can cause problems when certain dependencies are
being used, see e.g. https://github.com/zeit/next.js/issues/7894

This patch allows disabling of worker threads by setting
`config.experimental.cpus = 1`.

The benefit of spawning 1 worker thread, if there is any at all, should
very limited anyways, so the workload can just as well be processed in
the main thread.

* Disable parallel build for firebase authentication example

* Add integration test to cover #7894

* Rename test suite and add worker_threads config

* Disable worker_threads by default

* Update index.test.js

* Use workerThreads config for TerserPlugin

* Update to use workerThreads config in
TerserPlugin for consistency

* Disable node 12 specific test
2019-10-28 20:01:24 -04:00
Alexander Kachkaev
ad2a3d65fd Add configuration flags to disable integrated type checker (#9138)
* Add a configuration flag to disable integrated type checker

* Add tests for typescript-transpileonly

* Restore removed argument

* Make output more coherent

* Split transpileOnly into ignoreDevErrors and ignoreBuildErrors

* Minor stylistic change
2019-10-28 11:02:03 -07:00
JJ Kasper
2d9f199105 Add warning for getStaticParams without getStaticProps (#9226)
* Add warning for getStaticParams without getStaticProps

* Throw error instead of logging to make sure it's noticed

* Lower default concurrency for tests
2019-10-28 10:24:29 -07:00
Joe Haddad
34e0ce6f05
Remove react-ssr-prepass from Next Deps (#9224) 2019-10-28 06:49:07 -07:00
Jan Potoms
ab0a8647dc API: Take multiple values into account for the query (#9196)
* Take multiple values into account

* make typescript happy
2019-10-26 20:10:06 +02:00
Tim Neutkens
20978af0b0 v9.1.2-canary.9 2019-10-26 19:44:44 +02:00
htbvo
211c84e1c9 allow NextScript to optionally defer javascript (#8980)
* allow NextScript to optionally defer javascript

* move defer options to experimental feature

* combine defer flags into a single option

* Update deferScripts to work with serverless target

* Add test for defer and async property

* Read the async property

* Check versions of chrome and chromedriver

* Update to chromedriver 76

* Fix test
2019-10-26 19:27:22 +02:00
Tim Neutkens
2fcff3de49
Update Babel dependencies (#9203)
* Update Babel dependencies

* Update sizes
2019-10-26 15:59:15 +02:00
Christoph Tavan
e506c41e8c Ensure that all <link> elements have a key prop (#9204)
Before this patch users would see the following warning during initial
compilation:

```
Warning: Each child in a list should have a unique "key" prop. See https://fb.me/react-warning-keys for more information.
    in link
    in Head
    in html
    in Html
    in Document
    in Context.Provider
    in Context.Provider
```
2019-10-26 14:46:17 +02:00
Gerald Monaco
4421448f03 Add StrictMode toggle (#9161)
* Add StrictMode toggle

* Rename option to reactStrictMode

* Default to false initially
2019-10-26 00:20:38 +02:00
JJ Kasper
be42300e1f Ensure directory before flushing cache file (#9187)
* Ensure directory before flushing cache iSSG file

* Add test for prerender cache flush

* Nest the dynamic route test one more level

* update fetch for test

* Update error check
2019-10-25 13:56:00 -07:00
Miguel Ángel Durán
8227baf42c docs(api-routes): fix micro-cors example (#9184)
The correct option to use with `micro-cors` package is `allowMethods` instead `allowedMethods`. This PR fixes the example.
2019-10-23 17:14:51 -04:00
Joe Haddad
60ff5cc77e
v9.1.2-canary.8 2019-10-23 15:53:37 -04:00
JJ Kasper
d38da874cf Record src directory usage with version (#9023)
* Add tracking src dir usage to telemetry

* Move isSrcDir back to eventVersion

* Move spinner back

* Add test for isSrcDir telemetry

* Add test for dev mode
2019-10-22 22:42:16 -04:00
Joe Haddad
4328eea3a7
Add WSL to Metadata (#9171) 2019-10-22 21:13:18 -04:00
JJ Kasper
573fbff88a Add yarn check to tests (#9163)
* Add yarn check to tests

* Update yarn.lock

* Update lockfile some more

* Use resolutions to bump browserslist
2019-10-22 21:02:59 -04:00
Joe Haddad
b5d8767f44
Cache No-Revalidate Pages (#9170)
* Cache No-Revalidate Pages

* Specifically check for `false`
2019-10-22 20:40:33 -04:00
Joe Haddad
ae3410c3f3
Upgrade Lockfile (#9158)
* Upgrade Lockfile

* Fix types version mismatch

* Upgrade amphtml-validator

* Revert "Upgrade amphtml-validator"

This reverts commit 05068b2ad9f2f53429cf514b47b4f7924b0b9623.

* Disable AMP Tests

* Skip 2x more AMP tests
2019-10-22 11:42:43 -04:00
Joe Haddad
94c2c084ad
Upgrade React dependencies (#9152)
* Upgrade React dependencies

* Disable data tests

* Increase allowed default sizes
2019-10-21 14:27:21 -04:00
Joe Haddad
3a7603c44f
Update Prerender Error Message (#9143) 2019-10-20 18:11:29 -04:00
JJ Kasper
cd52fc9e91
v9.1.2-canary.7 2019-10-18 16:28:09 -05:00
Alex Castle
a82b5aed9b Update granular chunks to produce up to 25 chunks per entrypoint on high-complexity apps (#9129) 2019-10-18 13:36:03 -04:00
Joe Haddad
4d3cca3382
Warn on No Cache in CI (#9116)
* Warn on No Cache in CI

* Bold the note lead

* Add custom clarification for netlify

* Reorder

* Add tests

* Fix detection
2019-10-18 12:40:47 -04:00
Gerald Monaco
d28e46ac15 Support Concurrent Mode in Loadable (#9026) 2019-10-18 17:23:06 +02:00
Liran Cohen
b7efb3fffb Allow manually setting amphtml (#9098)
* allow to remove amphtml from desktop page

* only 1 link with amphtml rel

* clean up

* remove checkup for amphtml link

* Dedupe looping
2019-10-18 10:22:53 -05:00
JJ Kasper
499808fa2b
Make sure to update scope for page export declaration (#9115)
* Register page export declaration to scope

* Update to not need to traverse to update scope
2019-10-18 09:37:09 -05:00
Melanie Seltzer
c650ed9a2a Dedupe meta tags (#8960)
* Dedupe meta tag in favor of custom tag defined in _app

* Add test

* Fix comments
2019-10-18 01:40:54 -04:00
Joe Haddad
c5caa89209
v9.1.2-canary.6 2019-10-17 11:56:33 -04:00
JJ Kasper
31b2f51a03 Don't mark page as nextExport if it's SPR (#9113)
* Don't mark page as nextExport if it's SPR

* Add test for fetching prerender data after mount
2019-10-17 11:52:13 -04:00
Joe Haddad
4374e7c5d2
v9.1.2-canary.5 2019-10-16 17:38:17 -04:00
JJ Kasper
a3eb73240c Update to return JSON if data request (#9106)
* Update to return json if data request

* Update sending data

* Add test using serverless bundle directly

* Don't early return if fromExport
2019-10-16 17:24:28 -04:00
Joe Haddad
117d02359f
v9.1.2-canary.4 2019-10-16 14:56:32 -04:00
Joe Haddad
393af8e6b3
Fix SPR header name (#9104) 2019-10-16 14:54:07 -04:00
Gerald Monaco
beed775e55 Update legacy _app context (#9083) 2019-10-16 11:39:49 +02:00
Alex Castle
0886a1234d Optimize script tags (#9048)
* Update _document.tsx to optimize script loading

* Update maxInitialChunks to 15

* Undo change chunk count

* Adjust impl a bit

* Add CSS preload test

* Ensure build manifest not preloaded

* Correct file name

* break comment
2019-10-16 00:01:10 -04:00
JJ Kasper
d3cbb163be Fix SPR always revalidating in production (#9091)
* Add failing tests for SPR

* Fix SPR always revalidating in production

* Remove extra changes
2019-10-15 22:00:50 -04:00
Joe Haddad
07502ba2dd
v9.1.2-canary.3 2019-10-15 16:38:30 -04:00
Joe Haddad
0208356f67
Temporary: SPR: Use Group Index Mapping (#9089)
This pull request is a temporary addition that uses the `x-now-route-params` header in serverless.

This header returns the regex groups with indexes, not their named variants.
As a result, we must use the getRouteMatcher utility to reverse this into Next.js' expected names.

Since this got complex, I've added a test for it. We should probably remove this behavior sooner than later.
2019-10-15 16:30:10 -04:00
Joe Haddad
c77338bd31
Temporary: Add Support for Now Platform Headers (#9085) 2019-10-15 14:44:50 -04:00
Alex Castle
3263af513e Update framework chunk test regex to not select nested dependencies (#9012)
* Update framework chunk test regex to not select nested dependencies

* Update webpack-config.ts
2019-10-14 14:02:11 -04:00
Gerald Monaco
b2adfde983 Remove _document context (#9068) 2019-10-14 12:45:56 -04:00
Nishant Singh
09681cd597 [Docs] Update static file serving section (#9062)
This block seemed redundant 

```
To serve static files from the root directory you can add a folder called `public` and reference those files from the root, e.g: `/robots.txt`.
```

The block above this already mentions the same thing:
```
Create a folder called `public` in your project root directory. From your code you can then reference those files starting from the baseURL `/`
```

We could add the `robots.txt` eg to the first block itself if necessary
2019-10-13 19:18:10 +02:00