Skip to content

Commit

Permalink
Merge branch 'canary' into fix-sharp-require
Browse files Browse the repository at this point in the history
  • Loading branch information
David Bailey authored Feb 2, 2021
2 parents 850219e + 2079b74 commit 1081c0b
Show file tree
Hide file tree
Showing 26 changed files with 144 additions and 20 deletions.
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": "10.0.7-canary.0"
"version": "10.0.7-canary.1"
}
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": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-plugin-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/eslint-plugin-next",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/bundle-analyzer",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-codemod/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/codemod",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"license": "MIT",
"dependencies": {
"chalk": "4.1.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/next-env/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/env",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"keywords": [
"react",
"next",
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": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"main": "index.js",
"license": "MIT",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-google-analytics",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-sentry",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-sentry"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-plugin-storybook/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/plugin-storybook",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"repository": {
"url": "vercel/next.js",
"directory": "packages/next-plugin-storybook"
Expand Down
2 changes: 1 addition & 1 deletion packages/next-polyfill-module/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-module",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/polyfill-nomodule",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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)
}
})
}
)
}
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name":"bfj","main":"index.js","author":"Phil Booth (https://gitlab.com/philbooth)","license":"MIT"}
1 change: 1 addition & 0 deletions packages/next/next-server/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const defaultConfig: NextConfig = {
optimizeCss: false,
scrollRestoration: false,
scriptLoader: false,
stats: !!process.env.VERCEL_ANALYTICS_ID,
},
future: {
strictPostcssConfiguration: false,
Expand Down
13 changes: 7 additions & 6 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -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.1",
"@next/polyfill-module": "10.0.7-canary.1",
"@next/react-dev-overlay": "10.0.7-canary.1",
"@next/react-refresh-utils": "10.0.7-canary.1",
"@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.1",
"@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
9 changes: 9 additions & 0 deletions packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,14 @@ export async function ncc_babel_bundle_packages(task, opts) {
.target('compiled/babel/')
}

// eslint-disable-next-line camelcase
externals['bfj'] = 'next/dist/compiled/bfj'
export async function ncc_bfj(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('bfj')))
.ncc({ packageName: 'bfj' })
.target('compiled/bfj')
}
// eslint-disable-next-line camelcase
externals['cacache'] = 'next/dist/compiled/cacache'
export async function ncc_cacache(task, opts) {
Expand Down Expand Up @@ -672,6 +680,7 @@ export async function ncc(task) {
'ncc_async_sema',
'ncc_babel_bundle',
'ncc_babel_bundle_packages',
'ncc_bfj',
'ncc_cacache',
'ncc_cache_loader',
'ncc_ci_info',
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-overlay/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-dev-overlay",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"description": "A development-only overlay for developing React applications.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-refresh-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@next/react-refresh-utils",
"version": "10.0.7-canary.0",
"version": "10.0.7-canary.1",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
5 changes: 5 additions & 0 deletions test/integration/build-stats/next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
experimental: {
stats: true,
},
}
3 changes: 3 additions & 0 deletions test/integration/build-stats/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Index(props) {
return <p>Hello world</p>
}
20 changes: 20 additions & 0 deletions test/integration/build-stats/test/index.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* eslint-env jest */

import fs from 'fs-extra'
import { join } from 'path'
import { nextBuild } from 'next-test-utils'

jest.setTimeout(1000 * 60 * 1)

const appDir = join(__dirname, '../')
const statsPath = join(appDir, '.next/next-stats.json')

describe('Build Stats', () => {
it('outputs next-stats.json when enabled', async () => {
await nextBuild(appDir)
expect(await fs.pathExists(statsPath)).toBe(true)

const statsData = await fs.readFile(statsPath, 'utf8')
JSON.parse(statsData)
})
})
4 changes: 4 additions & 0 deletions test/integration/production/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,6 +782,10 @@ describe('Production Usage', () => {
expect(existsSync(join(appDir, '.next', 'profile-events.json'))).toBe(false)
})

it('should not emit stats', async () => {
expect(existsSync(join(appDir, '.next', 'next-stats.json'))).toBe(false)
})

it('should contain the Next.js version in window export', async () => {
let browser
try {
Expand Down
25 changes: 25 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4016,6 +4016,16 @@ before-after-hook@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.1.0.tgz#b6c03487f44e24200dd30ca5e6a1979c5d2fb635"

[email protected]:
version "7.0.2"
resolved "https://registry.yarnpkg.com/bfj/-/bfj-7.0.2.tgz#1988ce76f3add9ac2913fd8ba47aad9e651bfbb2"
integrity sha512-+e/UqUzwmzJamNF50tBV6tZPTORow7gQ96iFow+8b562OdMpEK0BcJEq2OSPEDmAbSMBQ7PKZ87ubFkgxpYWgw==
dependencies:
bluebird "^3.5.5"
check-types "^11.1.1"
hoopy "^0.1.4"
tryer "^1.0.1"

big.js@^5.2.2:
version "5.2.2"
resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328"
Expand Down Expand Up @@ -4619,6 +4629,11 @@ chardet@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.7.0.tgz#90094849f0937f2eedc2425d0d28a9e5f0cbad9e"

check-types@^11.1.1:
version "11.1.2"
resolved "https://registry.yarnpkg.com/check-types/-/check-types-11.1.2.tgz#86a7c12bf5539f6324eb0e70ca8896c0e38f3e2f"
integrity sha512-tzWzvgePgLORb9/3a0YenggReLKAIb2owL03H2Xdoe5pKcUyWRSEQ8xfCar8t2SIAuEDwtmx2da1YB52YuHQMQ==

[email protected]:
version "0.22.0"
resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-0.22.0.tgz#a9baa860a3f9b595a6b81b1a86873121ed3a269e"
Expand Down Expand Up @@ -7877,6 +7892,11 @@ homedir-polyfill@^1.0.0:
dependencies:
parse-passwd "^1.0.0"

hoopy@^0.1.4:
version "0.1.4"
resolved "https://registry.yarnpkg.com/hoopy/-/hoopy-0.1.4.tgz#609207d661100033a9a9402ad3dea677381c1b1d"
integrity sha512-HRcs+2mr52W0K+x8RzcLzuPPmVIKMSv97RGHy0Ea9y/mpcaK+xTrjICA04KAHi4GRzxliNqNJEFYWHghy3rSfQ==

hosted-git-info@^2.1.4, hosted-git-info@^2.7.1:
version "2.8.5"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.5.tgz#759cfcf2c4d156ade59b0b2dfabddc42a6b9c70c"
Expand Down Expand Up @@ -15507,6 +15527,11 @@ trough@^1.0.0:
dependencies:
glob "^7.1.2"

tryer@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/tryer/-/tryer-1.0.1.tgz#f2c85406800b9b0f74c9f7465b81eaad241252f8"
integrity sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==

ts-pnp@^1.1.6:
version "1.2.0"
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.2.0.tgz#a500ad084b0798f1c3071af391e65912c86bca92"
Expand Down

0 comments on commit 1081c0b

Please sign in to comment.