From 7c103fac7d96f7ebadf03620044f3b2c02c4df48 Mon Sep 17 00:00:00 2001 From: Naoyuki Kanezawa Date: Fri, 18 Feb 2022 15:39:30 +0700 Subject: [PATCH 01/43] fix process polyfill on middleware (#34426) Fixes the problem that global `process` variable has only the `env` field. Also fixed the issue that the `env` field is empty when the `process` module is used as the value of the variable (which happens when the module is contained in a dependency of application). ## Bug - [ ] Related issues linked using `fixes #number` - [x] Integration tests added - [ ] Errors have helpful link attached, see `contributing.md` --- .../webpack/loaders/next-middleware-loader.ts | 7 ++++++ packages/next/server/web/sandbox/context.ts | 1 + packages/next/server/web/sandbox/polyfills.ts | 3 ++- packages/next/types/misc.d.ts | 5 ++++ .../core/pages/global/_middleware.js | 12 ++++++++++ .../middleware/core/test/index.test.js | 24 +++++++++++++++++++ 6 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 test/integration/middleware/core/pages/global/_middleware.js diff --git a/packages/next/build/webpack/loaders/next-middleware-loader.ts b/packages/next/build/webpack/loaders/next-middleware-loader.ts index 3ccdc57c01f1..3beab89b7f4a 100644 --- a/packages/next/build/webpack/loaders/next-middleware-loader.ts +++ b/packages/next/build/webpack/loaders/next-middleware-loader.ts @@ -12,6 +12,13 @@ export default function middlewareLoader(this: any) { return ` import { adapter } from 'next/dist/server/web/adapter' + // The condition is true when the "process" module is provided + if (process !== global.process) { + // prefer local process but global.process has correct "env" + process.env = global.process.env; + global.process = process; + } + var mod = require(${stringifiedPagePath}) var handler = mod.middleware || mod.default; diff --git a/packages/next/server/web/sandbox/context.ts b/packages/next/server/web/sandbox/context.ts index de3876ffae94..42f480bb6a31 100644 --- a/packages/next/server/web/sandbox/context.ts +++ b/packages/next/server/web/sandbox/context.ts @@ -202,6 +202,7 @@ function createContext(options: { File, FormData, process: { + ...polyfills.process, env: buildEnvironmentVariablesFrom(options.env), }, ReadableStream: polyfills.ReadableStream, diff --git a/packages/next/server/web/sandbox/polyfills.ts b/packages/next/server/web/sandbox/polyfills.ts index 3b47e18af6cf..ce0834745265 100644 --- a/packages/next/server/web/sandbox/polyfills.ts +++ b/packages/next/server/web/sandbox/polyfills.ts @@ -1,6 +1,7 @@ import { Crypto as WebCrypto } from 'next/dist/compiled/@peculiar/webcrypto' import { CryptoKey } from 'next/dist/compiled/@peculiar/webcrypto' import { v4 as uuid } from 'next/dist/compiled/uuid' +import processPolyfill from 'next/dist/compiled/process' import { ReadableStream } from './readable-stream' import crypto from 'crypto' @@ -13,7 +14,7 @@ export function btoa(str: string) { return Buffer.from(str, 'binary').toString('base64') } -export { CryptoKey, ReadableStream } +export { CryptoKey, ReadableStream, processPolyfill as process } export class Crypto extends WebCrypto { // @ts-ignore Remove once types are updated and we deprecate node 12 diff --git a/packages/next/types/misc.d.ts b/packages/next/types/misc.d.ts index 555d3ad83d6e..cbbc83ee852e 100644 --- a/packages/next/types/misc.d.ts +++ b/packages/next/types/misc.d.ts @@ -331,6 +331,11 @@ declare module 'next/dist/compiled/comment-json' { export = m } +declare module 'next/dist/compiled/process' { + import m from 'process' + export = m +} + declare module 'pnp-webpack-plugin' { import webpack from 'webpack4' diff --git a/test/integration/middleware/core/pages/global/_middleware.js b/test/integration/middleware/core/pages/global/_middleware.js new file mode 100644 index 000000000000..7e3020009875 --- /dev/null +++ b/test/integration/middleware/core/pages/global/_middleware.js @@ -0,0 +1,12 @@ +import { NextResponse } from 'next/server' + +export async function middleware(request, ev) { + console.log(process.env.MIDDLEWARE_TEST) + + return NextResponse.json({ + process: { + env: process.env, + nextTick: typeof process.nextTick, + }, + }) +} diff --git a/test/integration/middleware/core/test/index.test.js b/test/integration/middleware/core/test/index.test.js index 805cf48fd395..6cc789bc76d9 100644 --- a/test/integration/middleware/core/test/index.test.js +++ b/test/integration/middleware/core/test/index.test.js @@ -108,6 +108,30 @@ describe('Middleware base tests', () => { } }) }) + + describe('global', () => { + beforeAll(async () => { + context.appPort = await findPort() + context.app = await launchApp(context.appDir, context.appPort, { + env: { + MIDDLEWARE_TEST: 'asdf', + }, + }) + }) + + it('should contains process polyfill', async () => { + const res = await fetchViaHTTP(context.appPort, `/global`) + const json = await res.json() + expect(json).toEqual({ + process: { + env: { + MIDDLEWARE_TEST: 'asdf', + }, + nextTick: 'function', + }, + }) + }) + }) }) function urlTests(_log, locale = '') { From ab40370ea5b69aa4dd601907eb85d25da1140b6b Mon Sep 17 00:00:00 2001 From: Andrew Gerard Date: Fri, 18 Feb 2022 02:12:56 -0700 Subject: [PATCH 02/43] Ensure workers are not left open (#34503) This fixes #33615. If an App uses `getInitialProps`, the build function never enters [this conditional block](https://github.com/vercel/next.js/blob/a52bd712fe797b59cfd05ceaa4c33096a0c346ff/packages/next/build/index.ts#L1481-L1484) and the static worker is left open. --- packages/next/build/index.ts | 3 +++ packages/next/lib/worker.ts | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 1e6eaff73433..27ed5cbe45e0 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -1910,6 +1910,9 @@ export default async function build( }) } + // ensure the worker is not left hanging + staticWorkers.close() + const analysisEnd = process.hrtime(analysisBegin) telemetry.record( eventBuildOptimize(pagePaths, { diff --git a/packages/next/lib/worker.ts b/packages/next/lib/worker.ts index 8182f2b6b0ea..023d9166e53f 100644 --- a/packages/next/lib/worker.ts +++ b/packages/next/lib/worker.ts @@ -85,4 +85,13 @@ export class Worker { this._worker = undefined return worker.end() } + + /** + * Quietly end the worker if it exists + */ + close(): void { + if (this._worker) { + this._worker.end() + } + } } From 4ad1c5a2bc3384d0eeaef2d05452748a3a9ae467 Mon Sep 17 00:00:00 2001 From: Lionel Date: Fri, 18 Feb 2022 11:03:27 +0100 Subject: [PATCH 03/43] Update wrong code snippet (#34520) Following the [example](https://nextjs.org/docs/advanced-features/custom-document), avoiding the following error: > Identifier 'Document' has already been declared ## 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` --- errors/no-stylesheets-in-head-component.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/errors/no-stylesheets-in-head-component.md b/errors/no-stylesheets-in-head-component.md index 3e3901a682dd..319cae672bfe 100644 --- a/errors/no-stylesheets-in-head-component.md +++ b/errors/no-stylesheets-in-head-component.md @@ -18,7 +18,7 @@ Add the stylesheet in a custom `Document` component. ```jsx // pages/_document.js -import Document, { Html, Head, Main, NextScript } from 'next/document' +import { Html, Head, Main, NextScript } from 'next/document' export default function Document() { return ( From ce76d1712e98d7310385c89ec1917242f7c5111c Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Fri, 18 Feb 2022 16:25:10 +0100 Subject: [PATCH 04/43] Leverage existing component checking warning for streaming (#34526) ## Bug Fixes: #31993 * Remove the simple component checking in middleware ssr * Leverage existing components checking for Component / App / Document, if any of these component is not valid react type or is undefined nextjs will error in dev mode with redbox. Like above. image - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` --- .../next-middleware-ssr-loader/index.ts | 4 -- packages/next/server/base-server.ts | 2 +- packages/next/server/load-components.ts | 8 ++- packages/next/server/render.tsx | 4 +- test/integration/react-18/test/index.test.js | 69 +++++++++++++------ 5 files changed, 56 insertions(+), 31 deletions(-) diff --git a/packages/next/build/webpack/loaders/next-middleware-ssr-loader/index.ts b/packages/next/build/webpack/loaders/next-middleware-ssr-loader/index.ts index d457fcaa72d3..870a6b901693 100644 --- a/packages/next/build/webpack/loaders/next-middleware-ssr-loader/index.ts +++ b/packages/next/build/webpack/loaders/next-middleware-ssr-loader/index.ts @@ -39,10 +39,6 @@ export default async function middlewareSSRLoader(this: any) { const reactLoadableManifest = self.__REACT_LOADABLE_MANIFEST const rscManifest = self.__RSC_MANIFEST - if (typeof pageMod.default !== 'function') { - throw new Error('Your page must export a \`default\` component') - } - // Set server context self.__server_context = { page: ${JSON.stringify(page)}, diff --git a/packages/next/server/base-server.ts b/packages/next/server/base-server.ts index 77160619770f..19e62dcc11f2 100644 --- a/packages/next/server/base-server.ts +++ b/packages/next/server/base-server.ts @@ -1122,7 +1122,7 @@ export default abstract class Server { const isSSG = !!components.getStaticProps const hasServerProps = !!components.getServerSideProps const hasStaticPaths = !!components.getStaticPaths - const hasGetInitialProps = !!(components.Component as any).getInitialProps + const hasGetInitialProps = !!components.Component?.getInitialProps // Toggle whether or not this is a Data request const isDataReq = !!query._nextDataReq && (isSSG || hasServerProps) diff --git a/packages/next/server/load-components.ts b/packages/next/server/load-components.ts index e4c86fee8bcb..b4d4b02a0ac0 100644 --- a/packages/next/server/load-components.ts +++ b/packages/next/server/load-components.ts @@ -1,3 +1,8 @@ +import type { + AppType, + DocumentType, + NextComponentType, +} from '../shared/lib/utils' import { BUILD_MANIFEST, REACT_LOADABLE_MANIFEST, @@ -5,7 +10,6 @@ import { import { join } from 'path' import { requirePage } from './require' import { BuildManifest } from './get-page-files' -import { AppType, DocumentType } from '../shared/lib/utils' import { interopDefault } from '../lib/interop-default' import { PageConfig, @@ -22,7 +26,7 @@ export type ManifestItem = { export type ReactLoadableManifest = { [moduleId: string]: ManifestItem } export type LoadComponentsReturnType = { - Component: React.ComponentType + Component: NextComponentType pageConfig: PageConfig buildManifest: BuildManifest reactLoadableManifest: ReactLoadableManifest diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx index d18e1f336b00..ce5b2a5d9a42 100644 --- a/packages/next/server/render.tsx +++ b/packages/next/server/render.tsx @@ -545,7 +545,7 @@ export async function renderToHTML( const defaultAppGetInitialProps = App.getInitialProps === (App as any).origGetInitialProps - const hasPageGetInitialProps = !!(Component as any).getInitialProps + const hasPageGetInitialProps = !!(Component as any)?.getInitialProps const pageIsDynamic = isDynamicRoute(pathname) @@ -561,7 +561,7 @@ export async function renderToHTML( 'getServerSideProps', 'getStaticPaths', ]) { - if ((Component as any)[methodName]) { + if ((Component as any)?.[methodName]) { throw new Error( `page ${pathname} ${methodName} ${GSSP_COMPONENT_MEMBER_ERROR}` ) diff --git a/test/integration/react-18/test/index.test.js b/test/integration/react-18/test/index.test.js index 8d68baaef191..2660a9fd20b1 100644 --- a/test/integration/react-18/test/index.test.js +++ b/test/integration/react-18/test/index.test.js @@ -11,11 +11,14 @@ import { nextStart, renderViaHTTP, fetchViaHTTP, + hasRedbox, + getRedboxHeader, } from 'next-test-utils' import blocking from './blocking' import concurrent from './concurrent' import basics from './basics' import strictMode from './strict-mode' +import webdriver from 'next-webdriver' // overrides react and react-dom to v18 const nodeArgs = ['-r', join(__dirname, 'require-hook.js')] @@ -23,6 +26,7 @@ const appDir = join(__dirname, '../app') const nextConfig = new File(join(appDir, 'next.config.js')) const dynamicHello = new File(join(appDir, 'components/dynamic-hello.js')) const unwrappedPage = new File(join(appDir, 'pages/suspense/unwrapped.js')) +const invalidPage = new File(join(appDir, 'pages/invalid.js')) const USING_CREATE_ROOT = 'Using the createRoot API for React' @@ -141,21 +145,22 @@ describe('Blocking mode', () => { }) function runTestsAgainstRuntime(runtime) { - describe(`Concurrent mode in the ${runtime} runtime`, () => { - beforeAll(async () => { - nextConfig.replace("// runtime: 'edge'", `runtime: '${runtime}'`) - dynamicHello.replace('suspense = false', `suspense = true`) - // `noSSR` mode will be ignored by suspense - dynamicHello.replace('let ssr', `let ssr = false`) - }) - afterAll(async () => { - nextConfig.restore() - dynamicHello.restore() - }) - - runTests(`runtime is set to '${runtime}'`, (context) => { + runTests( + `Concurrent mode in the ${runtime} runtime`, + (context, env) => { concurrent(context, (p, q) => renderViaHTTP(context.appPort, p, q)) + if (env === 'dev') { + it('should recover after undefined exported as default', async () => { + const browser = await webdriver(context.appPort, '/invalid') + + expect(await hasRedbox(browser)).toBe(true) + expect(await getRedboxHeader(browser)).toMatch( + `Error: The default export is not a React Component in page: "/invalid"` + ) + }) + } + it('should stream to users', async () => { const res = await fetchViaHTTP(context.appPort, '/ssr') expect(res.headers.get('etag')).toBeNull() @@ -189,17 +194,36 @@ function runTestsAgainstRuntime(runtime) { ) expect(res.headers.get('etag')).toBeDefined() }) - }) - }) + }, + { + beforeAll: (env) => { + if (env === 'dev') { + invalidPage.write(`export const value = 1`) + } + nextConfig.replace("// runtime: 'edge'", `runtime: '${runtime}'`) + dynamicHello.replace('suspense = false', `suspense = true`) + // `noSSR` mode will be ignored by suspense + dynamicHello.replace('let ssr', `let ssr = false`) + }, + afterAll: (env) => { + if (env === 'dev') { + invalidPage.delete() + } + nextConfig.restore() + dynamicHello.restore() + }, + } + ) } -function runTest(mode, name, fn) { +function runTest(env, name, fn, options) { const context = { appDir } - describe(`${name} (${mode})`, () => { + describe(`${name} (${env})`, () => { beforeAll(async () => { context.appPort = await findPort() context.stderr = '' - if (mode === 'dev') { + options?.beforeAll(env) + if (env === 'dev') { context.server = await launchApp(context.appDir, context.appPort, { nodeArgs, onStderr(msg) { @@ -217,16 +241,17 @@ function runTest(mode, name, fn) { } }) afterAll(async () => { + options?.afterAll(env) await killApp(context.server) }) - fn(context) + fn(context, env) }) } runTestsAgainstRuntime('edge') runTestsAgainstRuntime('nodejs') -function runTests(name, fn) { - runTest('dev', name, fn) - runTest('prod', name, fn) +function runTests(name, fn, options) { + runTest('dev', name, fn, options) + runTest('prod', name, fn, options) } From 924b71ccc16c434005c0f4111e86d658734c0133 Mon Sep 17 00:00:00 2001 From: LongYinan Date: Sat, 19 Feb 2022 00:04:43 +0800 Subject: [PATCH 05/43] build(next-swc): linux glibc compatible issue (#34481) Fix `GLIBC` compatible issues: - Fixes https://github.com/vercel/next.js/issues/33854 - All `CentOS 7` related issues in https://github.com/vercel/next.js/discussions/30468 Should also fix: - https://github.com/vercel/next.js/discussions/33530 Refactored jobs tested in https://github.com/Brooooooklyn/next.js/runs/5233199833?check_suite_focus=true ### `objdump` in `next@12.0.10`
Symbols node_modules/@next/swc-linux-x64-gnu/next-swc.linux-x64-gnu.node: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 0000000000000000 D *UND* 0000000000000000 napi_resolve_deferred 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __xpg_strerror_r 0000000000000000 D *UND* 0000000000000000 napi_typeof 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_setspecific 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.4 __stack_chk_fail 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_GetRegionStart 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memset 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fputs 0000000000000000 DF *UND* 0000000000000000 GCC_3.3 _Unwind_FindEnclosingFunction 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_GetTextRelBase 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 setgroups 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 stdout 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 madvise 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3 realpath 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawn_file_actions_adddup2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pow 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sigaltstack 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_self 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 trunc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __strncat_chk 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_setstacksize 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sigemptyset 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_detach 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __fxstat64 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_broadcast 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strtol 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_atexit 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 round 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sigaddset 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_RaiseException 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.15 posix_spawnp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memcmp 0000000000000000 D *UND* 0000000000000000 napi_queue_async_work 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_wrlock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 floor 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __vsnprintf_chk 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_key_create 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 close 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutexattr_destroy 0000000000000000 D *UND* 0000000000000000 napi_throw_error 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3 __ctype_toupper_loc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 poll 0000000000000000 D *UND* 0000000000000000 napi_reject_deferred 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 signal 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getcwd 0000000000000000 w D *UND* 0000000000000000 __gmon_start__ 0000000000000000 D *UND* 0000000000000000 napi_get_value_string_utf8 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_setsigmask 0000000000000000 D *UND* 0000000000000000 napi_create_promise 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dup2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_getguardsize 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __xstat64 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_getstack 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strerror 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getenv 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 read 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memrchr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_rdlock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fmod 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fork 0000000000000000 DF *UND* 0000000000000000 GCC_3.3 _Unwind_Backtrace 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawn_file_actions_destroy 0000000000000000 D *UND* 0000000000000000 napi_get_value_bool 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 setuid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.9 pipe2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __snprintf_chk 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_SetIP 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dlsym 0000000000000000 D *UND* 0000000000000000 napi_create_error 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 access 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 ioctl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strncpy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 localtime_r 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memmove 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 syscall 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 readlink 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fma 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getuid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sin 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strlen 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_setflags 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawn_file_actions_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strstr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_key_delete 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_getattr_np 0000000000000000 D *UND* 0000000000000000 napi_get_buffer_info 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 stderr 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_Resume 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_signal 0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.18 __cxa_thread_atexit_impl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_trylock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 writev 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 clock_gettime 0000000000000000 D *UND* 0000000000000000 napi_delete_async_work 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_getspecific 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_condattr_destroy 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_DeleteException 0000000000000000 D *UND* 0000000000000000 napi_create_function 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 prctl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 waitpid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 lseek64 0000000000000000 D *UND* 0000000000000000 napi_set_named_property 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 cos 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_init 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_GetIP 0000000000000000 w D *UND* 0000000000000000 _ITM_registerTMCloneTable 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 execvp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 ceil 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 environ 0000000000000000 D *UND* 0000000000000000 napi_get_cb_info 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutexattr_init 0000000000000000 D *UND* 0000000000000000 napi_coerce_to_object 0000000000000000 D *UND* 0000000000000000 napi_throw 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 mprotect 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.14 memcpy 0000000000000000 w D *UND* 0000000000000000 _ITM_deregisterTMCloneTable 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fcntl 0000000000000000 DF *UND* 0000000000000000 GCC_4.2.0 _Unwind_GetIPInfo 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 free 0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_finalize 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_unlock 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_GetDataRelBase 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_lock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dl_iterate_phdr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 sched_getaffinity 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_SetGR 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memchr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 open 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3 __tls_get_addr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 log10 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_wait 0000000000000000 D *UND* 0000000000000000 napi_create_async_work 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sysconf 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 munmap 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 log2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.3 pthread_condattr_setclock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 bcmp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_create 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_setsigdefault 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 abort 0000000000000000 D *UND* 0000000000000000 napi_create_string_utf8 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_condattr_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_sigmask 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutexattr_settype 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 __environ 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 mmap 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __errno_location 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 _exit 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 write 0000000000000000 DF *UND* 0000000000000000 GCC_3.3 _Unwind_GetCFA 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getrusage 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_unlock 0000000000000000 DF *UND* 0000000000000000 GCC_3.0 _Unwind_GetLanguageSpecificData 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sched_yield 0000000000000000 D *UND* 0000000000000000 napi_create_object 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 setgid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 chdir 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 open64 000000000039bbd0 g DF .text 000000000000032a Base napi_register_module_v1 0000000001ddd750 g DF .text 00000000000002e5 Base rust_eh_personality
There is `0000000000000000 w DF *UND* 0000000000000000 GLIBC_2.18 __cxa_thread_atexit_impl` introduced by https://github.com/rust-lang/rust/issues/36826 ### `objdump` in current branch
Symbols next-swc.linux-x64-gnu.node: file format elf64-x86-64 DYNAMIC SYMBOL TABLE: 0000000000000000 w D *UND* 0000000000000000 Base __gmon_start__ 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memcpy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 trunc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3 __tls_get_addr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 bcmp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memmove 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memset 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_lock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_trylock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memcmp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_unlock 0000000000000000 D *UND* 0000000000000000 Base napi_create_function 0000000000000000 D *UND* 0000000000000000 Base napi_set_named_property 0000000000000000 D *UND* 0000000000000000 Base napi_create_string_utf8 0000000000000000 D *UND* 0000000000000000 Base napi_coerce_to_object 0000000000000000 D *UND* 0000000000000000 Base napi_get_cb_info 0000000000000000 D *UND* 0000000000000000 Base napi_create_error 0000000000000000 D *UND* 0000000000000000 Base napi_throw 0000000000000000 D *UND* 0000000000000000 Base napi_throw_error 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fma 0000000000000000 D *UND* 0000000000000000 Base napi_create_object 0000000000000000 D *UND* 0000000000000000 Base napi_create_promise 0000000000000000 D *UND* 0000000000000000 Base napi_create_async_work 0000000000000000 D *UND* 0000000000000000 Base napi_queue_async_work 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strlen 0000000000000000 D *UND* 0000000000000000 Base napi_get_value_string_utf8 0000000000000000 D *UND* 0000000000000000 Base napi_get_value_bool 0000000000000000 D *UND* 0000000000000000 Base napi_typeof 0000000000000000 D *UND* 0000000000000000 Base napi_get_buffer_info 0000000000000000 D *UND* 0000000000000000 Base napi_reject_deferred 0000000000000000 D *UND* 0000000000000000 Base napi_resolve_deferred 0000000000000000 D *UND* 0000000000000000 Base napi_delete_async_work 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 close 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pow 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 round 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 localtime_r 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 log10 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 cos 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sin 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fmod 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 ceil 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_wait 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 sched_getaffinity 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sysconf 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.4 __xpg_strerror_r 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 syscall 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __errno_location 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 read 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 open64 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 poll 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 log2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 munmap 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 mmap 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dl_iterate_phdr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 clock_gettime 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getrusage 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 snprintf 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 access 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 vsnprintf 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 madvise 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strerror 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 mprotect 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_setspecific 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memchr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3 realpath 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getenv 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_key_create 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 stderr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fputs 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strncat 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 environ 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3 __ctype_toupper_loc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strncpy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strstr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 strtol 0000000000000000 DO *UND* 0000000000000000 GLIBC_2.2.5 stdout 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawn_file_actions_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutexattr_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_unlock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sched_yield 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getcwd 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_rdlock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_rwlock_wrlock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 getuid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 write 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fcntl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 lseek64 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 writev 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 memrchr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 ioctl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 waitpid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_broadcast 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_condattr_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.3 pthread_condattr_setclock 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_condattr_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_signal 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sigaltstack 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 abort 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 signal 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_self 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_getattr_np 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_getstack 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 malloc 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 free 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.3.2 pthread_cond_destroy 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutexattr_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutexattr_settype 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_mutex_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_getspecific 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_key_delete 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dlsym 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 readlink 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 chdir 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.9 pipe2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_setstacksize 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_create 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 prctl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_detach 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_attr_getguardsize 0000000000000000 w D *UND* 0000000000000000 Base __cxa_thread_atexit_impl 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawn_file_actions_init 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawn_file_actions_adddup2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sigemptyset 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_setsigmask 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 sigaddset 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_setsigdefault 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnattr_setflags 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fork 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 posix_spawnp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 _exit 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dup2 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 setgroups 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 setgid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 setuid 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 pthread_sigmask 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 execvp 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fprintf 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fflush 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 dladdr 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 fwrite 0000000000000000 DF *UND* 0000000000000000 GLIBC_2.2.5 __cxa_atexit 0000000002830dc0 g DF .text 00000000000002e5 Base rust_eh_personality 0000000000e10380 g DF .text 000000000000032a Base napi_register_module_v1
No more `GLIBC_2.18` symbols. Confirm it works on `centos:7` docker image. --- .github/workflows/build_test_deploy.yml | 616 +++++------------- packages/next-swc/.cargo/config.toml | 2 +- .../napi/npm/android-arm-eabi/README.md | 3 + .../napi/npm/android-arm-eabi/package.json | 18 + packages/next-swc/package.json | 1 + packages/next/package.json | 2 +- scripts/install-native.mjs | 1 + yarn.lock | 8 +- 8 files changed, 180 insertions(+), 471 deletions(-) create mode 100644 packages/next-swc/crates/napi/npm/android-arm-eabi/README.md create mode 100644 packages/next-swc/crates/napi/npm/android-arm-eabi/package.json diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 7906496c0d9a..e2b02075f956 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -518,13 +518,6 @@ jobs: - build - build-wasm - build-native - - build-windows-i686 - - build-windows-aarch64 - - build-linux-musl - - build-linux-arm7 - - build-linux-aarch64-gnu - - build-android-aarch64 - - build-linux-aarch64-musl env: NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }} steps: @@ -606,7 +599,7 @@ jobs: uses: actions/setup-node@v2 if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: - node-version: 14 + node-version: 16 check-latest: true - name: Install @@ -621,14 +614,14 @@ jobs: if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: path: ~/.cargo/registry - key: stable-ubuntu-18.04-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }} + key: stable-ubuntu-18.04-cargo-registry - name: Cache cargo index uses: actions/cache@v1 if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} with: path: ~/.cargo/git - key: stable-ubuntu-18.04-node@14-cargo-index-trimmed-${{ hashFiles('**/Cargo.lock') }} + key: stable-ubuntu-18.04-cargo-index # We use week in the turbo cache key to keep the cache from infinitely growing - id: get-week @@ -660,9 +653,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.28 - + - run: npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 - name: Build if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} run: turbo run build-native --cache-dir=".turbo" @@ -747,95 +738,137 @@ jobs: # Build binaries for publishing build-native: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} strategy: + fail-fast: false matrix: - os: [ubuntu-18.04, macos-latest, windows-latest] - description: [default] - include: - - os: ubuntu-18.04 - target: x86_64-unknown-linux-gnu - name: linux-x64-gnu - - os: windows-latest - target: x86_64-pc-windows-msvc - name: win32-x64-msvc - - os: macos-latest - target: x86_64-apple-darwin - name: darwin-x64 - - os: macos-latest - target: aarch64-apple-darwin - name: darwin-arm64 - description: m1 - - name: next-swc - ${{ matrix.os }} - ${{ matrix.target }} - node@14 - runs-on: ${{ matrix.os }} - + settings: + - host: macos-latest + target: 'x86_64-apple-darwin' + build: | + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release + strip -x packages/next-swc/native/next-swc.*.node + - host: windows-latest + build: | + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release + target: 'x86_64-pc-windows-msvc' + - host: windows-latest + build: | + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release --target i686-pc-windows-msvc + target: 'i686-pc-windows-msvc' + - host: ubuntu-latest + target: 'x86_64-unknown-linux-gnu' + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig + # Node.js in Baidu need to compatible with `GLIBC_2.12` + build: >- + set -e && + rustup toolchain install nightly-2021-11-15 && + rustup default nightly-2021-11-15 && + rustup target add x86_64-unknown-linux-gnu && + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 && + turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 && + llvm-strip -x packages/next-swc/native/next-swc.*.node + - host: ubuntu-latest + target: 'x86_64-unknown-linux-musl' + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + build: >- + set -e && + rustup toolchain install nightly-2021-11-15 && + rustup default nightly-2021-11-15 && + rustup target add x86_64-unknown-linux-musl && + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 && + turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl && + strip packages/next-swc/native/next-swc.*.node + - host: macos-latest + target: 'aarch64-apple-darwin' + build: | + sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; + export CC=$(xcrun -f clang); + export CXX=$(xcrun -f clang++); + SYSROOT=$(xcrun --sdk macosx --show-sdk-path); + export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-apple-darwin + strip -x packages/next-swc/native/next-swc.*.node + - host: ubuntu-latest + target: 'aarch64-unknown-linux-gnu' + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine-zig + build: >- + set -e && + rustup toolchain install nightly-2021-11-15 && + rustup default nightly-2021-11-15 && + rustup target add aarch64-unknown-linux-gnu && + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 && + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu --zig --zig-abi-suffix 2.12 && + llvm-strip -x packages/next-swc/native/next-swc.*.node + - host: ubuntu-18.04 + target: 'armv7-unknown-linux-gnueabihf' + setup: | + sudo apt-get update + sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf -y + build: | + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release --target armv7-unknown-linux-gnueabihf + arm-linux-gnueabihf-strip packages/next-swc/native/next-swc.*.node + - host: ubuntu-latest + target: aarch64-linux-android + build: | + export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" + export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang" + export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android24-clang++" + export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}" + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-linux-android + ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-strip packages/next-swc/native/next-swc.*.node + - host: ubuntu-latest + target: armv7-linux-androideabi + build: | + export CARGO_TARGET_ARMV7_LINUX_ANDROIDEABI_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" + export CC="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang" + export CXX="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi24-clang++" + export PATH="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin:${PATH}" + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release --target armv7-linux-androideabi + ${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-strip packages/next-swc/native/next-swc.*.node + - host: ubuntu-latest + target: 'aarch64-unknown-linux-musl' + docker: ghcr.io/napi-rs/napi-rs/nodejs-rust:lts-alpine + build: >- + set -e && + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 && + rustup toolchain install nightly-2021-11-15 && + rustup default nightly-2021-11-15 && + rustup target add aarch64-unknown-linux-musl && + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl && + llvm-strip -x packages/next-swc/native/next-swc.*.node + - host: windows-latest + target: 'aarch64-pc-windows-msvc' + build: | + npm i -g @napi-rs/cli@2.4.4 turbo@1.0.28 + turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-pc-windows-msvc + if: ${{ needs.build.outputs.isRelease == 'true' }} + needs: build + name: stable - ${{ matrix.settings.target }} - node@16 + runs-on: ${{ matrix.settings.host }} steps: # https://github.com/actions/virtual-environments/issues/1187 - name: tune linux network run: sudo ethtool -K eth0 tx off rx off - if: ${{ matrix.os == 'ubuntu-18.04' }} + if: ${{ matrix.settings.host == 'ubuntu-18.04' }} + - name: tune linux network + run: sudo ethtool -K eth0 tx off rx off + if: ${{ matrix.settings.host == 'ubuntu-latest' }} - name: tune windows network run: Disable-NetAdapterChecksumOffload -Name * -TcpIPv4 -UdpIPv4 -TcpIPv6 -UdpIPv6 - if: ${{ matrix.os == 'windows-latest' }} + if: ${{ matrix.settings.host == 'windows-latest' }} - name: tune mac network run: sudo sysctl -w net.link.generic.system.hwcksum_tx=0 && sudo sysctl -w net.link.generic.system.hwcksum_rx=0 - if: ${{ matrix.os == 'macos-latest' }} - - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - check-latest: true - + if: ${{ matrix.settings.host == 'macos-latest' }} # we use checkout here instead of the build cache since # it can fail to restore in different OS' - uses: actions/checkout@v2 - - # 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.28 - - - name: Install - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2021-11-15 - target: ${{ matrix.target }} - - - name: Cache cargo registry - uses: actions/cache@v1 - with: - path: ~/.cargo/registry - key: stable-${{ matrix.os }}-node@14-cargo-registry-trimmed-${{ hashFiles('**/Cargo.lock') }} - - - name: Cache cargo index - uses: actions/cache@v1 - with: - 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 }}- - 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' }} - run: | - sudo rm -Rf /Library/Developer/CommandLineTools/SDKs/*; - export CC=$(xcrun -f clang); - export CXX=$(xcrun -f clang++); - SYSROOT=$(xcrun --sdk macosx --show-sdk-path); - export CFLAGS="-isysroot $SYSROOT -isystem $SYSROOT"; # We use restore-key to pick latest cache. # We will not get exact match, but doc says # "If there are multiple partial matches for a restore key, the action returns the most recently created cache." @@ -844,65 +877,9 @@ jobs: uses: actions/cache@v2 with: path: ./packages/next-swc/target - key: next-swc-cargo-cache-${{ matrix.os }}--${{ hashFiles('**/Cargo.lock') }} + key: next-swc-cargo-cache-${{ matrix.settings.target }}--${{ hashFiles('**/Cargo.lock') }} restore-keys: | - next-swc-cargo-cache-${{ matrix.os }} - - - name: 'Build' - shell: bash - run: turbo run build-native --cache-dir=".turbo" -- --release --target ${{ matrix.target }} - env: - MACOSX_DEPLOYMENT_TARGET: '10.13' - - - name: Upload artifact - uses: actions/upload-artifact@v2.2.4 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.${{ matrix.name }}.node - - - name: Clear the cargo caches - run: | - cargo install cargo-cache --no-default-features --features ci-autoclean - cargo-cache - - build-windows-i686: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - windows-i686 - node@14 - runs-on: windows-latest - env: - CARGO_PROFILE_RELEASE_CODEGEN_UNITS: 32 - CARGO_PROFILE_RELEASE_LTO: 'false' - steps: - - name: Install node x86 - run: | - choco install nodejs-lts --x86 -y --force - refreshenv - - - name: Set 32bit Node.js path - run: | - echo "C:\\Program Files (x86)\\nodejs" >> $GITHUB_PATH - shell: bash - - - name: Node.js arch - run: node -e "console.log(process.arch)" - - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 - - # 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.28 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2021-11-15 - override: true - target: i686-pc-windows-msvc - + next-swc-cargo-cache-${{ matrix.settings.target }} - name: Turbo Cache id: turbo-cache uses: actions/cache@v2 @@ -914,349 +891,58 @@ jobs: turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - - name: Build - shell: bash - run: turbo run build-native --cache-dir=".turbo" -- --release --target i686-pc-windows-msvc - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.win32-ia32-msvc.node - - build-windows-aarch64: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - windows-aarch64 - node@14 - runs-on: windows-latest - steps: - name: Setup node uses: actions/setup-node@v2 + if: ${{ !matrix.settings.docker }} with: - node-version: 14 - - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 - - # 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.28 - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2021-11-15 - 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 }}- - turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - - - name: Build - shell: bash - run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-pc-windows-msvc - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.win32-arm64-msvc.node - - build-linux-musl: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - linux-musl - node@lts - runs-on: ubuntu-latest - steps: - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 - - - name: Login to registry - run: | - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL - env: - DOCKER_REGISTRY_URL: ghcr.io - DOCKER_USERNAME: ${{ github.actor }} - DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }} - - - name: Cache - uses: actions/cache@v2 - with: - path: | - target/ - key: linux-musl-publish-integration - - - name: Pull docker image - run: | - 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 }}- - 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):/build -w /build builder sh -c "npm i -g @napi-rs/cli@1.2.1 && npm i -g turbo@1.0.28 && turbo run build-native --cache-dir=".turbo" -- --release --target x86_64-unknown-linux-musl" - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.linux-x64-musl.node - - build-linux-aarch64-gnu: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - aarch64-unknown-linux-gnu - node@14 - runs-on: ubuntu-18.04 - steps: - - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 - - # 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.28 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2021-11-15 - override: true - target: aarch64-unknown-linux-gnu - - - name: Cache - uses: actions/cache@v2 - with: - path: | - target/ - key: aarch64-linux-gnu-publish-integration - - - name: Install cross compile toolchain - run: | - 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 }}- - turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - - - name: Cross build aarch64 - if: ${{ steps.binary-cache.outputs.cache-hit != 'true' }} - run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-gnu - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.linux-arm64-gnu.node - - build-linux-aarch64-musl: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - aarch64-unknown-linux-musl - node@14 - runs-on: ubuntu-18.04 - steps: - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 + node-version: 16 + check-latest: true + cache: yarn - # 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.28 - - name: Install Rust + - name: Install uses: actions-rs/toolchain@v1 + if: ${{ !matrix.settings.docker }} with: profile: minimal - toolchain: nightly-2021-11-15 override: true - target: aarch64-unknown-linux-musl - - - name: Cache - uses: actions/cache@v2 - with: - path: | - target/ - key: aarch64-linux-musl-publish-integration - - - name: Install cross compile toolchain - run: | - 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 }}- - turbo-${{ github.job }}-${{ github.ref_name }}-${{ needs.build.outputs.weekNum }}- - turbo-${{ github.job }}-canary-${{ needs.build.outputs.weekNum }}- - - - name: Cross build aarch64 - run: turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-unknown-linux-musl - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.linux-arm64-musl.node - - build-linux-arm7: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - arm7-unknown-linux-gnu - node@14 - runs-on: ubuntu-18.04 - steps: - - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 - - # 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.28 - - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal toolchain: nightly-2021-11-15 - override: true - target: armv7-unknown-linux-gnueabihf + target: ${{ matrix.settings.target }} - - name: Cache + - name: Cache cargo registry uses: actions/cache@v2 with: - path: | - target/ - key: arm7-linux-gnu-publish-integration - - - name: Install cross compile toolchain - run: | - sudo apt-get update - sudo apt-get install gcc-arm-linux-gnueabihf -y + path: ~/.cargo/registry + key: ${{ matrix.settings.target }}-cargo-registry - - name: Turbo Cache - id: turbo-cache + - name: Cache cargo index 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 - run: turbo run build-native --cache-dir=".turbo" -- --release --target armv7-unknown-linux-gnueabihf - - - name: Upload artifact - uses: actions/upload-artifact@v2 - with: - name: next-swc-binaries - path: packages/next-swc/native/next-swc.linux-arm-gnueabihf.node - - build-android-aarch64: - needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} - name: next-swc - Android - aarch64 - runs-on: macos-latest - steps: - - name: Setup node - uses: actions/setup-node@v2 - with: - node-version: 14 - - # we use checkout here instead of the build cache since - # it can fail to restore in different OS' - - uses: actions/checkout@v2 - - # 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.28 + path: ~/.cargo/git + key: ${{ matrix.settings.target }}-cargo-index - - name: Install Rust - uses: actions-rs/toolchain@v1 - with: - profile: minimal - toolchain: nightly-2021-11-15 - override: true - target: aarch64-linux-android + - name: Setup toolchain + run: ${{ matrix.settings.setup }} + if: ${{ matrix.settings.setup }} + shell: bash - - name: Turbo Cache - id: turbo-cache - uses: actions/cache@v2 + - name: Build in docker + uses: addnab/docker-run-action@v3 + if: ${{ matrix.settings.docker }} 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 }}- + image: ${{ matrix.settings.docker }} + options: -v ${{ env.HOME }}/.cargo/git:/root/.cargo/git -v ${{ env.HOME }}/.cargo/registry:/root/.cargo/registry -v ${{ github.workspace }}:/build -w /build + run: ${{ matrix.settings.build }} - - name: Build + - name: 'Build' + run: ${{ matrix.settings.build }} + if: ${{ !matrix.settings.docker }} shell: bash - run: | - export CARGO_TARGET_AARCH64_LINUX_ANDROID_LINKER="${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/darwin-x86_64/bin/aarch64-linux-android24-clang" - turbo run build-native --cache-dir=".turbo" -- --release --target aarch64-linux-android - name: Upload artifact uses: actions/upload-artifact@v2 with: name: next-swc-binaries - path: packages/next-swc/native/next-swc.android-arm64.node + path: packages/next-swc/native/next-swc.*.node build-wasm: needs: build diff --git a/packages/next-swc/.cargo/config.toml b/packages/next-swc/.cargo/config.toml index 1fb099927fed..1d7e537b13c3 100644 --- a/packages/next-swc/.cargo/config.toml +++ b/packages/next-swc/.cargo/config.toml @@ -21,7 +21,7 @@ rustflags = [ ] [target.aarch64-unknown-linux-musl] -linker = "aarch64-linux-gnu-gcc" +linker = "aarch64-linux-musl-gcc" rustflags = [ "-C", "target-feature=-crt-static", diff --git a/packages/next-swc/crates/napi/npm/android-arm-eabi/README.md b/packages/next-swc/crates/napi/npm/android-arm-eabi/README.md new file mode 100644 index 000000000000..7044554db68c --- /dev/null +++ b/packages/next-swc/crates/napi/npm/android-arm-eabi/README.md @@ -0,0 +1,3 @@ +# `@next/swc-android-arm-eabi` + +This is the **android-arm-eabi** binary for `@next/swc` diff --git a/packages/next-swc/crates/napi/npm/android-arm-eabi/package.json b/packages/next-swc/crates/napi/npm/android-arm-eabi/package.json new file mode 100644 index 000000000000..69ec8a4b23a9 --- /dev/null +++ b/packages/next-swc/crates/napi/npm/android-arm-eabi/package.json @@ -0,0 +1,18 @@ +{ + "name": "@next/swc-android-arm-eabi", + "version": "0.0.0", + "os": [ + "android" + ], + "cpu": [ + "arm" + ], + "main": "next-swc.android-arm-eabi.node", + "files": [ + "next-swc.android-arm-eabi.node" + ], + "license": "MIT", + "engines": { + "node": ">= 10" + } +} diff --git a/packages/next-swc/package.json b/packages/next-swc/package.json index 9f16469b8681..f71acc377734 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -16,6 +16,7 @@ "armv7-unknown-linux-gnueabihf", "aarch64-apple-darwin", "aarch64-linux-android", + "arm-linux-androideabi", "x86_64-unknown-freebsd", "x86_64-unknown-linux-musl", "aarch64-unknown-linux-musl", diff --git a/packages/next/package.json b/packages/next/package.json index 316aee06f97a..d681c2e8b8a1 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -115,7 +115,7 @@ "@babel/traverse": "7.15.0", "@babel/types": "7.15.0", "@hapi/accept": "5.0.2", - "@napi-rs/cli": "1.2.1", + "@napi-rs/cli": "2.4.4", "@napi-rs/triples": "1.0.3", "@next/polyfill-module": "12.1.0", "@next/polyfill-nomodule": "12.1.0", diff --git a/scripts/install-native.mjs b/scripts/install-native.mjs index a52305df8881..198b6385e13b 100644 --- a/scripts/install-native.mjs +++ b/scripts/install-native.mjs @@ -19,6 +19,7 @@ import fs from 'fs-extra' version: '1.0.0', optionalDependencies: { '@next/swc-android-arm64': 'canary', + '@next/swc-android-arm-eabi': 'canary', '@next/swc-darwin-arm64': 'canary', '@next/swc-darwin-x64': 'canary', '@next/swc-linux-arm-gnueabihf': 'canary', diff --git a/yarn.lock b/yarn.lock index 1ee4e9b20c7e..08be08516ea1 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3706,10 +3706,10 @@ call-me-maybe "^1.0.1" glob-to-regexp "^0.3.0" -"@napi-rs/cli@1.2.1": - version "1.2.1" - resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-1.2.1.tgz#eccdf9e0835aec3adcef30074bf69c110ea65960" - integrity sha512-7FoYn1JSK5rTIG9KcKfYnZL/O0UjUMMuzZCXd//bJdkLw0Xx9EqQJs1X/Mg4KqywJYb79LDfxRMiJRSukPGDNw== +"@napi-rs/cli@2.4.4": + version "2.4.4" + resolved "https://registry.yarnpkg.com/@napi-rs/cli/-/cli-2.4.4.tgz#878a38f0fba1709d89d66eba706745ce728a61a5" + integrity sha512-f+tvwCv1ka24dBqI2DgBhR7Oxl3DKHOp4onxLXwyBFt6iCADnr3YZIr1/2Iq5r3uqxFgaf01bfPsRQZPkEp0kQ== "@napi-rs/triples@1.0.3", "@napi-rs/triples@^1.0.3": version "1.0.3" From aa35aa13f11ff9188c09a916bd8eaee0dfb62003 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Orb=C3=A1n?= Date: Fri, 18 Feb 2022 17:42:05 +0100 Subject: [PATCH 06/43] chore: clarify GitHub action (bot) comments (#34546) For anyone landing on this PR, if you are new to contributing to open source, here is a helpful video with some good tips: [How to Contribute to Open Source (Next.js) ](https://www.youtube.com/watch?v=cuoNzXFLitc) We use two GitHub Actions (here bots) to help us maintain the project better: 1. Stalebot When an issue is triaged, we look for a reproduction and clear steps to reproduce the reported issue. This helps us identify bugs easier, which will result in a quicker resolution of the bug. Skipping these steps could mean that we will not be able to investigate. In these cases, the issue will receive a `please add a complete reproduction` label, that indicates to the original poster (or those following along in the issue) that we would like them to post the missed steps. Unless that happens within 30 days, we are marking the issue as stale. A day after, the issue is automatically closed. If someone finds this now-closed issue later, through the Stalebot we encourage that a new issue will be opened and reference the old one if it holds important/relevant contextual information. The reason is that newer releases might have already fixed the issue that was reported in the first place. This is indicated in the bug report issue template forms. 2. Lockbot This bot is similar to Stalebot, but it strictly operates on **already closed/resolved** issues, it **never** closes ongoing/open issue discussions. An issue can be closed for multiple reasons. It either has been closed by the original poster because they found the solution, or a PR merge included a fix in a recent Next.js release. It is important to look for the reason before commenting. If the issue was seemingly locked by accident, through the Lockbot comment we encourage that a new issue will be opened and reference the old one if it holds important/relevant contextual information. The reason is that newer releases might have already fixed the issue that was reported in the first place. This is indicated in the bug report issue template forms. Important: Issues can be closed/locked by accident, and we encourage everyone to feel welcome opening a new case and reference back to the old issue. Our team values everyone's opinion and we would like to make sure that we resolve any confusion in each individual case. --- .github/workflows/lock.yml | 4 ++-- .github/workflows/stale.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/lock.yml b/.github/workflows/lock.yml index bf90a0aaf429..41b7e8c78beb 100644 --- a/.github/workflows/lock.yml +++ b/.github/workflows/lock.yml @@ -20,8 +20,8 @@ jobs: steps: - uses: dessant/lock-threads@v3 with: - github-token: ${{ secrets.LOCK_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} issue-inactive-days: 30 - issue-comment: 'This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.' + issue-comment: 'This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.' pr-inactive-days: 30 log-output: true diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 9c858d67608b..cb6abe0bc488 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -16,7 +16,7 @@ jobs: with: repo-token: ${{ secrets.STALE_TOKEN }} only-labels: 'please add a complete reproduction' - close-issue-message: 'This issue has been automatically closed after 30 days of inactivity with no reproduction. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.' + close-issue-message: 'This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think this was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.' days-before-issue-close: 1 days-before-issue-stale: 30 days-before-pr-close: -1 From 44bc4d92f5e61da28fd658494e80eea3f59d3b34 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Fri, 18 Feb 2022 12:02:13 -0600 Subject: [PATCH 07/43] v12.1.1-canary.0 --- 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 3aa8531b8bb4..6f5ea94c351e 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "12.1.0" + "version": "12.1.1-canary.0" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 4e57156340a9..80080f1cca89 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.1.0", + "version": "12.1.1-canary.0", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index c141e9f35c9d..0809099cd2f7 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.1.0", + "version": "12.1.1-canary.0", "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.1.0", + "@next/eslint-plugin-next": "12.1.1-canary.0", "@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 16f5abeb55cb..1c49757b9d03 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.1.0", + "version": "12.1.1-canary.0", "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 90bd9a3bccf2..a69a2c0bf255 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.1.0", + "version": "12.1.1-canary.0", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 25b85d8f7df4..c89409fea431 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "12.1.0", + "version": "12.1.1-canary.0", "license": "MIT", "dependencies": { "chalk": "4.1.0", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 42a1b5c61c38..fa4c647088a0 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "12.1.0", + "version": "12.1.1-canary.0", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 06c4c6b95eb7..98e7de195679 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "12.1.0", + "version": "12.1.1-canary.0", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 2fedae0f986f..14d507724998 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.1.0", + "version": "12.1.1-canary.0", "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 9f6788d25e1b..b854ebc7b32d 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.1.0", + "version": "12.1.1-canary.0", "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 3882f7dc5d81..41e661030c92 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.1.0", + "version": "12.1.1-canary.0", "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 f71acc377734..21019962a9a5 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "12.1.0", + "version": "12.1.1-canary.0", "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 d681c2e8b8a1..a506ebba60e7 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "12.1.0", + "version": "12.1.1-canary.0", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -69,7 +69,7 @@ ] }, "dependencies": { - "@next/env": "12.1.0", + "@next/env": "12.1.1-canary.0", "caniuse-lite": "^1.0.30001283", "postcss": "8.4.5", "styled-jsx": "5.0.0", @@ -117,11 +117,11 @@ "@hapi/accept": "5.0.2", "@napi-rs/cli": "2.4.4", "@napi-rs/triples": "1.0.3", - "@next/polyfill-module": "12.1.0", - "@next/polyfill-nomodule": "12.1.0", - "@next/react-dev-overlay": "12.1.0", - "@next/react-refresh-utils": "12.1.0", - "@next/swc": "12.1.0", + "@next/polyfill-module": "12.1.1-canary.0", + "@next/polyfill-nomodule": "12.1.1-canary.0", + "@next/react-dev-overlay": "12.1.1-canary.0", + "@next/react-refresh-utils": "12.1.1-canary.0", + "@next/swc": "12.1.1-canary.0", "@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 a1d512c8a6f7..9ec2fdd3d028 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.1.0", + "version": "12.1.1-canary.0", "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 f797514e1ac9..0389263d1fe1 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.1.0", + "version": "12.1.1-canary.0", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", From 9e77ef4ec6d9faaeb0e01469337382b04ba34c42 Mon Sep 17 00:00:00 2001 From: Steven Date: Fri, 18 Feb 2022 13:44:32 -0500 Subject: [PATCH 08/43] Fix `next/image` incorrectly warning for `position: absolute` parent (#34551) - Fixes #33007 - Fixes #31340 --- packages/next/client/image.tsx | 3 ++- .../default/pages/layout-fill-inside-nonrelative.js | 4 ++++ test/integration/image-component/default/test/index.test.js | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/next/client/image.tsx b/packages/next/client/image.tsx index 2bc5f9ed8cb1..c16b26a05678 100644 --- a/packages/next/client/image.tsx +++ b/packages/next/client/image.tsx @@ -280,7 +280,8 @@ function handleLoading( } else if ( layout === 'fill' && parent.position !== 'relative' && - parent.position !== 'fixed' + parent.position !== 'fixed' && + parent.position !== 'absolute' ) { console.warn( `Image with src "${src}" may not render properly with a parent using position:"${parent.position}". Consider changing the parent style to position:"relative" with a width and height.` diff --git a/test/integration/image-component/default/pages/layout-fill-inside-nonrelative.js b/test/integration/image-component/default/pages/layout-fill-inside-nonrelative.js index 855c370058fe..2c831a789e89 100644 --- a/test/integration/image-component/default/pages/layout-fill-inside-nonrelative.js +++ b/test/integration/image-component/default/pages/layout-fill-inside-nonrelative.js @@ -2,6 +2,7 @@ import React from 'react' import Image from 'next/image' import jpg from '../public/test.jpg' import png from '../public/test.png' +import avif from '../public/test.avif' import webp from '../public/test.webp' const Page = () => { @@ -14,6 +15,9 @@ const Page = () => {
+
+ +
diff --git a/test/integration/image-component/default/test/index.test.js b/test/integration/image-component/default/test/index.test.js index 7d406b9e6335..2821fe553d6c 100644 --- a/test/integration/image-component/default/test/index.test.js +++ b/test/integration/image-component/default/test/index.test.js @@ -669,6 +669,9 @@ function runTests(mode) { expect(warnings).not.toMatch( /Image with src (.*)png(.*) may not render properly/gm ) + expect(warnings).not.toMatch( + /Image with src (.*)avif(.*) may not render properly/gm + ) expect(warnings).not.toMatch( /Image with src (.*)webp(.*) may not render properly/gm ) From 670eb03841d242cadfd6040c323f256ffde718fa Mon Sep 17 00:00:00 2001 From: Mitchell Abbott Date: Fri, 18 Feb 2022 12:51:02 -0600 Subject: [PATCH 09/43] Convert custom-server-hapi Example to Typescript (#34507) In the contributing doc, it mentions "Examples should be TypeScript first, if possible" so I thought about converting some examples to be typescript along with updating a couple in my free time. Let me know if that would be an issue. ## 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/custom-server-hapi/next-env.d.ts | 5 ++++ examples/custom-server-hapi/next-wrapper.js | 26 ------------------- examples/custom-server-hapi/nodemon.json | 5 ++++ examples/custom-server-hapi/package.json | 19 ++++++++++---- .../custom-server-hapi/pages/{a.js => a.tsx} | 0 .../custom-server-hapi/pages/{b.js => b.tsx} | 0 .../pages/{index.js => index.tsx} | 0 .../custom-server-hapi/server/next-wrapper.ts | 16 ++++++++++++ .../{server.js => server/server.ts} | 6 ++--- examples/custom-server-hapi/tsconfig.json | 21 +++++++++++++++ .../custom-server-hapi/tsconfig.server.json | 12 +++++++++ 11 files changed, 76 insertions(+), 34 deletions(-) create mode 100644 examples/custom-server-hapi/next-env.d.ts delete mode 100644 examples/custom-server-hapi/next-wrapper.js create mode 100644 examples/custom-server-hapi/nodemon.json rename examples/custom-server-hapi/pages/{a.js => a.tsx} (100%) rename examples/custom-server-hapi/pages/{b.js => b.tsx} (100%) rename examples/custom-server-hapi/pages/{index.js => index.tsx} (100%) create mode 100644 examples/custom-server-hapi/server/next-wrapper.ts rename examples/custom-server-hapi/{server.js => server/server.ts} (81%) create mode 100644 examples/custom-server-hapi/tsconfig.json create mode 100644 examples/custom-server-hapi/tsconfig.server.json diff --git a/examples/custom-server-hapi/next-env.d.ts b/examples/custom-server-hapi/next-env.d.ts new file mode 100644 index 000000000000..4f11a03dc6cc --- /dev/null +++ b/examples/custom-server-hapi/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/custom-server-hapi/next-wrapper.js b/examples/custom-server-hapi/next-wrapper.js deleted file mode 100644 index 431191084fa8..000000000000 --- a/examples/custom-server-hapi/next-wrapper.js +++ /dev/null @@ -1,26 +0,0 @@ -const nextHandlerWrapper = (app) => { - const handler = app.getRequestHandler() - return async ({ raw, url, query }, h) => { - url.query = query - await handler(raw.req, raw.res, url) - return h.close - } -} - -const pathWrapper = - (app, pathName, opts) => - async ({ raw, query, params }, h) => { - const html = await app.render( - raw.req, - raw.res, - pathName, - { ...query, ...params }, - opts - ) - return h.response(html).code(raw.res.statusCode) - } - -module.exports = { - pathWrapper, - nextHandlerWrapper, -} diff --git a/examples/custom-server-hapi/nodemon.json b/examples/custom-server-hapi/nodemon.json new file mode 100644 index 000000000000..c9fa4132a155 --- /dev/null +++ b/examples/custom-server-hapi/nodemon.json @@ -0,0 +1,5 @@ +{ + "watch": ["server"], + "exec": "ts-node --project tsconfig.server.json server/server.ts", + "ext": "js ts" +} diff --git a/examples/custom-server-hapi/package.json b/examples/custom-server-hapi/package.json index 6de2563a24e1..60b0362bd7c6 100644 --- a/examples/custom-server-hapi/package.json +++ b/examples/custom-server-hapi/package.json @@ -1,15 +1,24 @@ { "private": true, "scripts": { - "dev": "node server.js", - "build": "next build", - "start": "cross-env NODE_ENV=production node server.js" + "dev": "nodemon", + "build": "next build && tsc --project tsconfig.server.json", + "start": "cross-env NODE_ENV=production node dist/server.js" }, "dependencies": { - "@hapi/hapi": "^18.3.1", - "cross-env": "^5.2.0", + "@hapi/hapi": "^20.2.1", + "cross-env": "^7.0.3", "next": "latest", "react": "^17.0.2", "react-dom": "^17.0.2" + }, + "devDependencies": { + "@types/hapi__hapi": "^20.0.10", + "@types/node": "^16.11.25", + "@types/react": "^17.0.39", + "@types/react-dom": "^17.0.11", + "nodemon": "^2.0.15", + "ts-node": "^10.5.0", + "typescript": "^4.5.5" } } diff --git a/examples/custom-server-hapi/pages/a.js b/examples/custom-server-hapi/pages/a.tsx similarity index 100% rename from examples/custom-server-hapi/pages/a.js rename to examples/custom-server-hapi/pages/a.tsx diff --git a/examples/custom-server-hapi/pages/b.js b/examples/custom-server-hapi/pages/b.tsx similarity index 100% rename from examples/custom-server-hapi/pages/b.js rename to examples/custom-server-hapi/pages/b.tsx diff --git a/examples/custom-server-hapi/pages/index.js b/examples/custom-server-hapi/pages/index.tsx similarity index 100% rename from examples/custom-server-hapi/pages/index.js rename to examples/custom-server-hapi/pages/index.tsx diff --git a/examples/custom-server-hapi/server/next-wrapper.ts b/examples/custom-server-hapi/server/next-wrapper.ts new file mode 100644 index 000000000000..596aac18c613 --- /dev/null +++ b/examples/custom-server-hapi/server/next-wrapper.ts @@ -0,0 +1,16 @@ +import type { NextServer } from 'next/dist/server/next' +import type { Lifecycle } from '@hapi/hapi' +import type { NextUrlWithParsedQuery } from 'next/dist/server/request-meta' + +const nextHandlerWrapper = (app: NextServer): Lifecycle.Method => { + const handler = app.getRequestHandler() + + return async ({ raw, url, query }, h) => { + const nextUrl = url as unknown as NextUrlWithParsedQuery + nextUrl.query = query + await handler(raw.req, raw.res, nextUrl) + return h.close + } +} + +export { nextHandlerWrapper } diff --git a/examples/custom-server-hapi/server.js b/examples/custom-server-hapi/server/server.ts similarity index 81% rename from examples/custom-server-hapi/server.js rename to examples/custom-server-hapi/server/server.ts index 90101efe9d8e..ea7dc52ef78e 100644 --- a/examples/custom-server-hapi/server.js +++ b/examples/custom-server-hapi/server/server.ts @@ -1,6 +1,6 @@ -const next = require('next') -const Hapi = require('@hapi/hapi') -const { /* pathWrapper, */ nextHandlerWrapper } = require('./next-wrapper') +import next from 'next' +import Hapi from '@hapi/hapi' +import { nextHandlerWrapper } from './next-wrapper' const port = parseInt(process.env.PORT, 10) || 3000 const dev = process.env.NODE_ENV !== 'production' diff --git a/examples/custom-server-hapi/tsconfig.json b/examples/custom-server-hapi/tsconfig.json new file mode 100644 index 000000000000..fe57f7dbf638 --- /dev/null +++ b/examples/custom-server-hapi/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["dom", "dom.iterable", "esnext"], + "baseUrl": ".", + "allowJs": true, + "skipLibCheck": true, + "strict": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve" + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] +} diff --git a/examples/custom-server-hapi/tsconfig.server.json b/examples/custom-server-hapi/tsconfig.server.json new file mode 100644 index 000000000000..0cf1e05d407a --- /dev/null +++ b/examples/custom-server-hapi/tsconfig.server.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "dist", + "lib": ["es2019"], + "target": "es2019", + "isolatedModules": false, + "noEmit": false + }, + "include": ["server/**/*.ts"] +} From 204a95586dccefb24bc0790f2a39f267310dc402 Mon Sep 17 00:00:00 2001 From: Gerald Monaco Date: Fri, 18 Feb 2022 11:07:19 -0800 Subject: [PATCH 10/43] Remove useMaybeDeferContent hook (#34506) --- packages/next/pages/_document.tsx | 391 ++++++++++------------ packages/next/server/render.tsx | 8 - packages/next/shared/lib/html-context.ts | 3 +- packages/next/shared/lib/utils.ts | 5 - test/unit/use-maybe-defer-content.test.ts | 12 - 5 files changed, 171 insertions(+), 248 deletions(-) delete mode 100644 test/unit/use-maybe-defer-content.test.ts diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index 6af1f81fc86a..309ae6321dcb 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -492,7 +492,6 @@ export class Head extends Component< unstable_runtimeJS, unstable_JsPreload, disableOptimizedLoading, - useMaybeDeferContent, optimizeCss, optimizeFonts, runtime, @@ -610,36 +609,96 @@ export class Head extends Component< inAmpMode ) - // Must use nested component to allow use of a custom hook - const DeferrableHead = () => { - const getDynamicHeadContent = () => { - return ( + return ( + + {!hasConcurrentFeatures && this.context.isDevelopment && ( <> - {head} - +