@modern-js/utils 2.15.1-alpha.0 → 2.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/FileSizeReporter.js +69 -92
  3. package/dist/cjs/alias.js +34 -58
  4. package/dist/cjs/analyzeProject.js +58 -41
  5. package/dist/cjs/applyOptionsChain.js +15 -42
  6. package/dist/cjs/babel.js +28 -39
  7. package/dist/cjs/chainId.js +7 -25
  8. package/dist/cjs/clearConsole.js +7 -25
  9. package/dist/cjs/commands.js +14 -29
  10. package/dist/cjs/compatRequire.js +22 -38
  11. package/dist/cjs/compiled.js +120 -139
  12. package/dist/cjs/constants.js +143 -98
  13. package/dist/cjs/debug.js +8 -26
  14. package/dist/cjs/emptyDir.js +10 -28
  15. package/dist/cjs/ensureAbsolutePath.js +13 -36
  16. package/dist/cjs/ensureArray.js +10 -26
  17. package/dist/cjs/findExists.js +14 -37
  18. package/dist/cjs/generateMetaTags.js +12 -31
  19. package/dist/cjs/getBrowserslist.js +20 -27
  20. package/dist/cjs/getCoreJsVersion.js +49 -37
  21. package/dist/cjs/getEntryOptions.js +14 -29
  22. package/dist/cjs/getPackageManager.js +23 -46
  23. package/dist/cjs/getPort.js +26 -61
  24. package/dist/cjs/getServerConfig.js +51 -43
  25. package/dist/cjs/getTargetDir.js +50 -38
  26. package/dist/cjs/import.js +16 -27
  27. package/dist/cjs/index.js +61 -60
  28. package/dist/cjs/is/index.js +53 -68
  29. package/dist/cjs/is/nodeEnv.js +13 -29
  30. package/dist/cjs/is/platform.js +13 -26
  31. package/dist/cjs/is/type.js +14 -33
  32. package/dist/cjs/logger.js +54 -50
  33. package/dist/cjs/monorepo.js +47 -78
  34. package/dist/cjs/nodeEnv.js +29 -31
  35. package/dist/cjs/path.js +42 -63
  36. package/dist/cjs/pathSerializer.js +43 -51
  37. package/dist/cjs/plugin.js +11 -29
  38. package/dist/cjs/prettyInstructions.js +35 -68
  39. package/dist/cjs/printBuildError.js +15 -37
  40. package/dist/cjs/react.js +18 -41
  41. package/dist/cjs/readTsConfig.js +21 -39
  42. package/dist/cjs/removeSlash.js +13 -27
  43. package/dist/cjs/resolve.js +25 -31
  44. package/dist/cjs/routes.js +22 -42
  45. package/dist/cjs/runtime/index.js +18 -17
  46. package/dist/cjs/runtime/parsed.js +8 -26
  47. package/dist/cjs/runtimeExports.js +31 -56
  48. package/dist/cjs/ssr.js +13 -26
  49. package/dist/cjs/storage.js +51 -41
  50. package/dist/cjs/testUtils.js +8 -29
  51. package/dist/cjs/types.js +4 -15
  52. package/dist/cjs/universal/constants.js +13 -26
  53. package/dist/cjs/universal/formatWebpack.js +16 -44
  54. package/dist/cjs/universal/nestedRoutes.js +94 -46
  55. package/dist/cjs/universal/pluginDagSort.js +58 -0
  56. package/dist/cjs/universal/remixRouter.js +18 -17
  57. package/dist/cjs/universal/serialize.js +16 -37
  58. package/dist/cjs/version.js +25 -41
  59. package/dist/cjs/wait.js +7 -25
  60. package/dist/cjs/watch.js +69 -43
  61. package/dist/esm/FileSizeReporter.js +40 -52
  62. package/dist/esm/alias.js +9 -19
  63. package/dist/esm/analyzeProject.js +3 -7
  64. package/dist/esm/applyOptionsChain.js +5 -17
  65. package/dist/esm/babel.js +6 -8
  66. package/dist/esm/chainId.js +1 -4
  67. package/dist/esm/clearConsole.js +1 -4
  68. package/dist/esm/commands.js +6 -12
  69. package/dist/esm/compatRequire.js +10 -17
  70. package/dist/esm/compiled.js +32 -76
  71. package/dist/esm/constants.js +143 -89
  72. package/dist/esm/debug.js +1 -4
  73. package/dist/esm/emptyDir.js +1 -4
  74. package/dist/esm/ensureAbsolutePath.js +1 -4
  75. package/dist/esm/ensureArray.js +4 -5
  76. package/dist/esm/findExists.js +1 -4
  77. package/dist/esm/generateMetaTags.js +6 -10
  78. package/dist/esm/getBrowserslist.js +8 -6
  79. package/dist/esm/getCoreJsVersion.js +1 -4
  80. package/dist/esm/getEntryOptions.js +5 -5
  81. package/dist/esm/getPackageManager.js +1 -4
  82. package/dist/esm/getPort.js +10 -25
  83. package/dist/esm/getServerConfig.js +2 -9
  84. package/dist/esm/getTargetDir.js +1 -4
  85. package/dist/esm/import.js +3 -4
  86. package/dist/esm/is/index.js +18 -30
  87. package/dist/esm/is/nodeEnv.js +5 -12
  88. package/dist/esm/is/platform.js +2 -6
  89. package/dist/esm/is/type.js +8 -18
  90. package/dist/esm/logger.js +37 -17
  91. package/dist/esm/monorepo.js +21 -38
  92. package/dist/esm/nodeEnv.js +18 -11
  93. package/dist/esm/path.js +16 -23
  94. package/dist/esm/pathSerializer.js +21 -21
  95. package/dist/esm/plugin.js +1 -4
  96. package/dist/esm/prettyInstructions.js +13 -32
  97. package/dist/esm/printBuildError.js +4 -11
  98. package/dist/esm/react.js +1 -4
  99. package/dist/esm/readTsConfig.js +2 -6
  100. package/dist/esm/removeSlash.js +3 -8
  101. package/dist/esm/resolve.js +14 -11
  102. package/dist/esm/routes.js +3 -9
  103. package/dist/esm/runtime/parsed.js +2 -5
  104. package/dist/esm/runtimeExports.js +17 -22
  105. package/dist/esm/ssr.js +1 -4
  106. package/dist/esm/storage.js +2 -6
  107. package/dist/esm/testUtils.js +2 -8
  108. package/dist/esm/types.js +1 -0
  109. package/dist/esm/universal/constants.js +2 -6
  110. package/dist/esm/universal/formatWebpack.js +10 -22
  111. package/dist/esm/universal/nestedRoutes.js +41 -27
  112. package/dist/esm/universal/pluginDagSort.js +50 -0
  113. package/dist/esm/universal/serialize.js +4 -5
  114. package/dist/esm/version.js +5 -7
  115. package/dist/esm/wait.js +1 -3
  116. package/dist/esm/watch.js +14 -9
  117. package/dist/types/universal/pluginDagSort.d.ts +1 -0
  118. package/package.json +17 -5
