Skip to content

Commit

Permalink
Merge branch 'canary' into canary
Browse files Browse the repository at this point in the history
  • Loading branch information
kuldeepkeshwar authored Jul 15, 2020
2 parents f5d5bc9 + 893e57d commit cddfeda
Show file tree
Hide file tree
Showing 28 changed files with 295 additions and 324 deletions.
7 changes: 7 additions & 0 deletions examples/using-preact/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ module.exports = withPrefresh({
}
}

if (isServer) {
// mark `preact` stuffs as external for server bundle to prevent duplicate copies of preact
config.externals.push(
/^(preact|preact-render-to-string|preact-context-provider)([\\/]|$)/
)
}

// Install webpack aliases:
const aliases = config.resolve.alias || (config.resolve.alias = {})
aliases.react = aliases['react-dom'] = 'preact/compat'
Expand Down
13 changes: 1 addition & 12 deletions examples/with-apollo-and-redux/components/PostList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { useQuery } from '@apollo/react-hooks'
import { NetworkStatus } from 'apollo-client'
import gql from 'graphql-tag'
import { gql, useQuery, NetworkStatus } from '@apollo/client'
import ErrorMessage from './ErrorMessage'
import PostUpvoter from './PostUpvoter'

Expand Down Expand Up @@ -42,15 +40,6 @@ export default function PostList() {
variables: {
skip: allPosts.length,
},
updateQuery: (previousResult, { fetchMoreResult }) => {
if (!fetchMoreResult) {
return previousResult
}
return Object.assign({}, previousResult, {
// Append the new posts results to the old one
allPosts: [...previousResult.allPosts, ...fetchMoreResult.allPosts],
})
},
})
}

Expand Down
3 changes: 1 addition & 2 deletions examples/with-apollo-and-redux/components/PostUpvoter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag'
import { gql, useMutation } from '@apollo/client'
import PropTypes from 'prop-types'

const UPDATE_POST_MUTATION = gql`
Expand Down
3 changes: 1 addition & 2 deletions examples/with-apollo-and-redux/components/Submit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag'
import { gql, useMutation } from '@apollo/client'
import { ALL_POSTS_QUERY, allPostsQueryVars } from './PostList'

const CREATE_POST_MUTATION = gql`
Expand Down
15 changes: 11 additions & 4 deletions examples/with-apollo-and-redux/lib/apollo.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMemo } from 'react'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
import { concatPagination } from '@apollo/client/utilities'

let apolloClient

Expand All @@ -12,7 +11,15 @@ function createApolloClient() {
uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn', // Server URL (must be absolute)
credentials: 'same-origin', // Additional fetch() options like `credentials` or `headers`
}),
cache: new InMemoryCache(),
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
allPosts: concatPagination(),
},
},
},
}),
})
}

Expand Down
6 changes: 1 addition & 5 deletions examples/with-apollo-and-redux/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,8 @@
"start": "next start"
},
"dependencies": {
"@apollo/react-hooks": "3.1.3",
"apollo-cache-inmemory": "1.6.3",
"apollo-client": "2.6.4",
"apollo-link-http": "1.5.16",
"@apollo/client": "^3.0.0",
"graphql": "14.5.8",
"graphql-tag": "2.10.1",
"next": "latest",
"prop-types": "^15.6.0",
"react": "^16.11.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/with-apollo-and-redux/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloProvider } from '@apollo/client'
import { Provider } from 'react-redux'
import { useStore } from '../lib/redux'
import { useApollo } from '../lib/apollo'
Expand Down
10 changes: 0 additions & 10 deletions examples/with-apollo/.babelrc

This file was deleted.

13 changes: 1 addition & 12 deletions examples/with-apollo/components/PostList.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { useQuery } from '@apollo/react-hooks'
import { NetworkStatus } from 'apollo-client'
import gql from 'graphql-tag'
import { gql, useQuery, NetworkStatus } from '@apollo/client'
import ErrorMessage from './ErrorMessage'
import PostUpvoter from './PostUpvoter'

Expand Down Expand Up @@ -43,15 +41,6 @@ export default function PostList() {
variables: {
skip: allPosts.length,
},
updateQuery: (previousResult, { fetchMoreResult }) => {
if (!fetchMoreResult) {
return previousResult
}
return Object.assign({}, previousResult, {
// Append the new posts results to the old one
allPosts: [...previousResult.allPosts, ...fetchMoreResult.allPosts],
})
},
})
}

