Skip to content

Commit f892aba

Browse files
[sitecore-jss-nextjs/react][nextjs/react][v20] Update next to v13, react to 18 (#1830)
* Update next to v13 * Update react to v18
1 parent ba019ca commit f892aba

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+2788
-972
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. The format
33

44
This project does NOT adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), and major versions of this project denote compatibility with Sitecore Platform versions. Refer to the "Headless Services" section in the [Sitecore modules compatibility table](https://support.sitecore.com/kb?id=kb_article_view&sysparm_article=KB1000576) or the [Headless Rendering download page](https://dev.sitecore.net/Downloads/Sitecore_Headless_Rendering.aspx) for more details on versioning.
55

6+
## 20.4.0
7+
8+
* `[sitecore-jss-nextjs]` `[nextjs]` Update nextjs to version 13
9+
* `[sitecore-jss-react]` `[sitecore-jss-forms-react]` `[react]` Update react to version 18
10+
* `[sitecore-jss-nextjs]` `[nextjs]` `[sitecore-jss-react]` `[sitecore-jss-forms]` `[react]` Update typescript to version 4.9
11+
612
## 20.3.2
713

814
### 🐛 Bug Fixes

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"prettier": "^1.14.3",
3030
"typedoc": "^0.22.5",
3131
"typedoc-plugin-markdown": "^3.11.3",
32-
"typescript": "~4.3.5"
32+
"typescript": "~4.9.4"
3333
},
3434
"workspaces": [
3535
"packages/*",

packages/create-sitecore-jss/src/common/processes/transform.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
openPackageJson,
1111
sortKeys,
1212
writeFileToPath,
13+
isDevEnvironment,
1314
} from '../utils/helpers';
1415
import { diffLines, diffJson, Change } from 'diff';
1516
import { BaseArgs } from '../args/base';
@@ -192,6 +193,7 @@ export const transform = async (
192193
const ejsData: Data = {
193194
...answers,
194195
helper: {
196+
isDev: isDevEnvironment(answers.destination),
195197
getPascalCaseName: getPascalCaseName,
196198
getAppPrefix: getAppPrefix,
197199
},

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/Navigation.tsx

+6-8
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,8 @@ const Navigation = (): JSX.Element => {
1212
return (
1313
<div className="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom">
1414
<h5 className="my-0 mr-md-auto font-weight-normal">
15-
<Link href="/">
16-
<a className="text-dark">
17-
<img src={`${publicUrl}/sc_logo.svg`} alt="Sitecore" />
18-
</a>
15+
<Link href="/" className="text-dark">
16+
<img src={`${publicUrl}/sc_logo.svg`} alt="Sitecore" />
1917
</Link>
2018
</h5>
2119
<nav className="my-2 my-md-0 mr-md-3">
@@ -27,11 +25,11 @@ const Navigation = (): JSX.Element => {
2725
>
2826
{t('Documentation')}
2927
</a>
30-
<Link href="/styleguide">
31-
<a className="p-2 text-dark">{t('Styleguide')}</a>
28+
<Link className="p-2 text-dark" href="/styleguide">
29+
{t('Styleguide')}
3230
</Link>
33-
<Link href="/graphql">
34-
<a className="p-2 text-dark">{t('GraphQL')}</a>
31+
<Link className="p-2 text-dark" href="/graphql">
32+
{t('GraphQL')}
3533
</Link>
3634
</nav>
3735
</div>

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Image.tsx

+9-9
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ const StyleguideFieldUsageImage = (props: StyleguideFieldUsageImageProps): JSX.E
4747
E.g. we have used 'priority' to demonstrate how an image could be considered high priority and preload.
4848
Lazy loading is automatically disabled for images using priority.
4949
See here for all the features provided by next/image: https://nextjs.org/docs/api-reference/next/image
50-
next/image generates responsive srcSet automatically based on layout. See https://nextjs.org/docs/api-reference/next/image#layout.
50+
'fill' causes the next/image to fill the parent element instead of setting width and height. See https://nextjs.org/docs/api-reference/next/image#fill.
5151
IMPORTANT: The generated sizes should match your Sitecore server-side allowlist. See /sitecore/config/*.config (search for 'allowedMediaParams')
5252
*/}
5353
<p>Srcset responsive image</p>
54-
<NextImage
55-
field={props.fields.sample2}
56-
height="105"
57-
width="200"
58-
sizes="50vw"
59-
layout="responsive"
60-
priority
61-
/>
54+
<div style={{ position: 'relative', height: 160, width: 300 }}>
55+
<NextImage
56+
field={props.fields.sample2}
57+
sizes="(min-width: 960px) 300px, 100px"
58+
fill
59+
priority
60+
/>
61+
</div>
6262
</StyleguideSpecimen>
6363
);
6464

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/fields/Styleguide-FieldUsage-Number.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ const StyleguideFieldUsageText = (props: StyleguideFieldUsageTextProps): JSX.Ele
2323

2424
{/* Direct access to the value, which is a JS number, is also supported. */}
2525
<p>
26-
JS value type: {typeof fieldValue}
27-
<br />
28-
JS value: {fieldValue}
26+
<>
27+
JS value type: {typeof fieldValue}
28+
<br />
29+
JS value: {fieldValue}
30+
</>
2931
</p>
3032
</StyleguideSpecimen>
3133
);

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/graphql/GraphQL-IntegratedDemo.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const GraphQLIntegratedDemo = (props: GraphQlIntegratedDemoProps): JSX.Element =
115115
{contextItem.children.results.map((child: Item) => (
116116
<li key={child.id}>
117117
<NextLink href={child.url.path}>
118-
<a>{child.pageTitle.value}</a>
118+
{child.pageTitle.value}
119119
</NextLink>
120120
&nbsp; (editable title too! <Text field={child.pageTitle.jsonValue} />)
121121
</li>

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/styleguide/Styleguide-CustomRouteType.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const StyleguideCustomRouteType = (): JSX.Element => {
2828
<RichText field={fields.content} />
2929

3030
<Link href="/styleguide">
31-
<a>Return to the Styleguide</a>
31+
Return to the Styleguide
3232
</Link>
3333
</div>
3434
);

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/styleguide/Styleguide-Multilingual.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ const StyleguideMultilingual = (props: StyleguideMultilingualProps): JSX.Element
3232
<p>
3333
{/* In case if href already includes locale: https://nextjs.org/docs/advanced-features/i18n-routing#transition-between-locales */}
3434
<Link href="/en/styleguide" locale={false}>
35-
<a>Show in English</a>
35+
Show in English
3636
</Link>
3737
<br />
3838
<Link href="/styleguide" locale="<%- language %>">
39-
<a>Show in <%- language %></a>
39+
Show in <%- language %>
4040
</Link>
4141
</p>
4242

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/components/styleguide/Styleguide-RouteFields.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const StyleguideRouteFields = (props: StyleguideRouteFieldsProps): JSX.Element =
2727
</p>
2828
<p>
2929
<Link href="/styleguide/custom-route-type">
30-
<a>Sample of using a custom route type</a>
30+
Sample of using a custom route type
3131
</Link>
3232
</p>
3333
</StyleguideSpecimen>

packages/create-sitecore-jss/src/templates/nextjs-styleguide/src/lib/next-config/plugins/disconnected.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ const disconnectedPlugin = (nextConfig = {}) => {
2727
},
2828
];
2929
},
30-
3130
webpack: (config, options) => {
3231
// Prevent webpack-5 from throwing error for sitecore-import.json when app first starts
3332
config.resolve.fallback = {
3433
'sitecore/manifest/sitecore-import.json': false,
35-
...config.resolve.fallback
34+
...config.resolve.fallback,
3635
};
3736

3837
// Overload the Webpack config if it was already overloaded
@@ -41,7 +40,7 @@ const disconnectedPlugin = (nextConfig = {}) => {
4140
}
4241

4342
return config;
44-
}
43+
},
4544
});
4645
};
4746

