Skip to content

Commit

Permalink
Resolving upstream conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
janicklas-ralph committed Oct 29, 2019
2 parents 7ca58b6 + f5969d2 commit 8e0815d
Show file tree
Hide file tree
Showing 44 changed files with 715 additions and 213 deletions.
5 changes: 5 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ commands:
- run:
name: Installing Dependencies
command: yarn install --frozen-lockfile --check-files
- run:
name: Install correct Chrome Driver version
command: yarn add chromedriver@76 -W && git checkout yarn.lock package.json
- run: google-chrome --version
- run: chromedriver --version
yarn_lint:
steps:
- run:
Expand Down
2 changes: 1 addition & 1 deletion examples/with-immutable-redux-wrapper/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Immutable Redux Example

> This example and documentation is based on the [with-redux](https://github.com/zeit/next.js/tree/master/examples/with-redux) example.
> This example and documentation is based on the [with-redux-wrapper](https://github.com/zeit/next.js/tree/master/examples/with-redux-wrapper) example.
## How to use

Expand Down
2 changes: 1 addition & 1 deletion examples/with-immutable-redux-wrapper/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"immutable": "4.0.0-rc.9",
"next": "latest",
"next-redux-wrapper": "2.0.0-beta.6",
"next-redux-wrapper": "4.0.1",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "^5.0.1",
Expand Down
20 changes: 16 additions & 4 deletions examples/with-react-intl/pages/_app.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import App from 'next/app'
import React from 'react'
import { IntlProvider } from 'react-intl'
import { createIntl, createIntlCache, RawIntlProvider } from 'react-intl'

// This is optional but highly recommended
// since it prevents memory leak
const cache = createIntlCache()

export default class MyApp extends App {
static async getInitialProps ({ Component, router, ctx }) {
static async getInitialProps ({ Component, ctx }) {
let pageProps = {}

if (Component.getInitialProps) {
Expand All @@ -21,10 +25,18 @@ export default class MyApp extends App {
render () {
const { Component, pageProps, locale, messages } = this.props

const intl = createIntl(
{
locale,
messages
},
cache
)

return (
<IntlProvider locale={locale} messages={messages}>
<RawIntlProvider value={intl}>
<Component {...pageProps} />
</IntlProvider>
</RawIntlProvider>
)
}
}
4 changes: 4 additions & 0 deletions examples/with-react-native-web/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
presets: ['next/babel'],
plugins: [['react-native-web', { commonjs: true }]]
}
3 changes: 2 additions & 1 deletion examples/with-react-native-web/next.config.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
module.exports = {
webpack: config => {
webpack: (config, { defaultLoaders }) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
'react-native$': 'react-native-web'
}
config.resolve.extensions.push('.web.js', '.web.ts', '.web.tsx')
return config
}
}
3 changes: 3 additions & 0 deletions examples/with-react-native-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-native-web": "^0.11.6"
},
"devDependencies": {
"babel-plugin-react-native-web": "^0.11.7"
}
}
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "9.1.2-canary.8"
"version": "9.1.2-canary.9"
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
"babel-jest": "24.8.0",
"browserstack-local": "1.4.0",
"cheerio": "0.22.0",
"chromedriver": "75.1.0",
"chromedriver": "76.0.1",
"clone": "2.1.2",
"coveralls": "3.0.3",
"cross-spawn": "6.0.5",
Expand All @@ -107,7 +107,7 @@
"prettier": "1.17.1",
"react": "16.10.2",
"react-dom": "16.10.2",
"react-ssr-prepass": "1.0.5",
"react-ssr-prepass": "1.0.7",
"release": "6.0.1",
"request-promise-core": "1.1.2",
"rimraf": "2.6.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/create-next-app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "9.1.2-canary.8",
"version": "9.1.2-canary.9",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "9.1.2-canary.8",
"version": "9.1.2-canary.9",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "9.1.2-canary.8",
"version": "9.1.2-canary.9",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
16 changes: 16 additions & 0 deletions packages/next/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2316,6 +2316,22 @@ To learn more about TypeScript checkout its [documentation](https://www.typescri
> **Note**: Next.js does not enable TypeScript's `strict` mode by default.
> When you feel comfortable with TypeScript, you may turn this option on in your `tsconfig.json`.

> **Note**: By default, Next.js reports TypeScript errors during development for pages you are actively working on.
> TypeScript errors for inactive pages do not block the development process.
> Trying to run `next build` for an app that has TypeScript errors on any page will fail.
>
> If you don't want to leverage this behavior and prefer to do type checks manually, set the following options in your `next.config.js`:
>
> ```js
> // next.config.js
> module.exports = {
> typescript: {
> ignoreDevErrors: true,
> ignoreBuildErrors: true,
> },
> }
> ```

### Exported types

Next.js provides `NextPage` type that can be used for pages in the `pages` directory. `NextPage` adds definitions for [`getInitialProps`](#fetching-data-and-component-lifecycle) so that it can be used without any extra typing needed.
Expand Down
3 changes: 2 additions & 1 deletion packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export default async function build(dir: string, conf = null): Promise<void> {

const staticCheckWorkers = new Worker(staticCheckWorker, {
numWorkers: config.experimental.cpus,
enableWorkerThreads: true,
enableWorkerThreads: config.experimental.workerThreads,
})

const analysisBegin = process.hrtime()
Expand Down Expand Up @@ -471,6 +471,7 @@ export default async function build(dir: string, conf = null): Promise<void> {
sprPages,
silent: true,
buildExport: true,
threads: config.experimental.cpus,
pages: combinedPages,
outdir: path.join(distDir, 'export'),
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/build/output/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ store.subscribe(state => {
}

if (state.typeChecking) {
Log.info('bundled successfully, waiting for typecheck results ...')
Log.info('bundled successfully, waiting for typecheck results...')
return
}

Expand Down
12 changes: 10 additions & 2 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ export default async function getBaseWebpackConfig(
const useTypeScript = Boolean(
typeScriptPath && (await fileExists(tsConfigPath))
)
const ignoreTypeScriptErrors = dev
? config.typescript && config.typescript.ignoreDevErrors
: config.typescript && config.typescript.ignoreBuildErrors

const resolveConfig = {
// Disable .mjs for node_modules bundling
Expand Down Expand Up @@ -193,11 +196,12 @@ export default async function getBaseWebpackConfig(
const webpackMode = dev ? 'development' : 'production'

const terserPluginConfig = {
parallel: true,
sourceMap: false,
cache: true,
cpus: config.experimental.cpus,
distDir: distDir,
parallel: true,
sourceMap: false,
workerThreads: config.experimental.workerThreads,
}
const terserOptions = {
parse: {
Expand Down Expand Up @@ -749,6 +753,9 @@ export default async function getBaseWebpackConfig(
'process.env.__NEXT_EXPORT_TRAILING_SLASH': JSON.stringify(
config.exportTrailingSlash
),
'process.env.__NEXT_DEFER_SCRIPTS': JSON.stringify(
config.experimental.deferScripts
),
'process.env.__NEXT_MODERN_BUILD': JSON.stringify(
config.experimental.modern && !dev
),
Expand Down Expand Up @@ -867,6 +874,7 @@ export default async function getBaseWebpackConfig(
}),
!isServer &&
useTypeScript &&
!ignoreTypeScriptErrors &&
new ForkTsCheckerWebpackPlugin(
PnpWebpackPlugin.forkTsCheckerOptions({
typescript: typeScriptPath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const writeFileP = promisify(writeFile)
const readFileP = promisify(readFile)

export default class TaskRunner {
constructor({ distDir, cpus, cache }) {
constructor({ distDir, cpus, cache, workerThreads }) {
if (cache) {
mkdirp.sync((this.cacheDir = join(distDir, 'cache', 'next-minifier')))
}
// In some cases cpus() returns undefined
// https://github.com/nodejs/node/issues/19022
this.maxConcurrentWorkers = cpus
this.useWorkerThreads = workerThreads
}

run(tasks, callback) {
Expand All @@ -28,7 +29,7 @@ export default class TaskRunner {

if (this.maxConcurrentWorkers > 1) {
this.workers = new Worker(worker, {
enableWorkerThreads: true,
enableWorkerThreads: this.useWorkerThreads,
numWorkers: this.maxConcurrentWorkers,
})
this.boundWorkers = options => this.workers.default(options)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export class TerserPlugin {
cache = false,
cpus,
distDir,
workerThreads,
} = options

this.cpus = cpus
this.distDir = distDir
this.workerThreads = workerThreads
this.options = {
warningsFilter,
sourceMap,
Expand Down Expand Up @@ -134,6 +136,7 @@ export class TerserPlugin {
distDir: this.distDir,
cpus: this.cpus,
cache: this.options.cache,
workerThreads: this.workerThreads,
})

const processedAssets = new WeakSet()
Expand Down
2 changes: 1 addition & 1 deletion packages/next/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default async function(
{
maxRetries: 0,
numWorkers: threads,
enableWorkerThreads: true,
enableWorkerThreads: nextConfig.experimental.workerThreads,
exposedMethods: ['default'],
}
) as any
Expand Down
10 changes: 9 additions & 1 deletion packages/next/next-server/server/api-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,15 @@ export function getQueryParser({ url }: IncomingMessage) {

const query: { [key: string]: string | string[] } = {}
for (const [key, value] of params) {
query[key] = value
if (query[key]) {
if (Array.isArray(query[key])) {
;(query[key] as string[]).push(value)
} else {
query[key] = [query[key], value]
}
} else {
query[key] = value
}
}

return query
Expand Down
2 changes: 2 additions & 0 deletions packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const defaultConfig: { [key: string]: any } = {
profiling: false,
publicDirectory: false,
sprFlushToDisk: true,
deferScripts: false,
workerThreads: false,
},
future: {
excludeDefaultMomentLocales: false,
Expand Down
3 changes: 3 additions & 0 deletions packages/next/next-server/server/load-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export type LoadComponentsReturnType = {
props: any
revalidate: number | false
}
unstable_getStaticParams?: () => void
buildManifest?: any
reactLoadableManifest?: any
Document?: any
Expand All @@ -40,6 +41,7 @@ export async function loadComponents(
Component,
pageConfig: Component.config || {},
unstable_getStaticProps: Component.unstable_getStaticProps,
unstable_getStaticParams: Component.unstable_getStaticParams,
}
}
const documentPath = join(
Expand Down Expand Up @@ -87,5 +89,6 @@ export async function loadComponents(
reactLoadableManifest,
pageConfig: ComponentMod.config || {},
unstable_getStaticProps: ComponentMod.unstable_getStaticProps,
unstable_getStaticParams: ComponentMod.unstable_getStaticParams,
}
}
8 changes: 8 additions & 0 deletions packages/next/next-server/server/render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ type RenderOpts = {
props: any
revalidate: number | false
}
unstable_getStaticParams?: () => void
}

function renderDocument(
Expand Down Expand Up @@ -268,6 +269,7 @@ export async function renderToHTML(
reactLoadableManifest,
ErrorDebug,
unstable_getStaticProps,
unstable_getStaticParams,
} = renderOpts

const isSpr = !!unstable_getStaticProps
Expand All @@ -283,6 +285,12 @@ export async function renderToHTML(
throw new Error(SPR_GET_INITIAL_PROPS_CONFLICT + ` ${pathname}`)
}

if (!!unstable_getStaticParams && !isSpr) {
throw new Error(
`unstable_getStaticParams was added without a unstable_getStaticProps in ${pathname}. Without unstable_getStaticProps, unstable_getStaticParams does nothing`
)
}

if (dev) {
const { isValidElementType } = require('react-is')
if (!isValidElementType(Component)) {
Expand Down
Loading

0 comments on commit 8e0815d

Please sign in to comment.