Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nextjs] Fix build errors when app uses personalize initializer, add utils, site submodule exports #1430

Merged
merged 6 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ Our versioning strategy is as follows:

### 🛠 Breaking Changes

* `[sitecore-jss-rendering-host]` `startDevServer` is retired. `startRenderingHostServer` is the only way to start the rendering host from now on. ([#1426](https://github.com/Sitecore/jss/pull/1426))
* `[sitecore-jss-react]` `[sitecore-jss-nextjs]` FEaaS component is now server rendered. Prop type used FEaaSWrapper has been modified alongside with FEaaSWrapper implementation. Make sure you use the updated type and the updated wrapper. ([#1413](https://github.com/Sitecore/jss/pull/1413))
* `[sitecore-jss-rendering-host]` `startDevServer` is retired. `startRenderingHostServer` is the only way to start the rendering host from now on. ([#1426](https://github.com/Sitecore/jss/pull/1426))
* `[sitecore-jss-nextjs]` Some imports have been moved to avoid accidentally importing nextjs server logic inside client componenents([#1430](https://github.com/Sitecore/jss/pull/1430/)):
* SiteInfo and SiteResolver imports have been moved from '@sitecore-jss/sitecore-jss-nextjs/middleware' module to '@sitecore-jss/sitecore-jss-nextjs/site'
* tryParseEnvValue import has been moved from '@sitecore-jss/sitecore-jss-nextjs/middleware' module to '@sitecore-jss/sitecore-jss-nextjs/utils'

### 🎉 New Features & Improvements

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SiteInfo } from '@sitecore-jss/sitecore-jss-nextjs/middleware';
import { SiteInfo } from '@sitecore-jss/sitecore-jss-nextjs/site';
import config from 'temp/config';
import { SiteResolverPlugin } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SiteInfo, tryParseEnvValue } from '@sitecore-jss/sitecore-jss-nextjs/middleware';
import { SiteInfo } from '@sitecore-jss/sitecore-jss-nextjs/site';
import { tryParseEnvValue } from '@sitecore-jss/sitecore-jss-nextjs/utils';
import config from 'temp/config';
import { SiteResolverPlugin } from '..';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SiteInfo, SiteResolver } from '@sitecore-jss/sitecore-jss-nextjs/middleware';
import { SiteInfo, SiteResolver } from '@sitecore-jss/sitecore-jss-nextjs/site';
import * as plugins from 'temp/site-resolver-plugins';

/*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SiteInfo } from '@sitecore-jss/sitecore-jss-nextjs/middleware';
import { SiteInfo } from '@sitecore-jss/sitecore-jss-nextjs/site';
import config from 'temp/config';
import { SiteResolverPlugin } from '..';

Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/site.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types/site/index';
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/site.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/cjs/site/index');
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
import { EditingDataCache, editingDataDiskCache } from './editing-data-cache';
import { EditingData, isEditingData } from './editing-data';
import { QUERY_PARAM_EDITING_SECRET } from './editing-data-service';
import { getJssEditingSecret } from '../utils';
import { getJssEditingSecret } from '../utils/utils';

export interface EditingDataMiddlewareConfig {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AxiosDataFetcher, debug } from '@sitecore-jss/sitecore-jss';
import { EditingData } from './editing-data';
import { EditingDataCache, editingDataDiskCache } from './editing-data-cache';
import { getJssEditingSecret } from '../utils';
import { getJssEditingSecret } from '../utils/utils';
import { PreviewData } from 'next';

export const QUERY_PARAM_EDITING_SECRET = 'secret';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
editingDataService,
QUERY_PARAM_EDITING_SECRET,
} from './editing-data-service';
import { getJssEditingSecret } from '../utils';
import { getJssEditingSecret } from '../utils/utils';

export interface EditingRenderMiddlewareConfig {
/**
Expand Down
25 changes: 20 additions & 5 deletions packages/sitecore-jss-nextjs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,27 @@ export {
HTMLLink,
enableDebug,
} from '@sitecore-jss/sitecore-jss';
export {
isEditorActive,
resetEditorChromes,
resolveUrl,
tryParseEnvValue,
// we will remove the root exports for these later
// we cannot mark exports as deprected directly, so we're using this hack instead
import {
isEditorActive as isEditorActiveDep,
resetEditorChromes as resetEditorChromesDep,
resolveUrl as resolveUrlDep,
tryParseEnvValue as tryParseEnvValueDep,
} from '@sitecore-jss/sitecore-jss/utils';
/** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
const {
isEditorActiveDep: isEditorActive,
resetEditorChromesDep: resetEditorChromes,
resolveUrlDep: resolveUrl,
tryParseEnvValueDep: tryParseEnvValue,
} = {
isEditorActiveDep,
resetEditorChromesDep,
resolveUrlDep,
tryParseEnvValueDep,
};
export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue };
export {
LayoutService,
LayoutServiceData,
Expand Down
2 changes: 0 additions & 2 deletions packages/sitecore-jss-nextjs/src/middleware/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
export { RedirectsMiddleware, RedirectsMiddlewareConfig } from './redirects-middleware';
export { PersonalizeMiddleware, PersonalizeMiddlewareConfig } from './personalize-middleware';
export { MultisiteMiddleware, MultisiteMiddlewareConfig } from './multisite-middleware';
export { SiteResolver, SiteInfo } from '@sitecore-jss/sitecore-jss/site';
export { tryParseEnvValue } from '@sitecore-jss/sitecore-jss/utils';
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/src/site/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { SiteResolver, SiteInfo } from '@sitecore-jss/sitecore-jss/site';
2 changes: 2 additions & 0 deletions packages/sitecore-jss-nextjs/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { getPublicUrl, handleEditorFastRefresh } from './utils';
export { tryParseEnvValue } from '@sitecore-jss/sitecore-jss/utils';
ambrauer marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions packages/sitecore-jss-nextjs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"middleware.d.ts",
"editing.d.ts",
"monitoring.d.ts",
"site.d.ts",
"utils.d.ts",
"src/tests/*",
"src/test-data/*",
"**/*.test.ts",
Expand Down
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './types/utils/index';
1 change: 1 addition & 0 deletions packages/sitecore-jss-nextjs/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./dist/cjs/utils/index');