* Compile for the current version of Node.js by default when producing server builds.
* Update packages/next/build/babel/preset.ts
Co-Authored-By: Joe Haddad <timer150@gmail.com>
* Include server variation in Babel cacheKey
Following this example confused me at first because it looked like it was using native fetch, and when that didn't work server-side I wasn't sure if that was my mistake or an issue with the docs.
* 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
In versions prior to ^9, default export with AMP was to create a
`index.html` file for each page. This has changed in ^9.0 with intruduction of a new
configuration options `exportTrailingSlash`. Current docs for AMP
exports are not correct for this behaviour.
Fixes#7931
* 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__
This function is used to return the /pages folder content.
The way it is today is that every run might result in a different order of files, which makes the whole webpack chunks be different.
An ordered list of files will result in a deterministic build, which will improve caching.
* API routes examples and documentation
* Update examples/api-routes-micro/README.md
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update examples/api-routes/README.md
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Apply suggestions from code review
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update API routes docs
* Improve example to reflect dynamic routes
* Update readme to reflect API routes changes
* Apply suggestions from review
* 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 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
* Added basic example for dynamic routing
* Added some basic docs for dynamic routing
* Added more docs for dynamic routing
* Used doctoc
* fixed lint issues
* Added useRouter to docs
* Removed getInitialProps examples that are only using router props
* Added useRouter to the navigation
* Small fix
* Updated to the latest dynamic routes implementation
* lint fix
* Update dynamic routing example
* Tweak dynamic routing documentation
* Make basic example basic again
* Adjust dynamic routes section
* Remove query param for dynamic routes example
* Remove old note
* Fix linting
* 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
Using runtime configuration can cause you to de-optimize entire classes of optimizations.
These optimizations could make your application an order of magnitude faster (i.e. prerendering).
* 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
* Re-require all module information for client-side initializers list
We really should re-work how our loadable code words, because this passes an excessive number of modules to the client.
In the ideal world, we only pass the entry module id of each chunk, but there's no point in investing the time until we switch to webpack 5 which completely revamps the chunk graph API.
* Get a unique set of ids
* Update getInitialprops docs
* Update docs for prefetch
* Updated prefetch docs
* Removed hotSelfAccept from docs and othr changes
* Prefer /public
* dots dots dots dots
* Added docs for Automatic Pre-rendering
* Added a note to <Link />
* Removed 404 example
* Added references for Automatic pre-rendering
* Added a typescript section for AMP
* Executed doctoc again to add AMP sections
* Properly explain automatic pre-rendering
* Switch back to LF
* Apply corrections
Co-Authored-By: Joe Haddad <timer150@gmail.com>
* Minor corrections
* Added back some periods
* Added back some periods
* 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
* replace recursive-copy with own implementation
* update yarn.lock
* do not filter out not directories
* do not fail if folder already exists
* replace `\` by `/` when sending pathes to filter
* use fs-extra only in tests
* investigate and test recursive-copy npm module
* improve test by creating fixtures programmatically
* remove recursive-copy npm module test
* add recursive-copy to bench
* add bench:recursive-copy script
* fix Sema import in recursive-copy.ts
* small improvements
* 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
* 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
* Revise dynamic route generation
This implements a new tree-based route sorting algorithm that uses a Depth-First-Traversal approach to correctly sort the routes.
This provides better clarity over a `.sort()` based approach and will scale well as we add new features in the future.
* Update import
* 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
* 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
* 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
* App, Document, Page, Error types description
* Router description
* Added head changed router
* Additions
* Fix examples
* Push and replace details
* Update packages/next-server/lib/head.tsx
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update packages/next-server/lib/utils.ts
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update packages/next/types/index.d.ts
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update packages/next/pages/_document.tsx
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update packages/next/pages/_document.tsx
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update packages/next/pages/_app.tsx
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* Update packages/next/pages/_document.tsx
Co-Authored-By: Luis Fernando Alvarez D. <luis@zeit.co>
* 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
* Disable babel-loader cache in flying shuttle mode
* Move cleaning up old babel-loader caches
* Change option name for disabling cache on babel-loader
* Add retrying to CircleCi and run prepublish separately to get better logs in Azure
* Apply workaround for Azure node 10 and ncc
* Update incorrect webpack imports
* Use ncced autodll-webpack-plugin
* Move autodll-webpack-plugin to devDependencies
* Show helpful warning when @types/react isn't found
* Apply suggestions from code review
Co-Authored-By: Resi Respati <resir014@gmail.com>
* Update warning for yarn
* Check earlier so we can log one install command for TypeScript deps
As mentioned on previous PRs related to TypeScript, setting `esModuleInterop`
to `true` automatically sets `allowSyntheticDefaultImports` to `true` as
well, so this config validation is not required.
Reference: https://github.com/zeit/next.js/pull/7169#discussion_r280831148