diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index a91050e1b4643..2e9f99ee1e851 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -3,4 +3,7 @@ # https://docs.github.com/en/repositories/working-with-files/using-files/viewing-a-file#ignore-commits-in-the-blame-view # chore(examples): use default prettier for examples/templates (#60530) -4466ba436b996263307171d344cca199e8087744 \ No newline at end of file +4466ba436b996263307171d344cca199e8087744 + +# chore: update prettier to 3.2.5 (#65092) +64b718c6618b6c419872abbf22163ae543ac259e diff --git a/Cargo.lock b/Cargo.lock index e3d3c4d22faff..a906a01e6dbab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8601,7 +8601,7 @@ version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets 0.52.0", + "windows-targets 0.52.5", ] [[package]] @@ -8636,17 +8636,18 @@ dependencies = [ [[package]] name = "windows-targets" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a18201040b24831fbb9e4eb208f8892e1f50a37feb53cc7ff887feb8f50e7cd" +checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm 0.52.0", - "windows_aarch64_msvc 0.52.0", - "windows_i686_gnu 0.52.0", - "windows_i686_msvc 0.52.0", - "windows_x86_64_gnu 0.52.0", - "windows_x86_64_gnullvm 0.52.0", - "windows_x86_64_msvc 0.52.0", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", + "windows_i686_gnullvm", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] [[package]] @@ -8663,9 +8664,9 @@ checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" [[package]] name = "windows_aarch64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb7764e35d4db8a7921e09562a0304bf2f93e0a51bfccee0bd0bb0b666b015ea" +checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" [[package]] name = "windows_aarch64_msvc" @@ -8687,9 +8688,9 @@ checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" [[package]] name = "windows_aarch64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbaa0368d4f1d2aaefc55b6fcfee13f41544ddf36801e793edbbfd7d7df075ef" +checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" [[package]] name = "windows_i686_gnu" @@ -8711,9 +8712,15 @@ checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" [[package]] name = "windows_i686_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a28637cb1fa3560a16915793afb20081aba2c92ee8af57b4d5f28e4b3e7df313" +checksum = "88ba073cf16d5372720ec942a8ccbf61626074c6d4dd2e745299726ce8b89670" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" [[package]] name = "windows_i686_msvc" @@ -8735,9 +8742,9 @@ checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" [[package]] name = "windows_i686_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffe5e8e31046ce6230cc7215707b816e339ff4d4d67c65dffa206fd0f7aa7b9a" +checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" [[package]] name = "windows_x86_64_gnu" @@ -8759,9 +8766,9 @@ checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" [[package]] name = "windows_x86_64_gnu" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6fa32db2bc4a2f5abeacf2b69f7992cd09dca97498da74a151a3132c26befd" +checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" [[package]] name = "windows_x86_64_gnullvm" @@ -8777,9 +8784,9 @@ checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" [[package]] name = "windows_x86_64_gnullvm" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a657e1e9d3f514745a572a6846d3c7aa7dbe1658c056ed9c3344c4109a6949e" +checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" [[package]] name = "windows_x86_64_msvc" @@ -8801,9 +8808,9 @@ checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" [[package]] name = "windows_x86_64_msvc" -version = "0.52.0" +version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" +checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" diff --git a/lerna.json b/lerna.json index d8fa24c687f4b..e2bfbf20d9e3e 100644 --- a/lerna.json +++ b/lerna.json @@ -16,5 +16,5 @@ "registry": "https://registry.npmjs.org/" } }, - "version": "14.3.0-canary.50" + "version": "14.3.0-canary.51" } diff --git a/packages/create-next-app/package.json b/packages/create-next-app/package.json index 55083791ddfd1..2917c7f905db5 100644 --- a/packages/create-next-app/package.json +++ b/packages/create-next-app/package.json @@ -1,6 +1,6 @@ { "name": "create-next-app", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "keywords": [ "react", "next", diff --git a/packages/eslint-config-next/package.json b/packages/eslint-config-next/package.json index 64c4c609f98fa..4bb379eeea706 100644 --- a/packages/eslint-config-next/package.json +++ b/packages/eslint-config-next/package.json @@ -1,6 +1,6 @@ { "name": "eslint-config-next", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "description": "ESLint configuration used by Next.js.", "main": "index.js", "license": "MIT", @@ -10,7 +10,7 @@ }, "homepage": "https://nextjs.org/docs/app/building-your-application/configuring/eslint#eslint-config", "dependencies": { - "@next/eslint-plugin-next": "14.3.0-canary.50", + "@next/eslint-plugin-next": "14.3.0-canary.51", "@rushstack/eslint-patch": "^1.3.3", "@typescript-eslint/parser": "^5.4.2 || ^6.0.0 || 7.0.0 - 7.2.0", "eslint-import-resolver-node": "^0.3.6", diff --git a/packages/eslint-plugin-next/package.json b/packages/eslint-plugin-next/package.json index 91c5f4430e4ef..7bcbd70bb8a0d 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": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "description": "ESLint plugin for Next.js.", "main": "dist/index.js", "license": "MIT", diff --git a/packages/font/package.json b/packages/font/package.json index addcced0979de..1d7526a73c2d0 100644 --- a/packages/font/package.json +++ b/packages/font/package.json @@ -1,6 +1,6 @@ { "name": "@next/font", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "repository": { "url": "vercel/next.js", "directory": "packages/font" diff --git a/packages/next-bundle-analyzer/package.json b/packages/next-bundle-analyzer/package.json index e30ad25400552..cb1e1a932df72 100644 --- a/packages/next-bundle-analyzer/package.json +++ b/packages/next-bundle-analyzer/package.json @@ -1,6 +1,6 @@ { "name": "@next/bundle-analyzer", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "main": "index.js", "types": "index.d.ts", "license": "MIT", diff --git a/packages/next-codemod/package.json b/packages/next-codemod/package.json index 7e815faecf349..5ba76d71eac2c 100644 --- a/packages/next-codemod/package.json +++ b/packages/next-codemod/package.json @@ -1,6 +1,6 @@ { "name": "@next/codemod", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "license": "MIT", "repository": { "type": "git", diff --git a/packages/next-env/package.json b/packages/next-env/package.json index 25032852da2c3..352e71cc097dd 100644 --- a/packages/next-env/package.json +++ b/packages/next-env/package.json @@ -1,6 +1,6 @@ { "name": "@next/env", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "keywords": [ "react", "next", diff --git a/packages/next-mdx/package.json b/packages/next-mdx/package.json index 402f59435189a..a1b5a97298731 100644 --- a/packages/next-mdx/package.json +++ b/packages/next-mdx/package.json @@ -1,6 +1,6 @@ { "name": "@next/mdx", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "main": "index.js", "license": "MIT", "repository": { diff --git a/packages/next-plugin-storybook/package.json b/packages/next-plugin-storybook/package.json index 9463ac3c00285..335bb7e4befaa 100644 --- a/packages/next-plugin-storybook/package.json +++ b/packages/next-plugin-storybook/package.json @@ -1,6 +1,6 @@ { "name": "@next/plugin-storybook", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "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 b47759e023ea4..673e0a9047f12 100644 --- a/packages/next-polyfill-module/package.json +++ b/packages/next-polyfill-module/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-module", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "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 6b5fb7454d592..ce469be2eeb00 100644 --- a/packages/next-polyfill-nomodule/package.json +++ b/packages/next-polyfill-nomodule/package.json @@ -1,6 +1,6 @@ { "name": "@next/polyfill-nomodule", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "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 aa261d722c618..8624b64c5fbae 100644 --- a/packages/next-swc/package.json +++ b/packages/next-swc/package.json @@ -1,6 +1,6 @@ { "name": "@next/swc", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "private": true, "scripts": { "clean": "node ../../scripts/rm.mjs native", diff --git a/packages/next/package.json b/packages/next/package.json index fb4021d2faf04..f49fbf1796229 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -1,6 +1,6 @@ { "name": "next", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "description": "The React Framework", "main": "./dist/server/next.js", "license": "MIT", @@ -93,7 +93,7 @@ ] }, "dependencies": { - "@next/env": "14.3.0-canary.50", + "@next/env": "14.3.0-canary.51", "@swc/helpers": "0.5.11", "busboy": "1.6.0", "caniuse-lite": "^1.0.30001579", @@ -153,10 +153,10 @@ "@jest/types": "29.5.0", "@mswjs/interceptors": "0.23.0", "@napi-rs/triples": "1.2.0", - "@next/polyfill-module": "14.3.0-canary.50", - "@next/polyfill-nomodule": "14.3.0-canary.50", - "@next/react-refresh-utils": "14.3.0-canary.50", - "@next/swc": "14.3.0-canary.50", + "@next/polyfill-module": "14.3.0-canary.51", + "@next/polyfill-nomodule": "14.3.0-canary.51", + "@next/react-refresh-utils": "14.3.0-canary.51", + "@next/swc": "14.3.0-canary.51", "@opentelemetry/api": "1.6.0", "@playwright/test": "1.41.2", "@taskr/clear": "1.1.0", diff --git a/packages/next/src/build/webpack-config.ts b/packages/next/src/build/webpack-config.ts index a0d23e8fe2dcd..6417163780d3e 100644 --- a/packages/next/src/build/webpack-config.ts +++ b/packages/next/src/build/webpack-config.ts @@ -1275,6 +1275,14 @@ export default async function getBaseWebpackConfig( }, ...(hasAppDir ? [ + { + layer: WEBPACK_LAYERS.appRouteHandler, + test: new RegExp( + `private-next-app-dir\\/.*\\/route\\.(${pageExtensions.join( + '|' + )})$` + ), + }, { // Make sure that AsyncLocalStorage module instance is shared between server and client // layers. @@ -1700,17 +1708,23 @@ export default async function getBaseWebpackConfig( '.shared-runtime' ) const layer = resource.contextInfo.issuerLayer + let runtime - if (layer === WEBPACK_LAYERS.serverSideRendering) { - runtime = 'app-page' - } else if (!layer) { - runtime = 'pages' - } else { - throw new Error( - `shared-runtime module ${moduleName} cannot be used in ${layer} layer` - ) + switch (layer) { + case WEBPACK_LAYERS.appRouteHandler: + runtime = 'app-route' + break + case WEBPACK_LAYERS.serverSideRendering: + case WEBPACK_LAYERS.reactServerComponents: + case WEBPACK_LAYERS.appPagesBrowser: + case WEBPACK_LAYERS.actionBrowser: + runtime = 'app-page' + break + default: + runtime = 'pages' } + resource.request = `next/dist/server/future/route-modules/${runtime}/vendored/contexts/${moduleName}` } ), diff --git a/packages/next/src/build/webpack/plugins/next-types-plugin/index.ts b/packages/next/src/build/webpack/plugins/next-types-plugin/index.ts index c2d9dd5c31982..6321e0e4ac9c5 100644 --- a/packages/next/src/build/webpack/plugins/next-types-plugin/index.ts +++ b/packages/next/src/build/webpack/plugins/next-types-plugin/index.ts @@ -613,7 +613,11 @@ export class NextTypesPlugin { } return } - if (mod.layer !== WEBPACK_LAYERS.reactServerComponents) return + if ( + mod.layer !== WEBPACK_LAYERS.reactServerComponents && + mod.layer !== WEBPACK_LAYERS.appRouteHandler + ) + return const IS_LAYOUT = /[/\\]layout\.[^./\\]+$/.test(mod.resource) const IS_PAGE = !IS_LAYOUT && /[/\\]page\.[^.]+$/.test(mod.resource) diff --git a/packages/next/src/lib/constants.ts b/packages/next/src/lib/constants.ts index ffce24ceb5b6d..f8ebd11e33c13 100644 --- a/packages/next/src/lib/constants.ts +++ b/packages/next/src/lib/constants.ts @@ -115,8 +115,7 @@ const WEBPACK_LAYERS_NAMES = { */ shared: 'shared', /** - * The layer for server-only runtime and picking up `react-server` export conditions. - * Including app router RSC pages and app router custom routes. + * React Server Components layer (rsc). */ reactServerComponents: 'rsc', /** @@ -151,6 +150,10 @@ const WEBPACK_LAYERS_NAMES = { * The server bundle layer for metadata routes. */ appMetadataRoute: 'app-metadata-route', + /** + * The layer for the server bundle for App Route handlers. + */ + appRouteHandler: 'app-route-handler', } as const export type WebpackLayerName = @@ -163,6 +166,7 @@ const WEBPACK_LAYERS = { WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.actionBrowser, WEBPACK_LAYERS_NAMES.appMetadataRoute, + WEBPACK_LAYERS_NAMES.appRouteHandler, WEBPACK_LAYERS_NAMES.instrument, ], clientOnly: [ @@ -178,6 +182,7 @@ const WEBPACK_LAYERS = { WEBPACK_LAYERS_NAMES.reactServerComponents, WEBPACK_LAYERS_NAMES.actionBrowser, WEBPACK_LAYERS_NAMES.appMetadataRoute, + WEBPACK_LAYERS_NAMES.appRouteHandler, WEBPACK_LAYERS_NAMES.serverSideRendering, WEBPACK_LAYERS_NAMES.appPagesBrowser, WEBPACK_LAYERS_NAMES.shared, diff --git a/packages/next/src/server/future/route-modules/app-page/vendored/contexts/entrypoints.ts b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/entrypoints.ts index d117df846ddad..52274993f0abc 100644 --- a/packages/next/src/server/future/route-modules/app-page/vendored/contexts/entrypoints.ts +++ b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/entrypoints.ts @@ -3,5 +3,8 @@ export * as ServerInsertedHtml from '../../../../../../shared/lib/server-inserte export * as AppRouterContext from '../../../../../../shared/lib/app-router-context.shared-runtime' export * as HooksClientContext from '../../../../../../shared/lib/hooks-client-context.shared-runtime' export * as RouterContext from '../../../../../../shared/lib/router-context.shared-runtime' +export * as HtmlContext from '../../../../../../shared/lib/html-context.shared-runtime' export * as AmpContext from '../../../../../../shared/lib/amp-context.shared-runtime' +export * as LoadableContext from '../../../../../../shared/lib/loadable-context.shared-runtime' export * as ImageConfigContext from '../../../../../../shared/lib/image-config-context.shared-runtime' +export * as Loadable from '../../../../../../shared/lib/loadable.shared-runtime' diff --git a/packages/next/src/server/future/route-modules/app-page/vendored/contexts/html-context.ts b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/html-context.ts new file mode 100644 index 0000000000000..ae1126abb6f99 --- /dev/null +++ b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/html-context.ts @@ -0,0 +1,3 @@ +module.exports = require('../../module.compiled').vendored[ + 'contexts' +].HtmlContext diff --git a/packages/next/src/server/future/route-modules/app-page/vendored/contexts/loadable-context.ts b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/loadable-context.ts new file mode 100644 index 0000000000000..de9e07464c6fb --- /dev/null +++ b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/loadable-context.ts @@ -0,0 +1,3 @@ +module.exports = require('../../module.compiled').vendored[ + 'contexts' +].LoadableContext diff --git a/packages/next/src/server/future/route-modules/app-page/vendored/contexts/loadable.ts b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/loadable.ts new file mode 100644 index 0000000000000..f67d05a251655 --- /dev/null +++ b/packages/next/src/server/future/route-modules/app-page/vendored/contexts/loadable.ts @@ -0,0 +1 @@ +module.exports = require('../../module.compiled').vendored['contexts'].Loadable diff --git a/packages/react-refresh-utils/package.json b/packages/react-refresh-utils/package.json index 657833115edf0..6e1a3ce7cf818 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": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "description": "An experimental package providing utilities for React Refresh.", "repository": { "url": "vercel/next.js", diff --git a/packages/third-parties/package.json b/packages/third-parties/package.json index 453d1fcd57f51..a9ba6209f6a26 100644 --- a/packages/third-parties/package.json +++ b/packages/third-parties/package.json @@ -1,6 +1,6 @@ { "name": "@next/third-parties", - "version": "14.3.0-canary.50", + "version": "14.3.0-canary.51", "repository": { "url": "vercel/next.js", "directory": "packages/third-parties" @@ -26,7 +26,7 @@ "third-party-capital": "1.0.20" }, "devDependencies": { - "next": "14.3.0-canary.50", + "next": "14.3.0-canary.51", "outdent": "0.8.0", "prettier": "2.5.1" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a374532f713cd..9b34d4de73947 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -748,7 +748,7 @@ importers: packages/eslint-config-next: dependencies: '@next/eslint-plugin-next': - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../eslint-plugin-next '@rushstack/eslint-patch': specifier: ^1.3.3 @@ -810,7 +810,7 @@ importers: packages/next: dependencies: '@next/env': - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../next-env '@swc/helpers': specifier: 0.5.11 @@ -935,16 +935,16 @@ importers: specifier: 1.2.0 version: 1.2.0 '@next/polyfill-module': - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../next-polyfill-module '@next/polyfill-nomodule': - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../next-polyfill-nomodule '@next/react-refresh-utils': - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../react-refresh-utils '@next/swc': - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../next-swc '@opentelemetry/api': specifier: 1.6.0 @@ -1559,7 +1559,7 @@ importers: version: 1.0.20 devDependencies: next: - specifier: 14.3.0-canary.50 + specifier: 14.3.0-canary.51 version: link:../next outdent: specifier: 0.8.0 diff --git a/test/integration/next-image-legacy/default/pages/priority.js b/test/integration/next-image-legacy/default/pages/priority.js index f90a8c9a40573..5c83971d19a9b 100644 --- a/test/integration/next-image-legacy/default/pages/priority.js +++ b/test/integration/next-image-legacy/default/pages/priority.js @@ -60,6 +60,15 @@ const Page = () => { layout="responsive" />