packages/create-sitecore-jss/src/templates/nextjs/package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
"dependencies": {
3232
"@sitecore-jss/sitecore-jss-nextjs": "^20.4.0-canary",
3333
"graphql": "~15.8.0",
34-
"graphql-tag": "^2.11.0",
35-
"next": "^12.2.4",
36-
"next-localization": "^0.10.0",
37-
"react": "^17.0.2",
38-
"react-dom": "^17.0.2"
34+
"graphql-tag": "^2.12.6",
35+
"next": "^13.1.6",
36+
"next-localization": "^0.12.0",
37+
"react": "^18.2.0",
38+
"react-dom": "^18.2.0"
3939
},
4040
"devDependencies": {
4141
"@graphql-codegen/cli": "^1.19.1",
@@ -47,8 +47,9 @@
4747
"@graphql-typed-document-node/core": "^3.1.0",
4848
"@sitecore-jss/sitecore-jss-cli": "^20.4.0-canary",
4949
"@types/node": "^14.6.4",
50-
"@types/react": "^17.0.15",
51-
"@types/react-dom": "^17.0.9",
50+
"@types/nprogress": "^0.2.0",
51+
"@types/react": "^18.2.22",
52+
"@types/react-dom": "^18.2.0",
5253
"@typescript-eslint/eslint-plugin": "^4.29.1",
5354
"@typescript-eslint/parser": "^4.29.1",
5455
"axios": "^0.21.1",
@@ -62,11 +63,10 @@
6263
"eslint-plugin-prettier": "^3.1.4",
6364
"eslint-plugin-yaml": "^0.2.0",
6465
"graphql-let": "^0.16.2",
65-
"next-transpile-modules": "^9.0.0",
6666
"npm-run-all": "~4.1.5",
6767
"prettier": "^2.1.2",
68-
"ts-node": "^9.0.0",
69-
"typescript": "~4.3.5",
68+
"ts-node": "^10.9.1",
69+
"typescript": "~4.9.4",
7070
"yaml-loader": "^0.6.0"
7171
},
7272
"scripts": {

packages/create-sitecore-jss/src/templates/nextjs/src/Layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Layout = ({ layoutData }: LayoutProps): JSX.Element => {
2222
return (
2323
<>
2424
<Head>
25-
<title>{route?.fields?.pageTitle?.value || 'Page'}</title>
25+
<title>{route?.fields?.pageTitle?.value.toString() || 'Page'}</title>
2626
<link rel="icon" href={`${publicUrl}/favicon.ico`} />
2727
</Head>
2828

packages/create-sitecore-jss/src/templates/nextjs/src/lib/next-config/plugins/monorepo.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
1-
const withTM = require('next-transpile-modules')(['@sitecore-jss/sitecore-jss-nextjs'], {
2-
resolveSymlinks: false,
3-
});
41
const path = require('path');
52

63
const CWD = process.cwd();
7-
84
/**
95
* @param {import('next').NextConfig} nextConfig
106
*/
117
const monorepoPlugin = (nextConfig = {}) => {
12-
return withTM(Object.assign({}, nextConfig, {
8+
return Object.assign({}, nextConfig, {
139
webpack: (config, options) => {
1410
if (options.isServer) {
1511
config.externals = ['react', 'vertx', ...config.externals];
@@ -24,7 +20,7 @@ const monorepoPlugin = (nextConfig = {}) => {
2420

2521
return config;
2622
}
27-
}));
23+
});
2824
};
2925

3026
module.exports = monorepoPlugin;

0 commit comments

Comments
 (0)