From afaff59f96219b7da1f461a3a8d1f39bdfe6a411 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 8 Oct 2019 14:28:15 -0400 Subject: [PATCH 01/31] Monkeypatch @zeit/next-css@0.2.1-canary.4 (#8996) --- packages/next/build/webpack-config.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 67ec13747c7e6..454f0778add89 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -955,7 +955,11 @@ export default async function getBaseWebpackConfig( // old `css-loader` versions. Custom setups (that aren't next-sass // or next-less) likely have the newer version. // We still handle this gracefully below. - Object.prototype.hasOwnProperty.call(use.options, 'minimize') + (Object.prototype.hasOwnProperty.call(use.options, 'minimize') || + Object.prototype.hasOwnProperty.call( + use.options, + 'exportOnlyLocals' + )) ) ) { return From 3c9787927790748a90c19d148ae768f3e3b30d4b Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Tue, 8 Oct 2019 17:26:18 -0400 Subject: [PATCH 02/31] v9.1.2-canary.1 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next/package.json | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lerna.json b/lerna.json index 5da4d89b5b978..2d06d0ca05752 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "9.1.2-canary.0" + "version": "9.1.2-canary.1" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 052e78743106d..c50ce454c8d96 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "9.1.2-canary.0", + "version": "9.1.2-canary.1", "keywords": [ "react", "next", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 2a6e47f4de157..c8c0a2e667b7d 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "9.1.2-canary.0", + "version": "9.1.2-canary.1", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index d8318b4034dd4..64d89d1bd0699 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "9.1.2-canary.0", + "version": "9.1.2-canary.1", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next/package.json b/packages/next/package.json index e46ad5c6bf688..861b81df151d0 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "9.1.2-canary.0", + "version": "9.1.2-canary.1", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", From 32633c83ddac4f4389a07e02bf916ad5178268a7 Mon Sep 17 00:00:00 2001 From: Yamagishi Kazutoshi Date: Wed, 9 Oct 2019 08:48:09 +0900 Subject: [PATCH 03/31] Add src directory support for global CSS (#8999) --- packages/next/build/webpack-config.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 454f0778add89..6fd3494d6a5c8 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -299,14 +299,10 @@ export default async function getBaseWebpackConfig( : config.crossOrigin let customAppFile: string | null = config.experimental.css - ? await findPageFile( - path.join(dir, 'pages'), - '/_app', - config.pageExtensions - ) + ? await findPageFile(pagesDir, '/_app', config.pageExtensions) : null if (customAppFile) { - customAppFile = path.resolve(path.join(dir, 'pages', customAppFile)) + customAppFile = path.resolve(path.join(pagesDir, customAppFile)) } let webpackConfig: webpack.Configuration = { @@ -668,7 +664,7 @@ export default async function getBaseWebpackConfig( 'Custom ' )}. Please move all global CSS imports to ${chalk.cyan( customAppFile - ? path.relative(dir, customAppFile) + ? path.relative(pagesDir, customAppFile) : 'pages/_app.js' )}.\n` + `Read more: https://err.sh/next.js/global-css`, From 13f05f2cd4f9484f088290803f9767afebacf202 Mon Sep 17 00:00:00 2001 From: manfwh <841533182@qq.com> Date: Wed, 9 Oct 2019 23:15:34 +0800 Subject: [PATCH 04/31] Update README-zh-CN.md static-file-serving-eg-images (#9002) --- README-zh-CN.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README-zh-CN.md b/README-zh-CN.md index fb07b8038531f..9061ab8bb3677 100644 --- a/README-zh-CN.md +++ b/README-zh-CN.md @@ -133,7 +133,7 @@ export default () =>
Welcome to next.js!
- 自动打包编译 (使用 webpack 和 babel) - 热加载 - 以 `./pages`作为服务的渲染和索引 -- 静态文件服务. `./static/` 映射到 `/static/` (可以 [创建一个静态目录](#static-file-serving-eg-images) 在你的项目中) +- 静态文件服务. `./public/` 映射到 `/` (可以 [创建一个静态目录](#static-file-serving-eg-images) 在你的项目中) 这里有个简单的案例,可以下载看看 [sample app - nextgram](https://github.com/zeit/nextgram) @@ -227,13 +227,13 @@ export default () =>

hi there

### 静态文件服务(如图像) -在根目录下新建文件夹叫`static`。代码可以通过`/static/`来引入相关的静态资源。 +在根目录下新建文件夹叫`public`。代码可以通过`/`来引入相关的静态资源。 ```jsx -export default () => my image +export default () => my image ``` -_注意:不要自定义静态文件夹的名字,只能叫`static` ,因为只有这个名字 Next.js 才会把它当作静态资源。_ +_注意:不要自定义静态文件夹的名字,只能叫`public` ,因为只有这个名字 Next.js 才会把它当作静态资源。_ From e5202ffb24c90f5b4e22cc1e07be9e5f5005886f Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 9 Oct 2019 10:41:49 -0500 Subject: [PATCH 05/31] Add CSS fixture for src dir (#9001) * Add CSS fixture for src dir * Revert relative customAppFile dir and update tests --- packages/next/build/webpack-config.ts | 2 +- .../single-global-src/src/pages/_app.js | 12 +++++++ .../single-global-src/src/pages/index.js | 3 ++ .../single-global-src/styles/global.css | 3 ++ test/integration/css/test/index.test.js | 32 +++++++++++++++++-- 5 files changed, 49 insertions(+), 3 deletions(-) create mode 100644 test/integration/css/fixtures/single-global-src/src/pages/_app.js create mode 100644 test/integration/css/fixtures/single-global-src/src/pages/index.js create mode 100644 test/integration/css/fixtures/single-global-src/styles/global.css diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 6fd3494d6a5c8..73bf5e756b969 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -664,7 +664,7 @@ export default async function getBaseWebpackConfig( 'Custom ' )}. Please move all global CSS imports to ${chalk.cyan( customAppFile - ? path.relative(pagesDir, customAppFile) + ? path.relative(dir, customAppFile) : 'pages/_app.js' )}.\n` + `Read more: https://err.sh/next.js/global-css`, diff --git a/test/integration/css/fixtures/single-global-src/src/pages/_app.js b/test/integration/css/fixtures/single-global-src/src/pages/_app.js new file mode 100644 index 0000000000000..d6cf88cc354e8 --- /dev/null +++ b/test/integration/css/fixtures/single-global-src/src/pages/_app.js @@ -0,0 +1,12 @@ +import React from 'react' +import App from 'next/app' +import '../../styles/global.css' + +class MyApp extends App { + render () { + const { Component, pageProps } = this.props + return + } +} + +export default MyApp diff --git a/test/integration/css/fixtures/single-global-src/src/pages/index.js b/test/integration/css/fixtures/single-global-src/src/pages/index.js new file mode 100644 index 0000000000000..b23f4aa48f634 --- /dev/null +++ b/test/integration/css/fixtures/single-global-src/src/pages/index.js @@ -0,0 +1,3 @@ +export default function Home () { + return
This text should be red.
+} diff --git a/test/integration/css/fixtures/single-global-src/styles/global.css b/test/integration/css/fixtures/single-global-src/styles/global.css new file mode 100644 index 0000000000000..8e1524022baf8 --- /dev/null +++ b/test/integration/css/fixtures/single-global-src/styles/global.css @@ -0,0 +1,3 @@ +.red-text { + color: red; +} diff --git a/test/integration/css/test/index.test.js b/test/integration/css/test/index.test.js index 3402f6465c649..e647af834a5f4 100644 --- a/test/integration/css/test/index.test.js +++ b/test/integration/css/test/index.test.js @@ -44,6 +44,30 @@ describe('CSS Support', () => { }) }) + describe('Basic Global Support with src/ dir', () => { + const appDir = join(fixturesDir, 'single-global-src') + + beforeAll(async () => { + await remove(join(appDir, '.next')) + }) + + it('should build successfully', async () => { + await nextBuild(appDir) + }) + + it(`should've emitted a single CSS file`, async () => { + const cssFolder = join(appDir, '.next/static/css') + + const files = await readdir(cssFolder) + const cssFiles = files.filter(f => /\.css$/.test(f)) + + expect(cssFiles.length).toBe(1) + expect(await readFile(join(cssFolder, cssFiles[0]), 'utf8')).toContain( + 'color:red' + ) + }) + }) + describe('Multi Global Support', () => { const appDir = join(fixturesDir, 'multi-global') @@ -194,7 +218,9 @@ describe('CSS Support', () => { }) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.css') - expect(stderr).toContain('Please move all global CSS imports') + expect(stderr).toMatch( + /Please move all global CSS imports.*?pages(\/|\\)_app/ + ) }) }) @@ -211,7 +237,9 @@ describe('CSS Support', () => { }) expect(stderr).toContain('Failed to compile') expect(stderr).toContain('styles/global.css') - expect(stderr).toContain('Please move all global CSS imports') + expect(stderr).toMatch( + /Please move all global CSS imports.*?pages(\/|\\)_app/ + ) }) }) From 7f92c2649831791b3a2451d87a12097bc69f5552 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 9 Oct 2019 10:50:32 -0500 Subject: [PATCH 06/31] Fix global Bluebird causing HMR connection to fail (#9009) --- packages/next/server/on-demand-entry-handler.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/next/server/on-demand-entry-handler.ts b/packages/next/server/on-demand-entry-handler.ts index c54ec4db24845..53ce4197cc22a 100644 --- a/packages/next/server/on-demand-entry-handler.ts +++ b/packages/next/server/on-demand-entry-handler.ts @@ -366,8 +366,6 @@ export default function onDemandEntryHandler( req.on('close', () => { clearInterval(pingInterval) }) - // Do initial ping right after EventSource is finished being set up - setImmediate(() => runPing()) next() } } From 6ce6b96dfa9743b9480de2a8d89da098f5d93f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ismael=20Mart=C3=ADnez?= Date: Wed, 9 Oct 2019 19:28:06 -0300 Subject: [PATCH 07/31] Change to public folder in with-loading example (#9016) --- examples/with-loading/pages/_app.js | 2 +- examples/with-loading/{static => public}/nprogress.css | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename examples/with-loading/{static => public}/nprogress.css (100%) diff --git a/examples/with-loading/pages/_app.js b/examples/with-loading/pages/_app.js index 9ac9e58343d7b..5cb5ecc33b7e6 100644 --- a/examples/with-loading/pages/_app.js +++ b/examples/with-loading/pages/_app.js @@ -19,7 +19,7 @@ export default class MyApp extends App { <> {/* Import CSS for nprogress */} - +