Expand Down
3 changes: 1 addition & 2 deletions examples/with-apollo/components/PostUpvoter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag'
import { gql, useMutation } from '@apollo/client'

const UPDATE_POST_MUTATION = gql`
mutation updatePost($id: ID!, $votes: Int) {
Expand Down
3 changes: 1 addition & 2 deletions examples/with-apollo/components/Submit.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useMutation } from '@apollo/react-hooks'
import gql from 'graphql-tag'
import { gql, useMutation } from '@apollo/client'
import { ALL_POSTS_QUERY, allPostsQueryVars } from './PostList'

const CREATE_POST_MUTATION = gql`
Expand Down
15 changes: 11 additions & 4 deletions examples/with-apollo/lib/apolloClient.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useMemo } from 'react'
import { ApolloClient } from 'apollo-client'
import { InMemoryCache } from 'apollo-cache-inmemory'
import { HttpLink } from 'apollo-link-http'
import { ApolloClient, HttpLink, InMemoryCache } from '@apollo/client'
import { concatPagination } from '@apollo/client/utilities'

let apolloClient

Expand All @@ -12,7 +11,15 @@ function createApolloClient() {
uri: 'https://api.graph.cool/simple/v1/cixmkt2ul01q00122mksg82pn', // Server URL (must be absolute)
credentials: 'same-origin', // Additional fetch() options like `credentials` or `headers`
}),
cache: new InMemoryCache(),
cache: new InMemoryCache({
typePolicies: {
Query: {
fields: {
allPosts: concatPagination(),
},
},
},
}),
})
}

Expand Down
12 changes: 3 additions & 9 deletions examples/with-apollo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,13 @@
"start": "next start"
},
"dependencies": {
"@apollo/react-hooks": "3.1.3",
"apollo-cache-inmemory": "1.6.5",
"apollo-client": "2.6.8",
"apollo-link-http": "1.5.16",
"graphql": "^14.0.2",
"graphql-tag": "2.10.3",
"@apollo/client": "^3.0.0",
"graphql": "^15.3.0",
"next": "latest",
"prop-types": "^15.6.2",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"devDependencies": {
"babel-plugin-graphql-tag": "^2.5.0"
},
"devDependencies": {},
"license": "ISC"
}
2 changes: 1 addition & 1 deletion examples/with-apollo/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApolloProvider } from '@apollo/react-hooks'
import { ApolloProvider } from '@apollo/client'
import { useApollo } from '../lib/apolloClient'

