From 3fa771c2f0f4a0abfab61e3d3353e443d7af6759 Mon Sep 17 00:00:00 2001 From: nikospapcom Date: Fri, 27 Oct 2023 10:42:35 +0300 Subject: [PATCH 1/4] feat: Support next@14.0.0 --- code/frameworks/nextjs/package.json | 6 +- code/yarn.lock | 96 ++++++++++++++--------------- node_modules/.package-lock.json | 6 ++ 3 files changed, 57 insertions(+), 51 deletions(-) create mode 100644 node_modules/.package-lock.json diff --git a/code/frameworks/nextjs/package.json b/code/frameworks/nextjs/package.json index 76fdfcd405e1..0be65ee2da6d 100644 --- a/code/frameworks/nextjs/package.json +++ b/code/frameworks/nextjs/package.json @@ -119,13 +119,13 @@ "@types/babel__core": "^7", "@types/babel__plugin-transform-runtime": "^7", "@types/babel__preset-env": "^7", - "next": "13.5.4", + "next": "14.0.0", "typescript": "^4.9.3", "webpack": "^5.65.0" }, "peerDependencies": { "@next/font": "^13.0.0", - "next": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0", + "next": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", "webpack": "^5.0.0" @@ -145,7 +145,7 @@ } }, "engines": { - "node": ">=16.0.0" + "node": ">=18.17.0" }, "publishConfig": { "access": "public" diff --git a/code/yarn.lock b/code/yarn.lock index ac5d3a3cadb9..2e85205f3e12 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -3973,72 +3973,72 @@ __metadata: languageName: node linkType: hard -"@next/env@npm:13.5.4": - version: 13.5.4 - resolution: "@next/env@npm:13.5.4" - checksum: 69c013047371bde6c4dc6d03ec77140059bd4e3db38c1991a8aa8a9c8ce4d1370b98a141145a6f60e23f32ce97a3040b448bfd0455b0d9e5ba6efda8df33c89f +"@next/env@npm:14.0.0": + version: 14.0.0 + resolution: "@next/env@npm:14.0.0" + checksum: c43e81dbd162a29a4b380342e416209d69d731e8ced7688d09668ec8196f543e358ed65adad81a26e943c63a293d7a018552f8389b6b1ac95cd0f63f4ef257c0 languageName: node linkType: hard -"@next/swc-darwin-arm64@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-darwin-arm64@npm:13.5.4" +"@next/swc-darwin-arm64@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-darwin-arm64@npm:14.0.0" conditions: os=darwin & cpu=arm64 languageName: node linkType: hard -"@next/swc-darwin-x64@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-darwin-x64@npm:13.5.4" +"@next/swc-darwin-x64@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-darwin-x64@npm:14.0.0" conditions: os=darwin & cpu=x64 languageName: node linkType: hard -"@next/swc-linux-arm64-gnu@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-linux-arm64-gnu@npm:13.5.4" +"@next/swc-linux-arm64-gnu@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-linux-arm64-gnu@npm:14.0.0" conditions: os=linux & cpu=arm64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-arm64-musl@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-linux-arm64-musl@npm:13.5.4" +"@next/swc-linux-arm64-musl@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-linux-arm64-musl@npm:14.0.0" conditions: os=linux & cpu=arm64 & libc=musl languageName: node linkType: hard -"@next/swc-linux-x64-gnu@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-linux-x64-gnu@npm:13.5.4" +"@next/swc-linux-x64-gnu@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-linux-x64-gnu@npm:14.0.0" conditions: os=linux & cpu=x64 & libc=glibc languageName: node linkType: hard -"@next/swc-linux-x64-musl@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-linux-x64-musl@npm:13.5.4" +"@next/swc-linux-x64-musl@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-linux-x64-musl@npm:14.0.0" conditions: os=linux & cpu=x64 & libc=musl languageName: node linkType: hard -"@next/swc-win32-arm64-msvc@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-win32-arm64-msvc@npm:13.5.4" +"@next/swc-win32-arm64-msvc@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-win32-arm64-msvc@npm:14.0.0" conditions: os=win32 & cpu=arm64 languageName: node linkType: hard -"@next/swc-win32-ia32-msvc@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-win32-ia32-msvc@npm:13.5.4" +"@next/swc-win32-ia32-msvc@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-win32-ia32-msvc@npm:14.0.0" conditions: os=win32 & cpu=ia32 languageName: node linkType: hard -"@next/swc-win32-x64-msvc@npm:13.5.4": - version: 13.5.4 - resolution: "@next/swc-win32-x64-msvc@npm:13.5.4" +"@next/swc-win32-x64-msvc@npm:14.0.0": + version: 14.0.0 + resolution: "@next/swc-win32-x64-msvc@npm:14.0.0" conditions: os=win32 & cpu=x64 languageName: node linkType: hard @@ -7323,7 +7323,7 @@ __metadata: fs-extra: "npm:^11.1.0" image-size: "npm:^1.0.0" loader-utils: "npm:^3.2.0" - next: "npm:13.5.4" + next: "npm:14.0.0" node-polyfill-webpack-plugin: "npm:^2.0.1" pnp-webpack-plugin: "npm:^1.7.0" postcss: "npm:^8.4.21" @@ -7340,7 +7340,7 @@ __metadata: webpack: "npm:^5.65.0" peerDependencies: "@next/font": ^13.0.0 - next: ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 + next: ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 webpack: ^5.0.0 @@ -23937,20 +23937,20 @@ __metadata: languageName: node linkType: hard -"next@npm:13.5.4": - version: 13.5.4 - resolution: "next@npm:13.5.4" - dependencies: - "@next/env": "npm:13.5.4" - "@next/swc-darwin-arm64": "npm:13.5.4" - "@next/swc-darwin-x64": "npm:13.5.4" - "@next/swc-linux-arm64-gnu": "npm:13.5.4" - "@next/swc-linux-arm64-musl": "npm:13.5.4" - "@next/swc-linux-x64-gnu": "npm:13.5.4" - "@next/swc-linux-x64-musl": "npm:13.5.4" - "@next/swc-win32-arm64-msvc": "npm:13.5.4" - "@next/swc-win32-ia32-msvc": "npm:13.5.4" - "@next/swc-win32-x64-msvc": "npm:13.5.4" +"next@npm:14.0.0": + version: 14.0.0 + resolution: "next@npm:14.0.0" + dependencies: + "@next/env": "npm:14.0.0" + "@next/swc-darwin-arm64": "npm:14.0.0" + "@next/swc-darwin-x64": "npm:14.0.0" + "@next/swc-linux-arm64-gnu": "npm:14.0.0" + "@next/swc-linux-arm64-musl": "npm:14.0.0" + "@next/swc-linux-x64-gnu": "npm:14.0.0" + "@next/swc-linux-x64-musl": "npm:14.0.0" + "@next/swc-win32-arm64-msvc": "npm:14.0.0" + "@next/swc-win32-ia32-msvc": "npm:14.0.0" + "@next/swc-win32-x64-msvc": "npm:14.0.0" "@swc/helpers": "npm:0.5.2" busboy: "npm:1.6.0" caniuse-lite: "npm:^1.0.30001406" @@ -23988,7 +23988,7 @@ __metadata: optional: true bin: next: dist/bin/next - checksum: 0b0bc7fa42844859a0444a79122a48b5e65116c30ce077a3edaaecd7cee1d7925214a659391ae6ecf8dc612869a7a646ab3a1a8aa12d074ff17e3f18c53a2621 + checksum: cfb18a72d6e1d875efb1bb3806f9a06551f482c5cb87231e77e179a71d26f3d43700290988ad27e739302bfa7ff8ac8081aafd5456c39a2819fdd315617e5acf languageName: node linkType: hard diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 000000000000..b157d40c0f7a --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "@storybook/root", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} From 83f4ef010ce052b1d7599cc42db7b980ac65dab0 Mon Sep 17 00:00:00 2001 From: nikospapcom Date: Fri, 27 Oct 2023 10:50:53 +0300 Subject: [PATCH 2/4] chore: Remove package-lock file --- node_modules/.package-lock.json | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 node_modules/.package-lock.json diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json deleted file mode 100644 index b157d40c0f7a..000000000000 --- a/node_modules/.package-lock.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "@storybook/root", - "lockfileVersion": 3, - "requires": true, - "packages": {} -} From a27e78999178fae5c6558a2cb6548edd32e286b5 Mon Sep 17 00:00:00 2001 From: nikospapcom Date: Fri, 27 Oct 2023 11:34:01 +0300 Subject: [PATCH 3/4] chore: Revert node engine to 16 --- code/frameworks/nextjs/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/frameworks/nextjs/package.json b/code/frameworks/nextjs/package.json index 0be65ee2da6d..c4d58b73f0f1 100644 --- a/code/frameworks/nextjs/package.json +++ b/code/frameworks/nextjs/package.json @@ -145,7 +145,7 @@ } }, "engines": { - "node": ">=18.17.0" + "node": ">=16.0.0" }, "publishConfig": { "access": "public" From 715381c08d83ad68a5fd3b3502587f29c990edfd Mon Sep 17 00:00:00 2001 From: Valentin Palkovic Date: Fri, 27 Oct 2023 15:07:18 +0200 Subject: [PATCH 4/4] Fix next/legacy/image imports for Next.js v14 --- code/frameworks/nextjs/package.json | 4 ++-- code/frameworks/nextjs/src/images/webpack.ts | 2 +- code/frameworks/nextjs/src/nextImport/webpack.ts | 12 ++---------- code/yarn.lock | 6 +++--- 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/code/frameworks/nextjs/package.json b/code/frameworks/nextjs/package.json index c4d58b73f0f1..d5ba68b05c9f 100644 --- a/code/frameworks/nextjs/package.json +++ b/code/frameworks/nextjs/package.json @@ -119,12 +119,12 @@ "@types/babel__core": "^7", "@types/babel__plugin-transform-runtime": "^7", "@types/babel__preset-env": "^7", - "next": "14.0.0", + "next": "^14.0.0", "typescript": "^4.9.3", "webpack": "^5.65.0" }, "peerDependencies": { - "@next/font": "^13.0.0", + "@next/font": "^13.0.0|| ^14.0.0", "next": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0", "react": "^16.8.0 || ^17.0.0 || ^18.0.0", "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0", diff --git a/code/frameworks/nextjs/src/images/webpack.ts b/code/frameworks/nextjs/src/images/webpack.ts index e6b91f0712d3..e80e03545beb 100644 --- a/code/frameworks/nextjs/src/images/webpack.ts +++ b/code/frameworks/nextjs/src/images/webpack.ts @@ -20,7 +20,7 @@ const configureImageDefaults = (baseConfig: WebpackConfig): void => { 'next/image': path.resolve(__dirname, './images/next-image'), }; - if (semver.satisfies(version, '^13.0.0')) { + if (semver.satisfies(version, '>=13.0.0')) { resolve.alias = { ...resolve.alias, 'sb-original/next/legacy/image': require.resolve('next/legacy/image'), diff --git a/code/frameworks/nextjs/src/nextImport/webpack.ts b/code/frameworks/nextjs/src/nextImport/webpack.ts index b017462ae256..fc5d359ef8e2 100644 --- a/code/frameworks/nextjs/src/nextImport/webpack.ts +++ b/code/frameworks/nextjs/src/nextImport/webpack.ts @@ -7,20 +7,11 @@ export function configureNextImport(baseConfig: WebpackConfig) { const nextJSVersion = getNextjsVersion(); const isNext12 = semver.satisfies(nextJSVersion, '~12'); - const isNext13 = semver.satisfies(nextJSVersion, '~13'); const isNextVersionSmallerThan12dot2 = semver.lt(nextJSVersion, '12.2.0'); const isNextVersionSmallerThan13 = semver.lt(nextJSVersion, '13.0.0'); baseConfig.plugins = baseConfig.plugins ?? []; - if (!isNext13) { - baseConfig.plugins.push( - new IgnorePlugin({ - resourceRegExp: /next\/legacy\/image$/, - }) - ); - } - if (!isNext12 || isNextVersionSmallerThan12dot2) { baseConfig.plugins.push( new IgnorePlugin({ @@ -32,7 +23,8 @@ export function configureNextImport(baseConfig: WebpackConfig) { if (isNextVersionSmallerThan13) { baseConfig.plugins.push( new IgnorePlugin({ - resourceRegExp: /next\/dist\/shared\/lib\/hooks-client-context$/, + // ignore next/dist/shared/lib/hooks-client-context and next/legacy/image imports + resourceRegExp: /(next\/dist\/shared\/lib\/hooks-client-context|next\/legacy\/image)$/, }) ); } diff --git a/code/yarn.lock b/code/yarn.lock index 2e85205f3e12..a4f61e11d94f 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -7323,7 +7323,7 @@ __metadata: fs-extra: "npm:^11.1.0" image-size: "npm:^1.0.0" loader-utils: "npm:^3.2.0" - next: "npm:14.0.0" + next: "npm:^14.0.0" node-polyfill-webpack-plugin: "npm:^2.0.1" pnp-webpack-plugin: "npm:^1.7.0" postcss: "npm:^8.4.21" @@ -7339,7 +7339,7 @@ __metadata: typescript: "npm:^4.9.3" webpack: "npm:^5.65.0" peerDependencies: - "@next/font": ^13.0.0 + "@next/font": ^13.0.0|| ^14.0.0 next: ^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0 || ^13.0.0 || ^14.0.0 react: ^16.8.0 || ^17.0.0 || ^18.0.0 react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 @@ -23937,7 +23937,7 @@ __metadata: languageName: node linkType: hard -"next@npm:14.0.0": +"next@npm:^14.0.0": version: 14.0.0 resolution: "next@npm:14.0.0" dependencies: