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.
Arguments that held the same name as one of the default commands were filtered out, causing issues.
For example `next build build` would get rid of the second `build` parameter.
Fixes#6263
Fixes#5347
The main issue is that we were waiting only 1 level of dynamic imports, so the dynamic imports nested inside other dynamic import files were not awaited. This would cause either a flash of loading states or you wouldn't see the loading state (because of preload) but it would then show a hydration warning in development.
Thanks to @arthens for providing the reproduction that I modelled the tests after.
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
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.
* Set default `Error` status code to 404
This is an appropriate default behavior because:
1. When the server encounters an error, the `err` property is set.
2. When the client-side application crashes, the `err` property is set.
This means the "only" way to render the `/_error` page without an error
is when a page is not found (special condition).
Fixes#6243Closes#5437
* Add new integration test for client side 404
* single quotes
* Remove unused variable
* Standard needs to go away
* Whoops
* Check for null status code in res and err
* Only check response for valid statusCode
* Implement circular JSON err.sh link
* Add test for getInitialProps returning circular json
* Make test warn less
* Fix tests
* Add reference to original tests
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.
original code in `/lib/router/router.js`
```
urlIsNew (pathname, query) {
return this.pathname !== pathname || !shallowEquals(query, this.query)
}
```
the urlIsNew compare `this.pathname` to an argument `pathname`
the invokers:
```
// If asked to change the current URL we should reload the current page
// (not location.reload() but reload getInitialProps and other Next.js stuffs)
// We also need to set the method = replaceState always
// as this should not go into the history (That's how browsers work)
if (!this.urlIsNew(asPathname, asQuery)) {
method = 'replaceState'
}
```
the parameter here is `asPathname` destructured from `asPath`
so here is a problem when we reuse a single page rendered in two asPaths
pages/a.js
```
<>
<Link href='/a'><a>goto a</a></Link>
<Link href='/a' as='/b'><a>goto b</a></Link>
</>
```
If we navigate to page /a, then click 'goto b', actually the history is replaced, not pushed.
It is expected that history could be correctly pushed and popped as long as the browser url is changed.
Extends on #5927, instead of `.default` we'll expose `.render` which is semantically more correct / mirrors the naming of the custom server API.
I've updated the spec in #5927 to reflect this change.
(copied from #5927):
```js
const http = require('http')
const page = require('./.next/serverless/about.js')
const server = new http.Server((req, res) => page.render(req, res))
server.listen(3000, () => console.log('Listening on http://localhost:3000'))
```
Saw a reply on the original pull request that the WebSocket using a random port broke their set up so I added a `--websocket` or `-w` argument similar to the `-p` argument to allow manually setting this port also.
**This does not change existing behavior.**
building to serverless is completely opt-in.
- Implements `target: 'serverless'` in `next.config.js`
- Removes `next build --lambdas` (was only available on next@canary so far)
This implements the concept of build targets. Currently there will be 2 build targets:
- server (This is the target that already existed / the default, no changes here)
- serverless (New target aimed at compiling pages to serverless handlers)
The serverless target will output a single file per `page` in the `pages` directory:
- `pages/index.js` => `.next/serverless/index.js`
- `pages/about.js` => `.next/serverless/about.js`
So what is inside `.next/serverless/about.js`? All the code needed to render that specific page. It has the Node.js `http.Server` request handler function signature:
```ts
(req: http.IncomingMessage, res: http.ServerResponse) => void
```
So how do you use it? Generally you **don't** want to use the below example, but for illustration purposes it's shown how the handler is called using a plain `http.Server`:
```js
const http = require('http')
// Note that `.default` is needed because the exported module is an esmodule
const handler = require('./.next/serverless/about.js').default
const server = new http.Server((req, res) => handler(req, res))
server.listen(3000, () => console.log('Listening on http://localhost:3000'))
```
Generally you'll upload this handler function to an external service like [Now v2](https://zeit.co/now-2), the `@now/next` builder will be updated to reflect these changes. This means that it'll be no longer neccesary for `@now/next` to do some of the guesswork in creating smaller handler functions. As Next.js will output the smallest possible serverless handler function automatically.
The function has 0 dependencies so no node_modules are required to run it, and is generally very small. 45Kb zipped is the baseline, but I'm sure we can make it even smaller in the future.
One important thing to note is that the function won't try to load `next.config.js`, so `publicRuntimeConfig` / `serverRuntimeConfig` are not supported. Reasons are outlined here: #5846
So to summarize:
- every page becomes a serverless function
- the serverless function has 0 dependencies (they're all inlined)
- "just" uses the `req` and `res` coming from Node.js
- opt-in using `target: 'serverless'` in `next.config.js`
- Does not load next.config.js when executing the function
TODO:
- [x] Compile next/dynamic / `import()` into the function file, so that no extra files have to be uploaded.
- [x] Setting `assetPrefix` at build time for serverless target
- [x] Support custom /_app
- [x] Support custom /_document
- [x] Support custom /_error
- [x] Add `next.config.js` property for `target`
Need discussion:
- [ ] Since the serverless target won't support `publicRuntimeConfig` / `serverRuntimeConfig` as they're runtime values. I think we should support build-time env var replacement with webpack.DefinePlugin or similar.
- [ ] Serving static files with the correct cache-control, as there is no static file serving in the serverless target
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/)
})
```
This message is from @timneutkens after making changes:
- Convert executables to Typescript
- Remove `minimist` in favor of `arg`
- Implement `--node-args` usage: `--node-args="--throw-deprecation"`
- Adds tests for usage of the `next` cli
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)
}
```
# 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.
This PR Fixes#4920
So the problem is that when a next.js application is built on windows, the `pages-manifest.json` file is created with backslashes. If this built application is deployed to a linux hosting enviroment, the server will fail when trying to load the modules.
```
Error: Cannot find module '/user_code/next/server/bundles\pages\index.js
```
My simple solution is to modify the `pages-manifest.json` to always use linux separator (`/`), then also
modify `server/require.js` to, when requiring page, replace any separator (`\` or `/`) with current platform-specific file separator (`require('path').sep`).
The fix in `server/require.js` would be sufficient, but my opinion is that having some cross-platform consistency is nice.
This change was tested by bulding an application in windows and running it in linux and windows, aswell as building an application in linux and running it in linux and windows. The related tests was also run.
# Conflicts:
# test/integration/production/test/index.test.js
Fixes#3705Fixes#4656
- No longer automatically dedupe certain tags. Only the ones we know are *never* going to be duplicate like charSet, title etc.
- Fix `key=""` behavior, making sure that if a unique key is provided tags are deduped based on that.
For example:
```jsx
<meta property='fb:pages' content='one'>
<meta property='fb:pages' content='two'>
```
Would currently cause
```jsx
<meta property='fb:pages' content='two'>
```
### After this change:
```jsx
<meta property='fb:pages' content='one'>
<meta property='fb:pages' content='two'>
```
Then if you use next/head multiple times / want to be able to override:
```jsx
<meta property='fb:pages' content='one' key="not-unique-key">
<meta property='fb:pages' content='two' key="not-unique-key">
```
Would cause:
```jsx
<meta property='fb:pages' content='two'>
```
As `key` gets deduped correctly after this PR, similar to how React itself works.
- 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
**What's this PR?**
Based on the feedback on [this PR](https://github.com/zeit/next.js/pull/5722) @timneutkens asked me to create a test for `ssr: true`
**What's it do?**
- adds a test for setting `ssr: true` - /basic
- adds a test for setting `ssr: true` - /production
* Add node_modules bundling under the —lambdas flag for next build
* Run minifier when lambdas mode is enabled
* Add lambdas option to next.config.js
* Add test for lambdas option
Takes advantage of caching between builds for Terser, also makes writing caches for babel-loader faster by disabling compression.
Results for zeit.co (350 pages):
Without cache:
[4:16:22 PM] Compiled server in 1m
[4:16:57 PM] Compiled client in 2m
✨ Done in 125.83s.
With cache:
[4:19:38 PM] Compiled client in 17s
[4:19:50 PM] Compiled server in 29s
✨ Done in 31.79s.
Note: these results are from my multi-core Macbook Pro 2017, exact specs:
MacBook Pro (13-inch, 2017, Four Thunderbolt 3 Ports)
- 3,3 GHz Intel Core i5
- 16 GB 2133 MHz LPDDR3
- Intel Iris Plus Graphics 650 1536 MB
The `without cache` build runs uglify in parallel, so without cache is likely to take longer on environments where you have only 1 core available.
The `with cache` build however runs in a single thread, so the results should be similar.
* Update jest
* Let jest start chromedriver
This makes sure chromedriver always ends even if the test was canceled by the user.
* Properly close browser in production-config test
* Properly close browser in production/security test
* Properly close browser in export test
* Properly close browser in app-aspath test
* Remove taskr from project root
This isn’t needed anymore
* Readd taskr to project root (temporary)
* Improve global setup/teardown
* Properly close browser in basic/client-navigation test
Clicking an target=_blank link will open a second browser window. We can only close this by using broser.quit()
* Set a default path for wasm modules
* Added the mimetype "application/wasm" for wasm files
* Upgrade write-file-webpack-plugin to 4.4.1
* Made dynamic(import()) in test to dynamic(() => import())
* Add failing tests
* Upgrade wd module
* Pass dynamic import webpack ids to the client side
* Pass through webpack ids to initalializer and only use those
* Compile dynamic(import()) to dynamic(() => import())
* Default dynamicIds
* Use forked hard-source-plugin
* Possibly fix test
* Make tests fail less intermittently
* Temporarily disable hard-source in production
* Make sure dynamic import chunks are unique
* Disable hard-source
* Log html if error is thrown
* Fix test
Since we are now using webpacks `mode` flag we can get rid of:
* `webpack.optimize.ModuleConcatenationPlugin`
* `webpack.DefinePlugin` (`process.env.NODE_ENV`)
https://webpack.js.org/concepts/mode/
* Add test for /_next/development route
* Make sure useFileSystemPublicRoute: false only disables filesystem routing
* Bring back comment
* Add useFileSystemPublicRoutes tests
Currently, using `as` will cause the router to think the URL is not changing in the case where you're re-rendering the same page with a different route. This would most likely be an issue for custom servers
which are using shallow routing.
This should be an invisible change for non-custom-server users, since `as` is defaulted to `url` if not set.
This should resolve#3065.
Fixes#5038
The problem with `constructor` is that it doesn't have `context` yet when being called. It's also considered unsafe to add a side-effect on constructor except when server-rendering
~I am not sure if this is a valid fix yet, but I was going to let CI run the tests for me. I'll close and look into it if the build fails.~
Let me know if this will cause issues, but I don't think it should. The React docs recommends moving `componentWillMount` logic into the constructor
`<Container>` does not receive any property. There is no way the *scrollToHash* logic can work right now. I believe it's a regression. It was working fine at some point. I'm sorry, I'm too lazy to add a test.
This fix was tested on Material-UI 👌.
This bug reproduction is the following:
As soon as you want to transition to a new page with a hash. The scroll doesn't change.
- start on pageA
- you scrollTop to 100
- you move to pageB#hash
- you stay at scrollTop 100, but #hash is at scrollTop 400.
Depends on https://github.com/zeit/next-plugins/pull/228
Failing tests are expected as `@zeit/next-css` has to be updated/released first.
This implements rendering of `.css` chunks. Effectively removing the custom document requirement when adding next-css/sass/less/stylus.
* Compile pages to .next/static/<buildid>/pages/<page>
* Fix test
* Export class instead of using exports
* Use constant for static directory
* Add comment about what the middleware does
* Add support for custom App and Component enhancers
* Add ctx.renderPage test
* Add tests for single enhancer function
* Cleanup renderPage options check
* Cleanup
* Add comment about backwards compatibility for renderPage
* Add more test cases
There are occasions where it is useful to have `target='_blank'` on hyperlinks within your own app. (For example, if your app is being loaded in an iframe and you'd like for the links to break out in to new windows.)
With this PR, the `onClick` logic in Link now checks for an external target on the nested <a/> tag, and will fall back to the default behavior if it's present, similar to the logic for shift-/cmd-clicking the link.
## What's wrong
This problem is specific to errors that happen on the client _after_ the initial mounting of the component. (The router has special logic to handle exceptions thrown in `getInitialProps` during a client-side navigation, and I've confirmed this logic is correct.)
Specifically, if the page is mounted, and you raise an exception on the page, the exception will cause the error page to be mounted without ever invoking `getInitialProps` on the new App/Error page pairing.
This has been illustrated with multiple repros in #4574.
## Why is it broken
This regression was introduced two months ago in #4156, where the invocation of `getInitialProps` was removed from the app's top-level error handler. Specifically, [this line](https://github.com/zeit/next.js/pull/4156/files#diff-895656aeaccff5d7c0f56a113ede9662L147) was removed and [replaced by a comment](https://github.com/zeit/next.js/pull/4156/files#diff-895656aeaccff5d7c0f56a113ede9662R167) that says that "`App` will handle the calling of `getInitialProps`".
I believe the sentiment about "`App` will handle calling `getInitialProps`" is mistaken. In fact, it really doesn't make sense on its face, since it would require an instance lifecycle method of `App` (which is mounted immediately after the comment) to invoke the `static getInitialProps` method on the error page.
## How I fixed it
I've fixed this in a fork by restoring Lines 146 – 148 that were removed in #4156. I think this is the right fix, but Next.js's handling of `getInitialProps` could certainly be improved. (The code in [this conditional](86d01706a6/client/index.js (L173)) speaks to the unnecessary complexity around this.)
When clicking a next/link with a hash (#something) multiple times, it wouldn't keep the scrolling behavior browsers have. This makes sure we correctly trigger it.
Fixes#4686
Adds tests for @zeit/next-typescript so that we don't regress on this again.
I've fixed an issue in the `next` CLI too which caused lingering processes when the process gets force killed, which is what we do in the test suite, so it kept running if there was no manual quit.
This PR fixes#4615
From the issue :
> One thing we might consider is merging and showing a warning for keys not defined in exportPathMap
The behaviour after this PR is the following :
```js
// next.config.js
module.exports = {
exportPathMap: () => ({
'/': { page: '/', query: { a: 'blue' } }
})
}
```
| url called | `ctx.query` | warning ? |
|-|-|-|
| `/` | `{ a: 'blue' }` | |
| `/?a=red` | `{ a: 'blue' }` | |
| `/?b=green` | `{ a: 'blue', b: 'green' }` | `... parameter 'b' missing in exportPathMap` |
Is that the expected behaviour ? If not, I'll update the PR to shape the expected behavior.
resolves#4115
For now, I just added `'article:tag'` so it could be duplicated if we need more we have to extend:
```javascript
const ALLOWED_DUPLICATES = ['article:tag']
```
Allow `onClick` on `next/link` child. This should not be a breaking change, but it's a very useful feature. Real-life use cases include: analytics or closing menu on navigation, and other.
- [x] allow optional `onClick` on `next/link` component's child
- [x] call original `child.props.onClick(e)` before `this.linkClicked(e)`
- [x] add integration tests
- [x] cancel the navigation if `e.defaultPrevented === true`
Fixes#1490
* Don’t use chunkhash in development
* Add test for dynamic imports styling
* Remove pre-load of dynamic page
* Make sure the browser gets closed only once
Adds an example based off of @jthegedus work on firebase hosting, compatible with next v6 and using typescript in both the firebase functions and the next app.
* Handle production errors correctly
* Improved source map support
* Make react-hot-loader hold state again
* Remove console.log
* Load modules on demand
* Catch errors in rewriteErrorTrace
* Update comment
* Update comment
* Remove source-map-support
* Load modules in next-dev
* Make sure error logged has sourcemaps too
* Add tests for production runtime errors
* Add tests for development runtime errors. Fix issue with client side errors in development
* Move functionality back to renderError now that error handling is consistent
* Rename to applySourcemaps
* Expose pages/_app.js
* Add tests for _app and _document
* Uncomment deprecation warnings
* Add documentation for _app, improve documentation of _document
* Update docs / test for _document
* Add _document to client compiler in development
* Add missing app.js to comment
* Only warn once
* Add url-deprecated error page
* Combine tests
* Yse same message for all methods of ‘props.url’
* Update docs around _app
* Update documentation
* Quotes
* Update table of contents
* Add build manifest
* Split out css since they don’t have exact name
* Remove pages map
* Fix locations test
* Re-run tests
* Get consistent open ports
* Fix static tests
* Add comment about Cache-Control header
* Allow etags to be disabled with config option
- CR Change: Rename option to generateEtags
- CR Change: Add tests for etag generation
- CR Change: Refactor to use next.config.js
- Update documentation
* Use renderOpts instead of passing nextConfig
* Removed combine-assets-plugin, since its very broken
* Bundle everything into app.js on production build
* Clean up
* Removed app.js from server routes
* Renamed app.js -> main.js and removed commons from loading
* Remove commons and react CommonChunks
* Removed the commons route
* Killing the entire build-stats hack for app.js
* Removed unused md5-file package
* Add specific test cases for Error Recovery.
* Update hmr/about.js
* Add a test case: should recover after a bad return from the render function
* Add test case: should recover from errors in getInitialProps in client
* Add test case: should recover after an error reported via SSR
* Add a test case: should recover from 404 after a page has been added
* Refactor code base.
* Add next/config
* Set config on server start / client render
* Add documentation for next/config
* Add next/config support for next export
* Fix test
* Use the correct name
* Set default to empty object on the client side
* Add config tests
* Rename config to runtimeConfig
* Fix SSR error handling.
* Remove unwanted console.logs
* Fix a typo.
* Fix current tests.
* Add a new test case for this case.
* Error should only be logged if it is not a 404
* Add custom-server-typescript example (see #3694)
* Fix linting errors in custom-server-typescript
* Provide proper arguments to ts-node.
* Fix import and fix all linting errors.
* Use import in server as well.
* Update nodemon.json
* Remove special error script handling.
As a result of that, we can't detect 500 errors and buildIdMismatch via client side.
* Fix failing test cases.
* Refactor the code base.
* Remove Router.onAppUpdated
This reverts `fb7c862` per @timneutkens
- Removes the errors/*.md associated
- Puts back `poweredByHeader` for `next.config.js`
- Reincorporates test:
X-Powered-By header
✓ should set it by default (3ms)
✓ should not set it when poweredByHeader==false (5ms)
Also tested with `yarn link` and verified.
* Render error on the client without fetching additional scripts.
* Fix test cases.
* Remove unused '_document' page in ensurePage logic
* Remove console.error when page is not found
* Add example on how to pass data through js api during SSR
Requested in #1117
* Use content negotiation instead of a separate route
* Codereview feedback
* Move security related test cases into a its own file.
* Removes the unused renderScript function
* Add a nerv example. (#3573)
* Add a nerv example.
* Fix for indentation/style
* Fix for name
* Allow next/asset to work properly with dynamic assetPrefix
Now we use webpack's publicPath via client side.
* Add test cases for dynamic assetPrefix and next/asset.
* Speed up next build
* Document webpack config
* Speed up next build
* Remove comment
* Add comment
* Clean up rules
* Add comments
* Run in parallel
* Push plugins seperately
* Create a new chunk for react
* Don’t uglify react since it’s already uglified. Move react to commons in development
* Use the minified version directly
* Re-add globpattern
* Move loaders into a separate variable
* Add comment linking to Dan’s explanation
* Remove dot
* Add universal webpack
* Initial dev support
* Fix linting
* Add changes from Arunoda's work
* Made next dev works.
But super slow and no HMR support.
* Fix client side hot reload
* Server side hmr
* Only in dev
* Add on-demand-entries client + hot-middleware
* Add .babelrc support
* Speed up on demand entries by running in parallel
* Serve static generated files
* Add missing config in dev
* Add sass support
* Add support for .map
* Add cssloader config and fix .jsx support
* Rename
* use same defaults as css-loader. Fix linting
* Add NoEmitErrorsPlugin
* Add clientBootstrap
* Use webpackhotmiddleware on the multi compiler
* alpha.3
* Use babel 16.2.x
* Fix reloading after error
* Remove comment
* Release 5.0.0-univeral-alpha.1
* Remove check for React 16
* Release 5.0.0-universal-alpha.2
* React hot loader v4
* Use our static file rendering machanism to serve pages.
This should work well since the file path for a page is predictable.
* Release 5.0.0-universal-alpha.3
* Remove optional loaders
* Release 5.0.0-universal-alpha.4
* Remove clientBootstrap
* Remove renderScript
* Make sure pages bundles are served correctly
* Remove unused import
* Revert to using the same code as canary
* Fix hot loader
* Release 5.0.0-universal-alpha.5
* Check if externals dir exist before applying config
* Add typescript support
* Add support for transpiling certain packages in node_modules
Thanks to @giuseppeg’s work in https://github.com/zeit/next.js/pull/3319
* Add BABEL_DISABLE_CACHE support
* Make sourcemaps in production opt-in
* Revert "Add support for transpiling certain packages in node_modules"
This reverts commit d4b1d9babfb4b9ed4f4b12d56d52dee233e862da.
In favor of a better api around this.
* Support typescript through next.config.js
* Remove comments
* Bring back commons.js calculation
* Remove unused dependencies
* Move base.config.js to webpack.js
* Make sure to only invalidate webpackDevMiddleware one after other.
* Allow babel-loder caching by default.
* Add comment about preact support
* Bring back buildir replace
* Remove obsolete plugin
* Remove build replace, speed up build
* Resolve page entries like pages/day/index.js to pages/day.js
* Add componentDidCatch back
* Compile to bundles
* Use config.distDir everywhere
* Make sure the file is an array
* Remove console.log
* Apply optimization to uglifyjs
* Add comment pointing to source
* Create entries the same way in dev and production
* Remove unused and broken pagesGlobPattern
* day/index.js is automatically turned into day.js at build time
* Remove poweredByHeader option
* Load pages with the correct path.
* Release 5.0.0-universal-alpha.6
* Make sure react-dom/server can be overwritten by module-alias
* Only add react-hot-loader babel plugin in dev
* Release 5.0.0-universal-alpha.7
* Revert tests
* Release 5.0.0-universal-alpha.10
* Make sure next/head is working properly.
* Add wepack alias for 'next' back.
* Make sure overriding className in next/head works
* Alias react too
* Add missing r
* Fragment fallback has to wrap the children
* Use min.js
* Remove css.js
* Remove wallaby.js
* Release 5.0.0-universal-alpha.11
* Resolve relative to workdir instead of next
* Make sure we touch the right file
* Resolve next modules
* Remove dotjsx removal plugins since we use webpack on the server
* Revert "Resolve relative to workdir instead of next"
This reverts commit a13f3e4ab565df9e2c9a3dfc8eb4009c0c2e02ed.
* Externalize any locally loaded module lives outside of app dir.
* Remove server aliases
* Check node_modules reliably
* Add symlink to next for tests
* Make sure dynamic imports work locally.
This is why we need it: b545b519b2/lib/MainTemplate.js (L68)
We need to have the finally clause in the above in __webpack_require__.
webpack output option strictModuleExceptionHandling does that.
* dynmaic -> dynamic
* Remove webpack-node-externals
* Make sure dynamic imports support SSR.
* Remove css support in favor of next-css
* Make sure we load path from `/` since it’s included in the path matching
* Catch when ensurepage couldn’t be fulfilled for `.js.map`
* Register require cache flusher for both client and server
* Add comment explaining this is to facilitate hot reloading
* Only load module when needed
* Remove unused modules
* Release 5.0.0-universal-alpha.12
* Only log the `found babel` message once
* Make sure ondemand entries working correctly.
Now we are just using a single instance of OnDemandEntryHandler.
* Better sourcemaps
* Release 5.0.0-universal-alpha.13
* Lock uglify version to 1.1.6
* Release 5.0.0-universal-alpha.14
* Fix a typo.
* Introduce multi-zones support for mircofrontends
* Add section on css
* Add .jsx extension
* examples: add create-next-app (#3377)
* examples: add create-next-app
* fix with-typescript readme
* Upgrading with-flow example to the latest flow-bin ver. 0.59.0 (#3337)
For upgrading I used flow-upgrade module by https://yarnpkg.com/en/package/flow-upgrade
* doc'd fs-routing option & added note on `passHref` (#3384)
2 changes:
`passHref` - just added a cautionary note on the importance of `passHref`. We had a few days of no-href links on our site b/c we used a custom component instead of a raw `<a>` tag, and Google bot wasn't crawling our links (confirmed in Google cache). Hurt our SEO a bit, so I thought it was worth noting.
`useFileSystemPublicRoutes` - this is mentioned in https://github.com/zeit/next.js/pull/914 , but it doesn't appear any doc was actually added. We use `next-routes`, and we were serving all the files in `/pages/` in addition to their route patterns (ie duplicate content), which can be a pain w/ SEO and duplicate content.
* fix typo in readme.md (#3385)
* Upgrade styled-jsx to v2.2.1 (#3358)
* Pulled encoding to top of head (#3214)
* Remove next.d.ts to use @types/next (#3297)
* Add with-mobx-state-tree example (#3179)
* Adapt with-mobx example for with-mobx-state-tree
* Remove unnecessary lastUpdate parameter to show off snapshot
* update readme
* make other.js more closely mimic index.js
* Upgrade styled-jsx to v2.2.1
Includes some bug fixes.
* Fix linting
* Make sure import that doesn’t end in .jsx works
* Move tests
* Show error when .js and .jsx both exist
* Remove .jsx when importing from ‘path.jsx’
* Fixes
* Get .jsx resolver back
* Revert "Get .jsx resolver back"
This reverts commit 6f76712caa400e6f41a6a32ff80189a95b194cce.
* Revert "Revert "Get .jsx resolver back""
This reverts commit 69e592e86e53f28d0e1f78009196b76f2f831866.
* Add remove .jsx to preset
* Remove jsx resolver
* Revert "Remove jsx resolver"
This reverts commit 5e3ef1aca134de47657d91485809cd801e13329f.
* Revert "Revert "Remove jsx resolver""
This reverts commit 8248e5066cff1c7e33dac2e5a88ffe6856e3fc4e.
* Revert "Revert "Revert "Remove jsx resolver"""
This reverts commit 2a6d418a227ea4e59874b0374628ef497e527c52.
* Make 1 component not use .jsx
* Dump address.
* Use zero as the port.
* Limit test cases.
* throw address.
* Fail a specific error.
* Set a port manually.
* Make sure jest is working properly.
* Set the jest timeout time to 5 min.
* Run the actual test
* Run all production tests on Travis.
* Set the Jest default timeout to 5 min for all integration tests.
* Remove production only testing.
* Remove unwanted console.log
* Remove the addition number from test case
* Set the static export test jest timeout to 5 min.
* Run tests again if they failed once.
* Support de-deduping head tags by setting key
* move dedupe logic to `unique` function
* fix head tag deduping logic
* remove console.log
* use `toContain` assertions
* update de-duping head tags section in README
* allow use of filenames in exportPathMap
* add link test and handling for file paths when flattening links for export
* add note about exporting file paths to readme.md
* Updating React to v16.0.0
* Updating error handling from ReactReconciler to componentDidCatch
* Using hydrate() instead of render() on client side.
* React 16 is not making `charSet` lowercase but that is in spec.
* Add withRoute HOC
Rebased (squashed)
- removed routerToProps
- updated hoist-non-react-statics
- improved propTypes
* Expose the whole Router instead of the route.
* Make the example simple.
* Update examples and the readme.
* Add a test case.
* Layout ground works for next/async
* Implement the Dynamic Bundle feature.
* Add some test cases.
* Update README.
* Implement props aware dynamic bundle API.
* Update tests and README.
* Add a test case for React Context support.
* Always check with the fs when gettings chunks.
* Add a new set of test cases for dynamic imports in dev.
* Add dynamic import test cases for production.
* Add availableChunks support for static exports.
* Reload webpack via hot-reloader when needed.
We need to do this specially we removed a previosly
built page from the filesystem.
* Make sure reloading is happen only once
* Reload only if there's a missing page error.
* Remove debug logs.
* 2.4.2
* Refactor the codebase a bit.
* Move some commonly used regexp to a utils module.
* Handle the reloading well when there's a custom error page.
* Add a HMR test case.
* Close the browser in the test case.
* Introduce script tag based page loading system.
* Call ensurePage only in the dev mode.
* Implement router using the page-loader.
* Fix a typo and remove unwanted code.
* Fix some issues related to rendering.
* Fix production tests.
* Fix ondemand test cases.
* Fix unit tests.
* Get rid of eval completely.
* Remove all the inline code.
* Remove the json-pages plugin.
* Rename NEXT_PAGE_LOADER into __NEXT_PAGE_LOADER__
* Rename NEXT_LOADED_PAGES into __NEXT_LOADED_PAGES__
* Remove some unwanted code.
* Load everything async.
* Remove lib/eval-script.js
We no longer need it.
* Move webpack idle wait code to the page-loader.
Because that's the place to do it.
* Remove pageNotFound key from the error.
* Remove unused error field 'buildError'
* Add much better logic to normalize routes.
* Get rid of mitt.
* Introduce a better way to register pages.
* Came back to the mitt() based page-loader.
* Add link rel=preload support.
* Add assetPrefix support to add support for CDNs.
* Add assetPrefix support for preload links.
* Update readme.md
* Update references to `.next`
* Remove console logs and extraneous semi colons
* Remove lint errors
* Update references to .next and update docs
* Update options from nested to flat with `distDir`
* Add integration tests, and update `.gitignore`
* Rename integration folder to dist-dir to match standards
* Fix HMR not working issue.
Our hot-reload code on the server has custom webpack error dectection logic.
Is supports only multi-modules entries.
So, we need to all entries as multi-module entries
even if there's just a single entry.
* Add a test case for showing errors over HMR.
* Using developit/unfetch as the Fetch API polyfill
* Added the replace prop into the Link component
* Added integration test for replace prop on Link component
* Add support for URL objects in Link and Router
* Fix typo in comment
* Fix possible bug if the `href` prop is `null`
* Document the usage of URL objects in Link and Router
* Update readme.md
* Parse URL to get the host & hostname in `isLocal`
This should check if the current location and the checked URL have the same `host` or `hostname`.
* Format `as` parameter from object to string if required
* Format `href` and `as` inside the construct and componentWillReceiveProps
* Use `JSON.stringify` to compare objects
* Add usage example
* chore(package): update chromedriver to version 2.28.0 (#1386)
https://greenkeeper.io/
* Refactor the codebase a bit.
* Change the example name.
* Add a few test cases.
* Add the example to the README.
* Run tests serially.
* Make test result verbose.
* Don't wait until closing the browser.
* Add some debug logs.
* Add bailing support.
* Get the browser with a timeout.
* Add some comments.
* Remove istanbul babel tranformation.
Jest already do it and it's breaking our coveralls hit.
* Simplify route info handling.
* Add basic resolve=false support.
* Make sure to render getInitialProps always if it's the first render.
* Change resolve=false to shallow routing.
* Add test cases for shallow routing.
* Update README for shallow routing docs.
* Update docs.
* Update docs.
* Update docs.
* Add better hash URL support.
1. Add scrolling to given id related to hash
2. Hash changes won't trigger getInitialProps
* Add some comments.
* Fix tests.
* Add some test cases.
* Add a plan for dynamic entry middleware.
* Use dynamic pages middleware to load pages in dev.
* Add the first version of middleware but not tested.
* Integrated.
* Disable prefetching in development.
Otherwise it'll discard the use of dynamic-entries.
* Build custom document and error always.
* Refactor code base.
* Change branding as on-demand entries.
* Fix tests.
* Add a client side pinger for on-demand-entries.
* Dispose inactive entries.
* Add proper logs.
* Update grammer changes.
* Add integration tests for ondemand entries.
* Improve ondemand entry disposing logic.
* Try to improve testing.
* Make sure entries are not getting disposed in basic integration tests.
* Resolve conflicts.
* Fix tests.
* Fix issue when running Router.onRouteChangeComplete
* Simplify state management.
* Make sure we don't dispose the last active page.
* Reload invalid pages detected with the client side ping.
* Improve the pinger code.
* Touch the first page to speed up the future rebuild times.
* Add Websockets based pinger.
* Revert "Add Websockets based pinger."
This reverts commit f706a49a3d886d0231259b7a1fded750ced2e48f.
* Do not send requests per every route change.
* Make sure we are completing the middleware request always.
* Make sure test pages are prebuilt.
* Remove traces of glamor
As talked about with @rauchg. Glamor takes up around 60KB of the bundle (pre-gzip). Since styled-jsx is the way to go now and we support adding glamor by the user we should remove it as dependency cause it is bundled even when not used.
Added rehydration to the example, since we did that in our code.
There is only one thing I'm not sure about and want to discuss:
what should we do with next/css. Right now I added a throw for when it is imported. I'm not sure if we should do that / some other way to notify the user it has been removed. The reasoning behind the throw is that when we would do a console.warn the user would see 'css.default.<X>' not found because we don't have the glamor dependency anymore.
* Update yarn.lock
* Remove test for styles
* Reload the page if the buildIds are mismatch.
* Reload the browser with main.js and commons.js buildId mismatch.
* Implement proper reloading with an API to persist the state.
* Add some tests for force reload.
* Change _reload to _forceReload.
* Add a section about reload hooks to the README.
* Allow to add a hook to handle BUILD_ID mismatch.
* Remove readme docs.
* Do not show a custom error to the user.
* Cancel the routing when there's a BUILD_ID mismatch.
* Fix a typo.
* Passing route to SingletonRouter.onBuildIdMismatch
* Handle buildId mismatch automatically.
* Add support to reload the page when ask to change the same url.
* Do not run change() in the initial page load.
* Add integration tests.
* Add self-reload.js
* Randomize the port returned from test util's findPort().
* Use http's server.listen() to bind to a random available port.
* Update yarn.lock
* Update yarn.lock
* Make sure lastAppProps always have some value.
* Revert "Make sure lastAppProps always have some value."
This reverts commit b4ae722d9c1a4460e17dbdc041b111cbd492b2aa.
* Throw an error, if we found an empty object from getInitialProps.
* Add proper tests for getInitialProps empty check.
* Use jest-cli instead of gulp plugin.
* Use jest-cli instead of gulp plugin.
* Move fixtures into the examples dir.
* Move test code of example app to the basic example.
* Add isolated tests for server/resolve
* Allow tests to use cheerio.
* Use portfinder to get a unique port.
* Move back integration tests into the example dir.
* Introduce next-test-utils.
* Remove gulp-jest
* Add coveralls support.
* Use transpiled version of code in dist.
This is to make sure same file gets covered
by both unit/isolated tests and integration tests.
* Add support for source maps.
* Use code from dist always.
* Use nyc to stop instrument.
* Add integration test suite for production usage.
* Use jest-cli.
* Add support for running e2e tests.
* Check gzipPath with fs.stat before serving
Otherwise, serve package might throw issues other than ENOENT
* Install chromedriver with npm install.
* Install chrome on travis-ci.
* Add --forceExit to Jest.
* Run tests only on Node v6.
That's because selenium-webdriver only supports
Node 6 LTS.
* Use chromedriver NPM module to install chromedriver.
* Use wd as the webdriver client.
* Run chromedriver before tests.
* Run travis for both node 4 and 6
* Remove unwanted npm install script.
* Move some common text utilities to next-test-utils
* Add lint checks and testing in npm prepublish hook.
* Use npm on travis-ci.
We are having some caching issues with yarn and chromedriver.
* Make tests work on windows.\n But chromedriver doesn't work.
* Clean up dependencies.
* Run chromedriver in background without any tools.
* Fix a typo in the code.
* Use ES6 features used in node4 inside the gulpfile.
* Add some comments.
* Add support for running in windows.
* Stop chromedriver properly on windows.
* Fix typos.