Commit graph

464 commits

Author SHA1 Message Date
Sebastian Silbermann
4c23bac3bb
fix: use latest experimental method names (#12669) 2020-05-10 11:29:26 +02:00
JJ Kasper
92edfb953d
Cont. Update performance relayer and remove unstable prefix (#12665)
* updates relayer, uses web-vital lib, removes fid polyfill and removes unstable prefix from relayer

* simplify logic, fix null check

* update docs

* Update tests

* Rename relayWebVitals to reportWebVitals

Co-authored-by: housseindjirdeh <houssein@google.com>
2020-05-09 21:48:52 +02:00
Joe Haddad
e173967b9f
[Fast Refresh] New Compile Error Overlay (#12543) 2020-05-05 23:46:07 -04:00
Joe Haddad
e0449a5b9c
[Fast Refresh] New Overlay for Prerender Error (#12485) 2020-05-04 17:16:03 -04:00
Wang Guan
0d4707d69c
next/client/link: improve internal type annotation (#12468) 2020-05-04 16:59:38 -04:00
Joe Haddad
fbea795ad9
[Fast Refresh] Redesigned Runtime Error Experience (#12222) 2020-04-30 10:50:25 -04:00
JJ Kasper
9b8a9dea12
Fix basePath not being applied for GS(S)P data routes (#12200) 2020-04-26 17:14:39 +02:00
Joe Haddad
bc845f2206
Stabilize HMR tests on CI (#12029) 2020-04-19 15:58:55 -04:00
Joe Haddad
450d4bd0f3
Experimental: React Refresh Support (#12008)
* Add Fast Refresh Support

* Add Basic Acceptance Test

* Increase delay

* fix version

* Ignore test files

* Update packages/next/build/webpack/loaders/next-babel-loader.js

* Copy tests

* Redo test style

* drop directory

* fix compile

* fix remove function

* Update helpers
2020-04-19 13:58:31 -04:00
Joe Haddad
09e38847ea
Update HMR Client Runtime (#11977)
* Update HMR Client Runtime

* Increment event when building or different state

* Dismiss Old Type-Only Overlay

* Update packages/next/client/dev/error-overlay/hot-dev-client.js
2020-04-17 15:24:45 -04:00
JJ Kasper
d3e308a79f
Add basePath in link component and add/remove it consistently (#9988)
* Add basePath in link component and add/remove it consistently

* Update to not use regex for delBasePath

* Expose addBasePath as router method

* Revert "Expose addBasePath as router method"

This reverts commit 40fed596195c6affabf837e42d472452768e13a3.

* Expose basePath as router field

* Apply suggestion

* Expose basePath as router field

* remove un-used vars

* Update externals

* Apply lint fix

* Update size-limit test

* Update prefetch
2020-04-14 09:50:39 +02:00
Houssein Djirdeh
04ceba4309
Adds first input delay performance metric (#8884)
* measures fid

* updates typings, fixes logic, updates per review comments

* update to es5

* separate clearMeasures

* use relayer

* creates fid polyfll render helper + simplifies measure

* switch to dynamic import

* creates fid experimental flag

* removes unecessary time-to-first-input metric

* removes hydration measure removes

* default flag to false

Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-04-13 14:46:46 -04:00
Guy Bedford
d76844082b react-error-overlay 2020-03-30 16:26:25 -04:00
Guy Bedford
8c21494997 polyfills 2020-03-30 16:26:25 -04:00
shYkiSto
2db9563f13
fix(performance-relayer): properly clean up event listeners (#11410)
Co-authored-by: siarhei.fedarovich <siarhei.fedarovich@ticketmaster.com>
Co-authored-by: Joe Haddad <joe.haddad@zeit.co>
2020-03-30 13:04:27 -04:00
Armand Abric
886037b1ba
Add "noreferrer" to the prerender indicator doc link (#11005) 2020-03-12 11:23:58 -04:00
Joe Haddad
9d9f7a5873
Improve Sass Error (#10982)
* Improve Sass Error

* test sass error massage

* use quotes

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-11 16:34:14 -04:00
JJ Kasper
b274fe39d3
Update method for attaching GS(S)P identifier to page (#10859)
* Update to use separate export instead of attaching to Component to identify GS(S)P pages

* Handle initialProps being undefined
2020-03-05 23:15:10 -05:00
Joe Haddad
990eda2c88
Prefetch SSG Data (#10127)
* Prefetch SSG Data

* Update packages/next/client/page-loader.js

Co-Authored-By: JJ Kasper <jj@jjsweb.site>

* Revert router.ts

* Revert link.tsx

* undo change

* mimmic existing

* simplify

* Prefetch href and asPath

* fix load

* dedupe prefetchAs

* Inject script tag on hover

* comment prefetchAs

* minify code

* introduce lazy files

* Add some breathing room

* correct default type

* Prefetch non-dynamic data

* Prefetch dynamic route data

* Fix size test

* Humanize code

* add tests

* Disable code

* Only generate modern version in modern mode

* Extract function helper

* add comments

* Filter out dynamic route to simplify manifest size

* add test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-03-02 12:14:40 -05:00
Joe Haddad
24345c9d06
Correctly Dedupe Prefetching (#10758)
* Correctly Dedupe Prefetching

* add test
2020-02-29 18:06:18 -05:00
Prateek Bhatnagar
5a82812568
Adding new types of performance monitoring (#10421)
* add new types of performance monitoring

* adding LCP

* adding cls to perf relayer

* add test for cls and lcp

* nit fixes

* re-organizing code

* fixing tests for lcp

* updating size limits in test
2020-02-28 17:44:03 -06:00
Tim Neutkens
513a7d5b5c
Update head-manager to compress better (#10687)
* Update head-manager to compress better

* Decrease size limit test
2020-02-26 13:56:13 +01:00
Dmitry Ishkov
b3fad60d7d
use clearInterval instead of clearTimer on a timer (#10597)
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-02-19 12:39:22 -05:00
JJ Kasper
db04cc57c1
Make sure to handle rejection when prefetching pages (#10579)
* Make sure to handle rejection when prefetching pages

* Update comment

* Make sure to show prefetch error in development still
2020-02-18 15:28:29 -06:00
Tim Neutkens
0222a09cd0
Enable polyfillsOptimization (#10574)
* Enable polyfillsOptimization

* Update sizes

* Commons is no longer there

* Update test
2020-02-18 19:26:55 +01:00
Jan Potoms
3f691eaa45
Remove ts-ignore where possible (#10541)
* Remove ts-ignore where possible

And replace by typecasts

* More accurate types

* bend cliententries in a correct shape earlier on

* comment becomes unnecessary

* add webpack overload to allow for the next.js use case

* Avoid changing public interface

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-02-17 16:16:19 -05:00
Joe Haddad
41e24a516a
Speculate Navigations for Client-Side JS (#10560)
* Speculate Navigations for Client-Side JS

* add tests

* avoid desctructure
2020-02-17 14:46:15 -06:00
Joe Haddad
6d5c48742b
Implement isFallback Router Property (#10539)
This adds a `isFallback` property to detect if the page is being rendered in "fallback" mode or normal mode.
Accessed via the `useRouter()` hook.

---

Closes #10527
2020-02-15 13:01:10 -05:00
Joe Haddad
e38e3dd55a
Adjust SSG Loading Behavior (#10510)
* Adjust SSG Loading Behavior

* Update expected preview behavior

* Rename two corrections

* Only use skeleton in production for now

* Fix "should SSR SPR page correctly" test

* fix tests

* fix trailing comment letter

* disable test for now
2020-02-12 20:06:07 -05:00
JJ Kasper
3099f0881a
Add initial SSG fallback handling (#10424)
* Add initial SSG fallback handling

* Remove extra changes and update fallback handling

* Remove extra timeout for testing

* Update SSG tests in dynamic-routing suite

* Add racing to decide between rendering fallback and data

* Update size-limit test

* Update comment

* Make sure to follow correct route change order

* Make comment more verbose for racing

* Revert getStaticData to only return Promise

* Make sure to update URL on fallback

* Add retrying for data, de-dupe initial fallback request, and merge fallback replace

* Update to add preload for fallback pages data

* Add test for data preload link

* Use pre-built fallback in production mode

* Remove preload link for fallback from _document

* Update to make sure fallback is rendered correctly for serverless
2020-02-07 14:09:06 +01:00
Lachlan Campbell
c480c37c8e
Skip undefined attribute in Head (#9856)
* Fix #8655, skip rendering meta tags with undefined props

* Filter all tags, not just meta

* Only render defined props

* Remove filtering of undefined strings

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

* Replace Object.entries

* Remove filtering code

* Simplify code

* Add test

* Add tests for undefined head prop value and tweak check

* Update to strip undefined prop values to match react

* Update head.js

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-02-03 14:55:14 -05:00
JJ Kasper
e63d822161
Make sure to not override initial navigation when refreshing static page's query (#10353)
* Add failing case

* Make sure to only refresh query if still on initial page

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-31 20:19:59 -05:00
Tim Neutkens
e35005c214
[Experimental] Nomodule polyfills chunk (#10212)
* Polyfill Promise in polyfills chunk

* Override promise polyfill to use built-in

* Update sizes

* Update polyfills

* Test

* Add dep

* Use iife

* Unscope

* Revert "Unscope"

This reverts commit ab26bcefd551c544d5b3c577b7ce91e5ecfb9bb9.

* trigger

* Remove unused code

* Set helpers to true

* Update yarn.lock

* Fix test

* Update polyfills size

* Add comment

* Add back comment

* Put polyfills optimization under experimental flag

* Fix filename

* bring back promise for backwards compat until experimental feature is landed

* fix resolve alias check

* correct loader

* fix logic branches

* adjust !!

* adjust cache key

* Conditionally branch polyfill

* fix promise polyfill branching

* Re-add runtime

* fix base object

* fix yarn lock

* Add cache key

* correctly set caller

* add basic test

* Increment h=>i

* increment to j just in case

Co-authored-by: Joe Haddad <timer150@gmail.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-01-30 01:04:29 -05:00
Tim Neutkens
6988a2e0a5
Use builtins for React transform (#10207)
* Disable core-js on Next.js core files as it's not transforming anything important

* Move babel options to taskr plugin

* Disable transform-runtime for pages dir

* Disable correctly

* Disable corejs for core files

* Temporarily check if this fixes the error

* Use builtIns and exclude async-to-generator

* Update index.test.js
2020-01-22 16:24:02 +01:00
Tim Neutkens
7b0118a991
Disable core-js on Next.js core files as it's not transforming… (#10193)
* Disable core-js on Next.js core files as it's not transforming anything important

* Move babel options to taskr plugin

* Disable transform-runtime for pages dir

* Disable correctly

* Disable corejs for core files

* Temporarily check if this fixes the error
2020-01-22 14:34:49 +01:00
JJ Kasper
53e9983d83 Add hydration callback for testing (#10195)
* Add hydration callback for testing

* Update size-limit test
2020-01-21 15:33:58 -05:00
JJ Kasper
04f1dd52b9 Delay hydration until after page is visible in development (#10164)
* Delay hydration until after page is visible in development

* Tweak dead-code elimination
2020-01-20 21:41:41 +01:00
Prateek Bhatnagar
552f3b4302 fixing observing paint types in safari bug (#10076)
* fixing observing paint types in safari bug

* using try catch for performanceObserver fallback

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-14 23:16:38 -05:00
Tomas Cerskus
ce2714de73 Fix reading Component.__N_SSG (#10037)
* Fix error when reading Component.__NEXT_SPR in packages/next/client/index.js

* Use the .? optional chaining operator

Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>

* Update index.js

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-14 15:06:26 -05:00
Joe Haddad
2d76c4a9bb
Replace __NEXT_SPR with __N_SSG Identifier (#10090) 2020-01-14 14:40:20 -05:00
Houssein Djirdeh
01699c6ac3 removes performance measures and marks for concurrent and blocking modes (#10088)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-14 14:17:18 -05:00
Christopher Snyder
c294ad0a53 Fix missing quotes around in operator check for PerformanceObserver (#10018)
* Fix missing quotes around `in` operator check for PerformanceObserver

* Always call `getEntriesByType()` even if performance observer is supported.

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-10 17:00:32 -05:00
Joe Haddad
af82f322e5
Enable New CSS Support by Default (#9927)
* Enable New CSS Support by Default

* Adjust configs

* Fix invisible AMP body

* Fix AMP validation warning

* test fix

* Use expression that won't be eliminated by babel
2020-01-09 15:31:28 -05:00
Joe Haddad
3c8fff354b
Simplify <Link> Prefetch Deduping (#9987)
* Simplify `<Link>` Prefetch Deduping

* Fix test

* Update test/integration/preload-viewport/test/index.test.js

Co-Authored-By: JJ Kasper <jj@jjsweb.site>

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-01-07 18:25:44 -05:00
Brian Mathews
5a2182e62e Add assetPrefix when fetching script and style dependencies (#9933)
* Add assetPrefix when fetching script and style dependencies for granularChunks

* Lint

* Fix assetPrefix usage with granularChunks

* Add tests for granularChunks with assetPrefix

* Cleanup
2020-01-06 10:55:39 -05:00
Tim Neutkens
32ec4f6913 Allow for shortened names for certain items (#9949)
* Use smaller name as it's not shortened

* Remove export as it's not used and it'll be shortened

* Update size

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-04 15:53:33 -05:00
Tim Neutkens
7e817cab04 Remove rewriteUrlForNextExport from bundles when option is not enabled (#9946)
Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-04 12:16:57 -05:00
Tim Neutkens
72a0c5578e Remove async from void functions in page-loader (#9948)
* Remove async from void functions in page-loader

* Fix void return

* Update page-loader.js

* Update index.test.js
2020-01-04 11:58:32 -05:00
Tim Neutkens
1fd57d22d5
Remove experiment (#9945)
* Remove experiment

* Add back ssr-prepass for serverless test

* Update size as they both decreased

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2020-01-04 17:40:18 +01:00
Tim Neutkens
8898b853e6
Don't bundle prop-types to then tree shake it (#9944) 2020-01-04 14:12:11 +01:00
JJ Kasper
ae78e8f5be Fix get(Static|Initial)Props re-running when updating query (#9907)
* Add failing test for re-calling getStaticProps after updating query

* Fix get(Static|Initial)Props re-running when updating query

* Update invalid export tests

Co-authored-by: Joe Haddad <timer150@gmail.com>
2020-01-03 15:36:24 -05:00
Joe Haddad
4f0c74c543 Fix Potential Duplication of Page Loading (#9894) 2019-12-31 12:19:39 -06:00
Joe Haddad
69a34dd778
Fix IE11 Prefetching (#9823) 2019-12-24 15:40:06 -05:00
Joe Haddad
632e40f266
Optimize Prefetching (#9818)
* Optimize Prefetching

* fix css client nav test

* fix preload viewport test

* fix production test

* patch tests more

* Make page loader wait on prefetch

* no unhandled rejection

* Save some bytes
2019-12-24 10:07:44 -05:00
JJ Kasper
1ec7716fe6
Prevent re-observing for an already prefetched page (#9644)
* Prevent re-observing for an already prefetched page

* Update size-limit test

* Move prefetched setting

* Remove extra prefetched setting
2019-12-20 15:30:58 -06:00
JJ Kasper
1de765e452
Update to close SSE connection before unload (#9798) 2019-12-20 12:01:22 -06:00
Tim Neutkens
950d67b721
Add experiment for prefetching (#9747) 2019-12-14 11:21:48 +01:00
Joe Haddad
734989d836 [Experimental] CSS Module Support (#9686)
* CSS Module Support

* Fix Server-Side Render of CSS Modules

* Fix Jest Snapshots
https://github.com/facebook/jest/pull/8492

* Fix snapshots

* Add test for CSS module edit without remounting

* Add tests for dev and production style being applied

* Add missing TODOs

* Include/exclude should only be applied to issuer, not the CSS file itself

* Add CSS modules + node_modules tests

* Test that content is correct

* Create Multi Module Suite

* Add client-side navigation support for CSS

* Add tests for client-side nav

* Add some delays

* Try another fix

* Increase timeout to 3 minutes

* Fix test

* Give all unique directories
2019-12-11 11:46:12 +01:00
Prateek Bhatnagar
5b10ea003c adding duration for custom performance marks (#9592) 2019-12-05 13:36:51 -05:00
Joe Haddad
bf5e295c0c Correct URI Encoding Order (#9638)
* Correct URI Encoding Order

* Add prefetch test

* verify encoding
2019-12-05 12:10:37 -06:00
JJ Kasper
45832e4421 Make sure to parse query values for SSG page after hydration (#9545)
* Make sure to parse query values for SSG page after hydration

* Update to re-use __NEXT_SPR
2019-11-27 23:16:19 -05:00
Prateek Bhatnagar
698f522d71 Wait till load for paint metrics (#9406)
* wait till load to fire paint metrics as they might not be available upfront

* adding performance observer

* adding check for performance user timing
2019-11-26 10:52:38 +01:00
Janicklas Ralph
04a7f1e85d Replace url polyfill with self.URL (#9200)
* Adding native-url package

* Bumping native-url version

* Upgrading native-url

* Logging stats object for debugging

* Logging stats object for debugging

* Adding try catch to the error lines

* Experimenting with regex

* Experimenting with regex

* Experimenting with regex

* Testing regex changes

* Fixing defer-script test case to not include polyfill.js

* Meging changes with existing polyfill work

* Bumping version

* adjust webpack config

* Reduce size in size test

* Remove 1kb from legacy
2019-11-25 23:10:02 -05:00
Joe Haddad
553052f903
Remove unused property skeleton (#9393) 2019-11-12 19:26:42 -08:00
Joe Haddad
7bb7d70650
Polyfill Object.assign by Default (#9369)
* Polyfill `Object.assign` by Default

* fix formatting
2019-11-10 20:48:11 -08:00
Joe Haddad
18a9c7e371
Improve linting rules to catch more errors (#9374)
* Update `packages/`

* Update examples

* Update tests

* Update bench

* Update top level files

* Fix build

* trigger
2019-11-10 19:24:53 -08:00
Tim Neutkens
9b999b1ce3
Convert wrapper class to function component (#9095)
* Convert wrapper class to function component

* Remove unneeded export

* Check versions of chrome and chromedriver

* Update to chromedriver 76

* Revert config.yml

* Update with-router.tsx
2019-11-09 14:56:59 -08:00
Alex Castle
b37fcbb50b Prevent CSS script tags in granular chunks (#9306)
* Don't add script tags for css files on client side navigation with granular chunks

* Filter for JS, instead of against CSS
2019-11-05 06:54:17 +01:00
Janicklas Ralph
ff2d3fd87d Polyfill window.fetch by Default (#9168)
* Polyfilling fetch and object-assign

* Polyfilling corejs object-assign

* Adding object-assign in polyfills.js. IE11 does not support Object.assign

* Fixing failing test

* Updating object.assign polyfill to fix aliasing

* Updating test case value to match new build stats

* Increasing the size of default build to 225kb

* Fixing defer-script test case to not include polyfill.js

* Revert README.md

* Re-design the polyfill approach based on PR feedback

* Adding comment and fixing test case

* Rename polyfills chunk

* Extract aliases into helper

* Remove extra new line

* Fix TypeScript typings

* Adding _internal_fetch alias

* Adjust build manifest plugin

* Build manifest plugin changes - adding a separate entry for polyfills

* Rename polyfills entry in build-manifest.json

* Remove old comment

* Fix TS

* Set key

* Polyfills already added

* Filtring polyfill.module.js

* Fix test

* Add __internal_fetch to alias rule

* Adjust name

* bump size

* ignore polyfills

* sigh
2019-11-01 21:00:56 -04:00
Tim Neutkens
7c80febcf7 Initial plugins implementation (#9139)
* Add initial bit for plugins

* Add checks for needed metadata values

* Add test

* Initial plugins changes

* Add handling for _app middleware

* Add loading of _document middleware and
handling of multiple default export syntaxes

* Fix insert order for middleware member expression

* Remove early return from middleware plugin from testing

* Add tests for current plugin middlewares

* Update test plugin package.json

* Update handling for class default export

* Update to use webpack loader instead of babel
plugin, remove redundant middleware naming, and add field for required env for plugins

* Add middleware to support material-ui use case
and example material-ui plugin

* Update tests and remove tests stuff from google analytics plugin

* Remove old plugin suite

* Add init-server middleware

* Exit hard without stack trace when error in collecting plugins

* Add on-error-client and on-error-server and update
to run init-server with next-start in serverless mode

* Update init-client for google analytics plugin

* Add example Sentry plugin and update with-sentry-simple

* Remove middleware field/folder and use src dir for plugins

* Add post-hydration middleware and update
material-ui plugin

* Put plugins code behind flag

* Update chromedriver

* Revert "Update chromedriver"

This reverts commit 1461e978e677f7da05e29e0415ec614a04bf65f9.

* Update lock file

* Remove un-needed _app for sentry example

* Add auto loading of scoped packages, add plugins
config for manually listing plugins, and update
to only collect plugins once

* Update example plugins

* Expose plugins' config

* Rename plugin lifecycles and add babel-preset-build

* Rename other methods with unstable

* Update log when plugin config overrides auto-detecting
2019-11-01 14:13:13 -05:00
Ilya
8dd394a055 Load granular chunks with correct asset prefix (#8993)
* closes #8989

fix

closes #8989

* test

* Update next.config.js

* Revert page1.js

* Revert page2.js

* Delete page4.js

* Delete page3.js

* Update index.test.js

* Revert index.test.js

* Revert next.config.js
2019-10-30 10:25:11 -04:00
Gerald Monaco
f632567bcf Add experimental config for React Mode (#9207)
* Add experimental config for React Mode

* Use latest types

* Use latest types
2019-10-30 09:39:58 -04: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
Gerald Monaco
beed775e55 Update legacy _app context (#9083) 2019-10-16 11:39:49 +02:00
Joe Haddad
3762e75704
Inline relayPaintMetrics function (#8954)
This function was only used once. I missed it in review, but this should save us a few bytes.
2019-10-03 17:34:54 -04:00
Prateek Bhatnagar
5929e9da20 Add unstable_onPerformanceData helper for performance entries (#8480)
* Performance relayer for client side performance

* adding paint metrics

* fixing titles

* fixing route change measure

* accessing exports without loop

* adding more tests

* renaming the method

* adds experimental prefix to method name

* applying the suggested patch

* Update index.js
2019-10-03 15:15:23 -04:00
Joe Haddad
40b0b9b958
Reduce Timeframe That FOUC Styles Are Active (#8937)
* Show content as soon as <style> tags are added

* Add fallback removal

* Add test for when unused

* Ensure the function is ES5 compatible

* IE support

* Test it works on broken pages
2019-10-02 19:08:19 -04:00
Joe Haddad
29c1b93c89
s/Automatic Prerendering/Automatic Static Optimization/ (#8940)
* s/Automatic Prerendering/Automatic Static Optimization/

* Update more links
2019-10-02 18:03:00 -04:00
Joe Haddad
d9c6f20023 Remove React Suspense from Client Runtime (#8887) 2019-09-28 12:44:07 +02:00
JJ Kasper
5f4e606e84 Fix using withRouter in _app opting out of auto-export (#8811) 2019-09-20 16:49:49 -04:00
Joe Haddad
65358b7a33
Global CSS Support (#8710)
* Global CSS Support

* Fix webpack configuration

* oneOf rule isn't necessary yet

* Adjust CSS chunk naming

* Begin testing CSS behavior

* Add another test TODO

* Replace null-loader with ignore-loader

* Turn on chunks for new CSS feature

* Fix multi test suite

* Test CSS import order

* Test style HMR

* Test CSS compilation

* Test compilation and prefixing together

* Verify CSS styling works for Development and Production

* Add missing TODO

* Remove unnecessary test

* Adjust TODO message

* Hide page until React hydrates

* Revert "Hide page until React hydrates"

This reverts commit 898d4e0ee547b003d5790e2b11476740d645b907.

* Hide FOUC during development

* Test CSS imports

* Update tests TODO

* Add fixture for url() test

* Test `file-loader` support in CSS files

* Use a simple variant of cssnano

* Self-import

* Undo bundling

* Implement suggestion
2019-09-17 16:05:20 -04:00
JJ Kasper
583b4677ae Prevent URL from being updated while asPath is delayed (#8756)
* Prevent updating URL when delaying asPath

* Ignore TypeScript not liking __NEXT_DATA__

* Update another global to fix standard check
2019-09-16 12:15:18 -04:00
JJ Kasper
44bbf9ad27 Catch error from failing to unobserve (#8578)
* Catch error from failing to unobserve

* Update link.tsx
2019-09-16 16:56:56 +02:00
JJ Kasper
fe7c7342c7 Add link to docs for prerender indicator and allow disabling (#8610)
* Add link to docs for prerender indicator and allow disabling

* Fix lint error from example

* Disable by default when electron is detected

* Add button to dismiss indicator for session

* Update disabling indicator in electron
2019-09-15 23:18:11 +02:00
JJ Kasper
5a0dcbc95b Update pages-loader to return one value (#8629)
* Update pages-loader to return one value

* de-dupe page mod update also
2019-09-11 13:21:10 -04:00
JJ Kasper
a5ebe41a9a Delay updating asPath for auto exported pages (#8681)
* Delay updating asPath for auto exported pages

* Add additional test ensuring asPath is updated
2019-09-10 13:30:25 -04:00
Tim Neutkens
2ba352da39 Move next-server back into next package (#8613)
* Initial move

* Make emitting work

* Update paths

* Remove leftover files

* Add correct externals configuration

* Import correct path

* Update path to work with ts-server test

* Update lib directory

* Compile next-server/lib
2019-09-04 10:00:54 -04:00
Houssein Djirdeh
689b1319b6 Update performance marking (#8527)
* creates perf marks object constant

* updates clearmarks to only clear core marks

* adds test + fixes object constqnt reference

* hardcodes perf marks and removes constant

* adds test to check custom marks are not cleared
2019-08-30 22:40:05 -04:00
Jacky Shikerya
4adf710788 Encode URL paths in HTML and CSR (#8435)
* added filename encoder for testing

* fixes in page-loader

* fix possibly undefined

* conflict resolution

* Update packages/next/pages/_document.tsx

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* move encoding into individual tags as Joe suggested
2019-08-29 12:56:24 -04:00
Houssein Djirdeh
010059915d Add version property to Next.js instance (#8499)
* adds global for next version

* updates to use env variable and keeps it local

* Test Next.js version presence

* Unfocus test
2019-08-24 00:49:24 -04:00
JJ Kasper
56a134409c Debug TypeScript test suite (#8476)
* Tweak typescript test suite

* Revert "Tweak typescript test suite"

This reverts commit 9e0108da7c70e7ae45b412b60c07162383de65f3.

* Make sure HMR connection isn't being closed
while testing

* Update to not re-use NODE_ENV

* Break up/rework TypeScript test suite

* bump
2019-08-22 16:34:24 -04:00
Joe Haddad
847e892d71
Remove Flying Shuttle experiment (#8433)
* Remove Flying Shuttle experiment

* Remove more old tests

* Remove minify loader
2019-08-20 11:07:57 -04:00
Joe Haddad
a04a5f014a
Remove extra DOM method call (#8394) 2019-08-16 12:00:46 -04:00
Joe Haddad
771c0b450e
Use data-next-page instead of id=__NEXT_PAGE__ (#8380) 2019-08-15 13:56:26 -04:00
Prateek Bhatnagar
cffa2e3f21 Reverting clear measure (#8373) 2019-08-15 08:14:09 +02:00
Houssein Djirdeh
55ccb09dee fixes nav start argument in user timing check (#8348) 2019-08-13 11:48:30 -04:00
JJ Kasper
8c19d78a08 Also provide AppTree in NextPageContext (#8223)
* Also provide AppTree in NextPageContext

* Don't predefine AppTree as null in ctx

* Make update smaller

* Don’t reassign variable

* Add test for AppTree in NextPageContext

* Update utils.ts
2019-08-13 11:33:48 +02:00
Natalie Marleny
06876f1be0 fix: Warn when user specifies prefetch option as true (#8233)
* Warn when user specifies prefetch option as `true`

* Update index.test.js
2019-08-12 00:26:25 -04:00
Gerald Monaco
04cf779702 Add warning for missing <Head> (#8276)
* Add warning for missing <Head>

* Update the warning to be eliminated away in production

* Update head-manager.js
2019-08-11 22:48:05 -04:00
JJ Kasper
fc7e235f2c Followup optimizations for new experimentalPrerender (#8287)
* Add checking for hybrid AMP during static check

* Update to always hit server for prerender data

* Add removing of SPR code when not used

* Add checking for hybrid AMP during static check

* Update to always hit server for prerender data

* Add removing of SPR code when not used

* Update dead code elimination
2019-08-11 21:56:57 -04:00
Tim Neutkens
2b62c33f25
Only add flying-shuttle code when enabled (#8330)
Follow-up of #7536, small optimization / code removal when the feature is not enabled.
2019-08-12 00:03:11 +02:00
Houssein Djirdeh
d190f2e112 Adds user timing marks and measures for hydration/render (#8069)
* adds user timing marks for hydration step

* changes measure names and removes window namespaces by adding performance as a global to standard

* separates hydrate and render marks

* Add performance mark to router change instead of link click

* Changes performance mark name at router change

* adds checks for performance

* creates constants utils for performance and user timings
2019-08-09 15:43:29 -04:00
JJ Kasper
a4889f964e
Update handling of ref in next/link (#8254) 2019-08-08 13:11:17 -05:00
Alex Castle
3e8b36e879 Experimental: Granular build chunking (#7696)
* Refactor SplitChunksPlugin configs and add experimental chunking strategy

* Use typeDefs for SplitChunksConfig

* Modify build manifest plugin to create runtime build manifest

* Add support for granular chunks to page-loader

* Ensure normal behavior if experimental granularChunks flag is false

* Update client build manifest to remove iife & implicit global

* Factor out '/_next/' prepending into getDependencies

* Update packages/next/build/webpack-config.ts filepath regex

Co-Authored-By: Jason Miller <developit@users.noreply.github.com>

* Simplify dependency load ordering in page-loader.js

* Use SHA1 hash to shorten filenames for dependency modules

* Add scheduler to framework cacheGroup in webpack-config

* Update page loader to not duplicate script tags with query parameters

* Ensure no slashes end up in the file hashes

* Add prop-types to framework chunk

* Fix issue with mis-attributed events

* Increase modern build size budget--possibly decrement after consulting with @janicklasralph

* Use module.rawRequest for lib chunks

Co-Authored-By: Daniel Stockman <daniel.stockman@gmail.com>

* Dasherize lib chunk names

Co-Authored-By: Daniel Stockman <daniel.stockman@gmail.com>

* Fix typescript errors, reorganize lib name logic

* Dasherize rawRequest, short circuit name logic when rawRequest found

* Add `scheduler` package to test regex

* Fix a nit

* Adjust build manifest plugin

* Shorten key name

* Extract createPreloadLink helper

* Extract getDependencies helper

* Move method

* Minimize diff

* Minimize diff x2

* Fix Array.from polyfill

* Simplify page loader code

* Remove async=false for script tags

* Code golf `getDependencies` implementation

* Require lib chunks be in node_modules

* Update packages/next/build/webpack-config.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Replace remaining missed windows compat regex

* Trim client manifest

* Prevent duplicate link preload tags

* Revert size test changes

* Squash manifest size even further

* Add comment for clarity

* Code golfing 🏌️‍♂️

* Correctly select modern dependencies

* Ship separate modern client manifest when module/module enabled

* Update packages/next/build/webpack/plugins/build-manifest-plugin.ts

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Remove unneccessary filter from page-loader

* Add lookbehind to file extension regex in page-loader

* v9.0.3

* Update examples for Apollo with AppTree (#8180)

* Update examples for Apollo with AppTree

* Fix apolloClient being overwritten when rendering AppTree

* Golf page-loader (#8190)

* Remove lookbehind for module replacement

* Wait for build manifest promise before page load or prefetch

* Updating modern-only chunks inside the right entry point

* Fixing ts errors

* Rename variable

* Revert "Wait for build manifest promise before page load or prefetch"

This reverts commit c370528c6888ba7fa71162a0854534ed280224ef.

* Use proper typedef for webpack chunk

* Re-enable promisified client build manifest

* Fix bug in getDependencies map

* Insert check for granularChunks in page-loader

* Increase size limit temporarily for granular chunks

* Add 50ms delay to flaky test

* Set env.__NEXT_GRANULAR_CHUNKS in webpack config

* Reset size limit to 187

* Set process.env.__NEXT_GRANULAR_CHUNKS to false if selectivePageBuilding

* Update test/integration/production/test/index.test.js

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Do not create promise if not using chunking PR
2019-08-08 13:14:33 -04:00
JJ Kasper
8e4509caf2 Add warning for invalid href being passed to router (#8231)
* Add warning for bad href being passed to router

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Inline invalidHref for better code elimination
2019-08-07 10:47:13 -04:00
JJ Kasper
ca13752e24
Implement experimentalPrerender option (#7983)
* Revert "Remove Old Prerender Implementation (#8218)"

This reverts commit 2ab300dd81.

* Add contentHandler for page config

* Rename config from contentHandler to re-use
experimentalPrerender

* Remove un-needed changes

* Replace backslashes for manifest

* Update manifest output format

* Make prerender: true enable SPR behavior and update
to merge prerender-manifest for flying-shuttle

* Fix output path for / prerender file

* Add dynamic routes to test suite

* Add generating and previewing of skeletons
for prerendered dynamic routes

* remove inline prerender option

* update to not replace getInitialProps which allows
nested getInitialProps and add query when fetching prerender

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Remove legacy prerender option

* Apply suggestions from review

* Apply more suggestions from review

* Apply suggestions from code review

Co-Authored-By: Joe Haddad <timer150@gmail.com>

* Add handling of error when parsing json

* Update handling of moving exported pages

* Rename nextPreviewSkeleton to _nextPreviewSkeleton

* bump
2019-08-06 15:26:01 -05:00
Luis Fernando Alvarez D
d4d5ad4ba5 Remove propertyFields from the client router (#8219)
* Remove forEach over the components prop

* Remove propertyFields
2019-08-06 15:42:33 +02:00
Joe Haddad
8a74f0ae71
Golf page-loader (#8190) 2019-07-31 16:14:54 -04:00
JJ Kasper
4850bd03ef Provide AppTree to getInitialProps for getDataFromTree (#7732)
* Provide AppContainer to getInitialProps for getDataFromTree

* Update to only pass AppTree component instead of AppContainer

* Clean up props and remove extra imports

* Make updates from review

* De-dupe AppTree a bit

* Re-use wrapApp in router

* Remove un-needed change

* revert changes to examples until on stable

* Add test for AppTree
2019-07-30 14:00:19 -04:00
Olivier Tassinari
71f9288a54 Fix onError prop-type warning in Link (#8021)
The warning

> Warning: Failed prop type: Link: unknown props found: onError

can happen in this case:

```tsx
import * as React from 'react';
import NextLink, { LinkProps as NextLinkProps } from 'next/link';

type NextComposedProps = React.AnchorHTMLAttributes<HTMLAnchorElement> & NextLinkProps;

const NextComposed = React.forwardRef<HTMLAnchorElement, NextComposedProps>((props, ref) => {
  const { as, href, replace, scroll, passHref, shallow, prefetch, onError, ...other } = props;

  return (
    <NextLink
      href={href}
      prefetch={prefetch}
      as={as}
      replace={replace}
      scroll={scroll}
      shallow={shallow}
      passHref={passHref}
      onError={onError}
    >
      <a ref={ref} {...other} />
    </NextLink>
  );
});
```

*Taken from Material-UI Next.js integration example*
2019-07-25 18:52:27 +00:00
Gerald Monaco
e68307df3a Add next-head-count & remove next-head class (#8020)
Fixes #3494

Removes `class="next-head"` from the children of the `<Head>` component. Instead, a single sentinel meta element named `next-head-count` is appended. The content is the number of contiguous elements immediately preceding the sentinel that _would have had_ the `class="next-head"` attribute.

During an update, instead of searching for `class="next-head"`, the sentinel is located and the N previous elements are considered candidates for `oldTags`. New elements are inserted before the sentinel, and finally the sentinel is updated to reflect the new count.
2019-07-25 16:39:09 +00:00
Joe Haddad
f8b56da7e1 Revert "Improve type definitions" (#8098)
Reverts zeit/next.js#8097

This PR caused bundle sizes to increase. We need to fix this bug before we continue adding invalid TypeScript exports to our code.
2019-07-25 13:58:24 +00:00
Adam Misiorny
55e87ea50c Improve types (#8097) 2019-07-24 21:48:38 -05:00
Janicklas Ralph
f4e6149d1c Experimental module/nomodule support (#7704)
* Module/nomodule implementation based on RFC 7563

* Remove comment

* Fixing issue with building amp pages

* Fixing test cases for serverless mode

* Adding safari 10 nomodule fix. Preloading modern js by default

* Fixing size-limit integration test

* Bug fix

* Adding testcase for modern build

* Trigger rebuild

* Setting default crossOrigin value

* Moving modern config option inside experimental flag

* Adding nomodule attribute to safari-fix script

* Changing safari10NomoduleFix default value to true

* Removing safari-fix flag

* Changing .es6 to .module

* Disable modern default

* Removing default crossOrigin value. Setting modern flag to false by default. Fixed test cases

* Remove confusing defaults and mark required instead

* Adjust blacklist

* Move behavior of page marking

* Fixing childCompiler errors not being captured

* Tweak names

* Revert

* whoops

* Fixing bug with page-loader.js

* Changing modern babel cache name

* Rename helper

* Iterate over both bundles

* Correctly clamp bundle sizes

* Revert test

* Add modern mode tests

* Fix test

* test

* test2
2019-07-24 22:16:32 -04:00
Tim Neutkens
5030486a5d
Don’t add loadable if it’s not used (#7995) 2019-07-16 14:52:01 +02:00
Joe Haddad
60b4e678b0
Fix client-side hydration with dynamic routes (#7986)
* Add a test for the hash case

* Add a special hydration option to router

* Add additional tests wrt scrolling
2019-07-15 16:07:04 -07:00
JJ Kasper
4adef73ab8
Update link ref handling to clean up previous listeners (#7943) 2019-07-14 10:23:13 -07:00
not
a4355b0d0f Prevent blocking while hidden (#7930)
Allows clickthrough after indicator has been hidden.
2019-07-12 22:59:26 +02:00
Joe Haddad
45f80409dc Remove duplicated client code (#7907) 2019-07-11 23:23:07 +02:00
Luis Fernando Alvarez D
7b25e2995e Export types for link props (#7905)
* export LinkProps

* Add test
2019-07-11 14:52:21 -04:00
Luis Fernando Alvarez D
b94123ccc9 Improve exported router types (#7853)
* Added the RouteUrl type and improved router types

* Added more tests for router types

* Add build test for typescript types

* Add next-env.d.ts to the typescript test

* Removed next-env.d.ts

* Added next-env.d.ts to gitignore

* Remove route url re-exports

* renamed PublicRouterInstance to be NextRouter

* export the Url type

* Replaced BaseRouter with NextRouter in server/utils

* Don't export the Url type

* Update tsconfig.json
2019-07-11 13:35:39 -04:00
JJ Kasper
bf7af1d16b Add default values for runtime config (#7847)
* Add default values for runtime config

* Add test to ensure default values are set
for runtime config

* Only add runtimeConfig if it's not empty

* Only add runtimeConfig if it's not empty

* Simplify default value adding

* Reduce bundle size

* remove comment changes

* Fix typos

* Add test for runtimeConfig in __NEXT_DATA__
2019-07-10 10:43:04 -04:00
Joe Haddad
b60985b2be
Revert "fix(Link): Set focus back to the body element (#7693)" (#7753)
This reverts commit defde85e81.
2019-07-04 23:24:14 -04:00
Connor Bär
defde85e81 fix(Link): Set focus back to the body element (#7693)
* fix(Link): Set focus back to the body element

* refactor(Link): Fix typings

* Update blurring logic and add tests
2019-07-04 11:30:22 -04:00
Tim Neutkens
a785ff7376
Bring down bundle size (#7743) 2019-07-03 14:38:21 +02:00
JJ Kasper
7cf132f864
[Refactor] Move context providers to AppContainer (#7737) 2019-07-02 19:16:12 -07:00
JJ Kasper
6ce7c06d9c Add initial static indicator (#7682)
* Add initial static indicator

* Update indicator text to pre-rendered

* Update naming from static to prerender

* Update to not re-use nextExport var

* Update positioning of indicator to prevent overlap
2019-07-02 20:42:41 -04:00
Joe Haddad
e7110a0347
Asynchronously check for type errors (#7668)
* Asynchronously check for type errors

* Add TODO

* Fix webpack invalidation

* Show TypeScript error in dev client
2019-06-26 14:54:23 -04:00
JJ Kasper
e360c105ab
Update prefetch check to prevent re-prefetching (#7654)
* Update page-loader prefetch checking

* Add test for re-prefetching same bundle
2019-06-24 16:13:33 -07:00
Kuba Juszczyk
2debe7fb73 Allow opting out of automatic prefetch for Link (#7532)
* Restoring not working mouse event

* Restoring possibility of conditionally switching off the prefetch
2019-06-24 11:22:27 -07:00
March Works
7678ee2f2e set __next-build-watcher width and height to 0 (#7618) 2019-06-20 17:11:15 -07:00
Joe Haddad
6c625703ed
Dynamic Routes: Change impl from $param to [param] (#7623)
* Dynamic Routes: Change impl from $param to [param]

* Update expected test snapshot

* Update test to use new syntax

* Update test file

* Test more behavior

* Update route sorter for new param syntax

* Update dynamic routing tests

* Update danging test file

* Tweak test

* Fix dev and update tests
2019-06-20 18:27:04 -04:00
Joe Haddad
eddc852de3
Extract isDynamicRoute helper (#7622) 2019-06-20 14:41:02 -04:00
Kuba Juszczyk
e49f26d644 Restore onMouseEnter event (#7531) 2019-06-07 11:43:27 -04:00
Tim Neutkens
7e7f2c0a6d
Simplify a few parts of the codebase (#7506)
* Move client-side dev JS to dev folder

* Move eventsource polyfill

* Move source-map-support

* Move error boundary

* Deprecate Container in _app

* Make initialRender check better

* Remove unused code

* Only support one subscription as there is only one

* Don’t spread object

* Shorten property name

* Add container in development too

* Simplify query update logic
2019-06-05 20:15:42 +02:00
Joe Haddad
b3170d2648
Format missed files (#7464)
* Format missed files

* Remove unnecessary rule

* Fix type error
2019-05-29 18:19:32 -07:00
Tim Neutkens
3e51ddb8af
Move syntax formatting to prettier (#7454)
* Run prettier over packages/**/*.js

* Run prettier over packages/**/*.ts

* Run prettier over examples

* Remove tslint

* Run prettier over examples

* Run prettier over all markdown files

* Run prettier over json files
2019-05-29 13:57:26 +02:00
Rafael Almeida
5fa01b15c6 Improvements to build watcher (#7441)
* Remove fragment from _document

* Directly assign id instead of setAttribute

* Remove getElementById call by using the existing reference
2019-05-28 20:16:29 +02:00
JJ Kasper
ca85cc9973
Update styles on build indicator container (#7436) 2019-05-27 15:01:29 -07:00
Rafael Almeida
6f6f40dba7 Implement UI to show building activity (#6526)
* Initial version of build watcher working

* Move build watcher div to Main component

* Add a better design, remove container from DOM when not visible

* Fix flickering when closing and opening too fast

* Add a field on next config file for two styles and completely removal

* Ops, bring back fade-in animation

* Remove unnecessary commas

* Render building text by CSS, remove unnecessary jsx attribute

* Remove React usage

* Add support to IE/Edge

* Fix linter issues

* Set custom property with data attribute

* Use ondemand: 1 to don't override current listeners

* Use more strict rules to avoid outside CSS effects

* Use lighter box shadow

* Fix registering HMR callback

* Move initializing build watcher to client/next-dev

* Remove buildWatcherStyle and only use minimal

* Move build watcher element to render

* Move it to create element on initialize

* Fix type error from canary

* Remove extra log

* Simplify SVG markup
2019-05-27 13:59:25 -07:00
JJ Kasper
577cc7b6af Fix error overlay dismiss after fixing build error (#7335)
* Make sure to dismiss type error after being fixed

* Update test
2019-05-14 20:27:02 -04:00
JJ Kasper
28f1ca4f3e
re-add prefetch prop type with deprecated (#7292) 2019-05-10 14:33:40 -05:00
Lukáš Huvar
e0c3545829 Remove components from client router (#7281) 2019-05-07 16:20:13 -05:00
Luis Fernando Alvarez D
a7ca031313
Renamed IContext to be NextPageContext (#7272) 2019-05-06 16:42:04 -05:00
JJ Kasper
b97a47d273 Fix attempting to observe non-DOM refs in Link (#7249)
handleRef isn't called with valid DOM node
2019-05-06 15:44:18 +02:00
JJ Kasper
adbc1a8857
Remove unnecessary type from LinkProps (#7233) 2019-05-03 09:50:34 -05:00
JJ Kasper
2776dc731c Use intersection observer to preload in viewport (#7196)
* Use intersection observer to preload
links that are in viewport

* Clean up names

* Check for window before returning observer

* update check for IntersectionObserver

* Remove duplicate IntersectionObserver checks

* Add test for prefetching links in viewport
2019-05-01 15:14:27 +02:00
Luis Fernando Alvarez D
ab22b58818
Allow _app and _document to be extended with other props (#7184) 2019-04-29 11:47:40 -05:00
Luis Fernando Alvarez D
b963863106 Prefer type over interface (#7164) 2019-04-26 09:37:57 +02:00
Tim Neutkens
f8eb392fa5
Add types for next/link (#7160)
* Add types for next/link

* Fix link type errors

* fix router type error
2019-04-25 21:31:53 +02:00
Tim Neutkens
c9d599b698
Add .d.ts for next-server (#7133)
* Add .d.ts files

* Drop next declarations from index.d.ts

* Bring back number of errors

* Fix more errors

* Fix rewriteUrlForExport
2019-04-24 16:47:50 +02:00
Luis Fernando Alvarez D
254b23eb07
Add declaration files to /dist (#7118) 2019-04-23 16:12:33 -05:00
chuck
78783477e0 More Specific Info on Script Loading Error (#7108)
* add url info on script loading error message

* Update packages/next/client/page-loader.js

shorten error message for smaller bundle size

Co-Authored-By: chuck0523 <chuckinthestar@gmail.com>
2019-04-23 11:29:52 +02:00
Luis Fernando Alvarez D
db5b3dc8e3
Update types for with-router (#7106)
* Updated declarations for with-router
2019-04-22 17:32:10 -05:00
JJ Kasper
a27c235260 Update to share HMR and ondemand SSE connection (#7084)
We also close the connection when the window is in the background and re-connect when it is brought to the foreground. This prevents us from using up too many connections.
2019-04-22 05:51:09 +09:00
JJ Kasper
fdfbab5d25 Updated handling of AMP page reloading (#7052) 2019-04-16 18:04:41 -05:00
Luis Fernando Alvarez D
c48340cd8c
Move next/router to Typescript (#7019)
Added types to next/router
2019-04-15 23:00:48 -05:00
Simon Boudrias
01779429ab Set descriptive displayName on withRouter HOC (#7017)
Not sure when it was introduced, but on the latest Next v8.0.4, there's no descriptive name attached to the component returns from `withRouter`.

This makes it harder to debug and write test cases for components wrapped by `withRouter`.
2019-04-13 13:21:28 +02:00
JJ Kasper
09a2fe5c38
Amp page level reload (#6971)
* Only refresh the page when the active
page is updated in AMP mode

* Update handling of page reload to make sure it
still refreshes after a change to another page

* Update checking to be more accurate

* Fix amp-dev not being loaded without
experimental.amp and remove next.config from amp example

* Remove old with-amp example and
rename experimental-amp to with-amp

* update example name

Co-Authored-By: ijjk <jj@jjsweb.site>

* Update comment wording

Co-Authored-By: ijjk <jj@jjsweb.site>

* Use document for reload to keep scroll position

Co-Authored-By: ijjk <jj@jjsweb.site>

* fallback to reloading on error

Co-Authored-By: ijjk <jj@jjsweb.site>

* Update with-amp example readme
2019-04-12 20:54:27 -05:00
Joe Haddad
f301c4f063
Adjust onFinishCallback polyfill (#6984) 2019-04-09 21:49:44 -04:00
Joe Haddad
c59218c4d8
Remove use of Promise.finally in polyfill (#6975)
* Remove use of Promise.finally

* Move line for clarity
2019-04-09 12:25:21 -04:00
JJ Kasper
ac8b15a43e
Add useRequest hook and RequestContext (#6910)
* Add useRequest hook and RequestContext

* Add useRequest hook and RequestContext

* Fix merge conflict duplicate import
2019-04-05 14:43:40 -05:00
Joe Haddad
19c635175b
Make Client request BUILD_ID from the Server (#6891)
* Generate two versions of pages

* Add code VSCode deleted

* Add dynamicBuildId option to __NEXT_DATA__

* Reduce amount of diff

* Make getPageFile code easier to read

* Minimize diff

* minimize diff

* Fix default value for dynamicBuildId

* Fix weird bug

* Fetch the head build id on client

* Move __selectivePageBuilding

* Add tests

* Remove _this

* Add console warning
2019-04-04 17:54:01 -04:00
JJ Kasper
7e5e414bcb Add RouterContext in production mode (#6883) 2019-04-03 22:21:16 +02:00
JJ Kasper
b509841f5e Add useRouter hook (#6869)
This introduces the `useRouter` hook alternative to `withRouter`
2019-04-03 11:28:53 +02:00
Tim Neutkens
b1fdffec75
amp-bind data injection (#6840) 2019-04-02 16:09:34 +02:00
Tim Neutkens
355078c350
Separate toRoute function (#6766)
Because Typescript output is turned to commonjs for these modules currently it’s better to do this. Also convert withRouter to typescript, making it smaller.
2019-03-23 23:00:46 +01:00
Tim Neutkens
eb28d4cdcf
Remove hoist-non-react-statics from with-router (#6765)
* Remove hoist-non-react-statics from with-router

* Drop hoist-non-react-statics from package.json
2019-03-23 21:31:44 +01:00
Tim Neutkens
130aa3fd18
Remove unused parameters (#6735)
These two were unused 👍
2019-03-20 12:11:35 +01:00
Connor Davis
2c975b1cdc Catch errors when loading a page in case a script 404s (#6729)
* Catch errors when loading page

* return promise instead of await
2019-03-20 10:58:26 +01:00
Tim Neutkens
0e39b24592
Clean up ErrorBoundary component (#6703) 2019-03-18 18:08:51 +01:00
Tim Neutkens
b41c85e32a
Remove headManager property as it’s unused (#6700)
This was leftover from before we moved to `HeadManagerContext`

Also removes `emitterProp` as it's unused in the Next.js codebase too.
2019-03-18 16:22:36 +01:00
JJ Kasper
a6ddaefe22 Add experimental exportTrailingSlash config (#6664)
By default when `next export`ing a Next.js application we will automatically append a `/` to all urls to be fully compatible with the directory structure being output.

However since most platforms support directory indexes it makes sense to change this default in the future.

This PR adds `exportTrailingSlash` as experimental flag. We'll try this out for a bit on nextjs.org / zeit.co/docs before introducing it as new option.

The default value is `true` as this is the current behavior in stable Next.js.

```
{
  experimental: {
    exportTrailingSlash: false
  }
}
```

⚠️ as with all experimental flags being added this is subject to breaking between canary/stable versions.
2019-03-17 00:54:58 +01:00
JJ Kasper
ff7299d184 Update react-error-overlay and use reportRuntimeError (#6577)
Fixes: #5481
2019-03-08 16:24:15 +01:00
JJ Kasper
4c35b7e704
Add warning on stalled page load possibly from too many tabs open (#6514)
* Add warning on stalled page load possibly from too many tabs open

* Add test for stalled warning

* Update onDemand pinging to close on routeChangeStart and added
warning when onDemand handler detects multiple tabs from the same
browser
2019-03-02 16:51:14 -06:00
Joe Haddad
cc2b7bc8fa
Setup on-demand-entries ping to prevent AMP page disposal (#6484)
* refactor(on-demand-entries): extract method: setupPing

* Setup ping for amp pages

* Missed a call
2019-02-28 12:52:13 -05:00
Joe Haddad
c904126057
refactor(on-demand-entries): extract method: setupPing (#6483)
* refactor(on-demand-entries): extract method: setupPing

* Missed a call
2019-02-28 12:31:31 -05:00
Joe Haddad
f15cfeba0a
AMP automatic page refreshing in dev (#6392)
* AMP page reload

* Fix comment

* Skip dev files in production

* Polyfill event source

* Add HMR test for AMP

* Use webdriver

* Use a dynamic server for HMR test

* ffs
2019-02-25 17:00:14 -05:00
Connor Davis
b146eb5200
Replace del with rimraf package (#6411) 2019-02-22 13:49:30 -06:00
Tim Neutkens
b88addfcd5
Remove event-source-polyfill dependency (#6407) 2019-02-22 16:23:58 +01:00
Tim Neutkens
d0e90d05a0 Don’t hide parse error from on-demand-entries 2019-02-22 10:38:40 +01:00
JJ Kasper
71ae456a7c Fix invalid ping response throwing error in client (#6397) 2019-02-22 10:22:23 +01:00
Isaac Hinman
6e23b75c90 feat: Validate url.format calls (#6379) 2019-02-20 17:01:45 -05:00
Connor Davis
fcf1167cd4 Upgrade standard and fix files (#6358)
Upgrades `standard` to major version 12
2019-02-19 22:45:07 +01:00
JJ Kasper
bf69357f27 Remove onDemandEntries WebSocket server in favor of EventSource connection (#6354)
After talking with @timneutkens it was decided it'd be more streamlined to replace the onDemandEntries WebSocket with an alternative. Using the EventSource connection gives us these benefits over the WebSocket one:

- less code needed
- no extra server running
- no extra config for onDemandEntries
2019-02-19 21:58:47 +01:00
JJ Kasper
5d779a0289 Add falling back to fetch based pinging for onDemandEntries (#6310)
After discussion, I added falling back to fetch based pinging when the WebSocket fails to connect. I also added an example of how to proxy the onDemandEntries WebSocket when using a custom server. Fixes: #6296
2019-02-15 22:22:21 +01:00
Connor Davis
1e5d0908d0 Block Certain Env Keys That Are Used Internally (#6260)
Closes: #6244 

This will block the following keys:
```
NODE_.+
__.+
```

There doesn't seem to be a way to simulate a failed build or else I'd add tests for it.
2019-02-15 17:49:40 +01:00
Joe Haddad
9bb8fbf535
Update webpack message formatter (#6299) 2019-02-14 11:13:35 -05:00
Sultan Tarimo
1a416b688e Load ErrorComponent dynamically (#6171)
Closes #6152.

- Only dynamically load /_error.js when an exception occurs.
- Fix websocket “/_error.js” ping oddity.
2019-01-31 20:45:36 +00:00
Tim Neutkens
6c49bee959
Make side-effect.js smaller (#6118)
Start at making side-effect.js / head.js smaller.
2019-01-25 01:39:15 +01:00
Tim Neutkens
2a50c176cf
Make HMR still apply updates when there is a webpack warning (#6099)
Fixes #5363

I noticed this happening when making some changes on the nextjs.org/learn app. Basically we didn't apply updates when a warning was emitted from webpack. This would cause issues for users using eslint-loader or similar too.
2019-01-21 22:39:39 +01:00
Jason Aslakson
00003193df Additional config options for hot reloader web socket connection (#6083)
* Additional config options for hot reloader web socket connection

* Apply suggestions from code review

Accepting suggested code changes

Co-Authored-By: jaslakson <jason.aslakson@americastestkitchen.com>

* updated README with websocket proxy options

* Fix test / cleanup port setting

* Always set proxy_path
2019-01-19 13:39:09 +01:00
Alexander Nanberg
7e7be0e2e8 Revert #6030 (#6052)
* Revert #6030

* Fix _app childContextTypes
2019-01-14 15:41:09 +01:00
Alexander Nanberg
ff5cf6d4de Migrate next/head to use React.createContext (#6038)
Continuation of #5945
2019-01-14 01:59:26 +01:00
Tim Neutkens
2f22fbf8c2 Replace comment with import() for webpack dynamic entries compat 2019-01-11 22:55:14 +01:00
Alexander Nanberg
25fb3f9c2e Migrate next/router to use React.createContext (#6030)
Fixes parts of #5716. I had some issues with the test suite but I'm fairly certain that I got it working correctly.
2019-01-11 16:04:56 +01:00
Tim Neutkens
9ffd23eeef
Replace pages-plugin with loader (#5994)
* Remove unused argument

* Replace pages-plugin with loader

* Add loader-utils types

* Remove logs

* Bring back previous deposal behavior

* Remove console.log

* Remove webpack/utils as it’s no longer in use

* Remove hot-self-accept-loader

* Error Recovery tests

* Make hotSelfAccept a noop default loader

* Fix windows deleted/added

* Remove logging

* Remove unused variables

* Remove log

* Simplify entrypoint generation

* Don’t return the function

* Fix _app test

* Remove code that’s always true

* Move aliases to constants

* Use alias

* Join pages alias in reduce

* Default pages differently

* Loop over pages instead of manually defining

* Move entry generation into common function

* Update packages/next/build/webpack/loaders/next-client-pages-loader.ts

Co-Authored-By: timneutkens <tim@timneutkens.nl>

* Update packages/next/build/webpack/loaders/next-client-pages-loader.ts
2019-01-08 23:10:32 +01:00
Luc
fc19b233eb Replace event-emitter.js by mitt (#5987)
This PR aims at replacing next-server/lib/event-emitter.js by mitt.

Fix https://github.com/zeit/next.js/issues/4908

event-emitter.js is ~400 bytes gzipped vs mitt is 200 bytes
2019-01-04 21:49:21 +01:00
Tim Neutkens
662dfd4271
Drop module.hot from production bundles (#5967) 2018-12-31 19:06:36 +01:00
Tim Neutkens
18cb2c03df
Simplify default title (#5968) 2018-12-31 19:06:03 +01:00
Tim Neutkens
b0cad3370d
Use less code to detect replace instead of push (#5969) 2018-12-31 19:05:49 +01:00
Tim Neutkens
36164ead80
Don’t bundle next/asset if it’s not used (#5971) 2018-12-31 19:05:34 +01:00
Kyle Holmberg
72e7929242 Change page export validity check on client and server in development (#5857)
Resolves #4055 

Credit: https://github.com/zeit/next.js/pull/5095

I didn't use the ignore webpack plugin from the original PR and tested bundle size with https://github.com/zeit/next.js/pull/5339 - seems to be safe on that front.

Was able to get tests to pass locally, unsure of what goes wrong in CI 🤷‍♂️ 

**Questions**
1) The initial PR didn't include changes to `next-server/lib/router` in `getRouteInfo()`. Should the same changes be made within?

2) Should we add a test for rendering a component created via `forwardRef()`?

`component-with-forwardedRef`:
```javascript
export default React.forwardRef((props, ref) => <span {...props} forwardedRef={ref}>This is a component with a forwarded ref</span>);
```

some test:
```javascript
test('renders from forwardRef', async () => {
  const $ = await get$('/component-with-forwardedRef')
  const span = $('span')
  expect(span.text()).toMatch(/This is a component with a forwarded ref/)
})
```
2018-12-17 16:09:23 +01:00
JJ Kasper
af07611a63 Implement websockets based on-demand-entries ping (#4508)
Fixes #4495

Here's my approach for replacing the XHR on-demand-entries pinger #1364 #4495. I'm not sure if this is the way everyone wants to accomplish this since I saw mention of using a separate server and port for the dynamic entries websocket, but thought this would be a fairly clean solution since it doesn't need that.

With this method the only change when using a custom server is you have to listen for the upgrade event and pass it to next.getRequestHandler(). Example: 
```
const server = app.listen(port)
const handleRequest = next.getRequestHandler()

if(dev) {
  server.on('upgrade', handleRequest)
}
```
2018-12-14 12:25:59 +01:00
Tim Neutkens
1016b71011
Don’t prefetch on slow network / when datasaver is enabled (#5876)
Inspired by https://twitter.com/addyosmani/status/1073118564423356416

I've made the checking function slightly smaller (including both conditions on one line makes Terser optimize the condition).

cc @addyosmani
2018-12-13 19:08:23 +01:00
Connor Davis
419bec0b9b Fix #5674 Append crossOrigin on the client side too, add config option for crossOrigin (#5873)
# Fixes https://github.com/zeit/next.js/issues/5674

This adds config option
```js
// next.config.js
module.exports = {
  crossOrigin: 'anonymous'
}
```
This config option is defined in the webpack Define Plugin at build.
`Head` and `NextScript` now use the config option, if it's not explicitly set on the element.
This value is now passed to Webpack so it can add it to scripts that it loads.
The value is now used in `PageLoader` (on the client) so it can add it to the scripts and links that it loads.
Using `<Head crossOrigin>` or `<NextScript crossOrigin>` is now deprecated.
2018-12-13 01:05:21 +01:00
Tim Neutkens
fb92fdef54
Make sure const/async is transpiled (#5760)
* Make sure const/async is transpiled

* Use babel common compilation instead
2018-11-28 17:53:49 +01:00
Tim Neutkens
15bb1c5e79
Use Typescript to transpile Next.js core files instead of Babel (#5747)
- Replaces taskr-babel with taskr-typescript for the `next` package
- Makes sure Node 8+ is used, no unneeded transpilation
- Compile Next.js client side files through babel the same way pages are
- Compile Next.js client side files to esmodules, not commonjs, so that tree shaking works.
- Move error-debug.js out of next-server as it's only used/require in development
- Drop ansi-html as dependency from next-server
- Make next/link esmodule (for tree-shaking)
- Make next/router esmodule (for tree-shaking)
- add typescript compilation to next-server
- Remove last remains of Flow
- Move hoist-non-react-statics to next, out of next-server
- Move htmlescape to next, out of next-server
- Remove runtime-corejs2 from next-server
2018-11-28 15:03:02 +01:00
Tim Neutkens
c2eaf26ea9
Remove flow types (#5704)
* Remove flow-typed

* Remove flow types

* Remove the last types

* Bring back taskr dependency

* Revert "Bring back taskr dependency"

This reverts commit 38cb95d7274d63fe63c6ac3c95ca358a28c17895.

* Bring back preset-flow as it’s used for tests

* Revert "Revert "Bring back taskr dependency""

This reverts commit b4c933ef133f4039f544fb10bf31d5c95d3b27a2.
2018-11-21 16:04:37 +01:00
Tim Neutkens
b65c464d60
Move __NEXT_DATA__ into an application/json script tag (#5584)
* Move __NEXT_DATA__ into a application/json script tag

As outlined by @dav-is here https://github.com/zeit/next.js/pull/4943

* Set __NEXT_DATA__ for backwards compatability
2018-11-03 19:49:09 +01:00
Tim Neutkens
a2553bb46e
Remove registration code from initial markup (#5583)
Clears the way a bit for #4943, also makes _document.js less complex, and will allow us to move `__NEXT_DATA__` to a `application/json` script tag.

Also this causes a slightly smaller bundle size 😌
2018-11-03 01:59:54 +01:00
Tim Neutkens
965f50beb2
Remove pathname (#5424) 2018-10-10 21:58:15 +02:00
Tim Neutkens
82d56e063a
next-server (#5357) 2018-10-02 00:55:31 +02:00
Tim Neutkens
b1c4f3aec4
Monorepo (#5341)
- Implements Lerna
- Moves all source code into `packages/next`
- Keeps integration tests in the root directory
2018-10-01 01:02:10 +02:00