@modern-js/utils 2.35.0 → 2.35.1

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.
Files changed (83) hide show
  1. package/dist/cjs/cli/alias.js +3 -3
  2. package/dist/cjs/cli/constants/chainId.js +3 -3
  3. package/dist/cjs/cli/is/config.js +9 -11
  4. package/dist/cjs/cli/logger.js +6 -1
  5. package/dist/cjs/cli/port.js +1 -1
  6. package/dist/cjs/cli/prettyInstructions.js +2 -5
  7. package/dist/cjs/cli/require.js +1 -2
  8. package/dist/cjs/universal/formatWebpack.js +3 -3
  9. package/dist/esm/cli/alias.js +3 -3
  10. package/dist/esm/cli/constants/chainId.js +3 -3
  11. package/dist/esm/cli/is/config.js +9 -11
  12. package/dist/esm/cli/logger.js +6 -1
  13. package/dist/esm/cli/port.js +1 -1
  14. package/dist/esm/cli/prettyInstructions.js +2 -3
  15. package/dist/esm/cli/require.js +1 -2
  16. package/dist/esm/universal/formatWebpack.js +3 -3
  17. package/dist/esm-node/cli/alias.js +3 -3
  18. package/dist/esm-node/cli/constants/chainId.js +3 -3
  19. package/dist/esm-node/cli/is/config.js +9 -11
  20. package/dist/esm-node/cli/logger.js +6 -1
  21. package/dist/esm-node/cli/port.js +1 -1
  22. package/dist/esm-node/cli/prettyInstructions.js +2 -5
  23. package/dist/esm-node/cli/require.js +1 -2
  24. package/dist/esm-node/universal/formatWebpack.js +3 -3
  25. package/dist/types/cli/constants/chainId.d.ts +2 -2
  26. package/dist/types/cli/logger.d.ts +5 -0
  27. package/package.json +4 -75
  28. package/dist/cjs/runtime/nestedRoutes.js +0 -149
  29. package/dist/cjs/runtime/remixRouter.js +0 -6
  30. package/dist/cjs/runtime/router.js +0 -6
  31. package/dist/cjs/runtime-browser/index.js +0 -6
  32. package/dist/cjs/runtime-browser/parsed.js +0 -28
  33. package/dist/cjs/runtime-node/index.js +0 -28
  34. package/dist/cjs/runtime-node/loaderContext/createLoaderCtx.js +0 -34
  35. package/dist/cjs/runtime-node/loaderContext/createRequestCtx.js +0 -38
  36. package/dist/cjs/runtime-node/loaderContext/index.js +0 -22
  37. package/dist/cjs/runtime-node/nestedRoutes.js +0 -28
  38. package/dist/cjs/runtime-node/router.js +0 -6
  39. package/dist/cjs/runtime-node/serialize.js +0 -17
  40. package/dist/cjs/runtime-node/storage.js +0 -48
  41. package/dist/cjs/universal/time.js +0 -38
  42. package/dist/esm/runtime/nestedRoutes.js +0 -163
  43. package/dist/esm/runtime/remixRouter.js +0 -1
  44. package/dist/esm/runtime/router.js +0 -1
  45. package/dist/esm/runtime-browser/index.js +0 -1
  46. package/dist/esm/runtime-browser/parsed.js +0 -18
  47. package/dist/esm/runtime-node/index.js +0 -6
  48. package/dist/esm/runtime-node/loaderContext/createLoaderCtx.js +0 -20
  49. package/dist/esm/runtime-node/loaderContext/createRequestCtx.js +0 -24
  50. package/dist/esm/runtime-node/loaderContext/index.js +0 -3
  51. package/dist/esm/runtime-node/nestedRoutes.js +0 -20
  52. package/dist/esm/runtime-node/router.js +0 -1
  53. package/dist/esm/runtime-node/serialize.js +0 -6
  54. package/dist/esm/runtime-node/storage.js +0 -36
  55. package/dist/esm/universal/time.js +0 -29
  56. package/dist/esm-node/runtime/nestedRoutes.js +0 -129
  57. package/dist/esm-node/runtime/remixRouter.js +0 -1
  58. package/dist/esm-node/runtime/router.js +0 -1
  59. package/dist/esm-node/runtime-browser/index.js +0 -1
  60. package/dist/esm-node/runtime-browser/parsed.js +0 -18
  61. package/dist/esm-node/runtime-node/index.js +0 -6
  62. package/dist/esm-node/runtime-node/loaderContext/createLoaderCtx.js +0 -15
  63. package/dist/esm-node/runtime-node/loaderContext/createRequestCtx.js +0 -19
  64. package/dist/esm-node/runtime-node/loaderContext/index.js +0 -3
  65. package/dist/esm-node/runtime-node/nestedRoutes.js +0 -18
  66. package/dist/esm-node/runtime-node/router.js +0 -1
  67. package/dist/esm-node/runtime-node/serialize.js +0 -6
  68. package/dist/esm-node/runtime-node/storage.js +0 -38
  69. package/dist/esm-node/universal/time.js +0 -28
  70. package/dist/types/runtime/nestedRoutes.d.ts +0 -13
  71. package/dist/types/runtime/remixRouter.d.ts +0 -1
  72. package/dist/types/runtime/router.d.ts +0 -1
  73. package/dist/types/runtime-browser/index.d.ts +0 -1
  74. package/dist/types/runtime-browser/parsed.d.ts +0 -1
  75. package/dist/types/runtime-node/index.d.ts +0 -10
  76. package/dist/types/runtime-node/loaderContext/createLoaderCtx.d.ts +0 -7
  77. package/dist/types/runtime-node/loaderContext/createRequestCtx.d.ts +0 -7
  78. package/dist/types/runtime-node/loaderContext/index.d.ts +0 -4
  79. package/dist/types/runtime-node/nestedRoutes.d.ts +0 -3
  80. package/dist/types/runtime-node/router.d.ts +0 -1
  81. package/dist/types/runtime-node/serialize.d.ts +0 -1
  82. package/dist/types/runtime-node/storage.d.ts +0 -5
  83. package/dist/types/universal/time.d.ts +0 -1