export default function App({ Component, pageProps }) {
Expand Down
1 change: 1 addition & 0 deletions packages/next/build/webpack/config/blocks/css/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ export const css = curry(async function css(
// Extract CSS as CSS file(s) in the client-side production bundle.
fns.push(
plugin(
// @ts-ignore webpack 5 compat
new MiniCssExtractPlugin({
filename: 'static/css/[contenthash].css',
chunkFilename: 'static/css/[contenthash].css',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default class BuildManifestPlugin {
apply(compiler: Compiler) {
compiler.hooks.emit.tapAsync(
'NextJsBuildManifest',
(compilation, callback) => {
(compilation: any, callback: any) => {
const chunks: CompilationType.Chunk[] = compilation.chunks
const assetMap: BuildManifest = {
polyfillFiles: [],
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack/plugins/css-minimizer-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ export class CssMinimizerPlugin {
}

apply(compiler: webpack.Compiler) {
compiler.hooks.compilation.tap('CssMinimizerPlugin', (compilation) => {
compiler.hooks.compilation.tap('CssMinimizerPlugin', (compilation: any) => {
compilation.hooks.optimizeChunkAssets.tapPromise(
'CssMinimizerPlugin',
(chunks) =>
(chunks: webpack.compilation.Chunk[]) =>
Promise.all(
chunks
.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class DropClientPage implements Plugin {
apply(compiler: Compiler) {
compiler.hooks.compilation.tap(
PLUGIN_NAME,
(compilation, { normalModuleFactory }) => {
(compilation: any, { normalModuleFactory }: any) => {
// Recursively look up the issuer till it ends up at the root
function findEntryModule(mod: any): CompilationType.Module | null {
const queue = new Set([mod])
Expand Down
9 changes: 3 additions & 6 deletions packages/next/build/webpack/plugins/next-esm-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,9 @@ export class NextEsmPlugin implements Plugin {
}

apply(compiler: Compiler) {
compiler.hooks.make.tapAsync(
PLUGIN_NAME,
(compilation: CompilationType.Compilation, callback) => {
this.runBuild(compiler, compilation).then(callback)
}
)
compiler.hooks.make.tapAsync(PLUGIN_NAME, (compilation, callback) => {
this.runBuild(compiler, compilation).then(callback)
})
}

getLoaders(rules: RuleSetRule[], predicate: (loader: string) => boolean) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default class WebpackConformancePlugin {
for (const type of JS_TYPES) {
factory.hooks.parser
.for('javascript/' + type)
.tap(this.constructor.name, (parser) => {
.tap(this.constructor.name, (parser: any) => {
parser.hooks.program.tap(this.constructor.name, (ast: any) => {
const visitors: VisitorMap = {}
const that = this
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/terser-webpack-plugin/cjs.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/next/compiled/terser/bundle.min.js

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@
"@types/fresh": "0.5.0",
"@types/json5": "0.0.30",
"@types/jsonwebtoken": "8.3.7",
"@types/loader-utils": "1.1.3",
"@types/lodash.curry": "4.1.6",
"@types/lru-cache": "5.1.0",
"@types/mini-css-extract-plugin": "0.8.0",
"@types/nanoid": "2.0.0",
"@types/node-fetch": "2.3.4",
"@types/path-to-regexp": "1.7.0",
Expand All @@ -150,9 +148,7 @@
"@types/resolve": "0.0.8",
"@types/send": "0.14.4",
"@types/styled-jsx": "2.2.8",
"@types/terser-webpack-plugin": "2.2.0",
"@types/text-table": "0.2.1",
"@types/webpack-hot-middleware": "2.16.5",
"@types/webpack-sources": "0.1.5",
"@zeit/ncc": "0.22.0",
"amphtml-validator": "1.0.31",
Expand Down
1 change: 1 addition & 0 deletions packages/next/server/on-demand-entry-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class Invalidator {
// Work around a bug in webpack, calling `invalidate` on Watching.js
// doesn't trigger the invalid call used to keep track of the `.done` hook on multiCompiler
for (const compiler of this.multiCompiler.compilers) {
// @ts-ignore TODO: Check if this is still needed with webpack 5
compiler.hooks.invalid.call()
}
this.watcher.invalidate()
Expand Down
5 changes: 1 addition & 4 deletions packages/next/types/misc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,7 @@ declare module 'next/dist/compiled/unistore' {
export = m
}

declare module 'next/dist/compiled/terser-webpack-plugin' {
import m from 'terser-webpack-plugin'
export = m
}
declare module 'next/dist/compiled/terser-webpack-plugin'
declare module 'next/dist/compiled/comment-json' {
import m from 'comment-json'
export = m
Expand Down
Loading

0 comments on commit cddfeda

Please sign in to comment.