@pplancq/react-template 2.1.0 β†’ 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env CHANGED
@@ -37,6 +37,10 @@ ESLINT_CONFIG_TYPE='flat'
37
37
  # Default is false
38
38
  #DISABLE_SOURCE_MAP=false
39
39
 
40
+ # Sets the public URL or path for production environment.
41
+ # Default is 'http://localhost'
42
+ #PUBLIC_URL='http://localhost'
43
+
40
44
  # Sets the prefix for environment variables that will be passed to the frontend.
41
45
  # Access environment variables using import.meta.env.FRONT_FOO in the code.
42
46
  # Default is FRONT_
package/CHANGELOG.md CHANGED
@@ -1,3 +1,40 @@
1
+ ## @pplancq/react-template [2.3.0](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.2.0...@pplancq/react-template@2.3.0) (2024-12-09)
2
+
3
+ ### Features
4
+
5
+ * **webpack-config:** add PUBLIC_URL for sets the public URL or path for production environment ([e13e338](https://github.com/pplancq/dev-tools/commit/e13e33832953c44e9048ff68603f1865fcc01efd))
6
+ * **deps:** update react to v19 ([8ee050e](https://github.com/pplancq/dev-tools/commit/8ee050ed8d3ef2125bcf7e661239c4796bc9a4a4))
7
+
8
+ ### Bug Fixes
9
+
10
+ * **deps:** update dependency react-router to ^7.0.2 ([d47859e](https://github.com/pplancq/dev-tools/commit/d47859e67fa72c228d1483921f594ffc58d8f470))
11
+ * **deps:** update dependency yup to ^1.5.0 ([2ff356e](https://github.com/pplancq/dev-tools/commit/2ff356e6c823bc7fe9fee32f27c2a06057cbddd9))
12
+ * **deps:** update react-query mono repo to ^5.62.0 ([75cd49b](https://github.com/pplancq/dev-tools/commit/75cd49be2678b1a0b64cb076c051fb8b88d18c84))
13
+ * **deps:** update react-query mono repo to ^5.62.2 ([de08f42](https://github.com/pplancq/dev-tools/commit/de08f42859b3a0262642cfcd0a8ab69f32573095))
14
+
15
+
16
+ ### Dependencies
17
+
18
+ * **@pplancq/eslint-config:** upgraded to 4.0.4
19
+ * **@pplancq/webpack-config:** upgraded to 1.8.0
20
+
21
+ ## @pplancq/react-template [2.2.0](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.1.0...@pplancq/react-template@2.2.0) (2024-11-26)
22
+
23
+ ### Features
24
+
25
+ * **react-template:** migrate to react-router v7 ([fe86866](https://github.com/pplancq/dev-tools/commit/fe868665f1e028d844c2c55a99e856a043baa70c))
26
+
27
+ ### Bug Fixes
28
+
29
+ * **deps:** update react-query mono repo to ^5.61.0 ([ab3e03e](https://github.com/pplancq/dev-tools/commit/ab3e03e0309e9ffc48f405c328410fb81e6325d3))
30
+
31
+
32
+ ### Dependencies
33
+
34
+ * **@pplancq/eslint-config:** upgraded to 4.0.3
35
+ * **@pplancq/postcss-config:** upgraded to 2.1.5
36
+ * **@pplancq/webpack-config:** upgraded to 1.7.1
37
+
1
38
  ## @pplancq/react-template [2.1.0](https://github.com/pplancq/dev-tools/compare/@pplancq/react-template@2.0.1...@pplancq/react-template@2.1.0) (2024-11-18)
2
39
 
3
40
  ### Features
package/_gitignore CHANGED
@@ -26,3 +26,4 @@ yarn-debug.log*
26
26
  yarn-error.log*
27
27
 
28
28
  /.idea
29
+ /public/mockServiceWorker.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pplancq/react-template",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "license": "MIT",
5
5
  "description": "react template",
6
6
  "author": "pplancq <paul.plancq@outlook.fr>",
@@ -26,7 +26,8 @@
26
26
  "package:check": "npm exec --yes package-lock-utd@1.1.3",
27
27
  "remove:demo": "node ./scripts/removeDemo.js",
28
28
  "migrate:vite": "node ./scripts/migrateToVite.js",
29
- "_prepare": "husky"
29
+ "_prepare": "husky",
30
+ "postinstall": "msw init"
30
31
  },
31
32
  "bugs": {
32
33
  "url": "https://github.com/pplancq/dev-tools/issues"
@@ -37,16 +38,16 @@
37
38
  ],
38
39
  "dependencies": {
39
40
  "@hookform/resolvers": "^3.9.1",
40
- "@tanstack/react-query": "^5.60.2",
41
- "@tanstack/react-query-devtools": "^5.60.2",
42
- "react": "^18.3.1",
43
- "react-dom": "^18.3.1",
41
+ "@tanstack/react-query": "^5.62.2",
42
+ "@tanstack/react-query-devtools": "^5.62.2",
43
+ "react": "^19.0.0",
44
+ "react-dom": "^19.0.0",
44
45
  "react-hook-form": "^7.53.2",
45
- "react-router-dom": "^6.28.0",
46
- "yup": "^1.4.0"
46
+ "react-router": "^7.0.2",
47
+ "yup": "^1.5.0"
47
48
  },
48
49
  "devDependencies": {
49
- "@commitlint/cli": "^19.5.0",
50
+ "@commitlint/cli": "^19.6.0",
50
51
  "@pplancq/commitlint-config": "*",
51
52
  "@pplancq/eslint-config": "*",
52
53
  "@pplancq/postcss-config": "*",
@@ -54,30 +55,30 @@
54
55
  "@pplancq/stylelint-config": "*",
55
56
  "@pplancq/webpack-config": "*",
56
57
  "@testing-library/jest-dom": "^6.6.3",
57
- "@testing-library/react": "^16.0.1",
58
+ "@testing-library/react": "^16.1.0",
58
59
  "@testing-library/user-event": "^14.5.2",
59
- "@types/react": "^18.3.12",
60
- "@types/react-dom": "^18.3.1",
61
- "@vitejs/plugin-react-swc": "^3.7.1",
62
- "@vitest/coverage-v8": "^2.1.5",
60
+ "@types/react": "^19.0.1",
61
+ "@types/react-dom": "^19.0.1",
62
+ "@vitejs/plugin-react-swc": "^3.7.2",
63
+ "@vitest/coverage-v8": "^2.1.8",
63
64
  "concurrently": "^9.1.0",
64
- "eslint": "^9.14.0",
65
+ "eslint": "^9.16.0",
65
66
  "eslint-plugin-prettier": "^5.2.1",
66
- "husky": "^9.1.6",
67
+ "husky": "^9.1.7",
67
68
  "jsdom": "^25.0.1",
68
69
  "lint-staged": "^15.2.10",
69
- "msw": "^2.6.4",
70
- "prettier": "^3.3.3",
71
- "stylelint": "^16.10.0",
70
+ "msw": "^2.6.7",
71
+ "prettier": "^3.4.2",
72
+ "stylelint": "^16.11.0",
72
73
  "stylelint-prettier": "^5.0.2",
73
74
  "tsc-files": "^1.1.4",
74
- "typescript": "^5.6.3",
75
+ "typescript": "^5.7.2",
75
76
  "vite-plugin-svgr": "^4.3.0",
76
- "vite-tsconfig-paths": "^5.1.2",
77
- "vitest": "^2.1.5",
77
+ "vite-tsconfig-paths": "^5.1.3",
78
+ "vitest": "^2.1.8",
78
79
  "vitest-axe": "^1.0.0-pre.3",
79
80
  "vitest-sonar-reporter": "^2.0.0",
80
- "webpack": "^5.96.1",
81
+ "webpack": "^5.97.1",
81
82
  "webpack-cli": "^5.1.4",
82
83
  "webpack-dev-server": "^5.1.0"
83
84
  },
@@ -85,8 +86,8 @@
85
86
  "node": ">=20.12.2"
86
87
  },
87
88
  "volta": {
88
- "node": "22.11.0",
89
- "npm": "10.9.0"
89
+ "node": "22.12.0",
90
+ "npm": "10.9.2"
90
91
  },
91
92
  "browserslist": {
92
93
  "production": [
@@ -8,8 +8,8 @@
8
8
  * - Please do NOT serve this file on production.
9
9
  */
10
10
 
11
- const PACKAGE_VERSION = '2.6.5'
12
- const INTEGRITY_CHECKSUM = 'ca7800994cc8bfb5eb961e037c877074'
11
+ const PACKAGE_VERSION = '2.6.8'
12
+ const INTEGRITY_CHECKSUM = '00729d72e3b82faf54ca8b9621dbb96f'
13
13
  const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
14
14
  const activeClientIds = new Set()
15
15
 
@@ -199,7 +199,19 @@ async function getResponse(event, client, requestId) {
199
199
  // Remove the "accept" header value that marked this request as passthrough.
200
200
  // This prevents request alteration and also keeps it compliant with the
201
201
  // user-defined CORS policies.
202
- headers.delete('accept', 'msw/passthrough')
202
+ const acceptHeader = headers.get('accept')
203
+ if (acceptHeader) {
204
+ const values = acceptHeader.split(',').map((value) => value.trim())
205
+ const filteredValues = values.filter(
206
+ (value) => value !== 'msw/passthrough',
207
+ )
208
+
209
+ if (filteredValues.length > 0) {
210
+ headers.set('accept', filteredValues.join(', '))
211
+ } else {
212
+ headers.delete('accept')
213
+ }
214
+ }
203
215
 
204
216
  return fetch(requestClone, { headers })
205
217
  }
@@ -34,7 +34,7 @@ mkdirSync(resolveSrc('/pages/Home'));
34
34
  writeFileSync(resolveSrc('/pages/Home/index.ts'), "export { homeRoutes } from './routes';\n", { encoding: 'utf-8' });
35
35
  writeFileSync(
36
36
  resolveSrc('/pages/Home/routes.tsx'),
37
- "import type { RouteObject } from 'react-router-dom';\n" +
37
+ "import type { RouteObject } from 'react-router';\n" +
38
38
  "import { Home } from './Home';\n" +
39
39
  '\n' +
40
40
  'export const homeRoutes: RouteObject = {\n' +
@@ -1,7 +1,7 @@
1
1
  import { queryClient } from '@Front/config';
2
2
  import { withProvider } from '@Front/providers';
3
3
  import { createRouter } from '@Front/routing/routerFactory';
4
- import { RouterProvider } from 'react-router-dom';
4
+ import { RouterProvider } from 'react-router';
5
5
 
6
6
  import '@Front/assets/css';
7
7
 
@@ -1,6 +1,6 @@
1
1
  import logo from '@Front/assets/images/logo.png';
2
2
  import { Logo } from '@Front/ui/atoms/Logo';
3
- import { Link } from 'react-router-dom';
3
+ import { Link } from 'react-router';
4
4
 
5
5
  import classes from './Footer.module.css';
6
6
 
@@ -1,11 +1,11 @@
1
1
  import { render } from '@testing-library/react';
2
- import { BrowserRouter as Router } from 'react-router-dom';
2
+ import { BrowserRouter as Router } from 'react-router';
3
3
  import { Footer } from '../Footer';
4
4
 
5
5
  describe('Footer Component', () => {
6
6
  it('should render the Footer component correctly', () => {
7
7
  const { container } = render(
8
- <Router future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
8
+ <Router>
9
9
  <Footer />
10
10
  </Router>,
11
11
  );
@@ -7,6 +7,7 @@ exports[`Footer Component > should render the Footer component correctly 1`] = `
7
7
  >
8
8
  <hr />
9
9
  <a
10
+ data-discover="true"
10
11
  href="/"
11
12
  >
12
13
  <img
@@ -1,7 +1,7 @@
1
1
  import logo from '@Front/assets/images/logo.png';
2
2
  import { Logo } from '@Front/ui/atoms/Logo';
3
3
  import { Navigation } from '@Front/ui/molecules/Navigation';
4
- import { Link } from 'react-router-dom';
4
+ import { Link } from 'react-router';
5
5
 
6
6
  import classes from './Header.module.css';
7
7
 
@@ -1,11 +1,11 @@
1
1
  import { render } from '@testing-library/react';
2
- import { BrowserRouter as Router } from 'react-router-dom';
2
+ import { BrowserRouter as Router } from 'react-router';
3
3
  import { Header } from '../Header';
4
4
 
5
5
  describe('Header Component', () => {
6
6
  it('should render the Header component correctly', () => {
7
7
  const { container } = render(
8
- <Router future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
8
+ <Router>
9
9
  <Header />
10
10
  </Router>,
11
11
  );
@@ -6,6 +6,7 @@ exports[`Header Component > should render the Header component correctly 1`] = `
6
6
  class="_container_63c2ea"
7
7
  >
8
8
  <a
9
+ data-discover="true"
9
10
  href="/"
10
11
  >
11
12
  <img
@@ -23,6 +24,7 @@ exports[`Header Component > should render the Header component correctly 1`] = `
23
24
  <a
24
25
  aria-current="page"
25
26
  class="_a_75d6d6 active"
27
+ data-discover="true"
26
28
  href="/"
27
29
  >
28
30
  Demo
@@ -1,4 +1,4 @@
1
- import { RouteObject } from 'react-router-dom';
1
+ import { RouteObject } from 'react-router';
2
2
  import { ReactHookFormDemo } from './ReactHookFormDemo';
3
3
 
4
4
  export const reactHookFormDemoRoutes: RouteObject = {
@@ -1,4 +1,4 @@
1
- import { RouteObject } from 'react-router-dom';
1
+ import { RouteObject } from 'react-router';
2
2
  import { ReactQueryDemo } from './ReactQueryDemo';
3
3
 
4
4
  export const reactQueryDemoRoutes: RouteObject = {
@@ -1,11 +1,11 @@
1
1
  import { render } from '@testing-library/react';
2
- import { BrowserRouter as Router } from 'react-router-dom';
2
+ import { BrowserRouter as Router } from 'react-router';
3
3
  import { Demo } from '../Demo';
4
4
 
5
5
  describe('Demo Component', () => {
6
6
  it('should render the Demo component correctly', () => {
7
7
  const { container } = render(
8
- <Router future={{ v7_startTransition: true, v7_relativeSplatPath: true }}>
8
+ <Router>
9
9
  <Demo />
10
10
  </Router>,
11
11
  );
@@ -189,6 +189,7 @@ exports[`Demo Component > should render the Demo component correctly 1`] = `
189
189
  >
190
190
  <a
191
191
  class="_a_85a2c3"
192
+ data-discover="true"
192
193
  href="/reactQueryDemo"
193
194
  >
194
195
  Run Demo
@@ -226,6 +227,7 @@ exports[`Demo Component > should render the Demo component correctly 1`] = `
226
227
  >
227
228
  <a
228
229
  class="_a_85a2c3"
230
+ data-discover="true"
229
231
  href="/reactHookFormDemo"
230
232
  >
231
233
  Run Demo
@@ -1,5 +1,5 @@
1
1
  import { reactHookFormDemoRoutes } from '@Front/pages/Demo/ReactHookFormDemo';
2
- import { RouteObject } from 'react-router-dom';
2
+ import { RouteObject } from 'react-router';
3
3
  import { Demo } from './Demo';
4
4
  import { reactQueryDemoRoutes } from './ReactQueryDemo';
5
5
 
@@ -1,7 +1,7 @@
1
1
  import { Footer } from '@Front/components/Footer';
2
2
  import { Header } from '@Front/components/Header';
3
3
  import { MainTemplate } from '@Front/ui/templates/MainTemplate';
4
- import { Outlet } from 'react-router-dom';
4
+ import { Outlet } from 'react-router';
5
5
 
6
6
  export const Layout = () => {
7
7
  return (
@@ -48,8 +48,8 @@ Suppose we have a "UserProfile" page with a complex structure:
48
48
  // index.ts
49
49
  export { userProfileRoutes } from './routes';
50
50
 
51
- // routes.tsx (react-router-dom v6)
52
- import { RouteObject } from 'react-router-dom';
51
+ // routes.tsx (react-router v7)
52
+ import { RouteObject } from 'react-router';
53
53
  import { UserProfile } from './UserProfile';
54
54
 
55
55
  export const userProfileRoutes: RouteObject = {
@@ -1,6 +1,6 @@
1
1
  import logo from '@Front/assets/images/logo.png';
2
2
  import { Logo } from '@Front/ui/atoms/Logo';
3
- import { Link, useRouteError } from 'react-router-dom';
3
+ import { Link, useRouteError } from 'react-router';
4
4
 
5
5
  import classes from './UnexpectedError.module.css';
6
6
 
@@ -1,11 +1,11 @@
1
1
  # πŸ“routing
2
2
 
3
- The "routing" folder is responsible for managing navigation within the application. We use the `react-router-dom` library to facilitate route creation and navigation between different views of our application.
3
+ The "routing" folder is responsible for managing navigation within the application. We use the `react-router` library to facilitate route creation and navigation between different views of our application.
4
4
 
5
5
  ## πŸ“‘ Table of Contents
6
6
 
7
7
  - [Folder Organization](#folder-organization)
8
- - [Using `react-router-dom`](#react-router-dom)
8
+ - [Using `react-router`](#react-router)
9
9
  - [Using `appRoutes.ts`](#using-appRoutes)
10
10
  - [Learn More](#learn-more)
11
11
 
@@ -19,13 +19,13 @@ In the "routing" folder, you can find the following files and components:
19
19
 
20
20
  3. **`appRoutes.ts`** It contains a simple structure to define the paths of our application.
21
21
 
22
- ## <span id="react-router-dom">πŸ§‘πŸ»β€πŸ’» Using `react-router-dom` </span>
22
+ ## <span id="react-router">πŸ§‘πŸ»β€πŸ’» Using `react-router` </span>
23
23
 
24
- `react-router-dom` is a library that makes it easy to create routes in a React application. You can import it into the appropriate files to define routes and manage navigation between views. Here's a simple example of its usage:
24
+ `react-router` is a library that makes it easy to create routes in a React application. You can import it into the appropriate files to define routes and manage navigation between views. Here's a simple example of its usage:
25
25
 
26
26
  ```javascript
27
27
  import { createRoot } from 'react-dom/client';
28
- import { createBrowserRouter, RouterProvider } from 'react-router-dom';
28
+ import { createBrowserRouter, RouterProvider } from 'react-router/dom';
29
29
 
30
30
  const router = createBrowserRouter([
31
31
  {
@@ -62,7 +62,7 @@ export const appRoutes = {
62
62
  article: '/post/:id',
63
63
  };
64
64
  // component.tsx
65
- import { NavLink, generatePath } from 'react-router-dom';
65
+ import { NavLink, generatePath } from 'react-router/dom';
66
66
  import { appRoutes } from '@Front/routing/appRoutes';
67
67
  export const ComponentName = () => {
68
68
  return <NavLink to={generatePath(appRoutes.article, { id: 1 })}>link to article 1</NavLink>;
@@ -1,4 +1,4 @@
1
- import { createBrowserRouter } from 'react-router-dom';
1
+ import { createBrowserRouter } from 'react-router';
2
2
  import { routeObject } from './routes';
3
3
 
4
4
  interface CreateRouterProps {
@@ -8,11 +8,5 @@ interface CreateRouterProps {
8
8
  export const createRouter = ({ basename }: CreateRouterProps = {}) => {
9
9
  return createBrowserRouter(routeObject, {
10
10
  basename,
11
- future: {
12
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
13
- // @ts-expect-error
14
- v7_startTransition: true,
15
- v7_relativeSplatPath: true,
16
- },
17
11
  });
18
12
  };
@@ -1,6 +1,6 @@
1
1
  import { demoRoutes } from '@Front/pages/Demo';
2
2
  import { Layout } from '@Front/pages/Layout';
3
- import type { RouteObject } from 'react-router-dom';
3
+ import type { RouteObject } from 'react-router';
4
4
  import { UnexpectedError } from 'src/pages/UnexpectedError';
5
5
 
6
6
  export const routeObject: RouteObject[] = [
@@ -1,5 +1,5 @@
1
1
  import { ComponentProps } from 'react';
2
- import { NavLink as RouterNavLink } from 'react-router-dom';
2
+ import { NavLink as RouterNavLink } from 'react-router';
3
3
 
4
4
  type NavLinkProps = ComponentProps<typeof RouterNavLink>;
5
5
 
package/webpack.config.js CHANGED
@@ -15,7 +15,7 @@ module.exports = {
15
15
  // shared: {
16
16
  // react: { singleton: true, requiredVersion: deps.react },
17
17
  // 'react-dom': { singleton: true, requiredVersion: deps['react-dom'] },
18
- // 'react-router-dom': { singleton: true, requiredVersion: deps['react-router-dom'] },
18
+ // 'react-router': { singleton: true, requiredVersion: deps['react-router'] },
19
19
  // },
20
20
  // }),
21
21
  // ],