* Use Better Telemetry Directory
So, as it turns out, storing in `node_modules` is a bad idea.
Both npm and Yarn will remove additional files when you run `npm install` or `yarn install`.
Instead, we'll store this inside of Next.js' `distDir`. This should also be cached by users, if it's not, it probably won't be any worse as compared to `node_modules`.
* Fix directory name
* Fix build setup
* Record when export session is started
* Move more into branch
* Monkey patch `next-sass` and `next-less`
These two Next.js plugins use poor webpack practices: they define plugins without resolving themselves.
As a result, the resolution root is unknown by webpack and you get into package hoisting bugs.
To fix this, we emulate the logic these packages should've performed themselves on a best-effort basis.
* Add comments explaining the monkey patch
* Fix comment
* Update packages/next/build/webpack-config.ts
Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>
* 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
* Remove `config` export
This removes the `config` export instead of all exports.
Reverts #8889 (but with fixed behavior)
* Add test to ensure config object is dropped from client-bundle
These Recipies are not regularly audited to ensure they're using the most up-to-date and suggested practices.
We'll reintroduce the idea of "recipies" in the future, for now, the examples directory is a great place to start.
* Add auth0 example
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Remove LICENSE
* Add create next-app section
* Update to latest @auth0/nextjs-auth0
* Update user handling
* Update profile link to use <Link>
* Update .env template to reflect guides
* Simplify example
* Update example to prefer API call (temporary hardcoded url)
* Simplify state and ensure rerenders don’t race
* Clear up import being commented
* Make code style consistent
* Update pages to reflect required auth on the client-side
* Memoize the user on window
* Update now.json instruction
* Remove meta fields
* Update docs with explanation
* Update UI for auth0 example
## Changes
- [x] Remove _app.js usage
- [x] Migrate withRedux HOC to functional component
- [x] Add correct display name
- [x] Remove abstractions/boilerplate from example
- [x] Add useInterval HOC from Dan
* Add SPR Dynamic Routes to Manifest
This adds dynamic routes for SPR pages to the prerender manifest so we can configure the Now Builder to handle these routes as SPR routes. Otherwise, they're treated like normal `getInitialProps` pages.
* Fix types
* Configure the Default Revalidate
The default revalidate behavior should be configured by Next.js. Otherwise, the behavior might drift or change in non-semver compliant ways between Next.js and the builder (or other 3rd party setups).
* Add additional comment
The Now CDN does not support the `stale-if-error` header and already behaves like that for `stale-while-revalidate`.
Removing this header allows Now CDN to use its default headers instead of sending _only_ `stale-if-error` after stripping `s-maxage` and `stale-while-revalidate`.
* Add revalidate header and error when invalid
object from getStaticProps
* Make sprCache no-op in dev mode
* Update packages/next/next-server/server/next-server.ts
* Update tests for fixes
* Update getStaticProps error and add test
* Update manifest test
* Add validating revalidate value
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Change from error to warning high revalidate value
* initial commit for SPRv2
* Add initial SPR cache handling
* update SPR handling
* Implement SPR handling in render
* Update tests, handle caching with serverless next
start, add TODOs, and update manifest generating
* Handle no prerender-manifest from not being used
* Fix url.parse error
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Replace set with constants in next-page-config
* simplify sprStatus.used
* Add error if getStaticProps is used with getInitialProps
* Remove stale TODO
* Update revalidate values in SPR cache for non-seeded routes
* Apply suggestions from code review
* Remove concurrency type
* Rename variable for clarity
* Add copying prerender files during export
* Add comment for clarity
* Fix exporting
* Update comment
* Add additional note
* Rename variable
* Update to not re-export SPR pages from build
* Hard navigate when fetching data fails
* Remove default extension
* Add brackets
* Add checking output files to prerender tests
* Adjust export move logic
* Clarify behavior of export aggregation
* Update variable names for clarity
* Update tests
* Add comment
* s/an oxymoron/contradictory/
* rename
* Extract error case
* Add tests for exporting SPR pages and update
/_next/data endpoint to end with .json
* Relocate variable
* Adjust route building
* Rename to unstable
* Rename unstable_getStaticParams
* Fix linting
* Only add this when a data request
* Update prerender data tests
* s/isServerless/isLikeServerless/
* Don't rely on query for `next start` in serverless mode
* Rename var
* Update renderedDuringBuild check
* Add test for dynamic param with bracket
* Fix serverless next start handling
* remove todo
* Adjust comment
* Update calculateRevalidate
* Remove cache logic from render.tsx
* Remove extra imports
* Move SPR cache logic to next-server
* Remove old isDynamic prop
* Add calling App getInitialProps for SPR pages
* Update revalidate logic
* Add isStale to SprCacheValue
* Update headers for SPR
* add awaiting pendingRevalidation
* Dont return null for revalidation render
* Adjust logic
* Be sure to remove coalesced render
* Fix data for serverless
* Create a method coalescing utility
* Remove TODO
* Extract send payload helper
* Wrap in-line
* Move around some code
* Add tests for de-duping and revalidating
* Update prerender manifest test