@modern-js/utils 2.15.0 → 2.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/CHANGELOG.md +16 -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 +23 -43
  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 +4 -10
  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,5 +1,5 @@
1
1
  import { isFunction, logger, isPlainObject } from "./index";
2
- function applyOptionsChain(defaults, options, utils, mergeFn = Object.assign) {
2
+ export function applyOptionsChain(defaults, options, utils, mergeFn = Object.assign) {
3
3
  if (!options) {
4
4
  return defaults;
5
5
  }
@@ -9,27 +9,15 @@ function applyOptionsChain(defaults, options, utils, mergeFn = Object.assign) {
9
9
  const ret = options(defaults, utils);
10
10
  if (ret) {
11
11
  if (!isPlainObject(ret)) {
12
- logger.warn(
13
- `${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`
14
- );
12
+ logger.warn(`${options.name}: Function should mutate the config and return nothing, Or return a cloned or merged version of config object.`);
15
13
  }
16
14
  return ret;
17
15
  }
18
16
  } else if (Array.isArray(options)) {
19
- return options.reduce(
20
- (memo, cur) => applyOptionsChain(memo, cur, utils, mergeFn),
21
- defaults
22
- );
17
+ return options.reduce((memo, cur) => applyOptionsChain(memo, cur, utils, mergeFn), defaults);
23
18
  } else {
24
- throw new Error(
25
- `applyOptionsChain error:
26
- default options is: ${JSON.stringify(
27
- defaults
28
- )}`
29
- );
19
+ throw new Error(`applyOptionsChain error:
20
+ default options is: ${JSON.stringify(defaults)}`);
30
21
  }
31
22
  return defaults;
32
23
  }
33
- export {
34
- applyOptionsChain
35
- };
package/dist/esm/babel.js CHANGED
@@ -64,15 +64,17 @@ const modifyPresetOptions = (presetName, options, presets = []) => {
64
64
  preset[1] = {
65
65
  ...preset[1] || {},
66
66
  ...options
67
- // `options` is specific to different presets
68
67
  };
69
68
  }
70
69
  } else if (typeof preset === "string" && normalizeToPosixPath(preset).includes(presetName)) {
71
- presets[index] = [preset, options];
70
+ presets[index] = [
71
+ preset,
72
+ options
73
+ ];
72
74
  }
73
75
  });
74
76
  };
