Skip to content

Commit

Permalink
Merge branch 'canary' into bugfix/managed-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored May 19, 2021
2 parents b39ea88 + ea1cdb2 commit bac9a29
Show file tree
Hide file tree
Showing 23 changed files with 97 additions and 53 deletions.
4 changes: 0 additions & 4 deletions docs/api-reference/next.config.js/custom-webpack-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ In order to extend our usage of `webpack`, you can define a function that extend
```js
module.exports = {
webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
// Note: we provide webpack above so you should not `require` it
// Perform customizations to webpack config
config.plugins.push(new webpack.IgnorePlugin(/\/__tests__\//))

// Important: return the modified config
return config
},
Expand Down
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.2.1-canary.11"
"version": "10.2.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.2.1-canary.11",
"version": "10.2.1",
"keywords": [
"react",
"next",
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config-next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint-config-next",
"version": "10.2.1-canary.11",
"version": "10.2.1",
"description": "ESLint configuration used by NextJS.",
"main": "index.js",
"license": "MIT",
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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.1",
"main": "index.js",
"license": "MIT",
"repository": {
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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.1",
"description": "A polyfill for non-dead, nomodule browsers.",
"main": "dist/polyfill-nomodule.js",
"license": "MIT",
Expand Down
4 changes: 2 additions & 2 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ export default async function getBaseWebpackConfig(
splitChunks: isServer
? isWebpack5
? ({
filename: `${dev ? '[name]' : '[name].[contenthash]'}.js`,
filename: '[name].js',
// allow to split entrypoints
chunks: 'all',
// size of files is not so relevant for server build
Expand Down Expand Up @@ -931,7 +931,7 @@ export default async function getBaseWebpackConfig(
: 'static/webpack/[hash].hot-update.json',
// This saves chunks with the name given via `import()`
chunkFilename: isServer
? `${dev ? '[name]' : '[name].[contenthash]'}.js`
? '[name].js'
: `static/chunks/${isDevFallback ? 'fallback/' : ''}${
dev ? '[name]' : '[name].[contenthash]'
}.js`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,19 @@ export class FontStylesheetGatheringPlugin {
}

this.gatheredStylesheets.push(props.href)

if (isWebpack5) {
const buildInfo = parser?.state?.module?.buildInfo

if (buildInfo) {
buildInfo.valueDependencies.set(
FONT_MANIFEST,
this.gatheredStylesheets
)
}
}
}

// React JSX transform:
parser.hooks.call
.for('_jsx')
Expand Down Expand Up @@ -161,8 +173,24 @@ export class FontStylesheetGatheringPlugin {
}
compilation.hooks.finishModules.tapAsync(
this.constructor.name,
async (_: any, modulesFinished: Function) => {
const fontDefinitionPromises = this.gatheredStylesheets.map((url) =>
async (modules: any, modulesFinished: Function) => {
let fontStylesheets = this.gatheredStylesheets

if (isWebpack5) {
const fontUrls = new Set<string>()
modules.forEach((module: any) => {
const fontDependencies = module?.buildInfo?.valueDependencies?.get(
FONT_MANIFEST
)
if (fontDependencies) {
fontDependencies.forEach((v: string) => fontUrls.add(v))
}
})

fontStylesheets = Array.from(fontUrls)
}

const fontDefinitionPromises = fontStylesheets.map((url) =>
getFontDefinitionFromNetwork(url)
)

Expand All @@ -173,7 +201,7 @@ export class FontStylesheetGatheringPlugin {
if (css) {
const content = await minifyCss(css)
this.manifestContent.push({
url: this.gatheredStylesheets[promiseIndex],
url: fontStylesheets[promiseIndex],
content,
})
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/compiled/postcss-loader/cjs.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions packages/next/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "next",
"version": "10.2.1-canary.11",
"version": "10.2.1",
"description": "The React Framework",
"main": "./dist/server/next.js",
"license": "MIT",
Expand Down Expand Up @@ -64,10 +64,10 @@
"dependencies": {
"@babel/runtime": "7.12.5",
"@hapi/accept": "5.0.2",
"@next/env": "10.2.1-canary.11",
"@next/polyfill-module": "10.2.1-canary.11",
"@next/react-dev-overlay": "10.2.1-canary.11",
"@next/react-refresh-utils": "10.2.1-canary.11",
"@next/env": "10.2.1",
"@next/polyfill-module": "10.2.1",
"@next/react-dev-overlay": "10.2.1",
"@next/react-refresh-utils": "10.2.1",
"@opentelemetry/api": "0.14.0",
"assert": "2.0.0",
"ast-types": "0.13.2",
Expand Down Expand Up @@ -151,7 +151,7 @@
"@babel/preset-typescript": "7.12.7",
"@babel/traverse": "^7.12.10",
"@babel/types": "7.12.12",
"@next/polyfill-nomodule": "10.2.1-canary.11",
"@next/polyfill-nomodule": "10.2.1",
"@taskr/clear": "1.1.0",
"@taskr/esnext": "1.1.0",
"@taskr/watch": "1.1.0",
Expand Down Expand Up @@ -226,7 +226,7 @@
"ora": "4.0.4",
"path-to-regexp": "6.1.0",
"postcss-flexbugs-fixes": "5.0.2",
"postcss-loader": "4.0.3",
"postcss-loader": "4.3.0",
"postcss-preset-env": "6.7.0",
"postcss-scss": "3.0.5",
"recast": "0.18.5",
Expand Down
8 changes: 7 additions & 1 deletion packages/next/taskfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,13 @@ externals['postcss-loader'] = 'next/dist/compiled/postcss-loader'
export async function ncc_postcss_loader(task, opts) {
await task
.source(opts.src || relative(__dirname, require.resolve('postcss-loader')))
.ncc({ packageName: 'postcss-loader', externals })
.ncc({
packageName: 'postcss-loader',
externals: {
...externals,
'schema-utils': 'next/dist/compiled/schema-utils3',
},
})
.target('compiled/postcss-loader')
}
// eslint-disable-next-line camelcase
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.2.1-canary.11",
"version": "10.2.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.2.1-canary.11",
"version": "10.2.1",
"description": "An experimental package providing utilities for React Refresh.",
"repository": {
"url": "vercel/next.js",
Expand Down
2 changes: 1 addition & 1 deletion test/integration/build-output/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ describe('Build Output', () => {
expect(parseFloat(err404Size)).toBeCloseTo(gz ? 3.06 : 8.15, 1)
expect(err404Size.endsWith('kB')).toBe(true)

expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.5 : 203, 1)
expect(parseFloat(err404FirstLoad)).toBeCloseTo(gz ? 66.4 : 203, 1)
expect(err404FirstLoad.endsWith('kB')).toBe(true)

expect(parseFloat(sharedByAll)).toBeCloseTo(gz ? 63.4 : 195, 1)
Expand Down
18 changes: 15 additions & 3 deletions test/integration/create-next-app/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ describe('create next app', () => {
const res = await run([projectName, '--typescript'], { cwd })
expect(res.exitCode).toBe(0)

expect(
fs.existsSync(path.join(cwd, projectName, 'package.json'))
).toBeTruthy()
const pkgJSONPath = path.join(cwd, projectName, 'package.json')

expect(fs.existsSync(pkgJSONPath)).toBeTruthy()
expect(
fs.existsSync(path.join(cwd, projectName, 'pages/index.tsx'))
).toBeTruthy()
Expand All @@ -119,6 +119,18 @@ describe('create next app', () => {
expect(
fs.existsSync(path.join(cwd, projectName, '.gitignore'))
).toBeTruthy()

// Assert for dependencies specific to the typescript template
const pkgJSON = require(pkgJSONPath)
expect(Object.keys(pkgJSON.dependencies)).toEqual([
'next',
'react',
'react-dom',
])
expect(Object.keys(pkgJSON.devDependencies)).toEqual([
'@types/react',
'typescript',
])
})
})

Expand Down
21 changes: 14 additions & 7 deletions test/integration/font-optimization/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,22 @@ describe('Font Optimization', () => {

expect(testCss).toStrictEqual(snapshotCss)
})

// Re-run build to check if it works when build is cached
it('should work when build is cached', async () => {
await nextBuild(appDir)
const testJson = JSON.parse(
await fs.readFile(builtPage('font-manifest.json'), {
encoding: 'utf-8',
})
)
expect(testJson.length).toBeGreaterThan(0)
})
}

describe('Font optimization for SSR apps', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { experimental: {optimizeFonts: true} }`,
'utf8'
)
await fs.writeFile(nextConfig, `module.exports = { }`, 'utf8')