@@ -1,38 +1,19 @@
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 runtimeExports_exports = {};
29
- __export(runtimeExports_exports, {
30
- createRuntimeExportsUtils: () => createRuntimeExportsUtils
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
31
4
  });
32
- module.exports = __toCommonJS(runtimeExports_exports);
33
- var import_path = __toESM(require("path"));
34
- var import_compiled = require("./compiled");
35
- var import_path2 = require("./path");
5
+ Object.defineProperty(exports, "createRuntimeExportsUtils", {
6
+ enumerable: true,
7
+ get: () => createRuntimeExportsUtils
8
+ });
9
+ const _path = /* @__PURE__ */ _interop_require_default(require("path"));
10
+ const _compiled = require("./compiled");
11
+ const _path1 = require("./path");
12
+ function _interop_require_default(obj) {
13
+ return obj && obj.__esModule ? obj : {
14
+ default: obj
15
+ };
16
+ }
36
17
  const memo = (fn) => {
37
18
  const cache = /* @__PURE__ */ new Map();
38
19
  return (...params) => {
@@ -46,28 +27,22 @@ const memo = (fn) => {
46
27
  return res;
47
28
  };
48
29
  };
49
- const createRuntimeExportsUtils = memo(
50
- (pwd = "", namespace = "index") => {
51
- const entryExportFile = import_path.default.join(pwd, `.runtime-exports/${namespace}.js`);
52
- const addExport = (statement) => {
53
- statement = (0, import_path2.normalizeOutputPath)(statement);
54
- try {
55
- import_compiled.fs.ensureFileSync(entryExportFile);
56
- if (!import_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
57
- import_compiled.fs.appendFileSync(entryExportFile, `${statement}
30
+ const createRuntimeExportsUtils = memo((pwd = "", namespace = "index") => {
31
+ const entryExportFile = _path.default.join(pwd, `.runtime-exports/${namespace}.js`);
32
+ const addExport = (statement) => {
33
+ statement = (0, _path1.normalizeOutputPath)(statement);
34
+ try {
35
+ _compiled.fs.ensureFileSync(entryExportFile);
36
+ if (!_compiled.fs.readFileSync(entryExportFile, "utf8").includes(statement)) {
37
+ _compiled.fs.appendFileSync(entryExportFile, `${statement}
58
38
  `);
59
- }
60
- } catch {
61
39
  }
62
- };
63
- const getPath = () => entryExportFile;
64
- return {
65
- addExport,
66
- getPath
67
- };
68
- }
69
- );
70
- // Annotate the CommonJS export names for ESM import in node:
71
- 0 && (module.exports = {
72
- createRuntimeExportsUtils
40
+ } catch {
41
+ }
42
+ };
43
+ const getPath = () => entryExportFile;
44
+ return {
45
+ addExport,
46
+ getPath
47
+ };
73
48
  });
package/dist/cjs/ssr.js CHANGED
@@ -1,30 +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 __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
6
  for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var ssr_exports = {};
19
- __export(ssr_exports, {
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
20
13
  run: () => run,
21
14
  useHeaders: () => useHeaders
22
15
  });
23
- module.exports = __toCommonJS(ssr_exports);
24
- var import_storage = require("./storage");
25
- const { run, useContext: useHeaders } = (0, import_storage.createStorage)();
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- run,
29
- useHeaders
30
- });
16
+ const _storage = require("./storage");
17
+ const { run, useContext: useHeaders } = (0, _storage.createStorage)();
@@ -1,40 +1,56 @@
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 storage_exports = {};
29
- __export(storage_exports, {
30
- createStorage: () => createStorage
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
31
4
  });
32
- module.exports = __toCommonJS(storage_exports);
33
- var ah = __toESM(require("async_hooks"));
5
+ Object.defineProperty(exports, "createStorage", {
6
+ enumerable: true,
7
+ get: () => createStorage
8
+ });
9
+ const _async_hooks = /* @__PURE__ */ _interop_require_wildcard(require("async_hooks"));
10
+ function _getRequireWildcardCache(nodeInterop) {
11
+ if (typeof WeakMap !== "function")
12
+ return null;
13
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
14
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
15
+ return (_getRequireWildcardCache = function(nodeInterop2) {
16
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
17
+ })(nodeInterop);
18
+ }
19
+ function _interop_require_wildcard(obj, nodeInterop) {
20
+ if (!nodeInterop && obj && obj.__esModule) {
21
+ return obj;
22
+ }
23
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
24
+ return {
25
+ default: obj
26
+ };
27
+ }
28
+ var cache = _getRequireWildcardCache(nodeInterop);
29
+ if (cache && cache.has(obj)) {
30
+ return cache.get(obj);
31
+ }
32
+ var newObj = {};
33
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
34
+ for (var key in obj) {
35
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
36
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
37
+ if (desc && (desc.get || desc.set)) {
38
+ Object.defineProperty(newObj, key, desc);
39
+ } else {
40
+ newObj[key] = obj[key];
41
+ }
42
+ }
43
+ }
44
+ newObj.default = obj;
45
+ if (cache) {
46
+ cache.set(obj, newObj);
47
+ }
48
+ return newObj;
49
+ }
34
50
  const createStorage = () => {
35
51
  let storage;
36
- if (typeof ah.AsyncLocalStorage !== "undefined") {
37
- storage = new ah.AsyncLocalStorage();
52
+ if (typeof _async_hooks.AsyncLocalStorage !== "undefined") {
53
+ storage = new _async_hooks.AsyncLocalStorage();
38
54
  }
39
55
  const run = (context, cb) => {
40
56
  if (!storage) {
@@ -58,9 +74,7 @@ const createStorage = () => {
58
74
  }
59
75
  const context = storage.getStore();
60
76
  if (!context) {
61
- throw new Error(
62
- `Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`
63
- );
77
+ throw new Error(`Can't call useContext out of scope, make sure @modern-js/utils is a single version in node_modules`);
64
78
  }
65
79
  return context;
66
80
  };
@@ -69,7 +83,3 @@ const createStorage = () => {
69
83
  useContext
70
84
  };
71
85
  };
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- createStorage
75
- });
@@ -1,38 +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 __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var testUtils_exports = {};
19
- __export(testUtils_exports, {
20
- initSnapshotSerializer: () => initSnapshotSerializer
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "initSnapshotSerializer", {
6
+ enumerable: true,
7
+ get: () => initSnapshotSerializer
21
8
  });
22
- module.exports = __toCommonJS(testUtils_exports);
23
9
  const initSnapshotSerializer = (root) => {
24
10
  expect.addSnapshotSerializer({
25
11
  test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
26
12
  print: (val) => (
27
13
  // eslint-disable-next-line no-nested-ternary
28
- typeof val === "string" ? (
29
- // eslint-disable-next-line no-nested-ternary
30
- val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"`
31
- ) : val
14
+ typeof val === "string" ? val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"` : val
32
15
  )
33
16
  });
34
17
  };
35
- // Annotate the CommonJS export names for ESM import in node:
36
- 0 && (module.exports = {
37
- initSnapshotSerializer
38
- });
package/dist/cjs/types.js CHANGED
@@ -1,15 +1,4 @@
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var types_exports = {};
15
- module.exports = __toCommonJS(types_exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
@@ -1,30 +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 __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
6
  for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var constants_exports = {};
19
- __export(constants_exports, {
20
- HMR_SOCK_PATH: () => HMR_SOCK_PATH,
21
- ROUTE_MANIFEST: () => ROUTE_MANIFEST
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ ROUTE_MANIFEST: () => ROUTE_MANIFEST,
14
+ HMR_SOCK_PATH: () => HMR_SOCK_PATH
22
15
  });
23
- module.exports = __toCommonJS(constants_exports);
24
16
  const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
25
17
  const HMR_SOCK_PATH = "/webpack-hmr";
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- HMR_SOCK_PATH,
29
- ROUTE_MANIFEST
30
- });
@@ -1,25 +1,11 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var formatWebpack_exports = {};
19
- __export(formatWebpack_exports, {
20
- formatWebpackMessages: () => formatWebpackMessages
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "formatWebpackMessages", {
6
+ enumerable: true,
7
+ get: () => formatWebpackMessages
21
8
  });
22
- module.exports = __toCommonJS(formatWebpack_exports);
23
9
  const friendlySyntaxErrorLabel = "SyntaxError:";
24
10
  function isLikelyASyntaxError(message) {
25
11
  return message.includes(friendlySyntaxErrorLabel);
@@ -42,9 +28,7 @@ ${stats.stack}` : "";
42
28
  }
43
29
  lines = message.split("\n");
44
30
  lines = lines.map((line) => {
45
- const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(
46
- line
47
- );
31
+ const parsingError = /Line (\d+):(?:(\d+):)?\s*Parsing error: (.+)$/.exec(line);
48
32
  if (!parsingError) {
49
33
  return line;
50
34
  }
@@ -52,11 +36,8 @@ ${stats.stack}` : "";
52
36
  return `${friendlySyntaxErrorLabel} ${errorMessage} (${errorLine}:${errorColumn})`;
53
37
  });
54
38
  message = lines.join("\n");
55
- message = message.replace(
56
- /SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g,
57
- `${friendlySyntaxErrorLabel} $3 ($1:$2)
58
- `
59
- );
39
+ message = message.replace(/SyntaxError\s+\((\d+):(\d+)\)\s*(.+?)\n/g, `${friendlySyntaxErrorLabel} $3 ($1:$2)
40
+ `);
60
41
  lines = message.split("\n");
61
42
  if (lines.length > 2 && lines[1].trim() === "") {
62
43
  lines.splice(1, 1);
@@ -66,27 +47,22 @@ ${stats.stack}` : "";
66
47
  lines[1] = lines[1].replace("Error: ", "");
67
48
  }
68
49
  message = lines.join("\n");
69
- message = message.replace(
70
- /^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm,
71
- ""
72
- );
50
+ message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "");
73
51
  message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
74
52
  lines = message.split("\n");
75
- lines = lines.filter(
76
- (line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim()
77
- );
53
+ lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
78
54
  message = lines.join("\n");
79
55
  return message.trim();
80
56
  }
81
57
  function formatWebpackMessages(json) {
82
- var _a, _b, _c;
83
- const formattedErrors = (_a = json == null ? void 0 : json.errors) == null ? void 0 : _a.map(formatMessage);
84
- const formattedWarnings = (_b = json == null ? void 0 : json.warnings) == null ? void 0 : _b.map(formatMessage);
58
+ var _json_errors, _json_warnings, _result_errors;
59
+ const formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
60
+ const formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
85
61
  const result = {
86
62
  errors: formattedErrors || [],
87
63
  warnings: formattedWarnings || []
88
64
  };
89
- if ((_c = result.errors) == null ? void 0 : _c.some(isLikelyASyntaxError)) {
65
+ if ((_result_errors = result.errors) === null || _result_errors === void 0 ? void 0 : _result_errors.some(isLikelyASyntaxError)) {
90
66
  result.errors = result.errors.filter(isLikelyASyntaxError);
91
67
  }
92
68
  if (result.errors.length > 1) {
@@ -94,7 +70,3 @@ function formatWebpackMessages(json) {
94
70
  }
95
71
  return result;
96
72
  }
97
- // Annotate the CommonJS export names for ESM import in node:
98
- 0 && (module.exports = {
99
- formatWebpackMessages
100
- });
@@ -1,36 +1,68 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ function _export(target, all) {
6
6
  for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var nestedRoutes_exports = {};
19
- __export(nestedRoutes_exports, {
20
- renderNestedRoute: () => renderNestedRoute,
21
- transformNestedRoutes: () => transformNestedRoutes
7
+ Object.defineProperty(target, name, {
8
+ enumerable: true,
9
+ get: all[name]
10
+ });
11
+ }
12
+ _export(exports, {
13
+ transformNestedRoutes: () => transformNestedRoutes,
14
+ renderNestedRoute: () => renderNestedRoute
22
15
  });
23
- module.exports = __toCommonJS(nestedRoutes_exports);
24
- var import_jsx_runtime = require("react/jsx-runtime");
25
- var import_react = require("react");
26
- var import_react_router_dom = require("react-router-dom");
16
+ const _jsxruntime = require("react/jsx-runtime");
17
+ const _react = /* @__PURE__ */ _interop_require_wildcard(require("react"));
18
+ const _reactrouterdom = require("react-router-dom");
19
+ function _getRequireWildcardCache(nodeInterop) {
20
+ if (typeof WeakMap !== "function")
21
+ return null;
22
+ var cacheBabelInterop = /* @__PURE__ */ new WeakMap();
23
+ var cacheNodeInterop = /* @__PURE__ */ new WeakMap();
24
+ return (_getRequireWildcardCache = function(nodeInterop2) {
25
+ return nodeInterop2 ? cacheNodeInterop : cacheBabelInterop;
26
+ })(nodeInterop);
27
+ }
28
+ function _interop_require_wildcard(obj, nodeInterop) {
29
+ if (!nodeInterop && obj && obj.__esModule) {
30
+ return obj;
31
+ }
32
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
33
+ return {
34
+ default: obj
35
+ };
36
+ }
37
+ var cache = _getRequireWildcardCache(nodeInterop);
38
+ if (cache && cache.has(obj)) {
39
+ return cache.get(obj);
40
+ }
41
+ var newObj = {};
42
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
43
+ for (var key in obj) {
44
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
45
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
46
+ if (desc && (desc.get || desc.set)) {
47
+ Object.defineProperty(newObj, key, desc);
48
+ } else {
49
+ newObj[key] = obj[key];
50
+ }
51
+ }
52
+ }
53
+ newObj.default = obj;
54
+ if (cache) {
55
+ cache.set(obj, newObj);
56
+ }
57
+ return newObj;
58
+ }
27
59
  const transformNestedRoutes = (routes) => {
28
60
  const routeElements = [];
29
61
  for (const route of routes) {
30
62
  const routeElement = renderNestedRoute(route);
31
63
  routeElements.push(routeElement);
32
64
  }
33
- return (0, import_react_router_dom.createRoutesFromElements)(routeElements);
65
+ return (0, _reactrouterdom.createRoutesFromElements)(routeElements);
34
66
  };
35
67
  const renderNestedRoute = (nestedRoute, options = {}) => {
36
68
  const { children, index, id, component, isRoot, lazyImport, config } = nestedRoute;
@@ -44,46 +76,67 @@ const renderNestedRoute = (nestedRoute, options = {}) => {
44
76
  action: nestedRoute.action,
45
77
  hasErrorBoundary: nestedRoute.hasErrorBoundary,
46
78
  shouldRevalidate: nestedRoute.shouldRevalidate,
47
- handle: typeof config === "object" ? config == null ? void 0 : config.handle : {},
79
+ handle: typeof config === "object" ? config === null || config === void 0 ? void 0 : config.handle : {},
48
80
  index: nestedRoute.index,
49
81
  element: nestedRoute.element,
50
82
  errorElement: nestedRoute.errorElement
51
83
  };
52
84
  if (nestedRoute.error) {
53
- const errorElement = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(nestedRoute.error, {});
85
+ const errorElement = /* @__PURE__ */ (0, _jsxruntime.jsx)(nestedRoute.error, {});
54
86
  routeProps.errorElement = errorElement;
55
87
  }
56
88
  let element;
57
89
  if (Component) {
58
- if ((parent == null ? void 0 : parent.loading) && lazyImport) {
90
+ if ((parent === null || parent === void 0 ? void 0 : parent.loading) && lazyImport) {
59
91
  const Loading = parent.loading;
60
92
  if (isLoadableComponent(Component)) {
61
- element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Loading, {}) });
93
+ element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {
94
+ fallback: /* @__PURE__ */ (0, _jsxruntime.jsx)(Loading, {})
95
+ });
62
96
  } else {
63
- 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, {}) });
97
+ element = /* @__PURE__ */ (0, _jsxruntime.jsx)(_react.Suspense, {
98
+ fallback: /* @__PURE__ */ (0, _jsxruntime.jsx)(Loading, {}),
99
+ children: /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {})
100
+ });
64
101
  }
65
102
  } else if (isLoadableComponent(Component) && lazyImport) {
66
- element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
103
+ element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {});
67
104
  } else if (isRoot) {
68
- element = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
69
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, { ...props }),
70
- typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(DeferredDataComponent, {})
71
- ] });
105
+ element = /* @__PURE__ */ (0, _jsxruntime.jsxs)(_jsxruntime.Fragment, {
106
+ children: [
107
+ /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {
108
+ ...props
109
+ }),
110
+ typeof document === "undefined" && DeferredDataComponent && /* @__PURE__ */ (0, _jsxruntime.jsx)(DeferredDataComponent, {})
111
+ ]
112
+ });
72
113
  } else if (lazyImport) {
73
- element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: null, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {}) });
114
+ element = /* @__PURE__ */ (0, _jsxruntime.jsx)(_react.Suspense, {
115
+ fallback: null,
116
+ children: /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {})
117
+ });
74
118
  } else {
75
- element = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Component, {});
119
+ element = /* @__PURE__ */ (0, _jsxruntime.jsx)(Component, {});
76
120
  }
77
121
  } else {
78
- nestedRoute.loading = parent == null ? void 0 : parent.loading;
122
+ nestedRoute.loading = parent === null || parent === void 0 ? void 0 : parent.loading;
79
123
  }
80
124
  if (element) {
81
125
  routeProps.element = element;
82
126
  }
83
- const childElements = children == null ? void 0 : children.map((childRoute) => {
84
- return renderNestedRoute(childRoute, { parent: nestedRoute });
127
+ const childElements = children === null || children === void 0 ? void 0 : children.map((childRoute) => {
128
+ return renderNestedRoute(childRoute, {
129
+ parent: nestedRoute
130
+ });
85
131
  });
86
- const routeElement = index ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, { ...routeProps, index: true }, id) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_router_dom.Route, { ...routeProps, index: false, children: childElements }, id);
132
+ const routeElement = index ? /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Route, {
133
+ ...routeProps,
134
+ index: true
135
+ }, id) : /* @__PURE__ */ (0, _jsxruntime.jsx)(_reactrouterdom.Route, {
136
+ ...routeProps,
137
+ index: false,
138
+ children: childElements
139
+ }, id);
87
140
  return routeElement;
88
141
  };
89
142
  function createLoader(route) {
@@ -107,8 +160,3 @@ function createLoader(route) {
107
160
  function isLoadableComponent(component) {
108
161
  return component && component.displayName === "Loadable" && component.preload && typeof component.preload === "function";
109
162
  }
110
- // Annotate the CommonJS export names for ESM import in node:
111
- 0 && (module.exports = {
112
- renderNestedRoute,
113
- transformNestedRoutes
114
- });