This is the priority page

+
+
) } diff --git a/test/integration/next-image-legacy/default/test/index.test.ts b/test/integration/next-image-legacy/default/test/index.test.ts index fc0843ab9ffa7..7d57817bfbeee 100644 --- a/test/integration/next-image-legacy/default/test/index.test.ts +++ b/test/integration/next-image-legacy/default/test/index.test.ts @@ -146,6 +146,11 @@ function runTests(mode) { imagesrcset: '/_next/image?url=%2Fwide.png&w=640&q=75 640w, /_next/image?url=%2Fwide.png&w=750&q=75 750w, /_next/image?url=%2Fwide.png&w=828&q=75 828w, /_next/image?url=%2Fwide.png&w=1080&q=75 1080w, /_next/image?url=%2Fwide.png&w=1200&q=75 1200w, /_next/image?url=%2Fwide.png&w=1920&q=75 1920w, /_next/image?url=%2Fwide.png&w=2048&q=75 2048w, /_next/image?url=%2Fwide.png&w=3840&q=75 3840w', }, + { + imagesizes: '', + imagesrcset: + '/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x', + }, ]) // When priority={true}, we should _not_ set loading="lazy" @@ -171,6 +176,9 @@ function runTests(mode) { expect( await browser.elementById('responsive2').getAttribute('loading') ).toBe(null) + expect( + await browser.elementById('belowthefold').getAttribute('loading') + ).toBe(null) const warnings = (await browser.log()) .map((log) => log.message) diff --git a/test/integration/next-image-new/app-dir/app/priority/page.js b/test/integration/next-image-new/app-dir/app/priority/page.js index f1501e0a9917b..3ebb755ce08ac 100644 --- a/test/integration/next-image-new/app-dir/app/priority/page.js +++ b/test/integration/next-image-new/app-dir/app/priority/page.js @@ -66,6 +66,15 @@ const Page = () => { fetchPriority="low" />

