Skip to content

Commit

Permalink
Merge branch 'canary' into feature/less-styles
Browse files Browse the repository at this point in the history
  • Loading branch information
vbudovski authored Mar 18, 2021
2 parents f38576a + 60af3a1 commit bbd707c
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 74 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.10-canary.2"
"version": "10.0.10-canary.3"
}
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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
50 changes: 50 additions & 0 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1235,6 +1235,7 @@ export default async function getBaseWebpackConfig(
assetPrefix: config.assetPrefix,
target,
reactProductionProfiling,
webpack: !!config.webpack,
})

const cache: any = {
Expand All @@ -1257,6 +1258,55 @@ export default async function getBaseWebpackConfig(

// @ts-ignore TODO: remove ignore when webpack 5 is stable
webpackConfig.optimization.realContentHash = false

if (process.env.__NEXT_WEBPACK_LOGGING) {
const logInfra = process.env.__NEXT_WEBPACK_LOGGING.includes(
'infrastructure'
)
const logProfileClient = process.env.__NEXT_WEBPACK_LOGGING.includes(
'profile-client'
)
const logProfileServer = process.env.__NEXT_WEBPACK_LOGGING.includes(
'profile-server'
)
const logDefault = !logInfra && !logProfileClient && !logProfileServer

if (logDefault || logInfra) {
// @ts-ignore TODO: remove ignore when webpack 5 is stable
webpackConfig.infrastructureLogging = {
level: 'verbose',
debug: /FileSystemInfo/,
}
}

if (
logDefault ||
(logProfileClient && !isServer) ||
(logProfileServer && isServer)
) {
webpackConfig.plugins!.push((compiler: webpack.Compiler) => {
compiler.hooks.done.tap('next-webpack-logging', (stats) => {
console.log(
stats.toString({
colors: true,
// @ts-ignore TODO: remove ignore when webpack 5 is stable
logging: logDefault ? 'log' : 'verbose',
})
)
})
})
}

if ((logProfileClient && !isServer) || (logProfileServer && isServer)) {
webpackConfig.plugins!.push(
new webpack.ProgressPlugin({
// @ts-ignore TODO: remove ignore when webpack 5 is stable
profile: true,
})
)
webpackConfig.profile = true
}
}
}

webpackConfig = await buildConfiguration(webpackConfig, {
Expand Down
85 changes: 31 additions & 54 deletions packages/next/build/webpack/plugins/build-manifest-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,16 @@ function generateClientManifest(
})
}

function isJsFile(file: string): boolean {
// We don't want to include `.hot-update.js` files into the initial page
return !file.endsWith('.hot-update.js') && file.endsWith('.js')
}

function getFilesArray(files: any) {
if (!files) {
return []
}
if (isWebpack5) {
return Array.from(files)
}

return files
function getEntrypointFiles(entrypoint: any): string[] {
return (
entrypoint
?.getFiles()
.filter((file: string) => {
// We don't want to include `.hot-update.js` files into the initial page
return /(?<!\.hot-update)\.(js|css)($|\?)/.test(file)
})
.map((file: string) => file.replace(/\\/g, '/')) ?? []
)
}

// This plugin creates a build-manifest.json for all assets that are being output
Expand Down Expand Up @@ -109,8 +105,7 @@ export default class BuildManifestPlugin {
'NextJsBuildManifest-createassets'
)
return createAssetsSpan?.traceFn(() => {
const namedChunks: Map<string, webpack.compilation.Chunk> =
compilation.namedChunks
const entrypoints: Map<string, any> = compilation.entrypoints
const assetMap: DeepMutable<BuildManifest> = {
polyfillFiles: [],
devFiles: [],
Expand All @@ -132,59 +127,41 @@ export default class BuildManifestPlugin {
}
}

const mainJsChunk = namedChunks.get(CLIENT_STATIC_FILES_RUNTIME_MAIN)

const mainJsFiles: string[] = getFilesArray(mainJsChunk?.files).filter(
isJsFile
const mainFiles = new Set(
getEntrypointFiles(entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_MAIN))
)

const polyfillChunk = namedChunks.get(
CLIENT_STATIC_FILES_RUNTIME_POLYFILLS
)
assetMap.polyfillFiles = getEntrypointFiles(
entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_POLYFILLS)
).filter((file) => !mainFiles.has(file))

// Create a separate entry for polyfills
assetMap.polyfillFiles = getFilesArray(polyfillChunk?.files).filter(
isJsFile
)
assetMap.devFiles = getEntrypointFiles(
entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH)
).filter((file) => !mainFiles.has(file))

const reactRefreshChunk = namedChunks.get(
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH
)
assetMap.devFiles = getFilesArray(reactRefreshChunk?.files).filter(
isJsFile
assetMap.ampDevFiles = getEntrypointFiles(
entrypoints.get(CLIENT_STATIC_FILES_RUNTIME_AMP)
)

for (const entrypoint of compilation.entrypoints.values()) {
const isAmpRuntime = entrypoint.name === CLIENT_STATIC_FILES_RUNTIME_AMP
const systemEntrypoints = new Set([
CLIENT_STATIC_FILES_RUNTIME_MAIN,
CLIENT_STATIC_FILES_RUNTIME_POLYFILLS,
CLIENT_STATIC_FILES_RUNTIME_REACT_REFRESH,
CLIENT_STATIC_FILES_RUNTIME_AMP,
])

if (isAmpRuntime) {
for (const file of entrypoint.getFiles()) {
if (!(isJsFile(file) || file.endsWith('.css'))) {
continue
}
for (const entrypoint of compilation.entrypoints.values()) {
if (systemEntrypoints.has(entrypoint.name)) continue

assetMap.ampDevFiles.push(file.replace(/\\/g, '/'))
}
continue
}
const pagePath = getRouteFromEntrypoint(entrypoint.name)

if (!pagePath) {
continue
}

const filesForEntry: string[] = []

// getFiles() - helper function to read the files for an entrypoint from stats object
for (const file of entrypoint.getFiles()) {
if (!(isJsFile(file) || file.endsWith('.css'))) {
continue
}

filesForEntry.push(file.replace(/\\/g, '/'))
}
const filesForPage = getEntrypointFiles(entrypoint)

assetMap.pages[pagePath] = [...mainJsFiles, ...filesForEntry]
assetMap.pages[pagePath] = [...new Set([...mainFiles, ...filesForPage])]
}

// Add the runtime build manifest file (generated later in this file)
Expand Down
12 changes: 6 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.10-canary.2",
"version": "10.0.10-canary.3",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -62,10 +62,10 @@
"dependencies": {
"@babel/runtime": "7.12.5",
"@hapi/accept": "5.0.1",
"@next/env": "10.0.10-canary.2",
"@next/polyfill-module": "10.0.10-canary.2",
"@next/react-dev-overlay": "10.0.10-canary.2",
"@next/react-refresh-utils": "10.0.10-canary.2",
"@next/env": "10.0.10-canary.3",
"@next/polyfill-module": "10.0.10-canary.3",
"@next/react-dev-overlay": "10.0.10-canary.3",
"@next/react-refresh-utils": "10.0.10-canary.3",
"@opentelemetry/api": "0.14.0",
"ast-types": "0.13.2",
"browserslist": "4.16.1",
Expand Down Expand Up @@ -137,7 +137,7 @@
"@babel/preset-react": "7.12.10",
"@babel/preset-typescript": "7.12.7",
"@babel/types": "7.12.12",
"@next/polyfill-nomodule": "10.0.10-canary.2",
"@next/polyfill-nomodule": "10.0.10-canary.3",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
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.10-canary.2",
"version": "10.0.10-canary.3",
"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.10-canary.2",
"version": "10.0.10-canary.3",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down

0 comments on commit bbd707c

Please sign in to comment.