From 52cf7fe51e0e5c71766dbf918d6b10281cc8cd47 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 3 Jan 2022 13:31:23 -0600 Subject: [PATCH 01/20] Ensure setImmediate and punycode are polyfilled (#32768) * Ensure setimmediate and punycode are polyfilled * update compiled --- packages/next/build/webpack-config.ts | 5 ++- packages/next/compiled/punycode/package.json | 1 + packages/next/compiled/punycode/punycode.js | 1 + .../next/compiled/setimmediate/package.json | 1 + .../compiled/setimmediate/setImmediate.js | 1 + .../next/compiled/timers-browserify/main.js | 2 +- packages/next/package.json | 2 + packages/next/taskfile.js | 33 +++++++++++++- .../basic/node-browser-polyfills.test.ts} | 24 +++++------ .../node-browser-polyfills/pages/index.js} | 43 ++++++++++--------- .../polyfill-node-modules/next.config.js | 6 --- yarn.lock | 10 ++--- 12 files changed, 83 insertions(+), 46 deletions(-) create mode 100644 packages/next/compiled/punycode/package.json create mode 100644 packages/next/compiled/punycode/punycode.js create mode 100644 packages/next/compiled/setimmediate/package.json create mode 100644 packages/next/compiled/setimmediate/setImmediate.js rename test/{integration/polyfill-node-modules/test/index.test.js => development/basic/node-browser-polyfills.test.ts} (70%) rename test/{integration/polyfill-node-modules/pages/node-browser-polyfills.js => development/basic/node-browser-polyfills/pages/index.js} (69%) delete mode 100644 test/integration/polyfill-node-modules/next.config.js diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 37c918d622e4d..bbac49486d94a 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -615,6 +615,8 @@ export default async function getBaseWebpackConfig( : 'react-dom/cjs/react-dom-server.browser.production.min', } : {}), + + setimmediate: 'next/dist/compiled/setimmediate', }, ...(targetWeb ? { @@ -632,7 +634,7 @@ export default async function getBaseWebpackConfig( https: require.resolve('next/dist/compiled/https-browserify'), os: require.resolve('next/dist/compiled/os-browserify'), path: require.resolve('next/dist/compiled/path-browserify'), - punycode: require.resolve('punycode'), + punycode: require.resolve('next/dist/compiled/punycode'), process: require.resolve('next/dist/compiled/process'), // Handled in separate alias querystring: require.resolve('next/dist/compiled/querystring-es3'), @@ -650,6 +652,7 @@ export default async function getBaseWebpackConfig( vm: require.resolve('next/dist/compiled/vm-browserify'), zlib: require.resolve('next/dist/compiled/browserify-zlib'), events: require.resolve('next/dist/compiled/events/'), + setImmediate: require.resolve('next/dist/compiled/setimmediate'), }, } : undefined), diff --git a/packages/next/compiled/punycode/package.json b/packages/next/compiled/punycode/package.json new file mode 100644 index 0000000000000..cf52cbab85fed --- /dev/null +++ b/packages/next/compiled/punycode/package.json @@ -0,0 +1 @@ +{"name":"punycode","main":"punycode.js","author":{"name":"Mathias Bynens","url":"https://mathiasbynens.be/"},"license":"MIT"} diff --git a/packages/next/compiled/punycode/punycode.js b/packages/next/compiled/punycode/punycode.js new file mode 100644 index 0000000000000..ae4e2f0f0b46a --- /dev/null +++ b/packages/next/compiled/punycode/punycode.js @@ -0,0 +1 @@ +(function(){"use strict";var t={701:function(t){const e=2147483647;const o=36;const n=1;const r=26;const c=38;const s=700;const i=72;const f=128;const u="-";const l=/^xn--/;const a=/[^\0-\x7E]/;const p=/[\x2E\u3002\uFF0E\uFF61]/g;const d={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"};const _=o-n;const h=Math.floor;const w=String.fromCharCode;function error(t){throw new RangeError(d[t])}function map(t,e){const o=[];let n=t.length;while(n--){o[n]=e(t[n])}return o}function mapDomain(t,e){const o=t.split("@");let n="";if(o.length>1){n=o[0]+"@";t=o[1]}t=t.replace(p,".");const r=t.split(".");const c=map(r,e).join(".");return n+c}function ucs2decode(t){const e=[];let o=0;const n=t.length;while(o=55296&&r<=56319&&oString.fromCodePoint(...t);const basicToDigit=function(t){if(t-48<10){return t-22}if(t-65<26){return t-65}if(t-97<26){return t-97}return o};const digitToBasic=function(t,e){return t+22+75*(t<26)-((e!=0)<<5)};const adapt=function(t,e,n){let i=0;t=n?h(t/s):t>>1;t+=h(t/e);for(;t>_*r>>1;i+=o){t=h(t/_)}return h(i+(_+1)*t/(t+c))};const decode=function(t){const c=[];const s=t.length;let l=0;let a=f;let p=i;let d=t.lastIndexOf(u);if(d<0){d=0}for(let e=0;e=128){error("not-basic")}c.push(t.charCodeAt(e))}for(let i=d>0?d+1:0;i=s){error("invalid-input")}const u=basicToDigit(t.charCodeAt(i++));if(u>=o||u>h((e-l)/c)){error("overflow")}l+=u*c;const a=f<=p?n:f>=p+r?r:f-p;if(uh(e/d)){error("overflow")}c*=d}const u=c.length+1;p=adapt(l-f,u,f==0);if(h(l/u)>e-a){error("overflow")}a+=h(l/u);l%=u;c.splice(l++,0,a)}return String.fromCodePoint(...c)};const encode=function(t){const c=[];t=ucs2decode(t);let s=t.length;let l=f;let a=0;let p=i;for(const e of t){if(e<128){c.push(w(e))}}let d=c.length;let _=d;if(d){c.push(u)}while(_=l&&eh((e-a)/i)){error("overflow")}a+=(s-l)*i;l=s;for(const s of t){if(se){error("overflow")}if(s==l){let t=a;for(let e=o;;e+=o){const s=e<=p?n:e>=p+r?r:e-p;if(t=0){e._idleTimeoutId=setTimeout((function onTimeout(){if(e._onTimeout)e._onTimeout()}),t)}};n(619);t.setImmediate=typeof self!=="undefined"&&self.setImmediate||typeof global!=="undefined"&&global.setImmediate||this&&this.setImmediate;t.clearImmediate=typeof self!=="undefined"&&self.clearImmediate||typeof global!=="undefined"&&global.clearImmediate||this&&this.clearImmediate}};var t={};function __nccwpck_require__(n){var a=t[n];if(a!==undefined){return a.exports}var i=t[n]={exports:{}};var o=true;try{e[n].call(i.exports,i,i.exports,__nccwpck_require__);o=false}finally{if(o)delete t[n]}return i.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(832);module.exports=n})(); \ No newline at end of file +(function(){var e={832:function(e,t,i){var o=typeof global!=="undefined"&&global||typeof self!=="undefined"&&self||window;var n=Function.prototype.apply;t.setTimeout=function(){return new Timeout(n.call(setTimeout,o,arguments),clearTimeout)};t.setInterval=function(){return new Timeout(n.call(setInterval,o,arguments),clearInterval)};t.clearTimeout=t.clearInterval=function(e){if(e){e.close()}};function Timeout(e,t){this._id=e;this._clearFn=t}Timeout.prototype.unref=Timeout.prototype.ref=function(){};Timeout.prototype.close=function(){this._clearFn.call(o,this._id)};t.enroll=function(e,t){clearTimeout(e._idleTimeoutId);e._idleTimeout=t};t.unenroll=function(e){clearTimeout(e._idleTimeoutId);e._idleTimeout=-1};t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;if(t>=0){e._idleTimeoutId=setTimeout((function onTimeout(){if(e._onTimeout)e._onTimeout()}),t)}};i(505);t.setImmediate=typeof self!=="undefined"&&self.setImmediate||typeof global!=="undefined"&&global.setImmediate||this&&this.setImmediate;t.clearImmediate=typeof self!=="undefined"&&self.clearImmediate||typeof global!=="undefined"&&global.clearImmediate||this&&this.clearImmediate},505:function(e){"use strict";e.exports=require("next/dist/compiled/setimmediate")}};var t={};function __nccwpck_require__(i){var o=t[i];if(o!==undefined){return o.exports}var n=t[i]={exports:{}};var r=true;try{e[i].call(n.exports,n,n.exports,__nccwpck_require__);r=false}finally{if(r)delete t[i]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var i=__nccwpck_require__(832);module.exports=i})(); \ No newline at end of file diff --git a/packages/next/package.json b/packages/next/package.json index 23686a9cab205..45fd4ac6bc5f9 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -236,6 +236,7 @@ "postcss-safe-parser": "6.0.0", "postcss-scss": "3.0.5", "postcss-value-parser": "4.1.0", + "punycode": "2.1.1", "process": "0.11.10", "querystring-es3": "0.2.1", "raw-body": "2.4.1", @@ -244,6 +245,7 @@ "sass-loader": "10.2.0", "schema-utils2": "npm:schema-utils@2.7.1", "schema-utils3": "npm:schema-utils@3.0.0", + "setimmediate": "1.0.5", "semver": "7.3.2", "send": "0.17.1", "source-map": "0.6.1", diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index 7b088e7d4e0bc..f0c348e9c57c9 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -510,6 +510,32 @@ export async function ncc_util(task, opts) { .target('compiled/util') } +// eslint-disable-next-line camelcase +export async function ncc_punycode(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('punycode/'))) + .ncc({ + packageName: 'punycode', + externals, + mainFields: ['browser', 'main'], + target: 'es5', + }) + .target('compiled/punycode') +} + +// eslint-disable-next-line camelcase +export async function ncc_set_immediate(task, opts) { + await task + .source(opts.src || relative(__dirname, require.resolve('setimmediate/'))) + .ncc({ + packageName: 'setimmediate', + externals, + mainFields: ['browser', 'main'], + target: 'es5', + }) + .target('compiled/setimmediate') +} + // eslint-disable-next-line camelcase export async function ncc_timers_browserify(task, opts) { await task @@ -518,7 +544,10 @@ export async function ncc_timers_browserify(task, opts) { ) .ncc({ packageName: 'timers-browserify', - externals, + externals: { + ...externals, + setimmediate: 'next/dist/compiled/setimmediate', + }, mainFields: ['browser', 'main'], target: 'es5', }) @@ -1444,6 +1473,8 @@ export async function ncc(task, opts) { 'ncc_querystring_es3', 'ncc_string_decoder', 'ncc_util', + 'ncc_punycode', + 'ncc_set_immediate', 'ncc_timers_browserify', 'ncc_tty_browserify', 'ncc_vm_browserify', diff --git a/test/integration/polyfill-node-modules/test/index.test.js b/test/development/basic/node-browser-polyfills.test.ts similarity index 70% rename from test/integration/polyfill-node-modules/test/index.test.js rename to test/development/basic/node-browser-polyfills.test.ts index 0b10c4d09c546..de6352b400231 100644 --- a/test/integration/polyfill-node-modules/test/index.test.js +++ b/test/development/basic/node-browser-polyfills.test.ts @@ -1,22 +1,22 @@ -/* eslint-env jest */ - import { join } from 'path' import webdriver from 'next-webdriver' -import { findPort, launchApp, killApp } from 'next-test-utils' +import { createNext, FileRef } from 'e2e-utils' +import { NextInstance } from 'test/lib/next-modes/base' -const appDir = join(__dirname, '../') -let appPort -let app +describe('theme-ui SWC option', () => { + let next: NextInstance -describe('Basic Features', () => { beforeAll(async () => { - appPort = await findPort() - app = await launchApp(appDir, appPort) + next = await createNext({ + files: { + pages: new FileRef(join(__dirname, 'node-browser-polyfills/pages')), + }, + }) }) - afterAll(() => killApp(app)) + afterAll(() => next.destroy()) - it('should polyfill Node.js modules', async () => { - const browser = await webdriver(appPort, '/node-browser-polyfills') + it('should have polyfilled correctly', async () => { + const browser = await webdriver(next.url, '/') await browser.waitForCondition('window.didRender') diff --git a/test/integration/polyfill-node-modules/pages/node-browser-polyfills.js b/test/development/basic/node-browser-polyfills/pages/index.js similarity index 69% rename from test/integration/polyfill-node-modules/pages/node-browser-polyfills.js rename to test/development/basic/node-browser-polyfills/pages/index.js index 46fd712929db3..8f3c6e39be1f9 100644 --- a/test/integration/polyfill-node-modules/pages/node-browser-polyfills.js +++ b/test/development/basic/node-browser-polyfills/pages/index.js @@ -19,6 +19,7 @@ import timers from 'timers' import tty from 'tty' import util from 'util' import zlib from 'zlib' +import 'setimmediate' export default function NodeBrowserPolyfillPage() { const [state, setState] = useState({}) @@ -50,26 +51,28 @@ export default function NodeBrowserPolyfillPage() { assert.ok(!!util.inspect) assert.ok(!!zlib.Gzip) - setState({ - assert: true, - buffer: Buffer.from('hello world').toString('utf8'), - constants: constants.E2BIG, - hash: crypto.createHash('sha256').update('hello world').digest('hex'), - domain: true, - os: os.EOL, - path: path.join('/hello/world', 'test.txt'), - process: process.title, - querystring: querystring.stringify({ a: 'b' }), - stream: closedStream, - stringDecoder: true, - sys: true, - timers: true, - tty: true, - util: true, - http: true, - https: true, - vm: vm.runInNewContext('a + 5', { a: 100 }), - zlib: true, + setImmediate(() => { + setState({ + assert: true, + buffer: Buffer.from('hello world').toString('utf8'), + constants: constants.E2BIG, + hash: crypto.createHash('sha256').update('hello world').digest('hex'), + domain: true, + os: os.EOL, + path: path.join('/hello/world', 'test.txt'), + process: process.title, + querystring: querystring.stringify({ a: 'b' }), + stream: closedStream, + stringDecoder: true, + sys: true, + timers: true, + tty: true, + util: true, + http: true, + https: true, + vm: vm.runInNewContext('a + 5', { a: 100 }), + zlib: true, + }) }) }, []) diff --git a/test/integration/polyfill-node-modules/next.config.js b/test/integration/polyfill-node-modules/next.config.js deleted file mode 100644 index cc17cf48c578f..0000000000000 --- a/test/integration/polyfill-node-modules/next.config.js +++ /dev/null @@ -1,6 +0,0 @@ -module.exports = { - onDemandEntries: { - // Make sure entries are not getting disposed. - maxInactiveAge: 1000 * 60 * 60, - }, -} diff --git a/yarn.lock b/yarn.lock index d991d307b0cb1..73d0f74becf85 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16277,14 +16277,14 @@ punycode@1.3.2: resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= +punycode@2.1.1, punycode@^2.1.0, punycode@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + punycode@^1.2.4: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" -punycode@^2.1.0, punycode@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - pupa@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/pupa/-/pupa-2.1.1.tgz#f5e8fd4afc2c5d97828faa523549ed8744a20d62" @@ -17565,7 +17565,7 @@ set-value@^2.0.0, set-value@^2.0.1: is-plain-object "^2.0.3" split-string "^3.0.1" -setimmediate@^1.0.4: +setimmediate@1.0.5, setimmediate@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= From d0e72fd9fadcb1acfb595a779d87cd0762b08c3d Mon Sep 17 00:00:00 2001 From: Devin Wall Date: Mon, 3 Jan 2022 15:35:57 -0500 Subject: [PATCH 02/20] Fixes issue with makeStylesheetInert (#32027) Fixes https://github.com/vercel/next.js/issues/32024 Fixing makeStylesheetInert. Fixes log import. ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` Co-authored-by: Devin Wall <87490815+DevinWallKcl@users.noreply.github.com> --- packages/next/pages/_document.tsx | 27 +++++++++----- .../pages/_document.js | 36 +++++++++++++++++++ .../pages/index.js | 8 +++++ .../font-optimization/test/index.test.js | 6 ++++ 4 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js create mode 100644 test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index c1c00608dc5fb..8d314577f4584 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -452,21 +452,30 @@ export class Head extends Component< makeStylesheetInert(node: ReactNode): ReactNode[] { return React.Children.map(node, (c: any) => { if ( - c.type === 'link' && - c.props['href'] && + c?.type === 'link' && + c?.props?.href && OPTIMIZED_FONT_PROVIDERS.some(({ url }) => - c.props['href'].startsWith(url) + c?.props?.href?.startsWith(url) ) ) { - const newProps = { ...(c.props || {}) } - newProps['data-href'] = newProps['href'] - newProps['href'] = undefined + const newProps = { + ...(c.props || {}), + 'data-href': c.props.href, + href: undefined, + } + + return React.cloneElement(c, newProps) + } else if (c?.props?.children) { + const newProps = { + ...(c.props || {}), + children: this.makeStylesheetInert(c.props.children), + } + return React.cloneElement(c, newProps) - } else if (c.props && c.props['children']) { - c.props['children'] = this.makeStylesheetInert(c.props['children']) } + return c - }) + }).filter(Boolean) } render() { diff --git a/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js new file mode 100644 index 0000000000000..34851fcae15cb --- /dev/null +++ b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/_document.js @@ -0,0 +1,36 @@ +import Document, { Html, Head, Main, NextScript } from 'next/document' + +class MyDocument extends Document { + static async getInitialProps(ctx) { + const initialProps = await Document.getInitialProps(ctx) + return { ...initialProps } + } + + render() { + return ( + + + <> + {false && } + + + + + + +
+ + + + ) + } +} + +export default MyDocument diff --git a/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js new file mode 100644 index 0000000000000..136175234f558 --- /dev/null +++ b/test/integration/font-optimization/fixtures/make-stylesheet-inert-regression/pages/index.js @@ -0,0 +1,8 @@ +export default function Home() { + return ( +

+ Falsey values contained in an element contained in Head should not result + in an error! +

+ ) +} diff --git a/test/integration/font-optimization/test/index.test.js b/test/integration/font-optimization/test/index.test.js index a4d6f216f65a3..f4a4bdd18c6b4 100644 --- a/test/integration/font-optimization/test/index.test.js +++ b/test/integration/font-optimization/test/index.test.js @@ -328,4 +328,10 @@ describe('Font Optimization', () => { const { code } = await nextBuild(appDir) expect(code).toBe(0) }) + + test('makeStylesheetInert regression', async () => { + const appDir = join(fixturesDir, 'make-stylesheet-inert-regression') + const { code } = await nextBuild(appDir) + expect(code).toBe(0) + }) }) From a5fab84840d0bb384b7cf24d4825a350f0037811 Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 3 Jan 2022 16:17:46 -0500 Subject: [PATCH 03/20] Reduce install size for linux glibc/musl (#32850) In Next.js [12.0.1]( https://packagephobia.com/result?p=next@12.0.1), musl support was added which caused linux to install both glibc and musl binaries. This PR adds the `install` script to prevent installing unused binaries, reducing the install size by 47MB. We originally thought this could be added to Node.js core and thus npm but [it was rejected](https://github.com/nodejs/node/pull/41338). Note getReport() works on Node.js [`>=11.8.0`](https://nodejs.org/api/process.html#processreportgetreporterr) which is safe to use since Next.js requires [`"node": ">=12.22.0"`](https://github.com/vercel/next.js/blob/265f71e225ed18fcb099c28cf1b5c83519acc3b0/packages/next/package.json#L280). --- .../next-swc/crates/napi/npm/linux-arm64-gnu/install.js | 2 ++ .../next-swc/crates/napi/npm/linux-arm64-gnu/package.json | 6 +++++- .../next-swc/crates/napi/npm/linux-arm64-musl/install.js | 2 ++ .../next-swc/crates/napi/npm/linux-arm64-musl/package.json | 6 +++++- packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js | 2 ++ .../next-swc/crates/napi/npm/linux-x64-gnu/package.json | 6 +++++- packages/next-swc/crates/napi/npm/linux-x64-musl/install.js | 2 ++ .../next-swc/crates/napi/npm/linux-x64-musl/package.json | 6 +++++- 8 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js create mode 100644 packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js create mode 100644 packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js create mode 100644 packages/next-swc/crates/napi/npm/linux-x64-musl/install.js diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js new file mode 100644 index 0000000000000..296ba2215f890 --- /dev/null +++ b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js @@ -0,0 +1,2 @@ +const { glibcVersionRuntime } = process.report.getReport().header; +process.exit(glibcVersionRuntime ? 0 : 1); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json index eb097c5a75d50..ef8c28f7a8c65 100644 --- a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json +++ b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json @@ -9,8 +9,12 @@ ], "main": "next-swc.linux-arm64-gnu.node", "files": [ - "next-swc.linux-arm64-gnu.node" + "next-swc.linux-arm64-gnu.node", + "install.js" ], + "scripts": { + "install": "node install.js" + }, "license": "MIT", "engines": { "node": ">= 10" diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js b/packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js new file mode 100644 index 0000000000000..3cc50b7e18eda --- /dev/null +++ b/packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js @@ -0,0 +1,2 @@ +const { glibcVersionRuntime } = process.report.getReport().header; +process.exit(glibcVersionRuntime ? 1 : 0); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json b/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json index ac0d638a6e482..e27020587cea4 100644 --- a/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json +++ b/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json @@ -9,8 +9,12 @@ ], "main": "next-swc.linux-arm64-musl.node", "files": [ - "next-swc.linux-arm64-musl.node" + "next-swc.linux-arm64-musl.node", + "install.js" ], + "scripts": { + "install": "node install.js" + }, "license": "MIT", "engines": { "node": ">= 10" diff --git a/packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js b/packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js new file mode 100644 index 0000000000000..296ba2215f890 --- /dev/null +++ b/packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js @@ -0,0 +1,2 @@ +const { glibcVersionRuntime } = process.report.getReport().header; +process.exit(glibcVersionRuntime ? 0 : 1); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json b/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json index 07f4f9f039d19..70fb20fa9bd6e 100644 --- a/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json +++ b/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json @@ -9,8 +9,12 @@ ], "main": "next-swc.linux-x64-gnu.node", "files": [ - "next-swc.linux-x64-gnu.node" + "next-swc.linux-x64-gnu.node", + "install.js" ], + "scripts": { + "install": "node install.js" + }, "license": "MIT", "engines": { "node": ">= 10" diff --git a/packages/next-swc/crates/napi/npm/linux-x64-musl/install.js b/packages/next-swc/crates/napi/npm/linux-x64-musl/install.js new file mode 100644 index 0000000000000..3cc50b7e18eda --- /dev/null +++ b/packages/next-swc/crates/napi/npm/linux-x64-musl/install.js @@ -0,0 +1,2 @@ +const { glibcVersionRuntime } = process.report.getReport().header; +process.exit(glibcVersionRuntime ? 1 : 0); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json b/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json index 031a573ed3f9f..e4cfdba4ee1a7 100644 --- a/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json +++ b/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json @@ -9,8 +9,12 @@ ], "main": "next-swc.linux-x64-musl.node", "files": [ - "next-swc.linux-x64-musl.node" + "next-swc.linux-x64-musl.node", + "install.js" ], + "scripts": { + "install": "node install.js" + }, "license": "MIT", "engines": { "node": ">= 10" From 5378db8f807dbb9ff0993662f0a39d0f6cba2452 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 3 Jan 2022 15:46:09 -0600 Subject: [PATCH 04/20] v12.0.8-canary.15 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 18 +++++++++--------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- 15 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lerna.json b/lerna.json index 27d719a3c291d..08b20db531847 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.0.8-canary.14" + "version": "12.0.8-canary.15" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 8a372a22b8c59..261fe8b66b39b 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index c5c9156459dcc..7dc75ba2eadc4 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.0.8-canary.14", + "@next/eslint-plugin-next": "12.0.8-canary.15", "@rushstack/eslint-patch": "^1.0.8", "@typescript-eslint/parser": "^5.0.0", "eslint-import-resolver-node": "^0.3.4", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 90f4d1398f0b6..6528dee673870 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index 6bc81b90abe5e..de96439b3a53e 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 0432bebf22ddf..b2f179dd28940 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 47a277a0aaaa1..552ea16218a5a 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 9e3157f7bd6da..28b7108bdc896 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 6403a1dac08b5..08247c85a2850 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 867e70fecbae4..4749e9d426db1 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "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", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 0e73a87939b48..d07e5f151815a 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 57df6bef350e8..69e2ab8f8f254 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "private": true, "scripts": { "build-native": "napi build --platform --cargo-name next_swc_napi native", diff --git a/packages/next/package.json b/packages/next/package.json index 45fd4ac6bc5f9..56448eddc5124 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -71,8 +71,8 @@ ] }, "dependencies": { - "@next/env": "12.0.8-canary.14", - "@next/react-refresh-utils": "12.0.8-canary.14", + "@next/env": "12.0.8-canary.15", + "@next/react-refresh-utils": "12.0.8-canary.15", "caniuse-lite": "^1.0.30001283", "jest-worker": "27.0.0-next.5", "node-fetch": "2.6.1", @@ -125,10 +125,10 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "1.2.1", "@napi-rs/triples": "1.0.3", - "@next/polyfill-module": "12.0.8-canary.14", - "@next/polyfill-nomodule": "12.0.8-canary.14", - "@next/react-dev-overlay": "12.0.8-canary.14", - "@next/swc": "12.0.8-canary.14", + "@next/polyfill-module": "12.0.8-canary.15", + "@next/polyfill-nomodule": "12.0.8-canary.15", + "@next/react-dev-overlay": "12.0.8-canary.15", + "@next/swc": "12.0.8-canary.15", "@peculiar/webcrypto": "1.1.7", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", @@ -236,8 +236,8 @@ "postcss-safe-parser": "6.0.0", "postcss-scss": "3.0.5", "postcss-value-parser": "4.1.0", - "punycode": "2.1.1", "process": "0.11.10", + "punycode": "2.1.1", "querystring-es3": "0.2.1", "raw-body": "2.4.1", "react-server-dom-webpack": "0.0.0-experimental-13455d26d-20211104", @@ -245,9 +245,9 @@ "sass-loader": "10.2.0", "schema-utils2": "npm:schema-utils@2.7.1", "schema-utils3": "npm:schema-utils@3.0.0", - "setimmediate": "1.0.5", "semver": "7.3.2", "send": "0.17.1", + "setimmediate": "1.0.5", "source-map": "0.6.1", "stream-http": "3.1.1", "string-hash": "1.1.3", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 883681d2d01c0..e13532f0caa95 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index a639b283b6154..5e3f8d8b0d362 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.0.8-canary.14", + "version": "12.0.8-canary.15", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", From e01ef297e757f0435f82348496e68eb6919826a8 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 3 Jan 2022 18:47:18 -0600 Subject: [PATCH 05/20] Ensure middleware is output in standalone mode (#32967) --- packages/next/build/index.ts | 20 ++++---- packages/next/build/utils.ts | 49 ++++++++++++++----- test/production/required-server-files.test.ts | 16 ++++++ .../pages/middleware/_middleware.js | 3 ++ 4 files changed, 67 insertions(+), 21 deletions(-) create mode 100644 test/production/required-server-files/pages/middleware/_middleware.js diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index be3f4e04e8d33..08adb67428e13 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -1400,6 +1400,13 @@ export default async function build( 'utf8' ) + const middlewareManifest: MiddlewareManifest = JSON.parse( + await promises.readFile( + path.join(distDir, SERVER_DIRECTORY, MIDDLEWARE_MANIFEST), + 'utf8' + ) + ) + const outputFileTracingRoot = config.experimental.outputFileTracingRoot || dir @@ -1412,7 +1419,8 @@ export default async function build( distDir, pageKeys, outputFileTracingRoot, - requiredServerFiles.config + requiredServerFiles.config, + middlewareManifest ) }) } @@ -1961,13 +1969,6 @@ export default async function build( ) } - const middlewareManifest: MiddlewareManifest = JSON.parse( - await promises.readFile( - path.join(distDir, SERVER_DIRECTORY, MIDDLEWARE_MANIFEST), - 'utf8' - ) - ) - await promises.writeFile( path.join( distDir, @@ -2032,7 +2033,8 @@ export default async function build( path.relative(outputFileTracingRoot, distDir), SERVER_DIRECTORY, 'pages' - ) + ), + { overwrite: true } ) } diff --git a/packages/next/build/utils.ts b/packages/next/build/utils.ts index 6140d8c4388ef..b0332a1f5a898 100644 --- a/packages/next/build/utils.ts +++ b/packages/next/build/utils.ts @@ -16,6 +16,7 @@ import { SSG_GET_INITIAL_PROPS_CONFLICT, SERVER_PROPS_GET_INIT_PROPS_CONFLICT, SERVER_PROPS_SSG_CONFLICT, + MIDDLEWARE_ROUTE, } from '../lib/constants' import prettyBytes from '../lib/pretty-bytes' import { recursiveReadDir } from '../lib/recursive-readdir' @@ -40,6 +41,7 @@ import { NextConfigComplete } from '../server/config-shared' import isError from '../lib/is-error' import { recursiveDelete } from '../lib/recursive-delete' import { Sema } from 'next/dist/compiled/async-sema' +import { MiddlewareManifest } from './webpack/plugins/middleware-plugin' const { builtinModules } = require('module') const RESERVED_PAGE = /^\/(_app|_error|_document|api(\/|$))/ @@ -1156,7 +1158,8 @@ export async function copyTracedFiles( distDir: string, pageKeys: string[], tracingRoot: string, - serverConfig: { [key: string]: any } + serverConfig: { [key: string]: any }, + middlewareManifest: MiddlewareManifest ) { const outputPath = path.join(distDir, 'standalone') const copiedFiles = new Set() @@ -1202,6 +1205,23 @@ export async function copyTracedFiles( } for (const page of pageKeys) { + if (MIDDLEWARE_ROUTE.test(page)) { + const { files } = + middlewareManifest.middleware[page.replace(/\/_middleware$/, '')] + + for (const file of files) { + const originalPath = path.join(distDir, file) + const fileOutputPath = path.join( + outputPath, + path.relative(tracingRoot, distDir), + file + ) + await fs.mkdir(path.dirname(fileOutputPath), { recursive: true }) + await fs.copyFile(originalPath, fileOutputPath) + } + continue + } + const pageFile = path.join( distDir, 'server', @@ -1226,16 +1246,7 @@ const NextServer = require('next/dist/server/next-server').default const http = require('http') const path = require('path') -const nextServer = new NextServer({ - dir: path.join(__dirname), - dev: false, - conf: ${JSON.stringify({ - ...serverConfig, - distDir: `./${path.relative(dir, distDir)}`, - })}, -}) - -const handler = nextServer.getRequestHandler() +let handler const server = http.createServer(async (req, res) => { try { @@ -1246,12 +1257,26 @@ const server = http.createServer(async (req, res) => { res.end('internal server error') } }) -const currentPort = process.env.PORT || 3000 +const currentPort = parseInt(process.env.PORT, 10) || 3000 + server.listen(currentPort, (err) => { if (err) { console.error("Failed to start server", err) process.exit(1) } + const addr = server.address() + const nextServer = new NextServer({ + hostname: 'localhost', + port: currentPort, + dir: path.join(__dirname), + dev: false, + conf: ${JSON.stringify({ + ...serverConfig, + distDir: `./${path.relative(dir, distDir)}`, + })}, + }) + handler = nextServer.getRequestHandler() + console.log("Listening on port", currentPort) }) ` diff --git a/test/production/required-server-files.test.ts b/test/production/required-server-files.test.ts index 22459d8c1c343..61794732f0410 100644 --- a/test/production/required-server-files.test.ts +++ b/test/production/required-server-files.test.ts @@ -107,6 +107,22 @@ describe('should set-up next', () => { if (server) await killApp(server) }) + it('should output middleware correctly', async () => { + // the middleware-runtime is located in .next/static/chunks so ensure + // the folder is present + expect( + await fs.pathExists(join(next.testDir, 'standalone/.next/static/chunks')) + ).toBe(true) + expect( + await fs.pathExists( + join( + next.testDir, + 'standalone/.next/server/pages/middleware/_middleware.js' + ) + ) + ).toBe(true) + }) + it('should output required-server-files manifest correctly', async () => { expect(requiredFilesManifest.version).toBe(1) expect(Array.isArray(requiredFilesManifest.files)).toBe(true) diff --git a/test/production/required-server-files/pages/middleware/_middleware.js b/test/production/required-server-files/pages/middleware/_middleware.js new file mode 100644 index 0000000000000..c07ee4d1f4f82 --- /dev/null +++ b/test/production/required-server-files/pages/middleware/_middleware.js @@ -0,0 +1,3 @@ +export async function middleware(req) { + return new Response('hello from middleware') +} From 6f10d94d9070f37c76774450c6276457db046a1e Mon Sep 17 00:00:00 2001 From: Steven Date: Mon, 3 Jan 2022 19:47:48 -0500 Subject: [PATCH 06/20] Revert "Reduce install size for linux glibc/musl (#32850)" (#32973) This reverts commit a5fab84840d0bb384b7cf24d4825a350f0037811. Co-authored-by: JJ Kasper --- .../next-swc/crates/napi/npm/linux-arm64-gnu/install.js | 2 -- .../next-swc/crates/napi/npm/linux-arm64-gnu/package.json | 6 +----- .../next-swc/crates/napi/npm/linux-arm64-musl/install.js | 2 -- .../next-swc/crates/napi/npm/linux-arm64-musl/package.json | 6 +----- packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js | 2 -- .../next-swc/crates/napi/npm/linux-x64-gnu/package.json | 6 +----- packages/next-swc/crates/napi/npm/linux-x64-musl/install.js | 2 -- .../next-swc/crates/napi/npm/linux-x64-musl/package.json | 6 +----- 8 files changed, 4 insertions(+), 28 deletions(-) delete mode 100644 packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js delete mode 100644 packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js delete mode 100644 packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js delete mode 100644 packages/next-swc/crates/napi/npm/linux-x64-musl/install.js diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js deleted file mode 100644 index 296ba2215f890..0000000000000 --- a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/install.js +++ /dev/null @@ -1,2 +0,0 @@ -const { glibcVersionRuntime } = process.report.getReport().header; -process.exit(glibcVersionRuntime ? 0 : 1); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json index ef8c28f7a8c65..eb097c5a75d50 100644 --- a/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json +++ b/packages/next-swc/crates/napi/npm/linux-arm64-gnu/package.json @@ -9,12 +9,8 @@ ], "main": "next-swc.linux-arm64-gnu.node", "files": [ - "next-swc.linux-arm64-gnu.node", - "install.js" + "next-swc.linux-arm64-gnu.node" ], - "scripts": { - "install": "node install.js" - }, "license": "MIT", "engines": { "node": ">= 10" diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js b/packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js deleted file mode 100644 index 3cc50b7e18eda..0000000000000 --- a/packages/next-swc/crates/napi/npm/linux-arm64-musl/install.js +++ /dev/null @@ -1,2 +0,0 @@ -const { glibcVersionRuntime } = process.report.getReport().header; -process.exit(glibcVersionRuntime ? 1 : 0); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json b/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json index e27020587cea4..ac0d638a6e482 100644 --- a/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json +++ b/packages/next-swc/crates/napi/npm/linux-arm64-musl/package.json @@ -9,12 +9,8 @@ ], "main": "next-swc.linux-arm64-musl.node", "files": [ - "next-swc.linux-arm64-musl.node", - "install.js" + "next-swc.linux-arm64-musl.node" ], - "scripts": { - "install": "node install.js" - }, "license": "MIT", "engines": { "node": ">= 10" diff --git a/packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js b/packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js deleted file mode 100644 index 296ba2215f890..0000000000000 --- a/packages/next-swc/crates/napi/npm/linux-x64-gnu/install.js +++ /dev/null @@ -1,2 +0,0 @@ -const { glibcVersionRuntime } = process.report.getReport().header; -process.exit(glibcVersionRuntime ? 0 : 1); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json b/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json index 70fb20fa9bd6e..07f4f9f039d19 100644 --- a/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json +++ b/packages/next-swc/crates/napi/npm/linux-x64-gnu/package.json @@ -9,12 +9,8 @@ ], "main": "next-swc.linux-x64-gnu.node", "files": [ - "next-swc.linux-x64-gnu.node", - "install.js" + "next-swc.linux-x64-gnu.node" ], - "scripts": { - "install": "node install.js" - }, "license": "MIT", "engines": { "node": ">= 10" diff --git a/packages/next-swc/crates/napi/npm/linux-x64-musl/install.js b/packages/next-swc/crates/napi/npm/linux-x64-musl/install.js deleted file mode 100644 index 3cc50b7e18eda..0000000000000 --- a/packages/next-swc/crates/napi/npm/linux-x64-musl/install.js +++ /dev/null @@ -1,2 +0,0 @@ -const { glibcVersionRuntime } = process.report.getReport().header; -process.exit(glibcVersionRuntime ? 1 : 0); \ No newline at end of file diff --git a/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json b/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json index e4cfdba4ee1a7..031a573ed3f9f 100644 --- a/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json +++ b/packages/next-swc/crates/napi/npm/linux-x64-musl/package.json @@ -9,12 +9,8 @@ ], "main": "next-swc.linux-x64-musl.node", "files": [ - "next-swc.linux-x64-musl.node", - "install.js" + "next-swc.linux-x64-musl.node" ], - "scripts": { - "install": "node install.js" - }, "license": "MIT", "engines": { "node": ">= 10" From 69a56759ee881fde3f969a413e5e57d5466411ec Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Mon, 3 Jan 2022 18:58:27 -0600 Subject: [PATCH 07/20] v12.0.8-canary.16 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lerna.json b/lerna.json index 08b20db531847..4d6fa15273405 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.0.8-canary.15" + "version": "12.0.8-canary.16" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 261fe8b66b39b..8d51955543c62 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 7dc75ba2eadc4..f25dda3a909a2 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.0.8-canary.15", + "@next/eslint-plugin-next": "12.0.8-canary.16", "@rushstack/eslint-patch": "^1.0.8", "@typescript-eslint/parser": "^5.0.0", "eslint-import-resolver-node": "^0.3.4", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 6528dee673870..269dc9b3542cf 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index de96439b3a53e..cceaf658b8a8e 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index b2f179dd28940..7db20b5b3c686 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 552ea16218a5a..f222a8c841ee7 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 28b7108bdc896..e50d121782dc0 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 08247c85a2850..e5e8de82c36c4 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index 4749e9d426db1..ce08a6fb36eea 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "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", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index d07e5f151815a..989b1a4e57378 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 69e2ab8f8f254..0aae40c0cc7b1 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "private": true, "scripts": { "build-native": "napi build --platform --cargo-name next_swc_napi native", diff --git a/packages/next/package.json b/packages/next/package.json index 56448eddc5124..9e2607fdf0eab 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -71,8 +71,8 @@ ] }, "dependencies": { - "@next/env": "12.0.8-canary.15", - "@next/react-refresh-utils": "12.0.8-canary.15", + "@next/env": "12.0.8-canary.16", + "@next/react-refresh-utils": "12.0.8-canary.16", "caniuse-lite": "^1.0.30001283", "jest-worker": "27.0.0-next.5", "node-fetch": "2.6.1", @@ -125,10 +125,10 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "1.2.1", "@napi-rs/triples": "1.0.3", - "@next/polyfill-module": "12.0.8-canary.15", - "@next/polyfill-nomodule": "12.0.8-canary.15", - "@next/react-dev-overlay": "12.0.8-canary.15", - "@next/swc": "12.0.8-canary.15", + "@next/polyfill-module": "12.0.8-canary.16", + "@next/polyfill-nomodule": "12.0.8-canary.16", + "@next/react-dev-overlay": "12.0.8-canary.16", + "@next/swc": "12.0.8-canary.16", "@peculiar/webcrypto": "1.1.7", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index e13532f0caa95..92286bb240e55 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 5e3f8d8b0d362..eed0cab0437da 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.0.8-canary.15", + "version": "12.0.8-canary.16", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", From 7c8500f16ded01fb1bbf9b0b2595ecca29683e5e Mon Sep 17 00:00:00 2001 From: Mike K Date: Tue, 4 Jan 2022 03:57:59 +0200 Subject: [PATCH 08/20] Updated wrong link to example of gtag init in measuring-performance.md (#32974) Updated wrong link to example of gtag init ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ x ] Make sure the linting passes by running `yarn lint` --- docs/advanced-features/measuring-performance.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/advanced-features/measuring-performance.md b/docs/advanced-features/measuring-performance.md index 789d94bb8759c..0a861b416473d 100644 --- a/docs/advanced-features/measuring-performance.md +++ b/docs/advanced-features/measuring-performance.md @@ -164,7 +164,7 @@ export function reportWebVitals(metric) { > ```js > export function reportWebVitals({ id, name, label, value }) { > // Use `window.gtag` if you initialized Google Analytics as this example: -> // https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics/pages/_document.js +> // https://github.com/vercel/next.js/blob/canary/examples/with-google-analytics/pages/_app.js > window.gtag('event', name, { > event_category: > label === 'web-vital' ? 'Web Vitals' : 'Next.js custom metric', From 1be87040b071320e7a617be80ebbdc46817a5564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 4 Jan 2022 14:49:16 +0100 Subject: [PATCH 09/20] fix(examples): add missing dependencies wo (#32977) The `with-jest` example has been converted to TypeScript (#32705) , but `typescript` and `@types/react` were missing from `devDependencies` ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` --- examples/with-jest/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/with-jest/package.json b/examples/with-jest/package.json index a2a95622fd778..23e5d9ed94c85 100644 --- a/examples/with-jest/package.json +++ b/examples/with-jest/package.json @@ -17,10 +17,12 @@ "@testing-library/jest-dom": "5.16.1", "@testing-library/react": "12.1.2", "@testing-library/user-event": "13.5.0", + "@types/react": "17.0.38", "babel-jest": "27.4.5", "eslint": "8.5.0", "eslint-config-next": "latest", "eslint-plugin-testing-library": "5.0.1", - "jest": "27.4.5" + "jest": "27.4.5", + "typescript": "4.5.4" } } From 3ad2035ae6ab16361b5fd65706de444e73822bbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Tue, 4 Jan 2022 16:35:32 +0100 Subject: [PATCH 10/20] feat(cli): introduce `next info` CLI command (#32972) This PR adds a new command to the `next` CLI. Running `next info` will print useful information to the terminal about how/where Next.js is run. This information can be added to the Bug report when opening an issue in the repository. This makes reporting issues more accurate and doesn't require the user to guess certain details, the command will retrieve it on their behalf. Example output: ```sh $ npx --no-install next info Operating System: Platform: linux Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 Binaries: Node: 16.13.0 npm: 8.1.0 Yarn: 1.22.17 pnpm: 6.24.2 Relevant packages: next: 12.0.8-canary.14 react: 17.0.2 react-dom: 17.0.2 ``` The idea is based on #32858 ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` Co-authored-by: Steven <229881+styfle@users.noreply.github.com> --- .github/ISSUE_TEMPLATE/1.bug_report.yml | 6 ++ docs/api-reference/cli.md | 35 +++++++++++- package.json | 1 + packages/next/bin/next.ts | 1 + packages/next/cli/next-info.ts | 76 +++++++++++++++++++++++++ packages/next/shared/lib/utils.ts | 2 +- test/integration/cli/test/index.test.js | 43 ++++++++++++++ yarn.lock | 7 ++- 8 files changed, 166 insertions(+), 5 deletions(-) create mode 100755 packages/next/cli/next-info.ts diff --git a/.github/ISSUE_TEMPLATE/1.bug_report.yml b/.github/ISSUE_TEMPLATE/1.bug_report.yml index 440f9434bf332..d0aa0b7589ace 100644 --- a/.github/ISSUE_TEMPLATE/1.bug_report.yml +++ b/.github/ISSUE_TEMPLATE/1.bug_report.yml @@ -14,6 +14,12 @@ body: - type: markdown attributes: value: 'next@canary is the beta version of Next.js. It includes all features and fixes that are pending to land on the stable release line.' + - type: textarea + attributes: + label: Run `next info` (available from version 12.0.8 and up) + description: Please run `next info` in the root directory of your project and paste the results. You might need to use `npx --no-install next info` if next is not in the current PATH. + validations: + required: false - type: input attributes: label: What version of Next.js are you using? diff --git a/docs/api-reference/cli.md b/docs/api-reference/cli.md index b79edb5f0bbce..20b36920d7bf3 100644 --- a/docs/api-reference/cli.md +++ b/docs/api-reference/cli.md @@ -21,7 +21,7 @@ Usage $ next Available commands - build, start, export, dev, lint, telemetry + build, start, export, dev, lint, telemetry, info Options --version, -v Version number @@ -125,3 +125,36 @@ Next.js collects **completely anonymous** telemetry data about general usage. Participation in this anonymous program is optional, and you may opt-out if you'd not like to share any information. To learn more about Telemetry, [please read this document](https://nextjs.org/telemetry/). + +## Info + +`next info` prints relevant details about the current system which can be used to report Next.js bugs. +This information includes Operating System platform/arch/version, Binaries (Node.js, npm, Yarn, pnpm) and npm package versions (`next`, `react`, `react-dom`). + +Running the following in your project's root directory: + +```bash +next info +``` + +will give you information like this example: + +```bash + + Operating System: + Platform: linux + Arch: x64 + Version: #22-Ubuntu SMP Fri Nov 5 13:21:36 UTC 2021 + Binaries: + Node: 16.13.0 + npm: 8.1.0 + Yarn: 1.22.17 + pnpm: 6.24.2 + Relevant packages: + next: 12.0.8 + react: 17.0.2 + react-dom: 17.0.2 + +``` + +This information should then be pasted into GitHub Issues. diff --git a/package.json b/package.json index 84553d2b39362..0b9feec82bc10 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "@types/fs-extra": "8.1.0", "@types/http-proxy": "1.17.3", "@types/jest": "24.0.13", + "@types/node": "13.11.0", "@types/selenium-webdriver": "4.0.15", "@types/sharp": "0.29.3", "@types/string-hash": "1.1.1", diff --git a/packages/next/bin/next.ts b/packages/next/bin/next.ts index e8df92a3c8ae8..283e0996b7477 100755 --- a/packages/next/bin/next.ts +++ b/packages/next/bin/next.ts @@ -23,6 +23,7 @@ const commands: { [command: string]: () => Promise } = { lint: () => Promise.resolve(require('../cli/next-lint').nextLint), telemetry: () => Promise.resolve(require('../cli/next-telemetry').nextTelemetry), + info: () => Promise.resolve(require('../cli/next-info').nextInfo), } const args = arg( diff --git a/packages/next/cli/next-info.ts b/packages/next/cli/next-info.ts new file mode 100755 index 0000000000000..b0e957bc8dcc7 --- /dev/null +++ b/packages/next/cli/next-info.ts @@ -0,0 +1,76 @@ +#!/usr/bin/env node +import os from 'os' +import childProcess from 'child_process' + +import chalk from 'next/dist/compiled/chalk' +import arg from 'next/dist/compiled/arg/index.js' +import { printAndExit } from '../server/lib/utils' +import { cliCommand } from '../bin/next' +import isError from '../lib/is-error' + +const nextInfo: cliCommand = async (argv) => { + const validArgs: arg.Spec = { + // Types + '--help': Boolean, + // Aliases + '-h': '--help', + } + let args: arg.Result + try { + args = arg(validArgs, { argv }) + } catch (error) { + if (isError(error) && error.code === 'ARG_UNKNOWN_OPTION') { + return printAndExit(error.message, 1) + } + throw error + } + + if (args['--help']) { + console.log( + ` + Description + Prints relevant details about the current system which can be used to report Next.js bugs + + Usage + $ next info + + Learn more: ${chalk.cyan( + 'https://nextjs.org/docs/api-reference/cli#info' + )}` + ) + return + } + + console.log(` + Operating System: + Platform: ${os.platform()} + Arch: ${os.arch()} + Version: ${os.version()} + Binaries: + Node: ${process.versions.node} + npm: ${getBinaryVersion('npm')} + Yarn: ${getBinaryVersion('yarn')} + pnpm: ${getBinaryVersion('pnpm')} + Relevant packages: + next: ${getPackageVersion('next')} + react: ${getPackageVersion('react')} + react-dom: ${getPackageVersion('react-dom')}`) +} + +export { nextInfo } + +function getPackageVersion(packageName: string) { + try { + return require(`${packageName}/package.json`).version + } catch { + return 'N/A' + } +} + +function getBinaryVersion(binaryName: string) { + try { + return childProcess.execSync(`${binaryName} --version`).toString().trim() + } catch { + return 'N/A' + } +} diff --git a/packages/next/shared/lib/utils.ts b/packages/next/shared/lib/utils.ts index 34b948691263e..bbee6dc34aa6c 100644 --- a/packages/next/shared/lib/utils.ts +++ b/packages/next/shared/lib/utils.ts @@ -456,6 +456,6 @@ export interface CacheFs { readFile(f: string): Promise readFileSync(f: string): string writeFile(f: string, d: any): Promise - mkdir(dir: string): Promise + mkdir(dir: string): Promise stat(f: string): Promise<{ mtime: Date }> } diff --git a/test/integration/cli/test/index.test.js b/test/integration/cli/test/index.test.js index 3ed7724fe325c..e4ff3f49099c4 100644 --- a/test/integration/cli/test/index.test.js +++ b/test/integration/cli/test/index.test.js @@ -400,4 +400,47 @@ describe('CLI Usage', () => { expect(stderr).not.toContain('UnhandledPromiseRejectionWarning') }) }) + + describe('info', () => { + test('--help', async () => { + const help = await runNextCommand(['info', '--help'], { + stdout: true, + }) + expect(help.stdout).toMatch( + /Prints relevant details about the current system which can be used to report Next\.js bugs/ + ) + }) + + test('-h', async () => { + const help = await runNextCommand(['info', '-h'], { + stdout: true, + }) + expect(help.stdout).toMatch( + /Prints relevant details about the current system which can be used to report Next\.js bugs/ + ) + }) + + test('should print output', async () => { + const info = await runNextCommand(['info'], { + stdout: true, + }) + expect(info.stdout).toMatch( + new RegExp(` + Operating System: + Platform: .* + Arch: .* + Version: .* + Binaries: + Node: .* + npm: .* + Yarn: .* + pnpm: .* + Relevant packages: + next: .* + react: .* + react-dom: .* +`) + ) + }) + }) }) diff --git a/yarn.lock b/yarn.lock index 73d0f74becf85..2f69c2dd8bc93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4694,9 +4694,10 @@ dependencies: "@types/node" "*" -"@types/node@*", "@types/node@>= 8": - version "13.1.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-13.1.4.tgz#4cfd90175a200ee9b02bd6b1cd19bc349741607e" +"@types/node@*", "@types/node@13.11.0", "@types/node@>= 8": + version "13.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-13.11.0.tgz#390ea202539c61c8fa6ba4428b57e05bc36dc47b" + integrity sha512-uM4mnmsIIPK/yeO+42F2RQhGUIs39K2RFmugcJANppXe6J1nvH87PvzPZYpza7Xhhs8Yn9yIAVdLZ84z61+0xQ== "@types/node@10.12.18": version "10.12.18" From 5e5f1df4454f4b3004ebdb02b9ca1f319558f15b Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 4 Jan 2022 15:10:16 -0600 Subject: [PATCH 11/20] Re-enable turbo caching for swc build jobs (#32617) * Fix build-native jobs * Update to latest turbo * fix extra space * fix windows shell * Update to latest turbo * Bump Turbo (#32703) * Bump turbo to canary * Bump turbo * Update yaml too * add less specific restore key * update more restore keys * Fix non-unique key and cache wasm build * ensure turbo is installed for new jobs * remove old wasm cache * update directory check * bump * re-add if publish checks Co-authored-by: Jared Palmer --- .github/workflows/build_test_deploy.yml | 277 ++++++++++++------------ package.json | 2 +- yarn.lock | 81 ++++++- 3 files changed, 219 insertions(+), 141 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 3e0072d48d0f5..d3a4ecb10f452 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -552,7 +552,7 @@ jobs: - build-windows-aarch64 - build-linux-musl - build-linux-arm7 - - build-linux-aarch64 + - build-linux-aarch64-gnu - build-android-aarch64 - build-linux-aarch64-musl env: @@ -664,16 +664,17 @@ jobs: - id: get-week run: echo ::set-output name=WEEK::$(date +%U) - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- - # turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- + turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- # We use restore-key to pick latest cache. # We will not get exact match, but doc says @@ -683,19 +684,18 @@ jobs: uses: actions/cache@v2 with: path: ./packages/next-swc/target - key: next-swc-cargo-cache-ubuntu-18.04--${{ hashFiles('**/Cargo.lock') }} + key: next-swc-cargo-cache-dev-ubuntu-18.04-${{ hashFiles('**/Cargo.lock') }} restore-keys: | - next-swc-cargo-cache-ubuntu-18.04 + next-swc-cargo-cache-dev-ubuntu-18.04 # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Build if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} - working-directory: packages/next-swc - run: yarn build-native + run: turbo run build-native --cache-dir=".turbo" env: MACOSX_DEPLOYMENT_TARGET: '10.13' TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} @@ -829,6 +829,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 + - run: npm i -g turbo@1.0.24 - name: Install uses: actions-rs/toolchain@v1 @@ -849,15 +850,16 @@ jobs: path: ~/.cargo/git key: stable-${{ matrix.os }}-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} - # - name: Turbo cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-${{ matrix.name }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ matrix.name }}- + turbo-${{ github.job }}-${{ matrix.name }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-${{ matrix.name }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 setup if: ${{ matrix.target == 'aarch64-apple-darwin' }} @@ -880,8 +882,8 @@ jobs: next-swc-cargo-cache-${{ matrix.os }} - name: 'Build' - working-directory: packages/next-swc - run: yarn build-native --release --target ${{ matrix.target }} + shell: bash + run: turbo run build-native --cache-dir=".turbo" -- --release --target ${{ matrix.target }} env: MACOSX_DEPLOYMENT_TARGET: '10.13' TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} @@ -928,7 +930,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -937,20 +939,20 @@ jobs: override: true target: i686-pc-windows-msvc - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build shell: bash - working-directory: packages/next-swc - run: yarn build-native --release --target i686-pc-windows-msvc + run: turbo run build-native --cache-dir=".turbo" -- --release --target i686-pc-windows-msvc - name: Upload artifact uses: actions/upload-artifact@v2 @@ -976,7 +978,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -985,20 +987,20 @@ jobs: override: true target: aarch64-pc-windows-msvc - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build shell: bash - working-directory: packages/next-swc - run: yarn build-native --release --target aarch64-pc-windows-msvc + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-pc-windows-msvc - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1036,19 +1038,20 @@ jobs: docker pull ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine docker tag ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine builder - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: 'Build' run: | - docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd)/packages/next-swc:/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.14 && yarn build-native --release --target x86_64-unknown-linux-musl" + docker run --rm -v ~/.cargo/git:/root/.cargo/git -v ~/.cargo/registry:/root/.cargo/registry -v $(pwd):/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.24 && turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl" - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1056,7 +1059,7 @@ jobs: name: next-swc-binaries path: packages/next-swc/native/next-swc.linux-x64-musl.node - build-linux-aarch64: + build-linux-aarch64-gnu: needs: build if: ${{ needs.build.outputs.isRelease == 'true' }} name: next-swc - aarch64-unknown-linux-gnu - node@14 @@ -1076,7 +1079,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1098,20 +1101,20 @@ jobs: sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - working-directory: packages/next-swc if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: yarn build-native --release --target aarch64-unknown-linux-gnu + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1137,7 +1140,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 with: @@ -1158,19 +1161,19 @@ jobs: sudo apt-get update sudo apt-get install gcc-aarch64-linux-gnu -y - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - working-directory: packages/next-swc - run: yarn build-native --release --target aarch64-unknown-linux-musl + run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1198,7 +1201,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1220,19 +1223,19 @@ jobs: sudo apt-get update sudo apt-get install gcc-arm-linux-gnueabihf -y - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Cross build aarch64 - working-directory: packages/next-swc - run: yarn build-native --release --target armv7-unknown-linux-gnueabihf + run: turbo run build-native --cache-dir=".turbo" -- --release --target armv7-unknown-linux-gnueabihf - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1258,7 +1261,7 @@ jobs: # since the repo's dependencies aren't installed we need # to install napi globally - run: npm i -g @napi-rs/cli@1.2.1 - - run: npm i -g turbo@1.0.14 + - run: npm i -g turbo@1.0.24 - name: Install Rust uses: actions-rs/toolchain@v1 @@ -1268,22 +1271,22 @@ jobs: override: true target: aarch64-linux-android - # - name: Turbo Cache - # id: turbo-cache - # uses: actions/cache@v2 - # with: - # path: .turbo - # key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} - # restore-keys: | - # turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - # turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- + - name: Turbo Cache + id: turbo-cache + uses: actions/cache@v2 + with: + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - name: Build shell: bash - working-directory: packages/next-swc run: | export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang" - yarn build-native --release --target aarch64-linux-android + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-linux-android - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1318,22 +1321,27 @@ jobs: override: true target: wasm32-unknown-unknown - - name: Cache + - run: npm i -g turbo@1.0.24 + + - name: Turbo cache + id: turbo-cache uses: actions/cache@v2 with: - path: | - ~/.cargo/ - **/target/ - key: ${{ runner.os }}-publish-integration + path: .turbo + key: turbo-${{ github.job }}-${{ matrix.target }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}-${{ matrix.target }}- + turbo-${{ github.job }}-${{ matrix.target }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- + turbo-${{ github.job }}-${{ matrix.target }}-canary-${{ needs.build.outputs.weekNum }}- - name: Install wasm-pack run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build - run: (wasm-pack build packages/next-swc/crates/wasm --release --scope=next --target ${{ matrix.target }}) + run: turbo run build-wasm --cache-dir=".turbo" -- --target ${{ matrix.target }} - name: Add target to folder name - run: mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} + run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-${{ matrix.target }} || ls packages/next-swc/crates/wasm' - name: Upload artifact uses: actions/upload-artifact@v2 @@ -1358,6 +1366,8 @@ jobs: with: node-version: 14 + - run: npm i -g turbo@1.0.24 + - name: Install Rust if: ${{needs.build.outputs.docsChange != 'docs only change'}} uses: actions-rs/toolchain@v1 @@ -1367,34 +1377,29 @@ jobs: override: true target: wasm32-unknown-unknown - - name: Cache - if: ${{needs.build.outputs.docsChange != 'docs only change'}} - uses: actions/cache@v2 - with: - path: | - ~/.cargo/ - **/target/ - key: ${{ runner.os }}-publish-integration - - - name: Cache wasm binary - if: ${{needs.build.outputs.docsChange != 'docs only change'}} - id: binary-cache + - name: Turbo Cache + id: turbo-cache uses: actions/cache@v2 + if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: - path: packages/next-swc/crates/wasm/pkg-nodejs - key: dev-wasm-next-swc-nightly-2021-11-15-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + path: .turbo + key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}-${{ github.sha }} + restore-keys: | + turbo-${{ github.job }}- + turbo-${{ github.job }}-${{ github.ref_name }}-${{ steps.get-week.outputs.WEEK }}- + turbo-${{ github.job }}-canary-${{ steps.get-week.outputs.WEEK }}- - name: Install wasm-pack - if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} + if: ${{needs.build.outputs.docsChange != 'docs only change'}} run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh - name: Build - if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} - run: (wasm-pack build packages/next-swc/crates/wasm --dev --scope=next --target nodejs) + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + run: turbo run build-wasm --cache-dir=".turbo" -- --target nodejs --dev - name: Add target to folder name - if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} - run: mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + run: '[[ -d "packages/next-swc/crates/wasm/pkg" ]] && mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs || ls packages/next-swc/crates/wasm' - name: Upload artifact if: ${{needs.build.outputs.docsChange != 'docs only change'}} diff --git a/package.json b/package.json index 0b9feec82bc10..1d2b13d141d41 100644 --- a/package.json +++ b/package.json @@ -154,7 +154,7 @@ "tailwindcss": "1.1.3", "taskr": "1.1.0", "tree-kill": "1.2.2", - "turbo": "1.0.14", + "turbo": "1.0.24", "typescript": "4.4.3", "wait-port": "0.2.2", "web-streams-polyfill": "2.1.1", diff --git a/yarn.lock b/yarn.lock index 2f69c2dd8bc93..e81e097372622 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19017,10 +19017,83 @@ tunnel-agent@^0.6.0: dependencies: safe-buffer "^5.0.1" -turbo@1.0.14: - version "1.0.14" - resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.14.tgz#42ace0d1c699f0c1cb19b589b6d629dfa72b62b4" - integrity sha512-FfKP1rjx8LF/n8eibVOVlv7XzTszMHCg43RHCLFxGAEKluDCw3hyFAFNJumECktiGOt19M54h+HEGW/BDZeW2g== +turbo-darwin-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-darwin-64/-/turbo-darwin-64-1.0.24.tgz#f135baff0e44f9160c9b027e8c4dd2d5c8bb10a7" + integrity sha512-A65Wxp+jBMfI3QX2uObX6DKvk+TxNXTf7ufQTHvRSLeAreB8QiVzJdYE0nC6YdrRwfPgFY3L72dhYd2v8ouXDg== + +turbo-darwin-arm64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-darwin-arm64/-/turbo-darwin-arm64-1.0.24.tgz#c360d7cc6a7403855733e3aebb841b1227fbbb2e" + integrity sha512-31zfexqUhvk/CIfAUk2mwjlpEjIURXu4QG8hoWlGxpcpAhlnkIX6CXle+LoQSnU3+4EbNe2SE92fYXsT/SnHAg== + +turbo-freebsd-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-freebsd-64/-/turbo-freebsd-64-1.0.24.tgz#9ef8914e7d1aaa995a8001a0ad81f7cc4520d332" + integrity sha512-vZYbDkOHH5eeQrxsAYldrh2nDY884irtmgJdGbpjryJgnJx+xzriZfoFalm/d1ZfG3ArENRJqGU+k6BriefZzw== + +turbo-freebsd-arm64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-freebsd-arm64/-/turbo-freebsd-arm64-1.0.24.tgz#12644e8f1b077f9d7afb367f2b8c2a2e0592ca72" + integrity sha512-TDIu1PlyusY8AB69KGM4wGrCjtfbzmVF4Hlgf9mVeSWVKzqkRASorOEq1k8KvfZ+sBTS2GBMpqwpa1KVkYpVhw== + +turbo-linux-32@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-32/-/turbo-linux-32-1.0.24.tgz#6129f7560f5c48214c1724ae7e8196dedc56de21" + integrity sha512-lhhK7914sUtuWYcDO8LV7NQkvTIwpAZlYH0XEOC/OTiYRQJvtKbEySLvefvtwuGjx7cGNI6OYraUsY3WWoK3FA== + +turbo-linux-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-64/-/turbo-linux-64-1.0.24.tgz#221e3e14037e8fc3108e12a62de209d8a47f0348" + integrity sha512-EbfdrkwVsHDG7AIVQ1enWHoD6riAApx4VRAuFcQHTvJU9e+BuOQBMjb7e9jO4mUrpumtN3n20tP+86odRwsk5g== + +turbo-linux-arm64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-arm64/-/turbo-linux-arm64-1.0.24.tgz#95891e7d4375ccbf2478677568557948be33717a" + integrity sha512-H4rqlgP2L7G3iAB/un/7DclExzLUkQ1NoZ0p/1Oa7Wb8H1YUlc8GkwUmpIFd5AOFSPL75DjYvlS8T5Tm23i+1A== + +turbo-linux-arm@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-arm/-/turbo-linux-arm-1.0.24.tgz#f5acb74170a8b5a787915e799e7b52840c7c6982" + integrity sha512-lCNDVEkwxcn0acyPFVJgV5N5vKAP4LfXb+8uW/JpGHVoPHSONKtzYQG05J1KbHXpIjUT+DNgFtshtsdZYOewZQ== + +turbo-linux-mips64le@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-mips64le/-/turbo-linux-mips64le-1.0.24.tgz#f2cc99570222ac42fdcc0d0638f13bc0176859f9" + integrity sha512-AmrgQUDIe9AdNyh5YrI6pfMTUHD/gYfbylNmedLuN5Al3xINdZObcISzd/7VWd+V8wNW/1b9lUnt70Rv/KExfA== + +turbo-linux-ppc64le@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-linux-ppc64le/-/turbo-linux-ppc64le-1.0.24.tgz#4d9508290d24cfdbaca24e57d8bcd0127281e2ed" + integrity sha512-+6ESjsfrvRUr1AsurNcRTrqYr+XHG8g763+hXLog1MP9mn1cufZqWlAyE4G8/MLXDHsEKgK+tXqPLIyLBRjLEw== + +turbo-windows-32@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-windows-32/-/turbo-windows-32-1.0.24.tgz#2bf906c0cc9d675afc4693221fc339ade29e6c13" + integrity sha512-pqRys+FfHxuLVmW/AariITL5qpItp4WPAsYnWLx4u7VpCOO/qmTAI/SL7/jnTm4gxjBv3uf//lisu0AvEZd+TA== + +turbo-windows-64@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo-windows-64/-/turbo-windows-64-1.0.24.tgz#5dd30b10110f2bb69caa479ddd72b4c471fb0dea" + integrity sha512-YHAWha5XkW0Ate1HtwhzFD32kZFXtC8KB4ReEvHc9GM2inQob1ZinvktS0xi5MC5Sxl9+bObOWmsxeZPOgNCFA== + +turbo@1.0.24: + version "1.0.24" + resolved "https://registry.yarnpkg.com/turbo/-/turbo-1.0.24.tgz#5efdeb44aab2f5e97b24a3e0ed4a159bfcd0a877" + integrity sha512-bfOr7iW48+chDl+yKiZ5FIWzXOF6xOIyrAGPaWI+I5CdD27IZCEGvqvTV/weaHvjLbV7otybHQ56XCybBlVjoA== + optionalDependencies: + turbo-darwin-64 "1.0.24" + turbo-darwin-arm64 "1.0.24" + turbo-freebsd-64 "1.0.24" + turbo-freebsd-arm64 "1.0.24" + turbo-linux-32 "1.0.24" + turbo-linux-64 "1.0.24" + turbo-linux-arm "1.0.24" + turbo-linux-arm64 "1.0.24" + turbo-linux-mips64le "1.0.24" + turbo-linux-ppc64le "1.0.24" + turbo-windows-32 "1.0.24" + turbo-windows-64 "1.0.24" tweetnacl@^0.14.3, tweetnacl@~0.14.0: version "0.14.5" From cfa8ab9cbfb8818408654e223aa9253be619879e Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Tue, 4 Jan 2022 15:29:37 -0600 Subject: [PATCH 12/20] v12.0.8-canary.17 --- lerna.json | 2 +- packages/create-next-app/package.json | 2 +- packages/eslint-config-next/package.json | 4 ++-- packages/eslint-plugin-next/package.json | 2 +- packages/next-bundle-analyzer/package.json | 2 +- packages/next-codemod/package.json | 2 +- packages/next-env/package.json | 2 +- packages/next-mdx/package.json | 2 +- packages/next-plugin-storybook/package.json | 2 +- packages/next-polyfill-module/package.json | 2 +- packages/next-polyfill-nomodule/package.json | 2 +- packages/next-swc/package.json | 2 +- packages/next/package.json | 14 +++++++------- packages/react-dev-overlay/package.json | 2 +- packages/react-refresh-utils/package.json | 2 +- 15 files changed, 22 insertions(+), 22 deletions(-) diff --git a/lerna.json b/lerna.json index 4d6fa15273405..f975ce5a8ff8f 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.0.8-canary.16" + "version": "12.0.8-canary.17" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 8d51955543c62..a095e220fc013 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index f25dda3a909a2..97a558e6f4a10 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "description": "ESLint configuration used by NextJS.", "main": "index.js", "license": "MIT", @@ -9,7 +9,7 @@ "directory": "packages/eslint-config-next" }, "dependencies": { - "@next/eslint-plugin-next": "12.0.8-canary.16", + "@next/eslint-plugin-next": "12.0.8-canary.17", "@rushstack/eslint-patch": "^1.0.8", "@typescript-eslint/parser": "^5.0.0", "eslint-import-resolver-node": "^0.3.4", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 269dc9b3542cf..c25236678930a 100644 --- a/packages/eslint-plugin-next/package.json +++ b/packages/eslint-plugin-next/package.json @@ -1,6 +1,6 @@ { "name": "@next/eslint-plugin-next", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "description": "ESLint plugin for NextJS.", "main": "lib/index.js", "license": "MIT", diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index cceaf658b8a8e..9f0b2fcb47532 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 7db20b5b3c686..f4d5bbf559895 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index f222a8c841ee7..261cf37790415 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index e50d121782dc0..10a51f853ae26 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index e5e8de82c36c4..7792749f169c6 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "repository": { "url": "vercel/next.js", "directory": "packages/next-plugin-storybook" diff --git a/packages/next-polyfill-module/package.json b/packages/next-polyfill-module/package.json index ce08a6fb36eea..34924c34e3f15 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "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", diff --git a/packages/next-polyfill-nomodule/package.json b/packages/next-polyfill-nomodule/package.json index 989b1a4e57378..c7a2fc585bc0f 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "description": "A polyfill for non-dead, nomodule browsers.", "main": "dist/polyfill-nomodule.js", "license": "MIT", diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 0aae40c0cc7b1..8da471a5622b1 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "private": true, "scripts": { "build-native": "napi build --platform --cargo-name next_swc_napi native", diff --git a/packages/next/package.json b/packages/next/package.json index 9e2607fdf0eab..e7442ee8955a3 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -71,8 +71,8 @@ ] }, "dependencies": { - "@next/env": "12.0.8-canary.16", - "@next/react-refresh-utils": "12.0.8-canary.16", + "@next/env": "12.0.8-canary.17", + "@next/react-refresh-utils": "12.0.8-canary.17", "caniuse-lite": "^1.0.30001283", "jest-worker": "27.0.0-next.5", "node-fetch": "2.6.1", @@ -125,10 +125,10 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "1.2.1", "@napi-rs/triples": "1.0.3", - "@next/polyfill-module": "12.0.8-canary.16", - "@next/polyfill-nomodule": "12.0.8-canary.16", - "@next/react-dev-overlay": "12.0.8-canary.16", - "@next/swc": "12.0.8-canary.16", + "@next/polyfill-module": "12.0.8-canary.17", + "@next/polyfill-nomodule": "12.0.8-canary.17", + "@next/react-dev-overlay": "12.0.8-canary.17", + "@next/swc": "12.0.8-canary.17", "@peculiar/webcrypto": "1.1.7", "@taskr/clear": "1.1.0", "@taskr/esnext": "1.1.0", diff --git a/packages/react-dev-overlay/package.json b/packages/react-dev-overlay/package.json index 92286bb240e55..a22e41895c55c 100644 --- a/packages/react-dev-overlay/package.json +++ b/packages/react-dev-overlay/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-dev-overlay", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "description": "A development-only overlay for developing React applications.", "repository": { "url": "vercel/next.js", diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index eed0cab0437da..447adca6df43d 100644 --- a/packages/react-refresh-utils/package.json +++ b/packages/react-refresh-utils/package.json @@ -1,6 +1,6 @@ { "name": "@next/react-refresh-utils", - "version": "12.0.8-canary.16", + "version": "12.0.8-canary.17", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", From 0195a6f89e23e3e6e1985aae99982e543e20d313 Mon Sep 17 00:00:00 2001 From: Jared Palmer Date: Wed, 5 Jan 2022 08:48:42 -0500 Subject: [PATCH 13/20] Remove unused turbo remote cache env vars (#33030) --- .github/workflows/build_test_deploy.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index d3a4ecb10f452..d74d4da95102b 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -698,9 +698,6 @@ jobs: run: turbo run build-native --cache-dir=".turbo" env: MACOSX_DEPLOYMENT_TARGET: '10.13' - TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} - TURBO_TEAM: nextjs - TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 @@ -886,9 +883,6 @@ jobs: run: turbo run build-native --cache-dir=".turbo" -- --release --target ${{ matrix.target }} env: MACOSX_DEPLOYMENT_TARGET: '10.13' - TURBO_TOKEN: ${{secrets.TURBO_TOKEN}} - TURBO_TEAM: nextjs - TURBO_PROJECT: nextjs - name: Upload artifact uses: actions/upload-artifact@v2.2.4 From ce3a3d8eea92c1968dbfdb09176e3d82ccbf039a Mon Sep 17 00:00:00 2001 From: Hung Viet Nguyen Date: Wed, 5 Jan 2022 21:24:15 +0700 Subject: [PATCH 14/20] Rename api in with-redis example (#33016) Co-authored-by: JJ Kasper --- examples/with-redis/pages/api/create.js | 2 +- examples/with-redis/pages/api/features.js | 2 +- examples/with-redis/pages/api/subscribe.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/with-redis/pages/api/create.js b/examples/with-redis/pages/api/create.js index 1affbb4400608..df777bce298a0 100644 --- a/examples/with-redis/pages/api/create.js +++ b/examples/with-redis/pages/api/create.js @@ -2,7 +2,7 @@ import { v4 as uuidv4 } from 'uuid' import redis from '../../lib/redis' -export default async function upvote(req, res) { +export default async function create(req, res) { const { title } = req.body if (!title) { diff --git a/examples/with-redis/pages/api/features.js b/examples/with-redis/pages/api/features.js index 37c1e67abfd54..afa8546703e70 100644 --- a/examples/with-redis/pages/api/features.js +++ b/examples/with-redis/pages/api/features.js @@ -1,6 +1,6 @@ import redis from '../../lib/redis' -export default async function upvote(req, res) { +export default async function getAllFeatures(req, res) { const features = (await redis.hvals('features')) .map((entry) => JSON.parse(entry)) .sort((a, b) => b.score - a.score) diff --git a/examples/with-redis/pages/api/subscribe.js b/examples/with-redis/pages/api/subscribe.js index 4b1895b0b6ba0..436ff17642cdd 100644 --- a/examples/with-redis/pages/api/subscribe.js +++ b/examples/with-redis/pages/api/subscribe.js @@ -1,6 +1,6 @@ import redis from '../../lib/redis' -export default async function upvote(req, res) { +export default async function subscribe(req, res) { const { email } = req.body if (email && validateEmail(email)) { From 1ee13baf000ab391e6017c68eb4770768a8e7674 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 5 Jan 2022 09:22:22 -0600 Subject: [PATCH 15/20] Ensure NODE_ENV is not inlined for next/jest (#33032) --- packages/next/build/swc/options.js | 22 +++++++++++++--------- test/unit/jest-next-swc.test.ts | 7 +++++++ 2 files changed, 20 insertions(+), 9 deletions(-) create mode 100644 test/unit/jest-next-swc.test.ts diff --git a/packages/next/build/swc/options.js b/packages/next/build/swc/options.js index 6e2a852bfc0fc..103119885e47b 100644 --- a/packages/next/build/swc/options.js +++ b/packages/next/build/swc/options.js @@ -7,6 +7,7 @@ const regeneratorRuntimePath = require.resolve( function getBaseSWCOptions({ filename, + jest, development, hasReactRefresh, globalWindow, @@ -50,15 +51,17 @@ function getBaseSWCOptions({ }, optimizer: { simplify: false, - globals: { - typeofs: { - window: globalWindow ? 'object' : 'undefined', - }, - envs: { - NODE_ENV: development ? '"development"' : '"production"', - }, - // TODO: handle process.browser to match babel replacing as well - }, + globals: jest + ? null + : { + typeofs: { + window: globalWindow ? 'object' : 'undefined', + }, + envs: { + NODE_ENV: development ? '"development"' : '"production"', + }, + // TODO: handle process.browser to match babel replacing as well + }, }, regenerator: { importPath: regeneratorRuntimePath, @@ -86,6 +89,7 @@ export function getJestSWCOptions({ }) { let baseOptions = getBaseSWCOptions({ filename, + jest: true, development: false, hasReactRefresh: false, globalWindow: !isServer, diff --git a/test/unit/jest-next-swc.test.ts b/test/unit/jest-next-swc.test.ts new file mode 100644 index 0000000000000..55e10a32998cd --- /dev/null +++ b/test/unit/jest-next-swc.test.ts @@ -0,0 +1,7 @@ +/* eslint-env jest */ + +describe('jest next-swc preset', () => { + it('should have correct env', async () => { + expect(process.env.NODE_ENV).toBe('test') + }) +}) From 4a2bfa7aa62c5a58191d3f3e2222ef650749230f Mon Sep 17 00:00:00 2001 From: Guillaume FORTAINE Date: Wed, 5 Jan 2022 17:59:32 +0100 Subject: [PATCH 16/20] fix(examples/cms-contentful): add correct Content-Type + missing closing tag for html (#30321) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` --- examples/cms-contentful/pages/api/preview.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/cms-contentful/pages/api/preview.js b/examples/cms-contentful/pages/api/preview.js index 6ddc5a203f6d7..b5d2be17789df 100644 --- a/examples/cms-contentful/pages/api/preview.js +++ b/examples/cms-contentful/pages/api/preview.js @@ -22,10 +22,12 @@ export default async function preview(req, res) { // We don't redirect to req.query.slug as that might lead to open redirect vulnerabilities // res.writeHead(307, { Location: `/posts/${post.slug}` }) const url = `/posts/${post.slug}` + res.setHeader('Content-Type', 'text/html') res.write( ` - ` + + ` ) res.end() } From 066984e6d93da95e9e83c00398403a9fb6cce6ba Mon Sep 17 00:00:00 2001 From: Kumar Deepanshu <62591080+kumard3@users.noreply.github.com> Date: Wed, 5 Jan 2022 23:11:25 +0530 Subject: [PATCH 17/20] converted the old tailwind css example to typescript (#32808) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `yarn lint` --- examples/with-tailwindcss/.eslintrc.json | 3 +++ examples/with-tailwindcss/.gitignore | 3 +++ examples/with-tailwindcss/README.md | 8 ++++++++ examples/with-tailwindcss/next-env.d.ts | 5 +++++ examples/with-tailwindcss/next.config.js | 4 ++++ examples/with-tailwindcss/package.json | 9 +++++++-- .../pages/{_app.js => _app.tsx} | 3 ++- examples/with-tailwindcss/pages/api/hello.js | 5 ----- examples/with-tailwindcss/pages/api/hello.ts | 13 ++++++++++++ .../pages/{index.js => index.tsx} | 2 +- examples/with-tailwindcss/postcss.config.js | 2 -- examples/with-tailwindcss/tsconfig.json | 20 +++++++++++++++++++ 12 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 examples/with-tailwindcss/.eslintrc.json create mode 100644 examples/with-tailwindcss/next-env.d.ts create mode 100644 examples/with-tailwindcss/next.config.js rename examples/with-tailwindcss/pages/{_app.js => _app.tsx} (50%) delete mode 100644 examples/with-tailwindcss/pages/api/hello.js create mode 100644 examples/with-tailwindcss/pages/api/hello.ts rename examples/with-tailwindcss/pages/{index.js => index.tsx} (99%) create mode 100644 examples/with-tailwindcss/tsconfig.json diff --git a/examples/with-tailwindcss/.eslintrc.json b/examples/with-tailwindcss/.eslintrc.json new file mode 100644 index 0000000000000..bffb357a71225 --- /dev/null +++ b/examples/with-tailwindcss/.eslintrc.json @@ -0,0 +1,3 @@ +{ + "extends": "next/core-web-vitals" +} diff --git a/examples/with-tailwindcss/.gitignore b/examples/with-tailwindcss/.gitignore index 1437c53f70bc2..88b6f0d981643 100644 --- a/examples/with-tailwindcss/.gitignore +++ b/examples/with-tailwindcss/.gitignore @@ -32,3 +32,6 @@ yarn-error.log* # vercel .vercel + +# typescript +*.tsbuildinfo diff --git a/examples/with-tailwindcss/README.md b/examples/with-tailwindcss/README.md index 5981eee944757..dc54d0c3f47ed 100644 --- a/examples/with-tailwindcss/README.md +++ b/examples/with-tailwindcss/README.md @@ -1,3 +1,11 @@ +

+ +Next.js TypeScript Starter + +

+ +
+ # Next.js + Tailwind CSS Example This example shows how to use [Tailwind CSS](https://tailwindcss.com/) [(v3.0)](https://tailwindcss.com/blog/tailwindcss-v3) with Next.js. It follows the steps outlined in the official [Tailwind docs](https://tailwindcss.com/docs/guides/nextjs). diff --git a/examples/with-tailwindcss/next-env.d.ts b/examples/with-tailwindcss/next-env.d.ts new file mode 100644 index 0000000000000..4f11a03dc6cc3 --- /dev/null +++ b/examples/with-tailwindcss/next-env.d.ts @@ -0,0 +1,5 @@ +/// +/// + +// NOTE: This file should not be edited +// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/examples/with-tailwindcss/next.config.js b/examples/with-tailwindcss/next.config.js new file mode 100644 index 0000000000000..8b61df4e50f8a --- /dev/null +++ b/examples/with-tailwindcss/next.config.js @@ -0,0 +1,4 @@ +/** @type {import('next').NextConfig} */ +module.exports = { + reactStrictMode: true, +} diff --git a/examples/with-tailwindcss/package.json b/examples/with-tailwindcss/package.json index 0850b4715b9c0..777749724d872 100644 --- a/examples/with-tailwindcss/package.json +++ b/examples/with-tailwindcss/package.json @@ -11,8 +11,13 @@ "react-dom": "^17.0.2" }, "devDependencies": { + "@types/node": "17.0.4", + "@types/react": "17.0.38", "autoprefixer": "^10.4.0", - "postcss": "^8.4.4", - "tailwindcss": "^3.0.0" + "eslint": "8.5.0", + "eslint-config-next": "12.0.7", + "postcss": "^8.4.5", + "tailwindcss": "^3.0.7", + "typescript": "4.5.4" } } diff --git a/examples/with-tailwindcss/pages/_app.js b/examples/with-tailwindcss/pages/_app.tsx similarity index 50% rename from examples/with-tailwindcss/pages/_app.js rename to examples/with-tailwindcss/pages/_app.tsx index 1e1cec92425c8..3f5c9d5485860 100644 --- a/examples/with-tailwindcss/pages/_app.js +++ b/examples/with-tailwindcss/pages/_app.tsx @@ -1,6 +1,7 @@ import '../styles/globals.css' +import type { AppProps } from 'next/app' -function MyApp({ Component, pageProps }) { +function MyApp({ Component, pageProps }: AppProps) { return } diff --git a/examples/with-tailwindcss/pages/api/hello.js b/examples/with-tailwindcss/pages/api/hello.js deleted file mode 100644 index f163396631ba5..0000000000000 --- a/examples/with-tailwindcss/pages/api/hello.js +++ /dev/null @@ -1,5 +0,0 @@ -// Next.js API route support: https://nextjs.org/docs/api-routes/introduction - -export default function helloAPI(req, res) { - res.status(200).json({ name: 'John Doe' }) -} diff --git a/examples/with-tailwindcss/pages/api/hello.ts b/examples/with-tailwindcss/pages/api/hello.ts new file mode 100644 index 0000000000000..f8bcc7e5caed1 --- /dev/null +++ b/examples/with-tailwindcss/pages/api/hello.ts @@ -0,0 +1,13 @@ +// Next.js API route support: https://nextjs.org/docs/api-routes/introduction +import type { NextApiRequest, NextApiResponse } from 'next' + +type Data = { + name: string +} + +export default function handler( + req: NextApiRequest, + res: NextApiResponse +) { + res.status(200).json({ name: 'John Doe' }) +} diff --git a/examples/with-tailwindcss/pages/index.js b/examples/with-tailwindcss/pages/index.tsx similarity index 99% rename from examples/with-tailwindcss/pages/index.js rename to examples/with-tailwindcss/pages/index.tsx index 6b67e91ccd256..828dd6012730d 100644 --- a/examples/with-tailwindcss/pages/index.js +++ b/examples/with-tailwindcss/pages/index.tsx @@ -19,7 +19,7 @@ export default function Home() {

Get started by editing{' '} - pages/index.js + pages/index.tsx

diff --git a/examples/with-tailwindcss/postcss.config.js b/examples/with-tailwindcss/postcss.config.js index 3fa0a9514dc9d..33ad091d26d8a 100644 --- a/examples/with-tailwindcss/postcss.config.js +++ b/examples/with-tailwindcss/postcss.config.js @@ -1,5 +1,3 @@ -// If you want to use other PostCSS plugins, see the following: -// https://tailwindcss.com/docs/using-with-preprocessors module.exports = { plugins: { tailwindcss: {}, diff --git a/examples/with-tailwindcss/tsconfig.json b/examples/with-tailwindcss/tsconfig.json new file mode 100644 index 0000000000000..99710e857874f --- /dev/null +++ b/examples/with-tailwindcss/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} From 789a665a036ede0fc8006ff27d29ef38650f6efc Mon Sep 17 00:00:00 2001 From: Teo Stocco Date: Wed, 5 Jan 2022 18:48:12 +0100 Subject: [PATCH 18/20] Avoid page double render with emotion vanilla (#30541) > Based on https://github.com/vercel/next.js/blob/v12.0.1/packages/next/server/render.tsx#L522-L532, this avoids the need for double page render. After investigation, the potential unneeded render has been introduced in the official [example](https://github.com/vercel/next.js/pull/20228/files#diff-3976da223aaf15067ecdd0734ca277ebf4629c46d62f89d732ab392752d3572dR6) but does not exist in the earlier proposed [solution](https://gist.github.com/colinhacks/c40519a6a050a99091862319151377ec). There might a reason (layered override?) for it but I am unable to find relevant explanation. Original discussion in https://github.com/mantinedev/mantine/pull/348. ## Documentation / Examples - [x] Make sure the linting passes by running `yarn lint` --- examples/with-emotion-vanilla/pages/_document.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/with-emotion-vanilla/pages/_document.js b/examples/with-emotion-vanilla/pages/_document.js index e34725067736d..34ab85def6e17 100644 --- a/examples/with-emotion-vanilla/pages/_document.js +++ b/examples/with-emotion-vanilla/pages/_document.js @@ -3,9 +3,8 @@ import * as React from 'react' import { renderStatic } from '../shared/renderer' export default class AppDocument extends Document { static async getInitialProps(ctx) { - const page = await ctx.renderPage() - const { css, ids } = await renderStatic(page.html) const initialProps = await Document.getInitialProps(ctx) + const { css, ids } = await renderStatic(initialProps.html) return { ...initialProps, styles: ( From ef7e70ee5d07455d5e34b3e2df97240a75dc5486 Mon Sep 17 00:00:00 2001 From: Vicente Soriano Date: Wed, 5 Jan 2022 12:58:13 -0500 Subject: [PATCH 19/20] fix: typescript example supporting strict w/ version >= 4.4 (#33042) ## Documentation / Examples - [x] Make sure the linting passes by running `yarn lint` Closes: https://github.com/vercel/next.js/pull/32023 Fixes: https://github.com/vercel/next.js/issues/32015 --- examples/with-typescript/pages/api/users/index.ts | 2 +- examples/with-typescript/pages/users/[id].tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/with-typescript/pages/api/users/index.ts b/examples/with-typescript/pages/api/users/index.ts index 4efdba6f1a4e7..67a645ea39199 100644 --- a/examples/with-typescript/pages/api/users/index.ts +++ b/examples/with-typescript/pages/api/users/index.ts @@ -8,7 +8,7 @@ const handler = (_req: NextApiRequest, res: NextApiResponse) => { } res.status(200).json(sampleUserData) - } catch (err) { + } catch (err: any) { res.status(500).json({ statusCode: 500, message: err.message }) } } diff --git a/examples/with-typescript/pages/users/[id].tsx b/examples/with-typescript/pages/users/[id].tsx index 61720da5a7a5d..ca442c0c16a4b 100644 --- a/examples/with-typescript/pages/users/[id].tsx +++ b/examples/with-typescript/pages/users/[id].tsx @@ -55,7 +55,7 @@ export const getStaticProps: GetStaticProps = async ({ params }) => { // By returning { props: item }, the StaticPropsDetail component // will receive `item` as a prop at build time return { props: { item } } - } catch (err) { + } catch (err: any) { return { props: { errors: err.message } } } } From 551c9d696362df6eda5d02218a5826314f0642f9 Mon Sep 17 00:00:00 2001 From: Rohith Gilla Date: Wed, 5 Jan 2022 23:34:56 +0530 Subject: [PATCH 20/20] [chore] Update `deta` version in examples (#30204) ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have helpful link attached, see `contributing.md` ## Documentation / Examples - [x] Make sure the linting passes by running `yarn lint` --- examples/with-deta-base/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/with-deta-base/package.json b/examples/with-deta-base/package.json index a38fa7b3134b4..e7759e2daac70 100644 --- a/examples/with-deta-base/package.json +++ b/examples/with-deta-base/package.json @@ -6,7 +6,7 @@ "start": "next start" }, "dependencies": { - "deta": "^0.0.8", + "deta": "^1.0.1", "next": "latest", "react": "^17.0.2", "react-dom": "^17.0.2"