This is the priority page

+
+
) } diff --git a/test/integration/next-image-new/app-dir/test/index.test.ts b/test/integration/next-image-new/app-dir/test/index.test.ts index a54e5e51dbd84..ebff18725dc5f 100644 --- a/test/integration/next-image-new/app-dir/test/index.test.ts +++ b/test/integration/next-image-new/app-dir/test/index.test.ts @@ -180,6 +180,21 @@ function runTests(mode) { referrerpolicy: 'no-referrer', }) + expect( + entries.find( + (item) => + item.imagesrcset === + '/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x' + ) + ).toEqual({ + fetchpriority: 'high', + imagesizes: '', + imagesrcset: + '/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x', + crossorigin: '', + referrerpolicy: '', + }) + // When priority={true}, we should _not_ set loading="lazy" expect( await browser.elementById('basic-image').getAttribute('loading') @@ -216,6 +231,13 @@ function runTests(mode) { 'lazy' ) + expect( + await browser.elementById('belowthefold').getAttribute('fetchpriority') + ).toBe('high') + expect( + await browser.elementById('belowthefold').getAttribute('loading') + ).toBe(null) + const warnings = (await browser.log('browser')) .map((log) => log.message) .join('\n') diff --git a/test/integration/next-image-new/default/pages/priority.js b/test/integration/next-image-new/default/pages/priority.js index f1501e0a9917b..3ebb755ce08ac 100644 --- a/test/integration/next-image-new/default/pages/priority.js +++ b/test/integration/next-image-new/default/pages/priority.js @@ -66,6 +66,15 @@ const Page = () => { fetchPriority="low" />