if (fs.pathExistsSync(join(appDir, '.next'))) {
await fs.remove(join(appDir, '.next'))
Expand All @@ -237,7 +244,7 @@ describe('Font Optimization', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { target: 'serverless', experimental: {optimizeFonts: true} }`,
`module.exports = { target: 'serverless' }`,
'utf8'
)
await nextBuild(appDir)
Expand All @@ -254,7 +261,7 @@ describe('Font Optimization', () => {
beforeAll(async () => {
await fs.writeFile(
nextConfig,
`module.exports = { target: 'experimental-serverless-trace', experimental: {optimizeFonts: true} }`,
`module.exports = { target: 'experimental-serverless-trace' }`,
'utf8'
)
await nextBuild(appDir)
Expand Down
17 changes: 6 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2383,11 +2383,6 @@
call-me-maybe "^1.0.1"
glob-to-regexp "^0.3.0"

"@next/eslint-plugin-next@^10.1.3":
version "10.1.3"
resolved "https://registry.yarnpkg.com/@next/eslint-plugin-next/-/eslint-plugin-next-10.1.3.tgz#739743aa33aed28d97e670b9f80b84440cf2a3c7"
integrity sha512-KrZUb6cHXt/rPhN9bSrlVLAq+9LyNOWurqbrUww3OXmrFlXBDI8W6Z0ToDkQMkIH6gTtmpGbuctxCkQ2pgeXzQ==

"@nodelib/fs.scandir@2.1.3":
version "2.1.3"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.3.tgz#3a582bdb53804c6ba6d146579c46e52130cf4a3b"
Expand Down Expand Up @@ -12832,16 +12827,16 @@ postcss-loader@3.0.0:
postcss-load-config "^2.0.0"
schema-utils "^1.0.0"

postcss-loader@4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-4.0.3.tgz#337f51bbdfb02269fb42f7db9fc7f0a93c1b2e3f"
integrity sha512-jHboC/AOnJLPu8/974hODCJ/rNAa2YhhJOclUeuRlAmFpKmEcBY6az8y1ejHyYc2LThzPl8qPRekh2Yz3CiRKA==
postcss-loader@4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/postcss-loader/-/postcss-loader-4.3.0.tgz#2c4de9657cd4f07af5ab42bd60a673004da1b8cc"
integrity sha512-M/dSoIiNDOo8Rk0mUqoj4kpGq91gcxCfb9PoyZVdZ76/AuhxylHDYZblNE8o+EQ9AMSASeMFEKxZf5aU6wlx1Q==
dependencies:
cosmiconfig "^7.0.0"
klona "^2.0.4"
loader-utils "^2.0.0"
schema-utils "^2.7.1"
semver "^7.3.2"
schema-utils "^3.0.0"
semver "^7.3.4"

postcss-logical@^3.0.0:
version "3.0.0"
Expand Down

0 comments on commit bac9a29

Please sign in to comment.