@modern-js/utils 2.6.0 → 2.7.1-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @modern-js/utils
2
2
 
3
+ ## 2.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - dcad887024: feat: support deferred data for streaming ssr
8
+ feat: 流式渲染支持 deferred data
9
+ - 84bfb439b8: feat: support custom apiDir, lambdaDir and style of writing for bff
10
+ feat: 支持定制 api 目录,lambda 目录,bff 的写法
11
+
12
+ ### Patch Changes
13
+
14
+ - 0f15fc597c: fix: remove nestedRoutes export
15
+ fix: 移除 nestedRoutes 导出
16
+ - a4672f7c16: fix: lock @modern-js/utils/ssr by webpack alias
17
+ fix: 通过 webpack 别名将 @modern-js/utils/ssr 锁到同一版本
18
+ - 7fff9020e1: chore: make file naming consistent
19
+
20
+ chore: 统一文件命名为小驼峰格式
21
+
3
22
  ## 2.6.0
4
23
 
5
24
  ### Patch Changes
package/README.md CHANGED
@@ -19,8 +19,8 @@ Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-sta
19
19
 
20
20
  ## Contributing
21
21
 
22
- Please read the [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md).
22
+ Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
23
23
 
24
24
  ## License
25
25
 
26
- Modern.js is [MIT licensed](https://github.com/modern-js-dev/modern.js/blob/main/LICENSE).
26
+ Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
@@ -1 +1,2 @@
1
- export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
1
+ export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
2
+ export declare const isWebOnly: () => Promise<boolean>;
@@ -47,7 +47,8 @@ var __async = (__this, __arguments, generator) => {
47
47
  };
48
48
  var analyzeProject_exports = {};
49
49
  __export(analyzeProject_exports, {
50
- isApiOnly: () => isApiOnly
50
+ isApiOnly: () => isApiOnly,
51
+ isWebOnly: () => isWebOnly
51
52
  });
52
53
  module.exports = __toCommonJS(analyzeProject_exports);
53
54
  var path = __toESM(require("path"));
@@ -58,7 +59,12 @@ const isApiOnly = (appDirectory, entryDir) => __async(void 0, null, function* ()
58
59
  const options = (0, import_compiled.minimist)(process.argv.slice(2));
59
60
  return !existSrc || Boolean(options["api-only"]);
60
61
  });
62
+ const isWebOnly = () => __async(void 0, null, function* () {
63
+ const options = (0, import_compiled.minimist)(process.argv.slice(2));
64
+ return Boolean(options["web-only"]);
65
+ });
61
66
  // Annotate the CommonJS export names for ESM import in node:
62
67
  0 && (module.exports = {
63
- isApiOnly
68
+ isApiOnly,
69
+ isWebOnly
64
70
  });
@@ -0,0 +1 @@
1
+ export declare const getTargetDir: (from: string, baseDir: string, targetBaseDir: string) => string;
@@ -0,0 +1,41 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var getTargetDir_exports = {};
29
+ __export(getTargetDir_exports, {
30
+ getTargetDir: () => getTargetDir
31
+ });
32
+ module.exports = __toCommonJS(getTargetDir_exports);
33
+ var path = __toESM(require("path"));
34
+ const getTargetDir = (from, baseDir, targetBaseDir) => {
35
+ const relativePath = path.relative(baseDir, from);
36
+ return path.resolve(targetBaseDir, relativePath);
37
+ };
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ getTargetDir
41
+ });
package/dist/index.d.ts CHANGED
@@ -32,13 +32,13 @@ export * from './nodeEnv';
32
32
  export * from './wait';
33
33
  export * from './emptyDir';
34
34
  export * from './getServerConfig';
35
- export * from './ssr';
36
35
  export * from './tryResolve';
37
36
  export * from './analyzeProject';
38
37
  export * from './chainId';
39
38
  export * from './version';
40
39
  export * from './plugin';
41
40
  export * from './routes';
42
- export * from './test-utils';
41
+ export * from './testUtils';
43
42
  export * from './getCoreJsVersion';
44
- export * from './react';
43
+ export * from './react';
44
+ export * from './getTargetDir';
package/dist/index.js CHANGED
@@ -48,13 +48,13 @@ __reExport(src_exports, require("./nodeEnv"), module.exports);
48
48
  __reExport(src_exports, require("./wait"), module.exports);
49
49
  __reExport(src_exports, require("./emptyDir"), module.exports);
50
50
  __reExport(src_exports, require("./getServerConfig"), module.exports);
51
- __reExport(src_exports, require("./ssr"), module.exports);
52
51
  __reExport(src_exports, require("./tryResolve"), module.exports);