This is the priority page

+
+
) } diff --git a/test/integration/next-image-new/default/test/index.test.ts b/test/integration/next-image-new/default/test/index.test.ts index 0c2b59517d12b..539b1a8111bd3 100644 --- a/test/integration/next-image-new/default/test/index.test.ts +++ b/test/integration/next-image-new/default/test/index.test.ts @@ -181,6 +181,21 @@ function runTests(mode) { referrerpolicy: 'no-referrer', }) + expect( + entries.find( + (item) => + item.imagesrcset === + '/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x' + ) + ).toEqual({ + fetchpriority: 'high', + imagesizes: '', + imagesrcset: + '/_next/image?url=%2Ftest.tiff&w=640&q=75 1x, /_next/image?url=%2Ftest.tiff&w=828&q=75 2x', + crossorigin: '', + referrerpolicy: '', + }) + // When priority={true}, we should _not_ set loading="lazy" expect( await browser.elementById('basic-image').getAttribute('loading') @@ -217,6 +232,13 @@ function runTests(mode) { 'lazy' ) + expect( + await browser.elementById('belowthefold').getAttribute('fetchpriority') + ).toBe('high') + expect( + await browser.elementById('belowthefold').getAttribute('loading') + ).toBe(null) + const warnings = (await browser.log('browser')) .map((log) => log.message) .join('\n')