75
- const getBabelUtils = (config) => {
77
+ export const getBabelUtils = (config) => {
76
78
  const noop = () => {
77
79
  };
78
80
  return {
@@ -89,7 +91,7 @@ const getBabelUtils = (config) => {
89
91
  modifyPresetReactOptions: (options) => modifyPresetOptions("@babel/preset-react", options, config.presets || [])
90
92
  };
91
93
  };
92
- const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
94
+ export const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils) => {
93
95
  if (userBabelConfig) {
94
96
  const babelUtils = {
95
97
  ...getBabelUtils(defaultOptions),
@@ -99,7 +101,3 @@ const applyUserBabelConfig = (defaultOptions, userBabelConfig, extraBabelUtils)
99
101
  }
100
102
  return defaultOptions;
101
103
  };
102
- export {
103
- applyUserBabelConfig,
104
- getBabelUtils
105
- };
@@ -1,4 +1,4 @@
1
- const CHAIN_ID = {
1
+ export const CHAIN_ID = {
2
2
  /** Predefined rules */
3
3
  RULE: {
4
4
  /** Rule for .mjs */
@@ -168,6 +168,3 @@ const CHAIN_ID = {
168
168
  TS_CONFIG_PATHS: "ts-config-paths"
169
169
  }
170
170
  };
171
- export {
172
- CHAIN_ID
173
- };
@@ -1,8 +1,5 @@
1
- const clearConsole = () => {
1
+ export const clearConsole = () => {
2
2
  if (process.stdout.isTTY && !process.env.DEBUG) {
3
3
  process.stdout.write("\x1B[H\x1B[2J");
4
4
  }
5
5
  };
6
- export {
7
- clearConsole
8
- };
@@ -1,22 +1,16 @@
1
- const getFullArgv = () => {
2
- var _a;
3
- return ((_a = process.env.MODERN_ARGV) == null ? void 0 : _a.split(" ")) || process.argv;
1
+ export const getFullArgv = () => {
2
+ var _process_env_MODERN_ARGV;
3
+ return ((_process_env_MODERN_ARGV = process.env.MODERN_ARGV) === null || _process_env_MODERN_ARGV === void 0 ? void 0 : _process_env_MODERN_ARGV.split(" ")) || process.argv;
4
4
  };
5
- const getArgv = () => {
5
+ export const getArgv = () => {
6
6
  return getFullArgv().slice(2);
7
7
  };
8
- const getCommand = () => {
8
+ export const getCommand = () => {
9
9
  const args = getArgv();
10
10
  const command = args[0];
11
11
  return command;
12
12
  };
13
- const isDevCommand = () => {
13
+ export const isDevCommand = () => {
14
14
  const command = getCommand();
15
15
  return command === "dev" || command === "start";
16
16
  };
17
- export {
18
- getArgv,
19
- getCommand,
20
- getFullArgv,
21
- isDevCommand
22
- };
@@ -1,16 +1,16 @@
1
1
  import { findExists } from "./findExists";
2
- const compatRequire = (filePath, interop = true) => {
2
+ export const compatRequire = (filePath, interop = true) => {
3
3
  const mod = require(filePath);
4
- const rtnESMDefault = interop && (mod == null ? void 0 : mod.__esModule);
4
+ const rtnESMDefault = interop && (mod === null || mod === void 0 ? void 0 : mod.__esModule);
5
5
  return rtnESMDefault ? mod.default : mod;
6
6
  };
7
- const dynamicImport = new Function(
8
- "modulePath",
9
- "return import(modulePath)"
10
- );
11
- const requireExistModule = (filename, opt) => {
7
+ export const dynamicImport = new Function("modulePath", "return import(modulePath)");
8
+ export const requireExistModule = (filename, opt) => {
12
9
  const final = {
13
- extensions: [".ts", ".js"],
10
+ extensions: [
11
+ ".ts",
12
+ ".js"
13
+ ],
14
14
  interop: true,
15
15
  ...opt
16
16
  };
@@ -20,12 +20,12 @@ const requireExistModule = (filename, opt) => {
20
20
  }
21
21
  return compatRequire(exist, final.interop);
22
22
  };
23
- const cleanRequireCache = (filelist) => {
23
+ export const cleanRequireCache = (filelist) => {
24
24
  filelist.forEach((filepath) => {
25
25
  delete require.cache[filepath];
26
26
  });
27
27
  };
28
- function deleteRequireCache(path) {
28
+ export function deleteRequireCache(path) {
29
29
  if (require.cache[path]) {
30
30
  delete require.cache[path];
31
31
  }
@@ -33,10 +33,3 @@ function deleteRequireCache(path) {
33
33
  module.children = module.children.filter((item) => item.filename !== path);
34
34
  }
35
35
  }
36
- export {
37
- cleanRequireCache,
38
- compatRequire,
39
- deleteRequireCache,
40
- dynamicImport,
41
- requireExistModule
42
- };
@@ -1,77 +1,33 @@
1
1
  import { Import } from "./import";
2
- import { default as default2 } from "../compiled/fs-extra";
3
- import { default as default3 } from "../compiled/ora";
4
- import { default as default4 } from "../compiled/glob";
5
- import { default as default5 } from "../compiled/js-yaml";
6
- import { default as default6 } from "../compiled/chalk";
7
- import { default as default7 } from "../compiled/debug";
8
- import { default as default8 } from "../compiled/slash";
9
- import { default as default9 } from "../compiled/execa";
10
- import { default as default10 } from "../compiled/json5";
11
- import { default as default11 } from "../compiled/upath";
12
- import { default as default12 } from "../compiled/pkg-up";
13
- import { nanoid } from "../compiled/nanoid";
14
- import { default as default13 } from "../compiled/semver";
15
- import { default as default14 } from "../compiled/dotenv";
16
- import { default as default15 } from "../compiled/lodash";
17
- import { default as default16 } from "../compiled/globby";
18
- import { default as default17 } from "../compiled/address";
19
- import { default as default18 } from "../compiled/signale";
20
- import { default as default19 } from "../compiled/url-join";
21
- import { default as default20 } from "../compiled/minimist";
22
- import { default as default21 } from "../compiled/fast-glob";
23
- import { default as default22 } from "../compiled/filesize";
24
- import { default as default23 } from "../compiled/gzip-size";
25
- import { default as default24 } from "../compiled/strip-ansi";
26
- import { default as default25 } from "../compiled/dotenv-expand";
27
- import { default as default26 } from "../compiled/browserslist";
28
- import { default as default27 } from "../compiled/recursive-readdir";
29
- import { program, Command } from "../compiled/commander";
30
- import { Signale } from "../compiled/signale";
31
- const mime = Import.lazy(
32
- "../compiled/mime-types",
33
- require
34
- );
35
- const chokidar = Import.lazy(
36
- "../compiled/chokidar",
37
- require
38
- );
39
- const inquirer = Import.lazy(
40
- "../compiled/inquirer",
41
- require
42
- );
43
- export {
44
- Command,
45
- Signale,
46
- default17 as address,
47
- default26 as browserslist,
48
- default6 as chalk,
49
- chokidar,
50
- default7 as debug,
51
- default14 as dotenv,
52
- default25 as dotenvExpand,
53
- default9 as execa,
54
- default21 as fastGlob,
55
- default22 as filesize,
56
- default2 as fs,
57
- default4 as glob,
58
- default16 as globby,
59
- default23 as gzipSize,
60
- inquirer,
61
- default10 as json5,
62
- default15 as lodash,
63
- mime,
64
- default20 as minimist,
65
- nanoid,
66
- default3 as ora,
67
- default12 as pkgUp,
68
- program,
69
- default27 as recursiveReaddir,
70
- default13 as semver,
71
- default18 as signale,
72
- default8 as slash,
73
- default24 as stripAnsi,
74
- default11 as upath,
75
- default19 as urlJoin,
76
- default5 as yaml
77
- };
2
+ export { default as fs } from "../compiled/fs-extra";
3
+ export { default as ora } from "../compiled/ora";
4
+ export { default as glob } from "../compiled/glob";
5
+ export { default as yaml } from "../compiled/js-yaml";
6
+ export { default as chalk } from "../compiled/chalk";
7
+ export { default as debug } from "../compiled/debug";
8
+ export { default as slash } from "../compiled/slash";
9
+ export { default as execa } from "../compiled/execa";
10
+ export { default as json5 } from "../compiled/json5";
11
+ export { default as upath } from "../compiled/upath";
12
+ export { default as pkgUp } from "../compiled/pkg-up";
13
+ export { nanoid } from "../compiled/nanoid";
14
+ export { default as semver } from "../compiled/semver";
15
+ export { default as dotenv } from "../compiled/dotenv";
16
+ export { default as lodash } from "../compiled/lodash";
17
+ export { default as globby } from "../compiled/globby";
18
+ export { default as address } from "../compiled/address";
19
+ export { default as signale } from "../compiled/signale";
20
+ export { default as urlJoin } from "../compiled/url-join";
21
+ export { default as minimist } from "../compiled/minimist";
22
+ export { default as fastGlob } from "../compiled/fast-glob";
23
+ export { default as filesize } from "../compiled/filesize";
24
+ export { default as gzipSize } from "../compiled/gzip-size";
25
+ export { default as stripAnsi } from "../compiled/strip-ansi";
26
+ export { default as dotenvExpand } from "../compiled/dotenv-expand";
27
+ export { default as browserslist } from "../compiled/browserslist";
28
+ export { default as recursiveReaddir } from "../compiled/recursive-readdir";
29
+ export { program, Command } from "../compiled/commander";
30
+ export { Signale } from "../compiled/signale";
31
+ export const mime = Import.lazy("../compiled/mime-types", require);
32
+ export const chokidar = Import.lazy("../compiled/chokidar", require);
33
+ export const inquirer = Import.lazy("../compiled/inquirer", require);
@@ -1,22 +1,26 @@
1
- const ROUTE_SPEC_FILE = "route.json";
2
- const MAIN_ENTRY_NAME = "main";
3
- const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
4
- const SERVER_BUNDLE_DIRECTORY = "bundles";
5
- const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
6
- const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
7
- const SERVER_RENDER_FUNCTION_NAME = "serverRender";
8
- const LOADABLE_STATS_FILE = "loadable-stats.json";
9
- const API_DIR = "api";
10
- const SERVER_DIR = "server";
11
- const SHARED_DIR = "shared";
12
- const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
13
- const CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".mjs"];
14
- const OUTPUT_CONFIG_FILE = "modern.config.json";
15
- const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
16
- const ROUTE_MANIFEST_FILE = "routes-manifest.json";
17
- const LOADER_ROUTES_DIR = `loader-routes`;
18
- const DEFAULT_DEV_HOST = "0.0.0.0";
19
- const INTERNAL_APP_TOOLS_PLUGINS = {
1
+ export const ROUTE_SPEC_FILE = "route.json";
2
+ export const MAIN_ENTRY_NAME = "main";
3
+ export const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
4
+ export const SERVER_BUNDLE_DIRECTORY = "bundles";
5
+ export const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
6
+ export const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
7
+ export const SERVER_RENDER_FUNCTION_NAME = "serverRender";
8
+ export const LOADABLE_STATS_FILE = "loadable-stats.json";
9
+ export const API_DIR = "api";
10
+ export const SERVER_DIR = "server";
11
+ export const SHARED_DIR = "shared";
12
+ export const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
13
+ export const CONFIG_FILE_EXTENSIONS = [
14
+ ".js",
15
+ ".ts",
16
+ ".mjs"
17
+ ];
18
+ export const OUTPUT_CONFIG_FILE = "modern.config.json";
19
+ export const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
20
+ export const ROUTE_MANIFEST_FILE = "routes-manifest.json";
21
+ export const LOADER_ROUTES_DIR = `loader-routes`;
22
+ export const DEFAULT_DEV_HOST = "0.0.0.0";
23
+ export const INTERNAL_APP_TOOLS_PLUGINS = {
20
24
  "@modern-js/app-tools": "@modern-js/app-tools/cli",
21
25
  "@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
22
26
  "@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
@@ -32,10 +36,10 @@ const INTERNAL_APP_TOOLS_PLUGINS = {
32
36
  // legacy router (inner react-router-dom v5)
33
37
  "@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
34
38
  };
35
- const INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
39
+ export const INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
36
40
  "@modern-js/runtime": "@modern-js/runtime/cli"
37
41
  };
38
- const INTERNAL_MODULE_TOOLS_PLUGINS = {
42
+ export const INTERNAL_MODULE_TOOLS_PLUGINS = {
39
43
  "@modern-js/module-tools": "@modern-js/module-tools",
40
44
  "@modern-js/doc-tools": "@modern-js/doc-tools",
41
45
  "@modern-js/runtime": "@modern-js/runtime/cli",
@@ -47,16 +51,16 @@ const INTERNAL_MODULE_TOOLS_PLUGINS = {
47
51
  // legacy router (inner react-router-dom v5)
48
52
  "@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
49
53
  };
50
- const INTERNAL_MONOREPO_TOOLS_PLUGINS = {
54
+ export const INTERNAL_MONOREPO_TOOLS_PLUGINS = {
51
55
  "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
52
56
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
53
57
  };
54
- const INTERNAL_DOC_TOOLS_PLUGINS = {
58
+ export const INTERNAL_DOC_TOOLS_PLUGINS = {
55
59
  "@modern-js/doc-tools": "@modern-js/doc-tools",
56
60
  "@modern-js/runtime": "@modern-js/runtime/cli",
57
61
  "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
58
62
  };
59
- const INTERNAL_CLI_PLUGINS = {
63
+ export const INTERNAL_CLI_PLUGINS = {
60
64
  "@modern-js/app-tools": "@modern-js/app-tools/cli",
61
65
  "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
62
66
  "@modern-js/module-tools": "@modern-js/module-tools",
@@ -79,19 +83,19 @@ const INTERNAL_CLI_PLUGINS = {
79
83
  // legacy router (inner react-router-dom v5)
80
84
  "@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
81
85
  };
82
- const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
83
- const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
84
- const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
85
- const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
86
- const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
87
- const INTERNAL_SERVER_PLUGINS = {
86
+ export const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
87
+ export const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
88
+ export const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
89
+ export const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
90
+ export const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
91
+ export const INTERNAL_SERVER_PLUGINS = {
88
92
  [SERVER_PLUGIN_BFF]: "@modern-js/plugin-bff/server",
89
93
  [SERVER_PLUGIN_EXPRESS]: "@modern-js/plugin-express/server",
90
94
  [SERVER_PLUGIN_KOA]: "@modern-js/plugin-koa/server",
91
95
  [SERVER_PLUGIN_SERVER]: "@modern-js/plugin-server/server",
92
96
  [SERVER_PLUGIN_POLYFILL]: "@modern-js/plugin-polyfill/server"
93
97
  };
94
- const PLUGIN_SCHEMAS = {
98
+ export const PLUGIN_SCHEMAS = {
95
99
  "@modern-js/runtime": [
96
100
  {
97
101
  target: "runtime",
@@ -104,7 +108,11 @@ const PLUGIN_SCHEMAS = {
104
108
  target: "runtimeByEntries",
105
109
  schema: {
106
110
  type: "object",
107
- patternProperties: { [ENTRY_NAME_PATTERN]: { type: "object" } },
111
+ patternProperties: {
112
+ [ENTRY_NAME_PATTERN]: {
113
+ type: "object"
114
+ }
115
+ },
108
116
  additionalProperties: false
109
117
  }
110
118
  }
@@ -112,7 +120,11 @@ const PLUGIN_SCHEMAS = {
112
120
  "@modern-js/plugin-swc": [
113
121
  {
114
122
  target: "tools.swc",
115
- schema: { typeof: ["object"] }
123
+ schema: {
124
+ typeof: [
125
+ "object"
126
+ ]
127
+ }
116
128
  }
117
129
  ],
118
130
  "@modern-js/plugin-bff": [
@@ -122,12 +134,23 @@ const PLUGIN_SCHEMAS = {
122
134
  type: "object",
123
135
  properties: {
124
136
  prefix: {
125
- type: ["string", "array"],
126
- items: { type: "string" }
137
+ type: [
138
+ "string",
139
+ "array"
140
+ ],
141
+ items: {
142
+ type: "string"
143
+ }
127
144
  },
128
- fetcher: { type: "string" },
129
- proxy: { type: "object" },
130
- requestCreator: { type: "string" }
145
+ fetcher: {
146
+ type: "string"
147
+ },
148
+ proxy: {
149
+ type: "object"
150
+ },
151
+ requestCreator: {
152
+ type: "string"
153
+ }
131
154
  }
132
155
  }
133
156
  }
@@ -135,13 +158,23 @@ const PLUGIN_SCHEMAS = {
135
158
  "@modern-js/plugin-tailwindcss": [
136
159
  {
137
160
  target: "tools.tailwindcss",
138
- schema: { typeof: ["object", "function"] }
161
+ schema: {
162
+ typeof: [
163
+ "object",
164
+ "function"
165
+ ]
166
+ }
139
167
  }
140
168
  ],
141
169
  "@modern-js/plugin-proxy": [
142
170
  {
143
171
  target: "dev.proxy",
144
- schema: { typeof: ["string", "object"] }
172
+ schema: {
173
+ typeof: [
174
+ "string",
175
+ "object"
176
+ ]
177
+ }
145
178
  }
146
179
  ],
147
180
  "@modern-js/plugin-ssg": [
@@ -149,9 +182,15 @@ const PLUGIN_SCHEMAS = {
149
182
  target: "output.ssg",
150
183
  schema: {
151
184
  oneOf: [
152
- { type: "boolean" },
153
- { type: "object" },
154
- { instanceof: "Function" }
185
+ {
186
+ type: "boolean"
187
+ },
188
+ {
189
+ type: "object"
190
+ },
191
+ {
192
+ instanceof: "Function"
193
+ }
155
194
  ]
156
195
  }
157
196
  }
@@ -159,63 +198,112 @@ const PLUGIN_SCHEMAS = {
159
198
  "@modern-js/plugin-state": [
160
199
  {
161
200
  target: "runtime.state",
162
- schema: { type: ["boolean", "object"] }
201
+ schema: {
202
+ type: [
203
+ "boolean",
204
+ "object"
205
+ ]
206
+ }
163
207
  }
164
208
  ],
165
209
  "@modern-js/plugin-design-token": [
166
210
  // Legacy Features
167
211
  {
168
212
  target: "source.designSystem",
169
- schema: { typeof: ["object"] }
213
+ schema: {
214
+ typeof: [
215
+ "object"
216
+ ]
217
+ }
170
218
  },
171
219
  {
172
220
  target: "source.designSystem.supportStyledComponents",
173
- schema: { type: ["boolean"] }
221
+ schema: {
222
+ type: [
223
+ "boolean"
224
+ ]
225
+ }
174
226
  },
175
227
  {
176
228
  target: "designSystem",
177
- schema: { typeof: ["object"] }
229
+ schema: {
230
+ typeof: [
231
+ "object"
232
+ ]
233
+ }
178
234
  }
179
235
  ],
180
236
  "@modern-js/plugin-router": [
181
237
  {
182
238
  target: "runtime.router",
183
- schema: { type: ["boolean", "object"] }
239
+ schema: {
240
+ type: [
241
+ "boolean",
242
+ "object"
243
+ ]
244
+ }
184
245
  }
185
246
  ],
186
247
  "@modern-js/plugin-testing": [
187
248
  {
188
249
  target: "testing",
189
- schema: { typeof: ["object"] }
250
+ schema: {
251
+ typeof: [
252
+ "object"
253
+ ]
254
+ }
190
255
  },
191
256
  {
192
257
  target: "tools.jest",
193
- schema: { typeof: ["object", "function"] }
258
+ schema: {
259
+ typeof: [
260
+ "object",
261
+ "function"
262
+ ]
263
+ }
194
264
  }
195
265
  ],
196
266
  "@modern-js/plugin-garfish": [
197
267
  {
198
268
  target: "runtime.masterApp",
199
- schema: { type: ["boolean", "object"] }
269
+ schema: {
270
+ type: [
271
+ "boolean",
272
+ "object"
273
+ ]
274
+ }
200
275
  },
201
276
  {
202
277
  target: "dev.withMasterApp",
203
- schema: { type: ["object"] }
278
+ schema: {
279
+ type: [
280
+ "object"
281
+ ]
282
+ }
204
283
  },
205
284
  {
206
285
  target: "deploy.microFrontend",
207
- schema: { type: ["boolean", "object"] }
286
+ schema: {
287
+ type: [
288
+ "boolean",
289
+ "object"
290
+ ]
291
+ }
208
292
  }
209
293
  ],
210
294
  "@modern-js/plugin-nocode": [],
211
295
  "@modern-js/plugin-worker": [
212
296
  {
213
297
  target: "deploy.worker.ssr",
214
- schema: { type: ["boolean"] }
298
+ schema: {
299
+ type: [
300
+ "boolean"
301
+ ]
302
+ }
215
303
  }
216
304
  ]
217
305
  };
218
- const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
306
+ export const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
219
307
  allowNamespaces: true,
220
308
  allExtensions: true,
221
309
  allowDeclareFields: true,
@@ -224,37 +312,3 @@ const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
224
312
  optimizeConstEnums: true,
225
313
  isTSX: true
226
314
  };
227
- export {
228
- API_DIR,
229
- CONFIG_CACHE_DIR,
230
- CONFIG_FILE_EXTENSIONS,
231
- DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
232
- DEFAULT_DEV_HOST,
233
- DEFAULT_SERVER_CONFIG,
234
- ENTRY_NAME_PATTERN,
235
- INTERNAL_APP_TOOLS_PLUGINS,
236
- INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
237
- INTERNAL_CLI_PLUGINS,
238
- INTERNAL_DOC_TOOLS_PLUGINS,
239
- INTERNAL_MODULE_TOOLS_PLUGINS,
240
- INTERNAL_MONOREPO_TOOLS_PLUGINS,
241
- INTERNAL_SERVER_PLUGINS,
242
- LAUNCH_EDITOR_ENDPOINT,
243
- LOADABLE_STATS_FILE,
244
- LOADER_ROUTES_DIR,
245
- MAIN_ENTRY_NAME,
246
- OUTPUT_CONFIG_FILE,
247
- PLUGIN_SCHEMAS,
248
- ROUTE_MANIFEST_FILE,
249
- ROUTE_SPEC_FILE,
250
- SERVER_BUNDLE_DIRECTORY,
251
- SERVER_DIR,
252
- SERVER_PLUGIN_BFF,
253
- SERVER_PLUGIN_EXPRESS,
254
- SERVER_PLUGIN_KOA,
255
- SERVER_PLUGIN_POLYFILL,
256
- SERVER_PLUGIN_SERVER,
257
- SERVER_RENDER_FUNCTION_NAME,
258
- SERVER_WORKER_BUNDLE_DIRECTORY,
259
- SHARED_DIR
260
- };
package/dist/esm/debug.js CHANGED
@@ -1,5 +1,2 @@
1
1
  import { debug } from "../compiled/debug";
2
- const createDebugger = (scope) => debug(`modern-js:${scope}`);
3
- export {
4
- createDebugger
5
- };
2
+ export const createDebugger = (scope) => debug(`modern-js:${scope}`);
@@ -1,9 +1,6 @@
1
1
  import { fs } from "./compiled";
2
- const emptyDir = async (dir) => {
2
+ export const emptyDir = async (dir) => {
3
3
  if (await fs.pathExists(dir)) {
4
4
  await fs.emptyDir(dir);
5
5
  }
6
6
  };
7
- export {
8
- emptyDir
9
- };