53
52
  __reExport(src_exports, require("./analyzeProject"), module.exports);
54
53
  __reExport(src_exports, require("./chainId"), module.exports);
55
54
  __reExport(src_exports, require("./version"), module.exports);
56
55
  __reExport(src_exports, require("./plugin"), module.exports);
57
56
  __reExport(src_exports, require("./routes"), module.exports);
58
- __reExport(src_exports, require("./test-utils"), module.exports);
57
+ __reExport(src_exports, require("./testUtils"), module.exports);
59
58
  __reExport(src_exports, require("./getCoreJsVersion"), module.exports);
60
59
  __reExport(src_exports, require("./react"), module.exports);
60
+ __reExport(src_exports, require("./getTargetDir"), module.exports);
@@ -1,3 +1,6 @@
1
+ interface EntryPoint {
2
+ entryName: string;
3
+ }
1
4
  /**
2
5
  * Check if the package name is in dependencies or devDependencies.
3
6
  *
@@ -5,6 +8,7 @@
5
8
  * @param name - Package name.
6
9
  * @returns True if the name is in dependencies or devDependencies, false otherwise.
7
10
  */
11
+
8
12
  export declare const isDepExists: (appDirectory: string, name: string) => boolean;
9
13
  /**
10
14
  * Is typescript project.
@@ -47,6 +51,8 @@ export declare const isRouterV5: (config: {
47
51
  } | boolean;
48
52
  };
49
53
  }) => boolean;
50
- export * from './node-env';
54
+ export declare const isSSGEntry: (config: any, entryName: string, entrypoints: EntryPoint[]) => boolean;
55
+ export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
56
+ export * from './nodeEnv';
51
57
  export * from './platform';
52
58
  export * from './type';
package/dist/is/index.js CHANGED
@@ -32,8 +32,10 @@ __export(is_exports, {
32
32
  isEmpty: () => isEmpty,
33
33
  isFastRefresh: () => isFastRefresh,
34
34
  isRouterV5: () => isRouterV5,
35
+ isSSGEntry: () => isSSGEntry,
35
36
  isSSR: () => isSSR,
36
37
  isServiceWorker: () => isServiceWorker,
38
+ isSingleEntry: () => isSingleEntry,
37
39
  isTypescript: () => isTypescript,
38
40
  isUseSSRBundle: () => isUseSSRBundle
39
41
  });
@@ -41,8 +43,8 @@ module.exports = __toCommonJS(is_exports);
41
43
  var import_fs = __toESM(require("fs"));
42
44
  var import_path = __toESM(require("path"));
43
45
  var import_debug = require("../debug");
44
- var import_node_env = require("./node-env");
45
- __reExport(is_exports, require("./node-env"), module.exports);
46
+ var import_nodeEnv = require("./nodeEnv");
47
+ __reExport(is_exports, require("./nodeEnv"), module.exports);
46
48
  __reExport(is_exports, require("./platform"), module.exports);
47
49
  __reExport(is_exports, require("./type"), module.exports);
48
50
  const debug = (0, import_debug.createDebugger)("judge-depExists");
@@ -86,19 +88,27 @@ const isServiceWorker = (config) => {
86
88
  }
87
89
  return false;
88
90
  };
89
- const isFastRefresh = () => (0, import_node_env.isDev)() && process.env.FAST_REFRESH !== "false";
91
+ const isFastRefresh = () => (0, import_nodeEnv.isDev)() && process.env.FAST_REFRESH !== "false";
90
92
  const isRouterV5 = (config) => {
91
93
  var _a, _b, _c;
92
94
  return typeof ((_a = config.runtime) == null ? void 0 : _a.router) !== "boolean" && ((_c = (_b = config == null ? void 0 : config.runtime) == null ? void 0 : _b.router) == null ? void 0 : _c.mode) === "react-router-5";
93
95
  };
96
+ const isSSGEntry = (config, entryName, entrypoints) => {
97
+ const ssgConfig = config.output.ssg;
98
+ const useSSG = isSingleEntry(entrypoints) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig == null ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig == null ? void 0 : ssgConfig[entryName]);
99
+ return useSSG;
100
+ };
101
+ const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
94
102
  // Annotate the CommonJS export names for ESM import in node:
95
103
  0 && (module.exports = {
96
104
  isDepExists,
97
105
  isEmpty,
98
106
  isFastRefresh,
99
107
  isRouterV5,
108
+ isSSGEntry,
100
109
  isSSR,
101
110
  isServiceWorker,
111
+ isSingleEntry,
102
112
  isTypescript,
103
113
  isUseSSRBundle
104
114
  });
@@ -15,15 +15,15 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var node_env_exports = {};
19
- __export(node_env_exports, {
18
+ var nodeEnv_exports = {};
19
+ __export(nodeEnv_exports, {
20
20
  getNodeEnv: () => getNodeEnv,
21
21
  isDev: () => isDev,
22
22
  isProd: () => isProd,
23
23
  isProdProfile: () => isProdProfile,
24
24
  isTest: () => isTest
25
25
  });
26
- module.exports = __toCommonJS(node_env_exports);
26
+ module.exports = __toCommonJS(nodeEnv_exports);
27
27
  const getNodeEnv = () => process.env.NODE_ENV || "development";
28
28
  const isDev = () => getNodeEnv() === "development";
29
29
  const isProd = () => getNodeEnv() === "production";
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+
3
+ /**
4
+ * runtime utils for nested routes generating
5
+ */
6
+ import type { NestedRoute } from '@modern-js/types';
7
+ export declare const transformNestedRoutes: (routes: NestedRoute[]) => import("react-router-dom").RouteObject[];
8
+ export declare const renderNestedRoute: (nestedRoute: NestedRoute, options?: {
9
+ parent?: NestedRoute;
10
+ DeferredDataComponent?: () => JSX.Element | null;
11
+ }) => JSX.Element;
@@ -0,0 +1,129 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __defProps = Object.defineProperties;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropSymbols = Object.getOwnPropertySymbols;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __propIsEnum = Object.prototype.propertyIsEnumerable;
9
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
10
+ var __spreadValues = (a, b) => {
11
+ for (var prop in b || (b = {}))
12
+ if (__hasOwnProp.call(b, prop))
13
+ __defNormalProp(a, prop, b[prop]);
14
+ if (__getOwnPropSymbols)
15
+ for (var prop of __getOwnPropSymbols(b)) {
16
+ if (__propIsEnum.call(b, prop))
17
+ __defNormalProp(a, prop, b[prop]);
18
+ }
19
+ return a;
20
+ };
21
+ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __export = (target, all) => {
23
+ for (var name in all)
24
+ __defProp(target, name, { get: all[name], enumerable: true });
25
+ };
26
+ var __copyProps = (to, from, except, desc) => {
27
+ if (from && typeof from === "object" || typeof from === "function") {
28
+ for (let key of __getOwnPropNames(from))
29
+ if (!__hasOwnProp.call(to, key) && key !== except)
30
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
31
+ }
32
+ return to;
33
+ };
34
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
+ var nestedRoutes_exports = {};
36
+ __export(nestedRoutes_exports, {
37
+ renderNestedRoute: () => renderNestedRoute,
38
+ transformNestedRoutes: () => transformNestedRoutes
39
+ });
40
+ module.exports = __toCommonJS(nestedRoutes_exports);
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ var import_react = require("react");
43
+ var import_react_router_dom = require("react-router-dom");
44
+ const transformNestedRoutes = (routes) => {
45
+ const routeElements = [];
46
+ for (const route of routes) {
47
+ const routeElement = renderNestedRoute(route);
48
+ routeElements.push(routeElement);
49
+ }
50
+ return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
51
+ };
52
+ const renderNestedRoute = (nestedRoute, options = {}) => {
53
+ const { children, index, id, component, isRoot } = nestedRoute;
54
+ const Component = component;
55
+ const { parent, DeferredDataComponent } = options;
56
+ const routeProps = {
57
+ caseSensitive: nestedRoute.caseSensitive,
58
+ path: nestedRoute.path,
59
+ id: nestedRoute.id,
60
+ loader: createLoader(nestedRoute),
61
+ action: nestedRoute.action,
62
+ hasErrorBoundary: nestedRoute.hasErrorBoundary,
63
+ shouldRevalidate: nestedRoute.shouldRevalidate,
64
+ handle: nestedRoute.handle,
65
+ index: nestedRoute.index,
66
+ element: nestedRoute.element,
67
+ errorElement: nestedRoute.errorElement
68
+ };
69
+ if (nestedRoute.error) {
70
+ const errorElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(nestedRoute.error, {});
71
+ routeProps.errorElement = errorElement;
72
+ }
73
+ let element;
74
+ if (Component) {
75
+ if (parent == null ? void 0 : parent.loading) {
76
+ const Loading = parent.loading;
77
+ if (isLoadableComponent(Component)) {
78
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) });
79
+ } else {
80
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
81
+ }
82
+ } else if (isLoadableComponent(Component)) {
83
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
84
+ } else if (isRoot) {
85
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
86
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}),
87
+ typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
88
+ ] });
89
+ } else {
90
+ element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
91
+ }
92
+ } else {
93
+ nestedRoute.loading = parent == null ? void 0 : parent.loading;
94
+ }
95
+ if (element) {
96
+ routeProps.element = element;
97
+ }
98
+ const childElements = children == null ? void 0 : children.map((childRoute) => {
99
+ return renderNestedRoute(childRoute, { parent: nestedRoute });
100
+ });
101
+ const routeElement = index ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: true }), id) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, __spreadProps(__spreadValues({}, routeProps), { index: false, children: childElements }), id);
102
+ return routeElement;
103
+ };
104
+ function createLoader(route) {
105
+ const { loader } = route;
106
+ if (loader) {
107
+ return (args) => {
108
+ if (typeof route.lazyImport === "function") {
109
+ route.lazyImport();
110
+ }
111
+ return loader(args);
112
+ };
113
+ } else {
114
+ return () => {
115
+ if (typeof route.lazyImport === "function") {
116
+ route.lazyImport();
117
+ }
118
+ return null;
119
+ };
120
+ }
121
+ }
122
+ function isLoadableComponent(component) {
123
+ return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
124
+ }
125
+ // Annotate the CommonJS export names for ESM import in node:
126
+ 0 && (module.exports = {
127
+ renderNestedRoute,
128
+ transformNestedRoutes
129
+ });
@@ -1,13 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import os from 'os';
3
- interface EntryPoint {
4
- entryName: string;
5
- }
6
- export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
7
3
  export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
