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

Upgrade packages and refactor a bit #500

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -19,14 +19,14 @@
"lint:staged": "lint-staged --debug"
},
"devDependencies": {
"eslint": "8.6.0",
"eslint-config-ringcentral-typescript": "7.0.1",
"husky": "7.0.4",
"lerna": "4.0.0",
"lint-staged": "11.1.2",
"prettier": "2.5.1",
"eslint": "8.26.0",
"eslint-config-ringcentral-typescript": "7.0.3",
"husky": "8.0.1",
"lerna": "6.0.1",
"lint-staged": "13.0.3",
"prettier": "2.7.1",
"rimraf": "3.0.2",
"typescript": "4.5.2"
"typescript": "4.8.4"
},
"workspaces": [
"packages/*"
1 change: 0 additions & 1 deletion packages/demo-page/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
22 changes: 11 additions & 11 deletions packages/demo-page/package.json
Original file line number Diff line number Diff line change
@@ -11,23 +11,23 @@
"dependencies": {
"jsondiffpatch": "0.4.1",
"next-redux-wrapper": "*",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"redux": "4.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "8.0.4",
"redux": "4.2.0",
"redux-logger": "3.0.6"
},
"devDependencies": {
"@playwright/test": "1.17.1",
"@types/react": "17.0.37",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.20",
"@playwright/test": "1.27.1",
"@types/react": "18.0.24",
"@types/react-dom": "18.0.8",
"@types/react-redux": "7.1.24",
"@types/redux-logger": "3.0.9",
"next": "12.0.4",
"next": "13.0.1",
"next-redux-wrapper-configs": "*",
"playwright": "1.17.1",
"playwright": "1.27.1",
"rimraf": "3.0.2",
"typescript": "4.5.2"
"typescript": "4.8.4"
},
"author": "Kirill Konshin",
"repository": {
4 changes: 2 additions & 2 deletions packages/demo-page/src/components/store.tsx
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ import reducer, {State} from './reducer';
export const makeStore = (context: Context) => {
const store = createStore(reducer, applyMiddleware(logger));

if (module.hot) {
module.hot.accept('./reducer', () => {
if ((module as any).hot) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not familliar with module.hot; it's showing type errors because that property doesn't exist in there. Is this still used?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the way to hot-swap reducer on client side. This is Webpack's thing.

(module as any).hot.accept('./reducer', () => {
console.log('Replacing reducer');
store.replaceReducer(require('./reducer').default);
});
4 changes: 1 addition & 3 deletions packages/demo-page/src/pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -7,9 +7,7 @@ const ErrorPage = ({page}: any) => (
<>
<p>This is an error page, {page}.</p>
<nav>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/">Navigate to index</Link>
</nav>
</>
);
8 changes: 2 additions & 6 deletions packages/demo-page/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -15,13 +15,9 @@ const Page: NextPage<ConnectedPageProps> = ({custom}) => {
return (
<div className="index">
<pre>{JSON.stringify({page, custom}, null, 2)}</pre>
<Link href="/other">
<a>Navigate</a>
</Link>
<Link href="/other">Navigate</Link>
{' | '}
<Link href="/error">
<a>Navigate to error</a>
</Link>
<Link href="/error">Navigate to error</Link>
</div>
);
};
8 changes: 2 additions & 6 deletions packages/demo-page/src/pages/other.tsx
Original file line number Diff line number Diff line change
@@ -24,12 +24,8 @@ const OtherPage: NextPage<State> = () => {
<pre>{JSON.stringify({page}, null, 2)}</pre>
<nav>
<button onClick={bump}>bump</button>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/other2">
<a>Navigate to other 2</a>
</Link>
<Link href="/">Navigate to index</Link>
<Link href="/other2">Navigate to other 2</Link>
</nav>
</div>
);
8 changes: 2 additions & 6 deletions packages/demo-page/src/pages/other2.tsx
Original file line number Diff line number Diff line change
@@ -24,12 +24,8 @@ const OtherPage: NextPage<State> = () => {
<pre>{JSON.stringify({page}, null, 2)}</pre>
<nav>
<button onClick={bump}>bump</button>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/other">
<a>Navigate to other</a>
</Link>
<Link href="/">Navigate to index</Link>
<Link href="/other">Navigate to other</Link>
</nav>
</div>
);
4 changes: 1 addition & 3 deletions packages/demo-page/src/pages/pageProps.tsx
Original file line number Diff line number Diff line change
@@ -10,9 +10,7 @@ const PropsPage: NextPage<State> = props => {
<p>Using Next.js default prop in a wrapped component.</p>
<pre>{JSON.stringify(props)}</pre>
<nav>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/">Navigate to index</Link>
</nav>
</div>
);
1 change: 0 additions & 1 deletion packages/demo-redux-toolkit/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
16 changes: 8 additions & 8 deletions packages/demo-redux-toolkit/package.json
Original file line number Diff line number Diff line change
@@ -8,17 +8,17 @@
"start": "next --port=6060"
},
"dependencies": {
"@reduxjs/toolkit": "1.6.2",
"@reduxjs/toolkit": "1.8.6",
"next-redux-wrapper": "*",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"redux": "4.1.2"
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "8.0.4",
"redux": "4.2.0"
},
"devDependencies": {
"@playwright/test": "1.17.1",
"next": "12.0.4",
"playwright": "1.17.1"
"@playwright/test": "1.27.1",
"next": "13.0.1",
"playwright": "1.27.1"
},
"license": "MIT"
}
4 changes: 1 addition & 3 deletions packages/demo-redux-toolkit/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -8,9 +8,7 @@ export default function IndexPage() {
You can see &quot;Rendered content: undefined&quot; in browser console after navigating between these pages:
<br />
<br />
<Link href="/subject/1">
<a>Go to problem pages</a>
</Link>
<Link href="/subject/1">Go to problem pages</Link>
</div>
);
}
8 changes: 2 additions & 6 deletions packages/demo-redux-toolkit/pages/subject/[id].tsx
Original file line number Diff line number Diff line change
@@ -16,13 +16,9 @@ const Page = props => {
return (
<div className={`page${content.id}`}>
<h3>{content.name}</h3>
<Link href="/subject/1">
<a>Go id=1</a>
</Link>
<Link href="/subject/1">Go id=1</Link>
&nbsp;&nbsp;&nbsp;&nbsp;
<Link href="/subject/2">
<a>Go id=2</a>
</Link>
<Link href="/subject/2">Go id=2</Link>
</div>
);
};
1 change: 0 additions & 1 deletion packages/demo-saga-page/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
24 changes: 12 additions & 12 deletions packages/demo-saga-page/package.json
Original file line number Diff line number Diff line change
@@ -11,24 +11,24 @@
"dependencies": {
"jsondiffpatch": "0.4.1",
"next-redux-wrapper": "*",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"redux": "4.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "8.0.4",
"redux": "4.2.0",
"redux-logger": "3.0.6",
"redux-saga": "1.1.3"
"redux-saga": "1.2.1"
},
"devDependencies": {
"@playwright/test": "1.17.1",
"@types/react": "17.0.37",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.20",
"@playwright/test": "1.27.1",
"@types/react": "18.0.24",
"@types/react-dom": "18.0.8",
"@types/react-redux": "7.1.24",
"@types/redux-logger": "3.0.9",
"next": "12.0.4",
"next": "13.0.1",
"next-redux-wrapper-configs": "*",
"playwright": "1.17.1",
"playwright": "1.27.1",
"rimraf": "3.0.2",
"typescript": "4.5.2"
"typescript": "4.8.4"
},
"author": "Kirill Konshin",
"repository": {
1 change: 0 additions & 1 deletion packages/demo-saga/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
24 changes: 12 additions & 12 deletions packages/demo-saga/package.json
Original file line number Diff line number Diff line change
@@ -11,24 +11,24 @@
"dependencies": {
"jsondiffpatch": "0.4.1",
"next-redux-wrapper": "*",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"redux": "4.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "8.0.4",
"redux": "4.2.0",
"redux-logger": "3.0.6",
"redux-saga": "1.1.3"
"redux-saga": "1.2.1"
},
"devDependencies": {
"@playwright/test": "1.17.1",
"@types/react": "17.0.37",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.20",
"@playwright/test": "1.27.1",
"@types/react": "18.0.24",
"@types/react-dom": "18.0.8",
"@types/react-redux": "7.1.24",
"@types/redux-logger": "3.0.9",
"next": "12.0.4",
"next": "13.0.1",
"next-redux-wrapper-configs": "*",
"playwright": "1.17.1",
"playwright": "1.27.1",
"rimraf": "3.0.2",
"typescript": "4.5.2"
"typescript": "4.8.4"
},
"author": "Kirill Konshin",
"repository": {
1 change: 0 additions & 1 deletion packages/demo/next-env.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/// <reference types="next" />
/// <reference types="next/types/global" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
22 changes: 11 additions & 11 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
@@ -10,23 +10,23 @@
},
"dependencies": {
"next-redux-wrapper": "*",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"redux": "4.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "8.0.4",
"redux": "4.2.0",
"redux-logger": "3.0.6"
},
"devDependencies": {
"@playwright/test": "1.17.1",
"@types/react": "17.0.37",
"@types/react-dom": "17.0.11",
"@types/react-redux": "7.1.20",
"@playwright/test": "1.27.1",
"@types/react": "18.0.24",
"@types/react-dom": "18.0.8",
"@types/react-redux": "7.1.24",
"@types/redux-logger": "3.0.9",
"next": "12.0.4",
"next": "13.0.1",
"next-redux-wrapper-configs": "*",
"playwright": "1.17.1",
"playwright": "1.27.1",
"rimraf": "3.0.2",
"typescript": "4.5.2"
"typescript": "4.8.4"
},
"author": "Kirill Konshin",
"repository": {
4 changes: 2 additions & 2 deletions packages/demo/src/components/store.tsx
Original file line number Diff line number Diff line change
@@ -6,8 +6,8 @@ import reducer, {State} from './reducer';
export const makeStore = (context: Context) => {
const store = createStore(reducer, applyMiddleware(logger));

if (module.hot) {
module.hot.accept('./reducer', () => {
if ((module as any).hot) {
(module as any).hot.accept('./reducer', () => {
console.log('Replacing reducer');
store.replaceReducer(require('./reducer').default);
});
4 changes: 1 addition & 3 deletions packages/demo/src/pages/_error.tsx
Original file line number Diff line number Diff line change
@@ -12,9 +12,7 @@ const Error: NextPage = () => {
This is an error page, it also has access to store: <code>{app}</code>
</p>
<nav>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/">Navigate to index</Link>
</nav>
</>
);
12 changes: 3 additions & 9 deletions packages/demo/src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -44,17 +44,11 @@ class Index extends React.Component<PageProps> {

<pre>{JSON.stringify({pageProp, appProp, app, page}, null, 2)}</pre>

<Link href="/server">
<a>Navigate</a>
</Link>
<Link href="/server">Navigate</Link>
{' | '}
<Link href="/static">
<a>Navigate to static</a>
</Link>
<Link href="/static">Navigate to static</Link>
{' | '}
<Link href="/error">
<a>Navigate to error</a>
</Link>
<Link href="/error">Navigate to error</Link>
</div>
);
}
4 changes: 1 addition & 3 deletions packages/demo/src/pages/pageProps.tsx
Original file line number Diff line number Diff line change
@@ -10,9 +10,7 @@ const PropsPage: NextPage<State> = props => {
<p>Using Next.js default prop in a wrapped component.</p>
<pre>{JSON.stringify(props)}</pre>
<nav>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/">Navigate to index</Link>
</nav>
</div>
);
4 changes: 1 addition & 3 deletions packages/demo/src/pages/server.tsx
Original file line number Diff line number Diff line change
@@ -19,9 +19,7 @@ const Server: NextPage<OtherProps> = ({appProp, getServerSideProp}) => {
<pre>{JSON.stringify({app, page, getServerSideProp, appProp}, null, 2)}</pre>

<nav>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/">Navigate to index</Link>
</nav>
</div>
);
4 changes: 1 addition & 3 deletions packages/demo/src/pages/static.tsx
Original file line number Diff line number Diff line change
@@ -19,9 +19,7 @@ const Static: NextPage<OtherProps> = ({appProp, getStaticProp}) => {
<pre>{JSON.stringify({app, page, getStaticProp, appProp}, null, 2)}</pre>

<nav>
<Link href="/">
<a>Navigate to index</a>
</Link>
<Link href="/">Navigate to index</Link>
</nav>
</div>
);
31 changes: 16 additions & 15 deletions packages/wrapper/package.json
Original file line number Diff line number Diff line change
@@ -20,25 +20,26 @@
"start:tsc:es6": "yarn build:tsc:es6 --watch --preserveWatchOutput"
},
"devDependencies": {
"@types/jest": "27.0.1",
"@types/react": "17.0.37",
"@types/react-redux": "7.1.20",
"@types/react-test-renderer": "17.0.1",
"@types/jest": "29.2.1",
"@types/react": "18.0.24",
"@types/react-redux": "7.1.24",
"@types/react-test-renderer": "18.0.0",
"@types/redux-promise-middleware": "6.0.0",
"@types/webpack": "5.28.0",
"concurrently": "6.4.0",
"jest": "27.4.3",
"next": "12.0.4",
"concurrently": "7.5.0",
"jest": "29.2.2",
"jest-environment-jsdom": "29.2.2",
"next": "13.0.1",
"next-redux-wrapper-configs": "*",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-redux": "7.2.6",
"react-test-renderer": "17.0.2",
"redux": "4.1.2",
"redux-promise-middleware": "6.1.2",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-redux": "8.0.4",
"react-test-renderer": "18.2.0",
"redux": "4.2.0",
"redux-promise-middleware": "6.1.3",
"rimraf": "3.0.2",
"ts-jest": "27.0.7",
"typescript": "4.5.2"
"ts-jest": "29.0.3",
"typescript": "4.8.4"
},
"peerDependencies": {
"next": ">=9",
7 changes: 4 additions & 3 deletions packages/wrapper/src/index.tsx
Original file line number Diff line number Diff line change
@@ -262,6 +262,7 @@ export const createWrapper = <S extends Store>(makeStore: MakeStore<S>, config:
};

// Legacy
// eslint-disable-next-line import/no-anonymous-default-export
export default <S extends Store>(makeStore: MakeStore<S>, config: Config<S> = {}) => {
console.warn('/!\\ You are using legacy implementaion. Please update your code: use createWrapper() and wrapper.withRedux().');
return createWrapper(makeStore, config).withRedux;
@@ -285,11 +286,11 @@ type GetInitialPageProps<P> = NextComponentType<NextPageContext, any, P>['getIni
//FIXME Could be typeof App.getInitialProps & appGetInitialProps (not exported), see https://github.com/kirill-konshin/next-redux-wrapper/issues/412
type GetInitialAppProps<P> = ({Component, ctx}: AppContext) => Promise<AppInitialProps & {pageProps: P}>;

export type GetStaticPropsCallback<S extends Store, P> = (store: S) => GetStaticProps<P>;
export type GetServerSidePropsCallback<S extends Store, P> = (store: S) => GetServerSideProps<P>;
export type GetStaticPropsCallback<S extends Store, P extends {[key: string]: any}> = (store: S) => GetStaticProps<P>;
export type GetServerSidePropsCallback<S extends Store, P extends {[key: string]: any}> = (store: S) => GetServerSideProps<P>;
export type PageCallback<S extends Store, P> = (store: S) => GetInitialPageProps<P>;
export type AppCallback<S extends Store, P> = (store: S) => GetInitialAppProps<P>;
export type Callback<S extends Store, P> =
export type Callback<S extends Store, P extends {[key: string]: any}> =
| GetStaticPropsCallback<S, P>
| GetServerSidePropsCallback<S, P>
| PageCallback<S, P>
24,695 changes: 13,577 additions & 11,118 deletions yarn.lock

Large diffs are not rendered by default.