@@ -46,7 +46,7 @@ const validAlias = (modernConfig, { tsconfigPath }) => {
46
46
  };
47
47
  const mergeAlias = (alias) => (0, _applyOptionsChain.applyOptionsChain)({}, alias);
48
48
  const getAliasConfig = (aliasOption, option) => {
49
- var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
49
+ var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
50
50
  const isTsProject = _fs.default.existsSync(option.tsconfigPath);
51
51
  const alias = mergeAlias(aliasOption);
52
52
  if (!isTsProject) {
@@ -58,12 +58,12 @@ const getAliasConfig = (aliasOption, option) => {
58
58
  };
59
59
  }
60
60
  const tsconfig = (0, _get.readTsConfigByFile)(option.tsconfigPath);
61
- const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
61
+ const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
62
62
  return {
63
63
  absoluteBaseUrl: baseUrl ? _path.default.join(option.appDirectory, baseUrl) : option.appDirectory,
64
64
  paths: {
65
65
  ...alias,
66
- ...(_tsconfig1 = tsconfig) === null || _tsconfig1 === void 0 ? void 0 : (_tsconfig_compilerOptions1 = _tsconfig1.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
66
+ ...tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
67
67
  },
68
68
  isTsPath: true,
69
69
  isTsProject
@@ -99,8 +99,6 @@ const CHAIN_ID = {
99
99
  STYLE: "style-loader",
100
100
  /** postcss-loader */
101
101
  POSTCSS: "postcss",
102
- /** markdown-loader */
103
- MARKDOWN: "markdown",
104
102
  /** ignore-css-loader */
105
103
  IGNORE_CSS: "ignore-css",
106
104
  /** css-modules-typescript-loader */
@@ -181,7 +179,9 @@ const CHAIN_ID = {
181
179
  /** HtmlAsyncChunkPlugin */
182
180
  HTML_ASYNC_CHUNK: "html-async-chunk",
183
181
  /** SWC_POLYFILL_CHECKER */
184
- SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
182
+ SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin",
183
+ /** RouterPlugin */
184
+ ROUTER_MANIFEST: "route-plugin"
185
185
  },
186
186
  /** Predefined minimizers */
187
187
  MINIMIZER: {
@@ -32,12 +32,11 @@ _export(exports, {
32
32
  const _constants = require("../constants");
33
33
  const _type = require("./type");
34
34
  const isSSR = (config) => {
35
- var _server, _server1;
36
35
  const { server } = config;
37
- if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
36
+ if (server === null || server === void 0 ? void 0 : server.ssr) {
38
37
  return true;
39
38
  }
40
- if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
39
+ if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !(0, _type.isEmpty)(server.ssrByEntries)) {
41
40
  for (const name of Object.keys(server.ssrByEntries)) {
42
41
  if (server.ssrByEntries[name]) {
43
42
  return true;
@@ -47,29 +46,28 @@ const isSSR = (config) => {
47
46
  return false;
48
47
  };
49
48
  const isUseSSRBundle = (config) => {
50
- var _output;
51
49
  const { output } = config;
52
- if ((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) {
50
+ if (output === null || output === void 0 ? void 0 : output.ssg) {
53
51
  return true;
54
52
  }
55
53
  return isSSR(config);
56
54
  };
57
55
  const isServiceWorker = (config) => {
58
- var _deploy_worker, _deploy, _output;
56
+ var _deploy_worker;
59
57
  const { output, deploy } = config;
60
- if (((_deploy = deploy) === null || _deploy === void 0 ? void 0 : (_deploy_worker = _deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && (((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) || isSSR(config))) {
58
+ if ((deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && ((output === null || output === void 0 ? void 0 : output.ssg) || isSSR(config))) {
61
59
  return true;
62
60
  }
63
61
  return false;
64
62
  };
65
63
  const isRouterV5 = (config) => {
66
- var _config_runtime, _config_runtime_router, _config_runtime1, _config;
67
- return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime1 = _config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
64
+ var _config_runtime, _config_runtime_router, _config_runtime1;
65
+ return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
68
66
  };
69
67
  const isSSGEntry = (config, entryName, entrypoints) => {
70
- var _config_source, _ssgConfig, _ssgConfig1;
68
+ var _config_source;
71
69
  const ssgConfig = config.output.ssg;
72
- const useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof ((_ssgConfig = ssgConfig) === null || _ssgConfig === void 0 ? void 0 : _ssgConfig[0]) === "function" || Boolean((_ssgConfig1 = ssgConfig) === null || _ssgConfig1 === void 0 ? void 0 : _ssgConfig1[entryName]);
70
+ const useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[entryName]);
73
71
  return useSSG;
74
72
  };
75
73
  const isSingleEntry = (entrypoints, mainEntryName = _constants.MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
@@ -40,9 +40,14 @@ const LOG_TYPES = {
40
40
  label: "info",
41
41
  level: "info"
42
42
  },
43
+ ready: {
44
+ color: "green",
45
+ label: "ready",
46
+ level: "info"
47
+ },
43
48
  success: {
44
49
  color: "green",
45
- label: "Success",
50
+ label: "success",
46
51
  level: "info"
47
52
  },
48
53
  warn: {
@@ -48,7 +48,7 @@ const getPort = async (port, { tryLimits = 20, strictPort = false, slient = fals
48
48
  if (strictPort) {
49
49
  throw new Error(`Port "${original}" is occupied, please choose another one.`);
50
50
  } else if (!slient) {
51
- _logger.logger.info(`Something is already running on port ${original}. ${_compiled.chalk.yellow(`Use port ${port} instead.`)}`);
51
+ _logger.logger.info(`Port ${original} is in use. ${_compiled.chalk.yellow(`using port ${port}.`)}`);
52
52
  }
53
53
  }
54
54
  return port;
@@ -39,10 +39,7 @@ const getIpv4Interfaces = () => {
39
39
  const getAddressUrls = (protocol = "http", port, host) => {
40
40
  const LOCAL_LABEL = "Local: ";
41
41
  const NETWORK_LABEL = "Network: ";
42
- const isLocalhost = (url) => {
43
- var _url;
44
- return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
45
- };
42
+ const isLocalhost = (url) => url === null || url === void 0 ? void 0 : url.includes("localhost");
46
43
  if (host && host !== _constants.DEFAULT_DEV_HOST) {
47
44
  return [
48
45
  {
@@ -73,7 +70,7 @@ const prettyInstructions = (appContext, config) => {
73
70
  const isHttps = (0, _is.isDev)() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
74
71
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
75
72
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
76
- let message = "App running at:\n\n";
73
+ let message = "\n";
77
74
  if ((0, _is.isSingleEntry)(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
78
75
  message += urls.map(({ label, url }) => ` ${_compiled.chalk.bold(`> ${label.padEnd(10)}`)}${_compiled.chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
79
76
  `).join("");
@@ -31,9 +31,8 @@ _export(exports, {
31
31
  });
32
32
  const _fs = require("./fs");
33
33
  const compatRequire = (filePath, interop = true) => {
34
- var _mod;
35
34
  const mod = require(filePath);
36
- const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
35
+ const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
37
36
  return rtnESMDefault ? mod.default : mod;
38
37
  };
39
38
  const dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -98,9 +98,9 @@ export default {
98
98
  });
99
99
  }
100
100
  function formatWebpackMessages(json, color = defaultColor) {
101
- var _json_errors, _json, _json_warnings, _json1, _result_errors;
102
- const formattedErrors = (_json = json) === null || _json === void 0 ? void 0 : (_json_errors = _json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
103
- const formattedWarnings = (_json1 = json) === null || _json1 === void 0 ? void 0 : (_json_warnings = _json1.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
101
+ var _json_errors, _json_warnings, _result_errors;
102
+ const formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
103
+ const formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
104
104
  const result = {
105
105
  errors: formattedErrors || [],
106
106
  warnings: formattedWarnings || [],
@@ -24,7 +24,7 @@ export var mergeAlias = function(alias) {
24
24
  return applyOptionsChain({}, alias);
25
25
  };
26
26
  export var getAliasConfig = function(aliasOption, option) {
27
- var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
27
+ var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
28
28
  var isTsProject = fs.existsSync(option.tsconfigPath);
29
29
  var alias = mergeAlias(aliasOption);
30
30
  if (!isTsProject) {
@@ -36,10 +36,10 @@ export var getAliasConfig = function(aliasOption, option) {
36
36
  };
37
37
  }
38
38
  var tsconfig = readTsConfigByFile(option.tsconfigPath);
39
- var baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
39
+ var baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
40
40
  return {
41
41
  absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
42
- paths: _object_spread({}, alias, (_tsconfig1 = tsconfig) === null || _tsconfig1 === void 0 ? void 0 : (_tsconfig_compilerOptions1 = _tsconfig1.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths),
42
+ paths: _object_spread({}, alias, tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths),
43
43
  isTsPath: true,
44
44
  isTsProject: isTsProject
45
45
  };
@@ -89,8 +89,6 @@ export var CHAIN_ID = {
89
89
  STYLE: "style-loader",
90
90
  /** postcss-loader */
91
91
  POSTCSS: "postcss",
92
- /** markdown-loader */
93
- MARKDOWN: "markdown",
94
92
  /** ignore-css-loader */
95
93
  IGNORE_CSS: "ignore-css",
96
94
  /** css-modules-typescript-loader */
@@ -171,7 +169,9 @@ export var CHAIN_ID = {
171
169
  /** HtmlAsyncChunkPlugin */
172
170
  HTML_ASYNC_CHUNK: "html-async-chunk",
173
171
  /** SWC_POLYFILL_CHECKER */
174
- SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
172
+ SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin",
173
+ /** RouterPlugin */
174
+ ROUTER_MANIFEST: "route-plugin"
175
175
  },
176
176
  /** Predefined minimizers */
177
177
  MINIMIZER: {
@@ -1,12 +1,11 @@
1
1
  import { MAIN_ENTRY_NAME } from "../constants";
2
2
  import { isEmpty } from "./type";
3
3
  export var isSSR = function(config) {
4
- var _server, _server1;
5
4
  var server = config.server;
6
- if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
5
+ if (server === null || server === void 0 ? void 0 : server.ssr) {
7
6
  return true;
8
7
  }
9
- if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
8
+ if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
10
9
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
11
10
  try {
12
11
  for (var _iterator = Object.keys(server.ssrByEntries)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
@@ -33,29 +32,28 @@ export var isSSR = function(config) {
33
32
  return false;
34
33
  };
35
34
  export var isUseSSRBundle = function(config) {
36
- var _output;
37
35
  var output = config.output;
38
- if ((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) {
36
+ if (output === null || output === void 0 ? void 0 : output.ssg) {
39
37
  return true;
40
38
  }
41
39
  return isSSR(config);
42
40
  };
43
41
  export var isServiceWorker = function(config) {
44
- var _deploy_worker, _deploy, _output;
42
+ var _deploy_worker;
45
43
  var output = config.output, deploy = config.deploy;
46
- if (((_deploy = deploy) === null || _deploy === void 0 ? void 0 : (_deploy_worker = _deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && (((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) || isSSR(config))) {
44
+ if ((deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && ((output === null || output === void 0 ? void 0 : output.ssg) || isSSR(config))) {
47
45
  return true;
48
46
  }
49
47
  return false;
50
48
  };
51
49
  export var isRouterV5 = function(config) {
52
- var _config_runtime, _config_runtime_router, _config_runtime1, _config;
53
- return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime1 = _config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
50
+ var _config_runtime, _config_runtime_router, _config_runtime1;
51
+ return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
54
52
  };
55
53
  export var isSSGEntry = function(config, entryName, entrypoints) {
56
- var _config_source, _ssgConfig, _ssgConfig1;
54
+ var _config_source;
57
55
  var ssgConfig = config.output.ssg;
58
- var useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof ((_ssgConfig = ssgConfig) === null || _ssgConfig === void 0 ? void 0 : _ssgConfig[0]) === "function" || Boolean((_ssgConfig1 = ssgConfig) === null || _ssgConfig1 === void 0 ? void 0 : _ssgConfig1[entryName]);
56
+ var useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[entryName]);
59
57
  return useSSG;
60
58
  };
61
59
  export var isSingleEntry = function(entrypoints) {
@@ -22,9 +22,14 @@ var LOG_TYPES = {
22
22
  label: "info",
23
23
  level: "info"
24
24
  },
25
+ ready: {
26
+ color: "green",
27
+ label: "ready",
28
+ level: "info"
29
+ },
25
30
  success: {
26
31
  color: "green",
27
- label: "Success",
32
+ label: "success",
28
33
  level: "info"
29
34
  },
30
35
  warn: {
@@ -77,7 +77,7 @@ export var getPort = function() {
77
77
  if (strictPort) {
78
78
  throw new Error('Port "'.concat(original, '" is occupied, please choose another one.'));
79
79
  } else if (!slient) {
80
- logger.info("Something is already running on port ".concat(original, ". ").concat(chalk.yellow("Use port ".concat(port, " instead."))));
80
+ logger.info("Port ".concat(original, " is in use. ").concat(chalk.yellow("using port ".concat(port, "."))));
81
81
  }
82
82
  }
83
83
  return [
@@ -24,8 +24,7 @@ export var getAddressUrls = function() {
24
24
  var LOCAL_LABEL = "Local: ";
25
25
  var NETWORK_LABEL = "Network: ";
26
26
  var isLocalhost = function(url) {
27
- var _url;
28
- return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
27
+ return url === null || url === void 0 ? void 0 : url.includes("localhost");
29
28
  };
30
29
  if (host && host !== DEFAULT_DEV_HOST) {
31
30
  return [
@@ -59,7 +58,7 @@ export var prettyInstructions = function(appContext, config) {
59
58
  var routes = !apiOnly ? serverRoutes.filter(function(route) {
60
59
  return route.entryName;
61
60
  }) : serverRoutes;
62
- var message = "App running at:\n\n";
61
+ var message = "\n";
63
62
  if (isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
64
63
  message += urls.map(function(param) {
65
64
  var label = param.label, url = param.url;
@@ -2,9 +2,8 @@ import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
2
2
  import { findExists } from "./fs";
3
3
  export var compatRequire = function(filePath) {
4
4
  var interop = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
5
- var _mod;
6
5
  var mod = require(filePath);
7
- var rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
6
+ var rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
8
7
  return rtnESMDefault ? mod.default : mod;
9
8
  };
10
9
  export var dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -71,9 +71,9 @@ export function addErrorTips(errors) {
71
71
  }
72
72
  function formatWebpackMessages(json) {
73
73
  var color = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : defaultColor;
74
- var _json_errors, _json, _json_warnings, _json1, _result_errors;
75
- var formattedErrors = (_json = json) === null || _json === void 0 ? void 0 : (_json_errors = _json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
76
- var formattedWarnings = (_json1 = json) === null || _json1 === void 0 ? void 0 : (_json_warnings = _json1.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
74
+ var _json_errors, _json_warnings, _result_errors;
75
+ var formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
76
+ var formattedWarnings = json === null || json === void 0 ? void 0 : (_json_warnings = json.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
77
77
  var result = {
78
78
  errors: formattedErrors || [],
79
79
  warnings: formattedWarnings || [],
@@ -20,7 +20,7 @@ export const validAlias = (modernConfig, { tsconfigPath }) => {
20
20
  };
21
21
  export const mergeAlias = (alias) => applyOptionsChain({}, alias);
22
22
  export const getAliasConfig = (aliasOption, option) => {
23
- var _tsconfig_compilerOptions, _tsconfig, _tsconfig_compilerOptions1, _tsconfig1;
23
+ var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
24
24
  const isTsProject = fs.existsSync(option.tsconfigPath);
25
25
  const alias = mergeAlias(aliasOption);
26
26
  if (!isTsProject) {
@@ -32,12 +32,12 @@ export const getAliasConfig = (aliasOption, option) => {
32
32
  };
33
33
  }
34
34
  const tsconfig = readTsConfigByFile(option.tsconfigPath);
35
- const baseUrl = (_tsconfig = tsconfig) === null || _tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = _tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
35
+ const baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
36
36
  return {
37
37
  absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
38
38
  paths: {
39
39
  ...alias,
40
- ...(_tsconfig1 = tsconfig) === null || _tsconfig1 === void 0 ? void 0 : (_tsconfig_compilerOptions1 = _tsconfig1.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
40
+ ...tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
41
41
  },
42
42
  isTsPath: true,
43
43
  isTsProject
@@ -89,8 +89,6 @@ export const CHAIN_ID = {
89
89
  STYLE: "style-loader",
90
90
  /** postcss-loader */
91
91
  POSTCSS: "postcss",
92
- /** markdown-loader */
93
- MARKDOWN: "markdown",
94
92
  /** ignore-css-loader */
95
93
  IGNORE_CSS: "ignore-css",
96
94
  /** css-modules-typescript-loader */
@@ -171,7 +169,9 @@ export const CHAIN_ID = {
171
169
  /** HtmlAsyncChunkPlugin */
172
170
  HTML_ASYNC_CHUNK: "html-async-chunk",
173
171
  /** SWC_POLYFILL_CHECKER */
174
- SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin"
172
+ SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin",
173
+ /** RouterPlugin */
174
+ ROUTER_MANIFEST: "route-plugin"
175
175
  },
176
176
  /** Predefined minimizers */
177
177
  MINIMIZER: {
@@ -1,12 +1,11 @@
1
1
  import { MAIN_ENTRY_NAME } from "../constants";
2
2
  import { isEmpty } from "./type";
3
3
  export const isSSR = (config) => {
4
- var _server, _server1;
5
4
  const { server } = config;
6
- if ((_server = server) === null || _server === void 0 ? void 0 : _server.ssr) {
5
+ if (server === null || server === void 0 ? void 0 : server.ssr) {
7
6
  return true;
8
7
  }
9
- if (((_server1 = server) === null || _server1 === void 0 ? void 0 : _server1.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
8
+ if ((server === null || server === void 0 ? void 0 : server.ssrByEntries) && !isEmpty(server.ssrByEntries)) {
10
9
  for (const name of Object.keys(server.ssrByEntries)) {
11
10
  if (server.ssrByEntries[name]) {
12
11
  return true;
@@ -16,29 +15,28 @@ export const isSSR = (config) => {
16
15
  return false;
17
16
  };
18
17
  export const isUseSSRBundle = (config) => {
19
- var _output;
20
18
  const { output } = config;
21
- if ((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) {
19
+ if (output === null || output === void 0 ? void 0 : output.ssg) {
22
20
  return true;
23
21
  }
24
22
  return isSSR(config);
25
23
  };
26
24
  export const isServiceWorker = (config) => {
27
- var _deploy_worker, _deploy, _output;
25
+ var _deploy_worker;
28
26
  const { output, deploy } = config;
29
- if (((_deploy = deploy) === null || _deploy === void 0 ? void 0 : (_deploy_worker = _deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && (((_output = output) === null || _output === void 0 ? void 0 : _output.ssg) || isSSR(config))) {
27
+ if ((deploy === null || deploy === void 0 ? void 0 : (_deploy_worker = deploy.worker) === null || _deploy_worker === void 0 ? void 0 : _deploy_worker.ssr) && ((output === null || output === void 0 ? void 0 : output.ssg) || isSSR(config))) {
30
28
  return true;
31
29
  }
32
30
  return false;
33
31
  };
34
32
  export const isRouterV5 = (config) => {
35
- var _config_runtime, _config_runtime_router, _config_runtime1, _config;
36
- return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && ((_config = config) === null || _config === void 0 ? void 0 : (_config_runtime1 = _config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
33
+ var _config_runtime, _config_runtime_router, _config_runtime1;
34
+ return typeof ((_config_runtime = config.runtime) === null || _config_runtime === void 0 ? void 0 : _config_runtime.router) !== "boolean" && (config === null || config === void 0 ? void 0 : (_config_runtime1 = config.runtime) === null || _config_runtime1 === void 0 ? void 0 : (_config_runtime_router = _config_runtime1.router) === null || _config_runtime_router === void 0 ? void 0 : _config_runtime_router.mode) === "react-router-5";
37
35
  };
38
36
  export const isSSGEntry = (config, entryName, entrypoints) => {
39
- var _config_source, _ssgConfig, _ssgConfig1;
37
+ var _config_source;
40
38
  const ssgConfig = config.output.ssg;
41
- const useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof ((_ssgConfig = ssgConfig) === null || _ssgConfig === void 0 ? void 0 : _ssgConfig[0]) === "function" || Boolean((_ssgConfig1 = ssgConfig) === null || _ssgConfig1 === void 0 ? void 0 : _ssgConfig1[entryName]);
39
+ const useSSG = isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) ? Boolean(ssgConfig) : ssgConfig === true || typeof (ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[0]) === "function" || Boolean(ssgConfig === null || ssgConfig === void 0 ? void 0 : ssgConfig[entryName]);
42
40
  return useSSG;
43
41
  };
44
42
  export const isSingleEntry = (entrypoints, mainEntryName = MAIN_ENTRY_NAME) => entrypoints.length === 1 && entrypoints[0].entryName === mainEntryName;
@@ -17,9 +17,14 @@ const LOG_TYPES = {
17
17
  label: "info",
18
18
  level: "info"
19
19
  },
20
+ ready: {
21
+ color: "green",
22
+ label: "ready",
23
+ level: "info"
24
+ },
20
25
  success: {
21
26
  color: "green",
22
- label: "Success",
27
+ label: "success",
23
28
  level: "info"
24
29
  },
25
30
  warn: {
@@ -37,7 +37,7 @@ export const getPort = async (port, { tryLimits = 20, strictPort = false, slient
37
37
  if (strictPort) {
38
38
  throw new Error(`Port "${original}" is occupied, please choose another one.`);
39
39
  } else if (!slient) {
40
- logger.info(`Something is already running on port ${original}. ${chalk.yellow(`Use port ${port} instead.`)}`);
40
+ logger.info(`Port ${original} is in use. ${chalk.yellow(`using port ${port}.`)}`);
41
41
  }
42
42
  }
43
43
  return port;
@@ -19,10 +19,7 @@ const getIpv4Interfaces = () => {
19
19
  export const getAddressUrls = (protocol = "http", port, host) => {
20
20
  const LOCAL_LABEL = "Local: ";
21
21
  const NETWORK_LABEL = "Network: ";
22
- const isLocalhost = (url) => {
23
- var _url;
24
- return (_url = url) === null || _url === void 0 ? void 0 : _url.includes("localhost");
25
- };
22
+ const isLocalhost = (url) => url === null || url === void 0 ? void 0 : url.includes("localhost");
26
23
  if (host && host !== DEFAULT_DEV_HOST) {
27
24
  return [
28
25
  {
@@ -53,7 +50,7 @@ export const prettyInstructions = (appContext, config) => {
53
50
  const isHttps = isDev() && ((_appContext_builder = appContext.builder) === null || _appContext_builder === void 0 ? void 0 : (_appContext_builder_context_devServer = _appContext_builder.context.devServer) === null || _appContext_builder_context_devServer === void 0 ? void 0 : _appContext_builder_context_devServer.https);
54
51
  const urls = getAddressUrls(isHttps ? "https" : "http", port, (_config_dev = config.dev) === null || _config_dev === void 0 ? void 0 : _config_dev.host);
55
52
  const routes = !apiOnly ? serverRoutes.filter((route) => route.entryName) : serverRoutes;
56
- let message = "App running at:\n\n";
53
+ let message = "\n";
57
54
  if (isSingleEntry(entrypoints, (_config_source = config.source) === null || _config_source === void 0 ? void 0 : _config_source.mainEntryName) || apiOnly) {
58
55
  message += urls.map(({ label, url }) => ` ${chalk.bold(`> ${label.padEnd(10)}`)}${chalk.cyanBright(normalizeUrl(`${url}/${routes[0].urlPath}`))}
59
56
  `).join("");
@@ -1,8 +1,7 @@
1
1
  import { findExists } from "./fs";
2
2
  export const compatRequire = (filePath, interop = true) => {
3
- var _mod;
4
3
  const mod = require(filePath);
5
- const rtnESMDefault = interop && ((_mod = mod) === null || _mod === void 0 ? void 0 : _mod.__esModule);
4
+ const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
6
5
  return rtnESMDefault ? mod.default : mod;
7
6
  };
8
7
  export const dynamicImport = new Function("modulePath", "return import(modulePath)");
@@ -79,9 +79,9 @@ export default {
79
79
  });
80
80
  }
81
81
  function formatWebpackMessages(json, color = defaultColor) {
82
- var _json_errors, _json, _json_warnings, _json1, _result_errors;
83
- const formattedErrors = (_json = json) === null || _json === void 0 ? void 0 : (_json_errors = _json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
84
- const formattedWarnings = (_json1 = json) === null || _json1 === void 0 ? void 0 : (_json_warnings = _json1.warnings) === null || _json_warnings === void 0 ? void 0 : _json_warnings.map(formatMessage);
82
+ var _json_errors, _json_warnings, _result_errors;
83
+ const formattedErrors = json === null || json === void 0 ? void 0 : (_json_errors = json.errors) === null || _json_errors === void 0 ? void 0 : _json_errors.map(formatMessage);
84
+ 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
85
  const result = {
86
86
  errors: formattedErrors || [],
87
87
  warnings: formattedWarnings || [],
@@ -89,8 +89,6 @@ export declare const CHAIN_ID: {
89
89
  readonly STYLE: "style-loader";
90
90
  /** postcss-loader */
91
91
  readonly POSTCSS: "postcss";
92
- /** markdown-loader */
93
- readonly MARKDOWN: "markdown";
94
92
  /** ignore-css-loader */
95
93
  readonly IGNORE_CSS: "ignore-css";
96
94
  /** css-modules-typescript-loader */
@@ -172,6 +170,8 @@ export declare const CHAIN_ID: {
172
170
  readonly HTML_ASYNC_CHUNK: "html-async-chunk";
173
171
  /** SWC_POLYFILL_CHECKER */
174
172
  readonly SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin";
173
+ /** RouterPlugin */
174
+ readonly ROUTER_MANIFEST: "route-plugin";
175
175
  };
176
176
  /** Predefined minimizers */
177
177
  readonly MINIMIZER: {
@@ -27,6 +27,11 @@ declare const LOG_TYPES: {
27
27
  label: string;
28
28
  level: string;
29
29
  };
30
+ ready: {
31
+ color: string;
32
+ label: string;
33
+ level: string;
34
+ };
30
35
  success: {
31
36
  color: string;
32
37
  label: string;