8
4
  export declare const getAddressUrls: (protocol: string | undefined, port: number) => {
9
5
  type: string;
10
6
  url: string;
11
7
  }[];
12
- export declare const prettyInstructions: (appContext: any, config: any) => string;
13
- export {};
8
+ export declare const prettyInstructions: (appContext: any, config: any) => string;
@@ -29,14 +29,12 @@ var prettyInstructions_exports = {};
29
29
  __export(prettyInstructions_exports, {
30
30
  getAddressUrls: () => getAddressUrls,
31
31
  getIpv4Interfaces: () => getIpv4Interfaces,
32
- isSingleEntry: () => isSingleEntry,
33
32
  prettyInstructions: () => prettyInstructions
34
33
  });
35
34
  module.exports = __toCommonJS(prettyInstructions_exports);
36
35
  var import_os = __toESM(require("os"));
37
36
  var import_compiled = require("./compiled");
38
37
  var import_is = require("./is");
39
- const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === "main";
40
38
  const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, "$1");
41
39
  const getIpv4Interfaces = () => {
42
40
  const interfaces = import_os.default.networkInterfaces();
@@ -75,7 +73,7 @@ const prettyInstructions = (appContext, config) => {
75
73
  );
76
74
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
77
75
  let message = "App running at:\n\n";
78
- if (isSingleEntry(entrypoints) || apiOnly) {
76
+ if ((0, import_is.isSingleEntry)(entrypoints) || apiOnly) {
79
77
  message += urls.map(
80
78
  ({ type, url }) => ` ${import_compiled.chalk.bold(`> ${type.padEnd(10)}`)}${import_compiled.chalk.cyanBright(
81
79
  normalizeUrl(`${url}/${routes[0].urlPath}`)
@@ -113,6 +111,5 @@ const prettyInstructions = (appContext, config) => {
113
111
  0 && (module.exports = {
114
112
  getAddressUrls,
115
113
  getIpv4Interfaces,
116
- isSingleEntry,
117
114
  prettyInstructions
118
115
  });
@@ -0,0 +1 @@
1
+ export * from '@remix-run/router';
@@ -0,0 +1,17 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __copyProps = (to, from, except, desc) => {
6
+ if (from && typeof from === "object" || typeof from === "function") {
7
+ for (let key of __getOwnPropNames(from))
8
+ if (!__hasOwnProp.call(to, key) && key !== except)
9
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
+ }
11
+ return to;
12
+ };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+ var remix_router_exports = {};
16
+ module.exports = __toCommonJS(remix_router_exports);
17
+ __reExport(remix_router_exports, require("@remix-run/router"), module.exports);
@@ -0,0 +1 @@
1
+ export declare const serializeJson: (data: any) => string;
@@ -0,0 +1,40 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
20
+ // If the importer is in node compatibility mode or this is not an ESM
21
+ // file that has been converted to a CommonJS file using a Babel-
22
+ // compatible transform (i.e. "__esModule" has not been set), then set
23
+ // "default" to the CommonJS "module.exports" for node compatibility.
24
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
25
+ mod
26
+ ));
27
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
+ var serialize_exports = {};
29
+ __export(serialize_exports, {
30
+ serializeJson: () => serializeJson
31
+ });
32
+ module.exports = __toCommonJS(serialize_exports);
33
+ var import_serialize_javascript = __toESM(require("serialize-javascript"));
34
+ const serializeJson = (data) => {
35
+ return (0, import_serialize_javascript.default)(data, { isJSON: true });
36
+ };
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ serializeJson
40
+ });
@@ -15,11 +15,11 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
17
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var test_utils_exports = {};
19
- __export(test_utils_exports, {
18
+ var testUtils_exports = {};
19
+ __export(testUtils_exports, {
20
20
  initSnapshotSerializer: () => initSnapshotSerializer
21
21
  });
22
- module.exports = __toCommonJS(test_utils_exports);
22
+ module.exports = __toCommonJS(testUtils_exports);
23
23
  const initSnapshotSerializer = (root) => {
24
24
  expect.addSnapshotSerializer({
25
25
  test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
package/package.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "name": "@modern-js/utils",
3
3
  "description": "A Progressive React Framework for modern web development.",
4
4
  "homepage": "https://modernjs.dev",
5
- "bugs": "https://github.com/modern-js-dev/modern.js/issues",
6
- "repository": "modern-js-dev/modern.js",
5
+ "bugs": "https://github.com/web-infra-dev/modern.js/issues",
6
+ "repository": "web-infra-dev/modern.js",
7
7
  "license": "MIT",
8
8
  "keywords": [
9
9
  "react",
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.6.0",
14
+ "version": "2.7.1-alpha.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -23,6 +23,9 @@
23
23
  "./format": "./dist/format.js",
24
24
  "./logger": "./dist/logger.js",
25
25
  "./constants": "./dist/constants.js",
26
+ "./serialize": "./dist/serialize.js",
27
+ "./nestedRoutes": "./dist/nestedRoutes.js",
28
+ "./remix-router": "./dist/remix-router.js",
26
29
  "./ajv": "./compiled/ajv/index.js",
27
30
  "./glob": "./compiled/glob/index.js",
28
31
  "./chalk": "./compiled/chalk/index.js",
@@ -61,6 +64,12 @@
61
64
  "constants": [
62
65
  "./dist/constants.d.ts"
63
66
  ],
67
+ "serialize": [
68
+ "./dist/serialize.d.ts"
69
+ ],
70
+ "nestedRoutes": [
71
+ "./dist/nestedRoutes.d.ts"
72
+ ],
64
73
  "ajv": [
65
74
  "./compiled/ajv/types/ajv.d.ts"
66
75
  ],
@@ -120,22 +129,47 @@
120
129
  ],
121
130
  "chain-id": [
122
131
  "./dist/chainId.d.ts"
132
+ ],
133
+ "remix-router": [
134
+ "./dist/remix-router.d.ts"
123
135
  ]
124
136
  }
125
137
  },
126
138
  "dependencies": {
127
139
  "caniuse-lite": "^1.0.30001451",
128
- "lodash": "^4.17.21"
140
+ "lodash": "^4.17.21",
141
+ "serialize-javascript": "^6.0.0",
142
+ "@remix-run/router": "^1.3.2"
143
+ },
144
+ "peerDependencies": {
145
+ "react": ">=17.0.0",
146
+ "react-dom": ">=17.0.0",
147
+ "react-router-dom": "^6.8.1"
148
+ },
149
+ "peerDependenciesMeta": {
150
+ "react": {
151
+ "optional": true
152
+ },
153
+ "react-dom": {
154
+ "optional": true
155
+ },
156
+ "react-router-dom": {
157
+ "optional": true
158
+ }
129
159
  },
130
160
  "devDependencies": {
161
+ "react": ">=17.0.0",
162
+ "react-dom": ">=17.0.0",
163
+ "react-router-dom": "^6.8.1",
164
+ "@modern-js/types": "2.7.0",
165
+ "@scripts/build": "2.7.0",
166
+ "@scripts/jest-config": "2.7.0",
131
167
  "@types/jest": "^27",
132
168
  "@types/node": "^14",
133
169
  "jest": "^27",
134
170
  "typescript": "^4",
135
171
  "webpack": "^5.75.0",
136
- "@modern-js/types": "2.6.0",
137
- "@scripts/jest-config": "2.6.0",
138
- "@scripts/build": "2.6.0"
172
+ "@types/serialize-javascript": "^5.0.1"
139
173
  },
140
174
  "sideEffects": false,
141
175
  "scripts": {
File without changes
File without changes