@appigram/react-code-split-ssr 1.2.13 → 1.2.15

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.
@@ -9,10 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
11
11
  import { matchPath, Route, Routes } from "react-router-dom";
12
- const generateRoutes = (options = {
12
+ const generateRoutes = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (options = {
13
13
  pathname: "/",
14
14
  routes: [],
15
- }) => __awaiter(void 0, void 0, void 0, function* () {
15
+ }) {
16
16
  if (!Array.isArray(options.routes) || options.routes.length === 0) {
17
17
  throw new Error("options.routes must be an non-empty array");
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appigram/react-code-split-ssr",
3
- "version": "1.2.13",
3
+ "version": "1.2.15",
4
4
  "description": "React code splitting with SSR",
5
5
  "main": "./lib/index.js",
6
6
  "scripts": {
@@ -22,15 +22,15 @@
22
22
  "author": "Eugene Sysmanov",
23
23
  "license": "MIT",
24
24
  "devDependencies": {
25
- "@types/react": "^18.2.33",
25
+ "@types/react": "^18.3.1",
26
26
  "@types/react-router-dom": "^5.3.3",
27
27
  "tslint": "^6.1.3",
28
28
  "tslint-react": "^5.0.0",
29
- "typescript": "^5.2.2"
29
+ "typescript": "^5.4.5"
30
30
  },
31
31
  "dependencies": {
32
- "react": "^18.2.0",
33
- "react-dom": "^18.2.0",
34
- "react-router-dom": "^6.17.0"
32
+ "react": "^18.3.1",
33
+ "react-dom": "^18.3.1",
34
+ "react-router-dom": "^6.23.0"
35
35
  }
36
36
  }
package/src/bundle.tsx CHANGED
@@ -1,23 +1,23 @@
1
- import {useState, useEffect} from 'react'
1
+ import { useState, useEffect } from 'react';
2
2
 
3
3
  export interface IProps {
4
- mod: Promise<any>
5
- loading?: React.FC
4
+ mod: Promise<any>;
5
+ loading?: React.FC;
6
6
  }
7
7
 
8
8
  const Bundle = ({ mod, loading }: IProps) => {
9
- const [ state, setState ] = useState({ mod: null })
9
+ const [state, setState] = useState({ mod: null });
10
10
 
11
11
  useEffect(() => {
12
12
  (async function () {
13
- const Mod = await mod
14
- setState({ mod: Mod.default })
15
- })()
16
- }, [])
13
+ const Mod = await mod;
14
+ setState({ mod: Mod.default });
15
+ })();
16
+ }, []);
17
17
 
18
- const Mod = state.mod
19
- const Loading = loading || (() => <div />)
20
- return state.mod ? <Mod /> : <Loading />
21
- }
18
+ const Mod = state.mod;
19
+ const Loading = loading || (() => <div />);
20
+ return state.mod ? <Mod /> : <Loading />;
21
+ };
22
22
 
23
- export default Bundle
23
+ export default Bundle;
@@ -1,4 +1,4 @@
1
- import { ReactElement } from "react";
1
+ import React, { ReactElement } from "react";
2
2
  import { matchPath, Route, Routes } from "react-router-dom";
3
3
 
4
4
  export interface IJSXModule {
@@ -33,19 +33,19 @@ const generateRoutes = async (
33
33
  (route) => !!matchPath(route.path, options.pathname)
34
34
  );
35
35
 
36
- const preloadedElement = preload === undefined ? options.notFoundComp : preload.element
36
+ const preloadedElement = preload === undefined ? options.notFoundComp : preload.element;
37
37
 
38
38
  // fallback to previous version
39
39
  const preloadedComp: any = typeof preloadedElement === 'function' ?
40
40
  await preloadedElement().props.mod
41
41
  :
42
- await preloadedElement.props.mod
42
+ await preloadedElement.props.mod;
43
43
 
44
44
  const renderElement = (path: string, bundle: ReactElement) => {
45
45
  if (!preloadedComp) return bundle;
46
46
  const isRouteMatched = (preload && preload.path === path) || (!preload && !path);
47
47
  const Element = isRouteMatched ? preloadedComp.default : bundle;
48
- return isRouteMatched ? <Element /> : Element
48
+ return isRouteMatched ? <Element /> : Element;
49
49
  };
50
50
 
51
51
  return (
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import Bundle from './bundle'
2
- import generateRoutes from './generate-routes'
1
+ import Bundle from './bundle';
2
+ import generateRoutes from './generate-routes';
3
3
 
4
- export { Bundle, generateRoutes }
4
+ export { Bundle, generateRoutes };