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.
* Remove static optimization from message
This check does not pertain to automatic static optimization.
Closes https://github.com/zeit/next.js/issues/9042
* Update help message
* Add buildId to SPR data routes
* Update buildId replace in serverless loader
* Use new RegExp and add comment
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Test to ensure client transition and handle / data route
* Remove experimental.publicDirectory config
* Error when public is set as an output dir
* Remove experimental.publicDirectory checks
* Update publicFiles checking in next build
* Informative Error for Invalid Global CSS
This adds a helpful error message with a (basic) err.sh link for invalid Global CSS usage.
We'll want to expand on this topic more and offer alternatives when CSS Modules support lands.
* Update expected error message
* 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
* 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
* 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
* Fix CSS Ordering
This fixes CSS ordering between development and production.
Before this change, globally imported CSS would come _after_ `<style jsx global>` in development, but _before_ in production.
After this change, it'll always be applied before.
* Move to correct element
* Add tests
* Fix obnoxious indents
* Update test/integration/css/fixtures/with-styled-jsx/pages/index.js
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* 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
* Match public files priority in dev
* Remove un-needed old public file handling
* Run public file priority test for non-dev also
* Make sure to enable publicDirectory
* Add checking for conflicting pages in dev and during build
* Add error for public dir middleware conflict
* Add err.sh for _next conflict
* Move up public dir conflict checking
* Only run _next conflict check in dev when path contains it
* 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
* Fail build on duplicate pages
This will fail the `next build` command when a duplicate page is found.
In development, we'll emit a warning instead of crashing the dev server.
* Add test for warning in development
* Only issue a warning
* Fix production test
* Fix development test
* Remove useless arg
* Warn in development, too
* TypeScript report on active pages only
The TypeScript integration needs to report on active pages only.
When inactive pages are reported, they block the compilation and prevent the user from fixing the error (because the file isn't watched).
We cannot add the file to the webpack watcher because the compilation has already been sealed.
* Remove TODO message
* Test that inactive pages are not type checked
* better type for AppTree in NextPageContext
* updated tests
* new AppTreeType type and updated tests
* removed a commented out line
* another take on the type of AppTree, with updated tests
* allow passing additional props to AppType
* Update suite name
* 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
* Adjust lib chunk naming algorithm and prevent duplicate react-dom
* Remove alias for react-dom and update separator replacement logic
* Add comment to webpack-config
* Add integration test for react-dom duplication
* Switch to using hash for lib chunk names
* remove extra file from PR
* Remove another extraneous change
* Remove test based on lib chunk name
* Update index.test.js
* Check for TypeScript files for auto setup
This re-adds the behavior and only checks the `pages` directory for speed reasons.
* Adjust logic
* Handle not found too
* 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
* Add deprecation warning for App Container
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Tweak for more dead-code elimination
* Add warning when empty object is returned
from getInitialProps
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <joe.haddad@zeit.co>
* Apply suggestions from code review
Co-Authored-By: Jan Potoms <potoms.jan@gmail.com>
* Add experimental optimizeLibraries flag, currently prunes Moment.js locales
* expose moment for use in assertion
* try with the same setup as the production integration test
* Apply optimiztaions in dev and on server so they're consistent.
* fix build (oh dear)
* Update index.test.js
* Rename flag to future.excludeDefaultMomentLocales
* Adjust impl
* Fix dynamic APIs with query params
If you define a dynamic API such as
```
pages/
api/
[id].js
```
This api becomes available at `/api/[id]`. If you send a request with
a query parameter the value of `req.query.id` will include the query
string as well as the path parameter.
E.g. the request to `/api/2?test=123` will result in `req.query`
being
```javascript
{
id: "2?test=123",
test: "123",
}
```
instead of
```javascript
{
id: "2",
test: "123",
}
```
* Fix url parse in serverless loader
* Add serverless test
* Fix conflict between defaultPathMap and default 404.html export,if have a page in pages/404.js
* Update packages/next/export/index.js
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* add test export-override-404
* Add custom profiler / tracer
This captures both client/production builds and everything before and after is cpu profiled, which makes sure that the whole process instead of just webpack is included in the final report.
* Update tests
* Update profiling-plugin.js
* Rename profiling-plugin.js to profiling-plugin.ts
* Update profiling-plugin.ts
* Update and rename profiling-plugin.ts to profiling-plugin.js
* Update webpack-config.ts
* Update profiling-plugin.js
* Add types
* Add missing type
* Add back TypeScript linting
* Remove tracing-js
* Only read for typescript files if there's no tsconfig
* Update verifyTypeScriptSetup.ts
* Remove the recursive check for TS files
* Remove unused import
* Updated tests
* Add a check for the content of tsConfig
* Clean up
* utf8
* 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
* 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
* Throw error if next export detects an api route
* Moved the test to the export tests
* Added missing comma
* Move the API route comment
* Add comma after replace
* Show a warning instead
* 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
* 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
* 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
* Experimental: Serverless Trace target
The Serverless Trace target produces Serverless-handler wrapped entrypoints, but does not bundle all of `node_modules`.
This behavior increases bundling performance to be more akin to `target: 'server'`.
This mode is expected to be used with smart platforms (like [ZEIT Now](https://zeit.co/now) that can trace a program to its minimum dependencies.
* Use more generic variables
* Add asset relocator for production mode of serverless trace
* Verify Firebase compatiblity
* Revert "Add asset relocator for production mode of serverless trace"
This reverts commit 8404f1dcf28b60edab41a56c94b38dcd3fddec20.
* Add serverless trace tests
* Add _isLikeServerless helper
* Make constants
* Fix export
* Update packages/next-server/server/config.ts
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* Use a global helper for is like serverless
* Update import for isTargetLikeServerless
* Update packages/next/build/index.ts
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* 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
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.
This PR introduces the possibility to change the size of the parsed body. This brings features like:
- Adjusting the size of the incoming message
- Better security
* 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
* Completely rewrite Create Next App
* Sort imports
* Show what package manager is being used
* Fix project name suggestion
* Update tests for new implementation
* Use normal prepublish command for on-install
* Upgrade Node version
* Switch to 8.16
* Disable v8 cache
* Swap out update check package and fix CLI boot
* Update autoExport wording to automatic static optimization
* Add sufficiently informative error message
- Update other Next error message for consistency
* Implement feedback - add missing character
Co-Authored-By: Lukáš Huvar <lukas@huvar.cz>
* Fix TypeScript errors
* Update test from autoExport to automatic static optimization
- Also reflect new wording of error message for readability
* Add test for handle non-page in pages
- When target: severless
* 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
Notably, this PR fixes `faunadb` which relies on `formidable`.
n.b. `formidable` is an unmaintained legacy npm package that uses practices not compatible with the modern ecosystem.
* 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__
* Change static method handling and pages revert
* Allow and reflect old behaviour
* Post should return 501
* Add back old test
* Invert logic
* Handle 501 for pages in separate location
* Remove usage of 501 HTTP status code
* Prevent information leak
* Add test
* Only 405 if the page exists -- 404 if it doesn't
* Handle sent responses
* Revert "Handle sent responses"
This reverts commit 5e9012ae29b611c25ed1e090756a25dbe3437182.
* Fix bad test
* Switch back to quiet
* Update test/integration/production/test/index.test.js
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* Add prerender PageConfig option
* Update PageConfig type
* Add inlining of data when pre-render is set and add tests
* Update types import
* Add check for props
* Rename prerender to experimentalPrerender for now
* Remove `withAmp` and do not expose `isInAmpMode`
This pull request removes the `withAmp` higher-order component in favor of the exported configuration object.
Retaining this backwards compatibility isn't worth the extra maintenance burden, given it hasn't been released for very long and the migration is ultra-simple.
I'm 👎 on retaining backwards compatibility just for the sake of it.
Migration example follows. I'm willing to write a codemod if reviewers feel it's necessary.
*Before*
```js
import { withAmp } from 'next/amp'
function Home() {
return <h1>My AMP Page</h1>
}
export default withAmp(Home)
// or
export default withAmp(Home, { hybrid: true })
```
*After*
```js
export default function Home() {
return <h1>My AMP Page</h1>
}
export const config = {
amp: true,
// or
amp: 'hybrid',
}
```
* Fix { amp: 'hybrid' }
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* Update helper function to invoke only on get
* Tests for body parsing
* Update api-utils.ts
* Update next-server.ts
* Update packages/next-server/server/next-server.ts
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* Fix TypeScript typing
This correctly defines `process.browser` instead of `process.env.browser`.
It also removes `process.crossOrigin` because it's not found in our documentation anywhere and is mostly used for internal purposes.
* Make sure `process.browser` doesn't throw a type error
* Split globals from Next.js module
* Allow `test` as a valid NODE_ENV
* Fix type assignment
* Make sure global types get published
* Fix test
* 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
* Add handling for invalid pages during autoExport
* Add err.sh link for invalid page export
* Fix typo
* Apply suggestions from code review
Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>
* Add export const config support and make withAmp a no-op
* Use babel plugin for PageConfig
* Fix serverless-loader exports
* Add backwards compatibility for withAmp
* Default `target` in `loadConfig` instead of `next build`
We should set the target from the environment variable during `loadConfig` instead of in `next build`. This ensures all other locations in Next.js that rely on `config` can read the correct value to toggle behaviors.
* Use object destructuring
* Add tests for builder target
* Run start with serverless
* Adjust Flying Shuttle message
This adjusts the flying shuttle message for when a shuttle is not found or cannot be reused to reduce confusion to the user opting into the feature.
* Tweak message
* Cookies and Query parsing for API request
* Adding JSON and SEND
* First body parsing
* Body parsing
* Remove extra try catch
* Fix tests
* Only server bundling for API routes
* Update packages/next-server/server/api-utils.ts
Co-Authored-By: Tim Neutkens <tim@timneutkens.nl>
* Revert on demand server changes
* Use content-type for parsing
* Update packages/next-server/server/api-utils.ts
Co-Authored-By: Jan Potoms <potoms.jan@gmail.com>
* Add tests for server compilation
* Add body limit
* Change API to function chaining
* Limit test
* Refresh query on mount for exported pages
* Make sure to only refresh query if it is different
* Only update if search isn't empty
* Merge pre-rendered query values with
current query values
* Remove dynamic restriction for autoExporting
* Update dynamic routing test fo autoExport
* Remove autoExport from client-navigation test
* Remove logs and update trailing slash config
* Update nextExport tests in client-navigation
* Disable autoExport in export suite
* Upgrade to latest AMP toolbox optimizer
* Remove amphtml from AMP only and update tests
* Update tests
* Apply suggestions from code review
Co-Authored-By: Joe Haddad <timer150@gmail.com>
* 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
* Add canonicalBase config to allow setting
absolute path for canonical link
* Make sure canonicalBase is set for
export and serverless
* Move canonicalBase to amp.canonicalBase
* Update tests with canonicalBase config
* Update tests
* run lint-fix
* Fix canonicalBase config parsing
* Fix canonicalBase during export
* Update amphtml tests
* Update escape string regexp operators
* temp
* Extract getRouteRegex func
* First iteration of dynamic routing for production only
* Correctly order prod
* Add serverless support
* Single line it
* noop routes
* Format doc
* Fix dynamic routing for dev
* Add flag for dynamic routing
* Update packages/next-server/lib/router/router.ts
Co-Authored-By: JJ Kasper <jj@jjsweb.site>
* remove example
* Add router tests
* Format code
* Sort routes
* Update to not use posix path methods
* Add automatic exporting of pages with no getInitialProps
* Add support for exporting serverless to static
and serving the html files during next start
* Fix missing runtimeEnv when requiring page, re-add warning
when trying to export with serverless, and update tests
* Update flying-shuttle test
* revert un-used pagesManifest change
* remove query.amp RegExp test
* Fix windows backslashes not being replaced
* Re-enable serverless support for next start
* bump
* Fix getInitialProps check
* Fix incorrect error check
* Re-add check for reserved pages
* Fix static check
* Update to ignore /api pages and clean up some tests
* Re-add needed next.config for test and correct behavior
* Update RegExp for ignored pages for auto-static
* Add checking for custom getInitialProps in pages/_app
* Update isPageStatic logic to only use default export
* Re-add retrying to CircleCi
* Update query during dev to only have values
available during export for static pages
* Fix test
* Add warning when page without default export is
found and make sure to update pages-manifest
correctly in flying-shuttle mode
* Fix backslashes not being replaced
* Integrate auto-static with flying-shuttle
and make sure AMP is handled in flying-shuttle
* Add autoExport for opting in
* 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
* Remove loadGetInitialProps from _app and fix
cache-control header not being
* Update to still use loadGetInitialProps
in _app since it's simpler
* Add test for cache-control header with custom _app
* Add --no-subfolders argument to next export
* Use experimental.exportTrailingSlash instead of a cli flag
* Add experimental.exportTrailingSlash documentation
* Add tests for export with experimental.exportTrailingSlash
* Remove docs
* Remove comment
* Make styles compatible in AMP mode
* bump
* Update to parse styles from fragment for
backwards compat in AMP mode
* Add test for AMP styles fragment support
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.
This PR adds the `_error`-page as an `404.html`-export, even when it is not explicitly defined in a custom `exportPathMap`.
It also fixes two false negative tests related to this. Previously the tests were matching the fallback 404-page from the test-server, rather than the `404.html`-page from next, which was actually not being generated. The test server is also not set up to serve `/404.html` as `/404` which the tests now reflect.
**Caveat**
In its current state, this PR removes `/404.html` from the `defaultPathMap` passed to the custom `exportPathMap`-functions, since it instead adds it after that function is run. While it is possible that someone is relying on this to exist, it is to my knowledge undocumented and also unlikely to be used for anything but merging it into the custom pathMap.
Since this would now merge `undefined` which would result in it being added later on anyway, I deemed it safe, but would be happy to undo that part of the PR if necessary as it was only cleanup.
**Examples**
As a way to demonstrate what this PR does, this is how examples changed:
* `basic-export` - Behaviour is unchanged, still has a `404.html`
* `with-static-export` - Now has a `404.html`
if `&=1` is used to point to the `amphtml` version of a page it get's escaped causing it to become `&amp=1` this fixes it to stay as `&=1`
Closes: #7038
* Update amphtml and canonical rels, put amp behind
experimental flag again, and update checking for amp query
* Fix typescript error
* Re-add flag to next.config.js
* Make sure AmpContext is available during _document
render and update filtering of script tags in AMP mode
* Update amphtml test to make sure
AmpContext is set for _document render
* Fix stray comma in render.tsx
* Add WithAmp to enable AMP support for
pages instead of .amp.js
* Update handling for exporting AMP
* Fix ampPath in export for / path and
revert isAmp logic to handle right
* Update amphtml test suite
* Add handling for noDirtyAmp during
export and update amp-export test suite
* Update serverless and export-default-map
test suites
* Update require-page tests
* Add Flying Shuttle tests
* Test second version of server
* Finish first version of tests
* Apply suggestions from code review
Co-Authored-By: Timer <timer150@gmail.com>
* Apply suggestions from code review
Co-Authored-By: Timer <timer150@gmail.com>
* Remove CLI and negative page building
* Remove select all tests
* Update test of getSpecifiedPages
* Prune old tests from snapshot
* Remove old flying shuttle tests
* Fix re-rendering on client after navigating
back from external site
* Clean up tagging before unload
* Add check for history.state 1/2
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Add check for history.state 2/2
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Add check for options
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Add test for navigating to external site and back
also added testing in safari and firefox
* Add test for query in url
* Do not clear the console
Its rude to clear the console, you may be sharing output with other processes even in tty mode.
* Remove unused dependency
* Dedupe and cleanup dev output without clearing
* use logError
* Remove exit handler
* Add next helper
* Add log helpers
* Switch store to log helpers and a shallow object compare
* Update other files to use new logging utility
* request => build
* Update ready on messages
* Use case insensitive matching
* Add amp request header and check for amp
query in serverless mode
* Add serverless test for an AMP page
* Update to handle querystring weirdness
* Update serverless test config
* Get all modules included in build
* Add tests
* Get all modules contained per entry chunk
* Sort files
* Add specialized page entry to manifest
* Split manifest into pages and chunks key
* Update test
* Use relative paths to build directory
* Update test
* Added amp-toolbox-optimizer and added
optimizing AMP pages as dirty and clean
* Fix amp-optimizer breaking serverless build
* Exclude amp-toolbox-optimizer from serverless build
* Added check to make sure hybrid AMP pages
optimize cleanly during export
* Add check to make sure noDirtyAmp is applied
Drops user `<script>` tags and shows a warning in AMP mode. Right now they are only dropped in production mode and left in dev mode so the validator shows its warning since it looks like conflicting props log messages are being cleared causing them to not show.
Closes: #6688
Update tests to setup webdriver stuff in `jest-environment` and re-use one browser session instead of spawning one for each webdriver call to prevent creating too many BrowserStack sessions.
* Add default viewport meta tag (fixes#6698)
* Do not inject default viewport when rendering an AMP document
* Remove redundant viewport on error page
* Plumb withSideEffect() to pass through props, then use that for isAmp.
* Add tests for viewport meta tag.
* Fix linting
* Update dedupes test
* Add err.sh link and pool validation results
to wait to show error until export is finished
* Fix wording in amp-export-validation err.sh
* Update validation error message
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Update ways to fix text
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Update why the error occurred wording
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Update wording some more
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Add more export tests for AMP
* Remove console.log
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* remove extra line
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Break out client-navigation and rendering
test from basic test
* Try with parallelism dialed back to 3
* Update jest-junit for more compatible timings in CircleCI
* Bump to test timings
* Use filepath for suitename in jest-junit
* Store reports as artifacts
* Try using classname for timings
* Bump
* Remove reports from artifacts
* Add support for .amp.js pages and
resolving /page?amp=1 to page.amp.js
* Update amp tests
* Update example and clean up amp page resolving
* Add nested amp test
* page => normalizedPage
* Add type to page options
* Add handling of amp with all pageExtensions
and normalize page
* Make sure findPageFile only falls back to
amp if enabled
When overriding `config.resolve.alias` incorrectly webpack will throw an error because private-next-pages is not defined. This adds a more descriptive error explaining the error better.
Fixes: #6681
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.
* Check for the user's home directory in the build output
* Output files on windows for debugging
* add process cwd
* try more paths
* Add branch for winblows
* Print info on error
* set proper env
* try fix
* Show a better error when someone throws undefined
* Update error wording
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Update error wording in test
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* Update test and add check for statusCode
before updating error
### changes
#### remove trailing spaces
When I was using example I noticed trailing spaces.
So, this PR removes the trailing spaces of json file, README, and others.
`examples/with-jest-typescript/src/modules/cars/Overview.tsx` also has it, but this time it did not change as tslint error occurs at commit.
* Update to use the correct router instance in withRouter so error is
thrown when router method is used during SSR
* Revert changes to with-router and add error to methods on
direct router instance
* Extend Router and override methods with error instead
* Update ServerRouter, add err.sh, and add test
* 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
* Show error when `router` or `Component` are returned in _app.js
getInitialProps
* Update to only show error in dev mode
* Update packages/next-server/server/render.tsx
Co-Authored-By: ijjk <22380829+ijjk@users.noreply.github.com>
* make router UrlIsNew comparing method work as expected
* Remove shallow-equals from router and update urlIsNew check
* Remove shallow-equals test since it is no longer used
* Add integration test for asPath query
* 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
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
Relevant commit: f913aabe16
~~I needed to upgrade Standard to work with JSX fragment syntax.~~ This caused too much noise so I just stopped using Fragments.