Skip to content

Commit

Permalink
Merge branch 'canary' into create-next-app/support-pnpm
Browse files Browse the repository at this point in the history
  • Loading branch information
kawaemon committed Feb 3, 2021
2 parents ae02133 + 379ad1b commit 15616c3
Show file tree
Hide file tree
Showing 33 changed files with 295 additions and 151 deletions.
2 changes: 1 addition & 1 deletion examples/blog-starter/lib/api.js
Expand Up @@ -38,6 +38,6 @@ export function getAllPosts(fields = []) {
const posts = slugs
.map((slug) => getPostBySlug(slug, fields))
// sort posts by date in descending order
.sort((post1, post2) => (post1.date > post2.date ? '-1' : '1'))
.sort((post1, post2) => (post1.date > post2.date ? -1 : 1))
return posts
}
Expand Up @@ -2,17 +2,13 @@ import { useEffect } from 'react'
import { useRouter } from 'next/router'
import * as gtm from '../lib/gtm'

const handleRouteChange = () => {
gtm.pageview()
}

const GoogleTagManager = ({ children }) => {
const router = useRouter()

useEffect(() => {
router.events.on('routeChangeComplete', handleRouteChange)
router.events.on('routeChangeComplete', gtm.pageview)
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
router.events.off('routeChangeComplete', gtm.pageview)
}
}, [router.events])

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Expand Up @@ -17,5 +17,5 @@
"registry": "https://registry.npmjs.org/"
}
},
"version": "10.0.7-canary.0"
"version": "10.0.7-canary.2"
}
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -6,7 +6,7 @@
],
"scripts": {
"lerna": "lerna",
"dev": "lerna run build --stream --parallel",
"dev": "lerna run dev --stream --parallel",
"dev2": "while true; do yarn --check-files && yarn dev; done",
"testonly": "jest --runInBand",
"testheadless": "cross-env HEADLESS=true yarn testonly",
Expand Down
4 changes: 2 additions & 2 deletions packages/create-next-app/package.json
@@ -1,6 +1,6 @@
{
"name": "create-next-app",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"keywords": [
"react",
"next",
Expand All @@ -21,7 +21,7 @@
"dist"
],
"scripts": {
"build": "ncc build ./index.ts -w -o dist/",
"dev": "ncc build ./index.ts -w -o dist/",
"prerelease": "rimraf ./dist/",
"release": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register",
"prepublish": "yarn release"
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"description": "ESLint plugin for NextJS.",
"main": "lib/index.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-bundle-analyzer/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions packages/next-codemod/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand All @@ -17,7 +17,7 @@
],
"scripts": {
"prepublish": "yarn tsc -d -p tsconfig.json",
"build": "yarn tsc -d -w -p tsconfig.json",
"dev": "yarn tsc -d -w -p tsconfig.json",
"test": "jest"
},
"bin": "./bin/next-codemod.js"
Expand Down
4 changes: 2 additions & 2 deletions packages/next-env/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"keywords": [
"react",
"next",
Expand All @@ -22,7 +22,7 @@
"types"
],
"scripts": {
"build": "ncc build ./index.ts -w -o dist/",
"dev": "ncc build ./index.ts -w -o dist/",
"prerelease": "rimraf ./dist/",
"types": "tsc index.ts --declaration --emitDeclarationOnly --declarationDir types --esModuleInterop",
"release": "ncc build ./index.ts -o ./dist/ --minify --no-cache --no-source-map-register",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-mdx/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/mdx",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-google-analytics"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-sentry/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"description": "A standard library polyfill for ES Modules supporting browsers (Edge 16+, Firefox 60+, Chrome 61+, Safari 10.1+)",
"main": "dist/polyfill-module.js",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-nomodule/package.json
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
6 changes: 6 additions & 0 deletions packages/next/build/webpack-config.ts
Expand Up @@ -43,6 +43,7 @@ import { build as buildConfiguration } from './webpack/config'
import { __overrideCssConfiguration } from './webpack/config/blocks/css/overrideCssConfiguration'
import { pluginLoaderOptions } from './webpack/loaders/next-plugin-loader'
import BuildManifestPlugin from './webpack/plugins/build-manifest-plugin'
import BuildStatsPlugin from './webpack/plugins/build-stats-plugin'
import ChunkNamesPlugin from './webpack/plugins/chunk-names-plugin'
import { CssMinimizerPlugin } from './webpack/plugins/css-minimizer-plugin'
import { JsConfigPathsPlugin } from './webpack/plugins/jsconfig-paths-plugin'
Expand Down Expand Up @@ -1109,6 +1110,11 @@ export default async function getBaseWebpackConfig(
buildId,
rewrites,
}),
!isServer &&
config.experimental.stats &&
new BuildStatsPlugin({
distDir,
}),
new ProfilingPlugin(),
config.experimental.optimizeFonts &&
!dev &&
Expand Down
48 changes: 48 additions & 0 deletions packages/next/build/webpack/plugins/build-stats-plugin.ts
@@ -0,0 +1,48 @@
import fs from 'fs'
import path from 'path'
// @ts-ignore no types package
import bfj from 'next/dist/compiled/bfj'
import { spans } from './profiling-plugin'
import { webpack } from 'next/dist/compiled/webpack/webpack'
import { tracer, traceAsyncFn } from '../../tracer'

// This plugin creates a stats.json for a build when enabled
export default class BuildStatsPlugin {
private distDir: string

constructor(options: { distDir: string }) {
this.distDir = options.distDir
}

apply(compiler: webpack.Compiler) {
compiler.hooks.done.tapAsync(
'NextJsBuildStats',
async (stats, callback) => {
tracer.withSpan(spans.get(compiler), async () => {
try {
const writeStatsSpan = tracer.startSpan('NextJsBuildStats')
await traceAsyncFn(writeStatsSpan, () => {
return new Promise((resolve, reject) => {
const statsJson = stats.toJson({
source: false,
})
const fileStream = fs.createWriteStream(
path.join(this.distDir, 'next-stats.json')
)
const jsonStream = bfj.streamify(statsJson)
jsonStream.pipe(fileStream)
jsonStream.on('error', reject)
fileStream.on('error', reject)
jsonStream.on('dataError', reject)
fileStream.on('close', resolve)
})
})
callback()
} catch (err) {
callback(err)
}
})
}
)
}
}
4 changes: 4 additions & 0 deletions packages/next/bundles/webpack/packages/webpack.d.ts
@@ -0,0 +1,4 @@
export namespace webpack {
export type Compiler = any
export type Plugin = any
}
1 change: 1 addition & 0 deletions packages/next/compiled/bfj/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions packages/next/compiled/bfj/package.json
@@ -0,0 +1 @@
{"name":"bfj","main":"index.js","author":"Phil Booth (https://gitlab.com/philbooth)","license":"MIT"}
4 changes: 4 additions & 0 deletions packages/next/compiled/webpack/webpack.d.ts
@@ -0,0 +1,4 @@
export namespace webpack {
export type Compiler = any
export type Plugin = any
}
1 change: 1 addition & 0 deletions packages/next/next-server/server/config.ts
Expand Up @@ -87,6 +87,7 @@ const defaultConfig: NextConfig = {
optimizeCss: false,
scrollRestoration: false,
scriptLoader: false,
stats: false,
},
future: {
strictPostcssConfiguration: false,
Expand Down
15 changes: 8 additions & 7 deletions packages/next/package.json
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.2",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -45,7 +45,7 @@
"next": "./dist/bin/next"
},
"scripts": {
"build": "taskr",
"dev": "taskr",
"release": "taskr release",
"prepublish": "npm run release && yarn types",
"types": "tsc --declaration --emitDeclarationOnly --declarationDir dist",
Expand All @@ -63,10 +63,10 @@
"@ampproject/toolbox-optimizer": "2.7.1-alpha.0",
"@babel/runtime": "7.12.5",
"@hapi/accept": "5.0.1",
"@next/env": "10.0.7-canary.0",
"@next/polyfill-module": "10.0.7-canary.0",
"@next/react-dev-overlay": "10.0.7-canary.0",
"@next/react-refresh-utils": "10.0.7-canary.0",
"@next/env": "10.0.7-canary.2",
"@next/polyfill-module": "10.0.7-canary.2",
"@next/react-dev-overlay": "10.0.7-canary.2",
"@next/react-refresh-utils": "10.0.7-canary.2",
"@opentelemetry/api": "0.14.0",
"ast-types": "0.13.2",
"browserslist": "4.16.1",
Expand Down Expand Up @@ -135,7 +135,7 @@
"@babel/preset-react": "7.12.10",
"@babel/preset-typescript": "7.12.7",
"@babel/types": "7.12.12",
"@next/polyfill-nomodule": "10.0.7-canary.0",
"@next/polyfill-nomodule": "10.0.7-canary.2",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down Expand Up @@ -178,6 +178,7 @@
"babel-plugin-dynamic-import-node": "2.3.3",
"babel-plugin-transform-define": "2.0.0",
"babel-plugin-transform-react-remove-prop-types": "0.4.24",
"bfj": "7.0.2",
"cacache": "15.0.5",
"cache-loader": "4.1.0",
"ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/taskfile-babel.js
Expand Up @@ -82,7 +82,7 @@ module.exports = function (task) {
task.plugin('babel', {}, function* (
file,
serverOrClient,
{ stripExtension } = {}
{ stripExtension, dev } = {}
) {
// Don't compile .d.ts
if (file.base.endsWith('.d.ts')) return
Expand Down Expand Up @@ -111,7 +111,7 @@ module.exports = function (task) {
]
: false,
].filter(Boolean),
compact: true,
compact: !dev,
babelrc: false,
configFile: false,
cwd: __dirname,
Expand Down

0 comments on commit 15616c3

Please sign in to comment.