@modern-js/utils 2.21.1 → 2.22.1-alpha.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 (155) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/FileSizeReporter.d.ts +16 -0
  3. package/dist/FileSizeReporter.js +162 -0
  4. package/dist/alias.d.ts +25 -0
  5. package/dist/alias.js +108 -0
  6. package/dist/analyzeProject.d.ts +2 -0
  7. package/dist/analyzeProject.js +71 -0
  8. package/dist/applyOptionsChain.d.ts +3 -0
  9. package/dist/applyOptionsChain.js +58 -0
  10. package/dist/babel.d.ts +3 -0
  11. package/dist/babel.js +136 -0
  12. package/dist/chainId.d.ts +244 -0
  13. package/dist/chainId.js +196 -0
  14. package/dist/cjs/cli/alias.js +12 -4
  15. package/dist/cjs/cli/applyOptionsChain.js +3 -1
  16. package/dist/cjs/cli/babel.js +6 -2
  17. package/dist/cjs/cli/commands.js +12 -4
  18. package/dist/cjs/cli/common.js +9 -3
  19. package/dist/cjs/cli/constants/chainId.js +3 -1
  20. package/dist/cjs/cli/constants/index.js +93 -31
  21. package/dist/cjs/cli/ensure.js +6 -2
  22. package/dist/cjs/cli/fs.js +6 -2
  23. package/dist/cjs/cli/get/config.js +3 -1
  24. package/dist/cjs/cli/get/data.js +24 -8
  25. package/dist/cjs/cli/get/index.js +6 -2
  26. package/dist/cjs/cli/is/config.js +18 -6
  27. package/dist/cjs/cli/is/env.js +18 -6
  28. package/dist/cjs/cli/is/platform.js +6 -2
  29. package/dist/cjs/cli/is/project.js +21 -7
  30. package/dist/cjs/cli/is/type.js +27 -9
  31. package/dist/cjs/cli/logger.js +6 -2
  32. package/dist/cjs/cli/monorepo.js +21 -7
  33. package/dist/cjs/cli/package.js +12 -4
  34. package/dist/cjs/cli/path.js +39 -13
  35. package/dist/cjs/cli/pathSerializer.js +12 -4
  36. package/dist/cjs/cli/port.js +3 -1
  37. package/dist/cjs/cli/prettyInstructions.js +6 -2
  38. package/dist/cjs/cli/print.js +3 -1
  39. package/dist/cjs/cli/require.js +18 -6
  40. package/dist/cjs/cli/routes.js +3 -1
  41. package/dist/cjs/cli/runtimeExports.js +3 -1
  42. package/dist/cjs/cli/test.js +3 -1
  43. package/dist/cjs/cli/watch.js +6 -2
  44. package/dist/cjs/compiled.js +99 -33
  45. package/dist/cjs/import.js +6 -2
  46. package/dist/cjs/runtime/nestedRoutes.js +6 -2
  47. package/dist/cjs/runtime-browser/parsed.js +8 -2
  48. package/dist/cjs/runtime-node/index.js +9 -3
  49. package/dist/cjs/runtime-node/serialize.js +3 -1
  50. package/dist/cjs/runtime-node/storage.js +3 -1
  51. package/dist/cjs/universal/constants.js +6 -2
  52. package/dist/cjs/universal/formatWebpack.js +3 -1
  53. package/dist/cjs/universal/pluginDagSort.js +3 -1
  54. package/dist/clearConsole.d.ts +1 -0
  55. package/dist/clearConsole.js +31 -0
  56. package/dist/commands.d.ts +4 -0
  57. package/dist/commands.js +48 -0
  58. package/dist/compatRequire.d.ts +13 -0
  59. package/dist/compatRequire.js +82 -0
  60. package/dist/compiled.d.ts +43 -0
  61. package/dist/compiled.js +142 -0
  62. package/dist/constants.d.ts +244 -0
  63. package/dist/constants.js +320 -0
  64. package/dist/debug.d.ts +6 -0
  65. package/dist/debug.js +28 -0
  66. package/dist/emptyDir.d.ts +1 -0
  67. package/dist/emptyDir.js +52 -0
  68. package/dist/ensureAbsolutePath.d.ts +7 -0
  69. package/dist/ensureAbsolutePath.js +38 -0
  70. package/dist/ensureArray.d.ts +1 -0
  71. package/dist/ensureArray.js +32 -0
  72. package/dist/esm/runtime-browser/parsed.js +5 -1
  73. package/dist/findExists.d.ts +6 -0
  74. package/dist/findExists.js +45 -0
  75. package/dist/generateMetaTags.d.ts +16 -0
  76. package/dist/generateMetaTags.js +61 -0
  77. package/dist/getBrowserslist.d.ts +2 -0
  78. package/dist/getBrowserslist.js +31 -0
  79. package/dist/getCoreJsVersion.d.ts +1 -0
  80. package/dist/getCoreJsVersion.js +46 -0
  81. package/dist/getEntryOptions.d.ts +1 -0
  82. package/dist/getEntryOptions.js +54 -0
  83. package/dist/getPackageManager.d.ts +1 -0
  84. package/dist/getPackageManager.js +87 -0
  85. package/dist/getPort.d.ts +14 -0
  86. package/dist/getPort.js +112 -0
  87. package/dist/getServerConfig.d.ts +1 -0
  88. package/dist/getServerConfig.js +67 -0
  89. package/dist/getTargetDir.d.ts +1 -0
  90. package/dist/getTargetDir.js +41 -0
  91. package/dist/import.d.ts +5 -0
  92. package/dist/import.js +33 -0
  93. package/dist/index.d.ts +44 -0
  94. package/dist/index.js +60 -0
  95. package/dist/is/index.d.ts +58 -0
  96. package/dist/is/index.js +114 -0
  97. package/dist/is/nodeEnv.d.ts +8 -0
  98. package/dist/is/nodeEnv.js +39 -0
  99. package/dist/is/platform.d.ts +2 -0
  100. package/dist/is/platform.js +30 -0
  101. package/dist/is/type.d.ts +8 -0
  102. package/dist/is/type.js +64 -0
  103. package/dist/logger.d.ts +65 -0
  104. package/dist/logger.js +145 -0
  105. package/dist/monorepo.d.ts +11 -0
  106. package/dist/monorepo.js +137 -0
  107. package/dist/nodeEnv.d.ts +3 -0
  108. package/dist/nodeEnv.js +81 -0
  109. package/dist/path.d.ts +18 -0
  110. package/dist/path.js +92 -0
  111. package/dist/pathSerializer.d.ts +16 -0
  112. package/dist/pathSerializer.js +76 -0
  113. package/dist/plugin.d.ts +2 -0
  114. package/dist/plugin.js +46 -0
  115. package/dist/prettyInstructions.d.ts +9 -0
  116. package/dist/prettyInstructions.js +112 -0
  117. package/dist/printBuildError.d.ts +8 -0
  118. package/dist/printBuildError.js +57 -0
  119. package/dist/react.d.ts +1 -0
  120. package/dist/react.js +64 -0
  121. package/dist/readTsConfig.d.ts +2 -0
  122. package/dist/readTsConfig.js +47 -0
  123. package/dist/removeSlash.d.ts +3 -0
  124. package/dist/removeSlash.js +33 -0
  125. package/dist/resolve.d.ts +13 -0
  126. package/dist/resolve.js +63 -0
  127. package/dist/routes.d.ts +2 -0
  128. package/dist/routes.js +58 -0
  129. package/dist/runtimeExports.d.ts +4 -0
  130. package/dist/runtimeExports.js +73 -0
  131. package/dist/ssr.d.ts +8 -0
  132. package/dist/ssr.js +30 -0
  133. package/dist/storage.d.ts +5 -0
  134. package/dist/storage.js +75 -0
  135. package/dist/testUtils.d.ts +5 -0
  136. package/dist/testUtils.js +38 -0
  137. package/dist/types.d.ts +1 -0
  138. package/dist/types.js +15 -0
  139. package/dist/universal/constants.d.ts +9 -0
  140. package/dist/universal/constants.js +30 -0
  141. package/dist/universal/formatWebpack.d.ts +13 -0
  142. package/dist/universal/formatWebpack.js +100 -0
  143. package/dist/universal/nestedRoutes.d.ts +8 -0
  144. package/dist/universal/nestedRoutes.js +131 -0
  145. package/dist/universal/remixRouter.d.ts +1 -0
  146. package/dist/universal/remixRouter.js +17 -0
  147. package/dist/universal/serialize.d.ts +1 -0
  148. package/dist/universal/serialize.js +40 -0
  149. package/dist/version.d.ts +2 -0
  150. package/dist/version.js +92 -0
  151. package/dist/wait.d.ts +2 -0
  152. package/dist/wait.js +29 -0
  153. package/dist/watch.d.ts +8 -0
  154. package/dist/watch.js +90 -0
  155. package/package.json +5 -5
@@ -0,0 +1,244 @@
1
+ import { InternalPlugins } from '@modern-js/types';
2
+ /**
3
+ * route specification file
4
+ */
5
+
6
+ export declare const ROUTE_SPEC_FILE = "route.json";
7
+ /**
8
+ * main entry name
9
+ */
10
+
11
+ export declare const MAIN_ENTRY_NAME = "main";
12
+ /**
13
+ * open editor request path
14
+ */
15
+
16
+ export declare const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
17
+ /**
18
+ * server side bundles directory, which relative to dist.
19
+ */
20
+
21
+ export declare const SERVER_BUNDLE_DIRECTORY = "bundles";
22
+ /**
23
+ * server side bundles directory, which relative to dist.
24
+ */
25
+
26
+ export declare const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
27
+ /**
28
+ * entry name pattern used for ajv pattern properties.
29
+ */
30
+
31
+ export declare const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
32
+ /**
33
+ * SSR server render function name
34
+ */
35
+
36
+ export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
37
+ /**
38
+ * loadbale manifest json file
39
+ */
40
+
41
+ export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
42
+ /**
43
+ * internal specified folder
44
+ */
45
+
46
+ export declare const API_DIR = "api";
47
+ export declare const SERVER_DIR = "server";
48
+ export declare const SHARED_DIR = "shared";
49
+ /**
50
+ * Modern.config.ts cached dir
51
+ */
52
+
53
+ export declare const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
54
+ export declare const CONFIG_FILE_EXTENSIONS: string[];
55
+ /**
56
+ * Serialized config path
57
+ */
58
+
59
+ export declare const OUTPUT_CONFIG_FILE = "modern.config.json";
60
+ /**
61
+ * Default server config basename
62
+ */
63
+
64
+ export declare const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
65
+ /**
66
+ * Routes manifest filename
67
+ */
68
+
69
+ export declare const ROUTE_MANIFEST_FILE = "routes-manifest.json";
70
+ /**
71
+ * directory name for loader routes
72
+ */
73
+
74
+ export declare const LOADER_ROUTES_DIR = "loader-routes";
75
+ /**
76
+ * default host for dev
77
+ */
78
+
79
+ export declare const DEFAULT_DEV_HOST = "0.0.0.0";
80
+ /**
81
+ * Internal app-tools plugins that work as soon as they are installed.
82
+ */
83
+
84
+ export declare const INTERNAL_APP_TOOLS_PLUGINS: InternalPlugins;
85
+ export declare const INTERNAL_APP_TOOLS_RUNTIME_PLUGINS: InternalPlugins;
86
+ /**
87
+ * Internal module-tools plugins that work as soon as they are installed.
88
+ */
89
+
90
+ export declare const INTERNAL_MODULE_TOOLS_PLUGINS: InternalPlugins;
91
+ /**
92
+ * Internal monorepo-tools plugins that work as soon as they are installed.
93
+ */
94
+
95
+ export declare const INTERNAL_MONOREPO_TOOLS_PLUGINS: InternalPlugins;
96
+ /**
97
+ * Internal doc-tools plugins that work as soon as they are installed.
98
+ */
99
+
100
+ export declare const INTERNAL_DOC_TOOLS_PLUGINS: InternalPlugins;
101
+ /**
102
+ * Internal plugins that work as soon as they are installed.
103
+ */
104
+
105
+ export declare const INTERNAL_CLI_PLUGINS: InternalPlugins;
106
+ export declare const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
107
+ export declare const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
108
+ export declare const SERVER_PLUGIN_EGG = "@modern-js/plugin-egg";
109
+ export declare const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
110
+ export declare const SERVER_PLUGIN_NEST = "@modern-js/plugin-nest";
111
+ export declare const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
112
+ export declare const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
113
+ export declare const INTERNAL_SERVER_PLUGINS: InternalPlugins;
114
+ /**
115
+ * The schema registered in the plugin.
116
+ */
117
+
118
+ export declare const PLUGIN_SCHEMAS: {
119
+ '@modern-js/runtime': ({
120
+ target: string;
121
+ schema: {
122
+ type: string;
123
+ additionalProperties: boolean;
124
+ patternProperties?: undefined;
125
+ };
126
+ } | {
127
+ target: string;
128
+ schema: {
129
+ type: string;
130
+ patternProperties: {
131
+ "^[a-zA-Z0-9_-]+$": {
132
+ type: string;
133
+ };
134
+ };
135
+ additionalProperties: boolean;
136
+ };
137
+ })[];
138
+ '@modern-js/plugin-swc': {
139
+ target: string;
140
+ schema: {
141
+ typeof: string[];
142
+ };
143
+ }[];
144
+ '@modern-js/plugin-bff': {
145
+ target: string;
146
+ schema: {
147
+ type: string;
148
+ properties: {
149
+ prefix: {
150
+ type: string[];
151
+ items: {
152
+ type: string;
153
+ };
154
+ };
155
+ fetcher: {
156
+ type: string;
157
+ };
158
+ proxy: {
159
+ type: string;
160
+ };
161
+ requestCreator: {
162
+ type: string;
163
+ };
164
+ };
165
+ };
166
+ }[];
167
+ '@modern-js/plugin-tailwindcss': {
168
+ target: string;
169
+ schema: {
170
+ typeof: string[];
171
+ };
172
+ }[];
173
+ '@modern-js/plugin-proxy': {
174
+ target: string;
175
+ schema: {
176
+ typeof: string[];
177
+ };
178
+ }[];
179
+ '@modern-js/plugin-ssg': {
180
+ target: string;
181
+ schema: {
182
+ oneOf: ({
183
+ type: string;
184
+ instanceof?: undefined;
185
+ } | {
186
+ instanceof: string;
187
+ type?: undefined;
188
+ })[];
189
+ };
190
+ }[];
191
+ '@modern-js/plugin-state': {
192
+ target: string;
193
+ schema: {
194
+ type: string[];
195
+ };
196
+ }[];
197
+ '@modern-js/plugin-design-token': ({
198
+ target: string;
199
+ schema: {
200
+ typeof: string[];
201
+ type?: undefined;
202
+ };
203
+ } | {
204
+ target: string;
205
+ schema: {
206
+ type: string[];
207
+ typeof?: undefined;
208
+ };
209
+ })[];
210
+ '@modern-js/plugin-router': {
211
+ target: string;
212
+ schema: {
213
+ type: string[];
214
+ };
215
+ }[];
216
+ '@modern-js/plugin-testing': {
217
+ target: string;
218
+ schema: {
219
+ typeof: string[];
220
+ };
221
+ }[];
222
+ '@modern-js/plugin-garfish': {
223
+ target: string;
224
+ schema: {
225
+ type: string[];
226
+ };
227
+ }[];
228
+ '@modern-js/plugin-nocode': never[];
229
+ };
230
+ /**
231
+ * The `@babel/preset-typescript` default options.
232
+ *
233
+ * for:
234
+ * - `@modern-js/builder-rspack-provider`
235
+ * - `@modern-js/babel-preset-base`
236
+ */
237
+
238
+ export declare const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: {
239
+ allowNamespaces: boolean;
240
+ allExtensions: boolean;
241
+ allowDeclareFields: boolean;
242
+ optimizeConstEnums: boolean;
243
+ isTSX: boolean;
244
+ };
@@ -0,0 +1,320 @@
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 constants_exports = {};
19
+ __export(constants_exports, {
20
+ API_DIR: () => API_DIR,
21
+ CONFIG_CACHE_DIR: () => CONFIG_CACHE_DIR,
22
+ CONFIG_FILE_EXTENSIONS: () => CONFIG_FILE_EXTENSIONS,
23
+ DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: () => DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
24
+ DEFAULT_DEV_HOST: () => DEFAULT_DEV_HOST,
25
+ DEFAULT_SERVER_CONFIG: () => DEFAULT_SERVER_CONFIG,
26
+ ENTRY_NAME_PATTERN: () => ENTRY_NAME_PATTERN,
27
+ INTERNAL_APP_TOOLS_PLUGINS: () => INTERNAL_APP_TOOLS_PLUGINS,
28
+ INTERNAL_APP_TOOLS_RUNTIME_PLUGINS: () => INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
29
+ INTERNAL_CLI_PLUGINS: () => INTERNAL_CLI_PLUGINS,
30
+ INTERNAL_DOC_TOOLS_PLUGINS: () => INTERNAL_DOC_TOOLS_PLUGINS,
31
+ INTERNAL_MODULE_TOOLS_PLUGINS: () => INTERNAL_MODULE_TOOLS_PLUGINS,
32
+ INTERNAL_MONOREPO_TOOLS_PLUGINS: () => INTERNAL_MONOREPO_TOOLS_PLUGINS,
33
+ INTERNAL_SERVER_PLUGINS: () => INTERNAL_SERVER_PLUGINS,
34
+ LAUNCH_EDITOR_ENDPOINT: () => LAUNCH_EDITOR_ENDPOINT,
35
+ LOADABLE_STATS_FILE: () => LOADABLE_STATS_FILE,
36
+ LOADER_ROUTES_DIR: () => LOADER_ROUTES_DIR,
37
+ MAIN_ENTRY_NAME: () => MAIN_ENTRY_NAME,
38
+ OUTPUT_CONFIG_FILE: () => OUTPUT_CONFIG_FILE,
39
+ PLUGIN_SCHEMAS: () => PLUGIN_SCHEMAS,
40
+ ROUTE_MANIFEST_FILE: () => ROUTE_MANIFEST_FILE,
41
+ ROUTE_SPEC_FILE: () => ROUTE_SPEC_FILE,
42
+ SERVER_BUNDLE_DIRECTORY: () => SERVER_BUNDLE_DIRECTORY,
43
+ SERVER_DIR: () => SERVER_DIR,
44
+ SERVER_PLUGIN_BFF: () => SERVER_PLUGIN_BFF,
45
+ SERVER_PLUGIN_EGG: () => SERVER_PLUGIN_EGG,
46
+ SERVER_PLUGIN_EXPRESS: () => SERVER_PLUGIN_EXPRESS,
47
+ SERVER_PLUGIN_KOA: () => SERVER_PLUGIN_KOA,
48
+ SERVER_PLUGIN_NEST: () => SERVER_PLUGIN_NEST,
49
+ SERVER_PLUGIN_POLYFILL: () => SERVER_PLUGIN_POLYFILL,
50
+ SERVER_PLUGIN_SERVER: () => SERVER_PLUGIN_SERVER,
51
+ SERVER_RENDER_FUNCTION_NAME: () => SERVER_RENDER_FUNCTION_NAME,
52
+ SERVER_WORKER_BUNDLE_DIRECTORY: () => SERVER_WORKER_BUNDLE_DIRECTORY,
53
+ SHARED_DIR: () => SHARED_DIR
54
+ });
55
+ module.exports = __toCommonJS(constants_exports);
56
+ const ROUTE_SPEC_FILE = "route.json";
57
+ const MAIN_ENTRY_NAME = "main";
58
+ const LAUNCH_EDITOR_ENDPOINT = "/__open-stack-frame-in-editor";
59
+ const SERVER_BUNDLE_DIRECTORY = "bundles";
60
+ const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
61
+ const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
62
+ const SERVER_RENDER_FUNCTION_NAME = "serverRender";
63
+ const LOADABLE_STATS_FILE = "loadable-stats.json";
64
+ const API_DIR = "api";
65
+ const SERVER_DIR = "server";
66
+ const SHARED_DIR = "shared";
67
+ const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
68
+ const CONFIG_FILE_EXTENSIONS = [".js", ".ts", ".mjs"];
69
+ const OUTPUT_CONFIG_FILE = "modern.config.json";
70
+ const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
71
+ const ROUTE_MANIFEST_FILE = "routes-manifest.json";
72
+ const LOADER_ROUTES_DIR = `loader-routes`;
73
+ const DEFAULT_DEV_HOST = "0.0.0.0";
74
+ const INTERNAL_APP_TOOLS_PLUGINS = {
75
+ "@modern-js/app-tools": "@modern-js/app-tools/cli",
76
+ "@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
77
+ "@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
78
+ "@modern-js/plugin-bff": "@modern-js/plugin-bff/cli",
79
+ "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
80
+ "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
81
+ "@modern-js/plugin-express": "@modern-js/plugin-express/cli",
82
+ "@modern-js/plugin-egg": "@modern-js/plugin-egg/cli",
83
+ "@modern-js/plugin-koa": "@modern-js/plugin-koa/cli",
84
+ "@modern-js/plugin-nest": "@modern-js/plugin-nest/cli",
85
+ "@modern-js/plugin-server": "@modern-js/plugin-server/cli",
86
+ "@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
87
+ "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
88
+ "@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
89
+ // legacy router (inner react-router-dom v5)
90
+ "@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
91
+ };
92
+ const INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
93
+ "@modern-js/runtime": "@modern-js/runtime/cli"
94
+ };
95
+ const INTERNAL_MODULE_TOOLS_PLUGINS = {
96
+ "@modern-js/module-tools": "@modern-js/module-tools",
97
+ "@modern-js/doc-tools": "@modern-js/doc-tools",
98
+ "@modern-js/runtime": "@modern-js/runtime/cli",
99
+ "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
100
+ "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
101
+ "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
102
+ // TODO: Maybe can remove it
103
+ "@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
104
+ // legacy router (inner react-router-dom v5)
105
+ "@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
106
+ };
107
+ const INTERNAL_MONOREPO_TOOLS_PLUGINS = {
108
+ "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
109
+ "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
110
+ };
111
+ const INTERNAL_DOC_TOOLS_PLUGINS = {
112
+ "@modern-js/doc-tools": "@modern-js/doc-tools",
113
+ "@modern-js/runtime": "@modern-js/runtime/cli",
114
+ "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
115
+ };
116
+ const INTERNAL_CLI_PLUGINS = {
117
+ "@modern-js/app-tools": "@modern-js/app-tools/cli",
118
+ "@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
119
+ "@modern-js/module-tools": "@modern-js/module-tools",
120
+ "@modern-js/doc-tools": "@modern-js/doc-tools",
121
+ "@modern-js/runtime": "@modern-js/runtime/cli",
122
+ "@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
123
+ "@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
124
+ "@modern-js/plugin-bff": "@modern-js/plugin-bff/cli",
125
+ "@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
126
+ "@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
127
+ "@modern-js/plugin-express": "@modern-js/plugin-express/cli",
128
+ "@modern-js/plugin-egg": "@modern-js/plugin-egg/cli",
129
+ "@modern-js/plugin-koa": "@modern-js/plugin-koa/cli",
130
+ "@modern-js/plugin-nest": "@modern-js/plugin-nest/cli",
131
+ "@modern-js/plugin-server": "@modern-js/plugin-server/cli",
132
+ "@modern-js/plugin-swc": "@modern-js/plugin-swc",
133
+ "@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
134
+ "@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
135
+ "@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
136
+ // TODO: Maybe can remove it
137
+ "@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
138
+ // legacy router (inner react-router-dom v5)
139
+ "@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
140
+ };
141
+ const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
142
+ const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
143
+ const SERVER_PLUGIN_EGG = "@modern-js/plugin-egg";
144
+ const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
145
+ const SERVER_PLUGIN_NEST = "@modern-js/plugin-nest";
146
+ const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
147
+ const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
148
+ const INTERNAL_SERVER_PLUGINS = {
149
+ [SERVER_PLUGIN_BFF]: "@modern-js/plugin-bff/server",
150
+ [SERVER_PLUGIN_EXPRESS]: "@modern-js/plugin-express/server",
151
+ [SERVER_PLUGIN_EGG]: "@modern-js/plugin-egg/server",
152
+ [SERVER_PLUGIN_KOA]: "@modern-js/plugin-koa/server",
153
+ [SERVER_PLUGIN_NEST]: "@modern-js/plugin-nest/server",
154
+ [SERVER_PLUGIN_SERVER]: "@modern-js/plugin-server/server",
155
+ [SERVER_PLUGIN_POLYFILL]: "@modern-js/plugin-polyfill/server"
156
+ };
157
+ const PLUGIN_SCHEMAS = {
158
+ "@modern-js/runtime": [
159
+ {
160
+ target: "runtime",
161
+ schema: {
162
+ type: "object",
163
+ additionalProperties: false
164
+ }
165
+ },
166
+ {
167
+ target: "runtimeByEntries",
168
+ schema: {
169
+ type: "object",
170
+ patternProperties: { [ENTRY_NAME_PATTERN]: { type: "object" } },
171
+ additionalProperties: false
172
+ }
173
+ }
174
+ ],
175
+ "@modern-js/plugin-swc": [
176
+ {
177
+ target: "tools.swc",
178
+ schema: { typeof: ["object"] }
179
+ }
180
+ ],
181
+ "@modern-js/plugin-bff": [
182
+ {
183
+ target: "bff",
184
+ schema: {
185
+ type: "object",
186
+ properties: {
187
+ prefix: {
188
+ type: ["string", "array"],
189
+ items: { type: "string" }
190
+ },
191
+ fetcher: { type: "string" },
192
+ proxy: { type: "object" },
193
+ requestCreator: { type: "string" }
194
+ }
195
+ }
196
+ }
197
+ ],
198
+ "@modern-js/plugin-tailwindcss": [
199
+ {
200
+ target: "tools.tailwindcss",
201
+ schema: { typeof: ["object", "function"] }
202
+ }
203
+ ],
204
+ "@modern-js/plugin-proxy": [
205
+ {
206
+ target: "dev.proxy",
207
+ schema: { typeof: ["string", "object"] }
208
+ }
209
+ ],
210
+ "@modern-js/plugin-ssg": [
211
+ {
212
+ target: "output.ssg",
213
+ schema: {
214
+ oneOf: [
215
+ { type: "boolean" },
216
+ { type: "object" },
217
+ { instanceof: "Function" }
218
+ ]
219
+ }
220
+ }
221
+ ],
222
+ "@modern-js/plugin-state": [
223
+ {
224
+ target: "runtime.state",
225
+ schema: { type: ["boolean", "object"] }
226
+ }
227
+ ],
228
+ "@modern-js/plugin-design-token": [
229
+ // Legacy Features
230
+ {
231
+ target: "source.designSystem",
232
+ schema: { typeof: ["object"] }
233
+ },
234
+ {
235
+ target: "source.designSystem.supportStyledComponents",
236
+ schema: { type: ["boolean"] }
237
+ },
238
+ {
239
+ target: "designSystem",
240
+ schema: { typeof: ["object"] }
241
+ }
242
+ ],
243
+ "@modern-js/plugin-router": [
244
+ {
245
+ target: "runtime.router",
246
+ schema: { type: ["boolean", "object"] }
247
+ }
248
+ ],
249
+ "@modern-js/plugin-testing": [
250
+ {
251
+ target: "testing",
252
+ schema: { typeof: ["object"] }
253
+ },
254
+ {
255
+ target: "tools.jest",
256
+ schema: { typeof: ["object", "function"] }
257
+ }
258
+ ],
259
+ "@modern-js/plugin-garfish": [
260
+ {
261
+ target: "runtime.masterApp",
262
+ schema: { type: ["boolean", "object"] }
263
+ },
264
+ {
265
+ target: "dev.withMasterApp",
266
+ schema: { type: ["object"] }
267
+ },
268
+ {
269
+ target: "deploy.microFrontend",
270
+ schema: { type: ["boolean", "object"] }
271
+ }
272
+ ],
273
+ "@modern-js/plugin-nocode": []
274
+ };
275
+ const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
276
+ allowNamespaces: true,
277
+ allExtensions: true,
278
+ allowDeclareFields: true,
279
+ // aligns Babel's behavior with TypeScript's default behavior.
280
+ // https://babeljs.io/docs/en/babel-preset-typescript#optimizeconstenums
281
+ optimizeConstEnums: true,
282
+ isTSX: true
283
+ };
284
+ // Annotate the CommonJS export names for ESM import in node:
285
+ 0 && (module.exports = {
286
+ API_DIR,
287
+ CONFIG_CACHE_DIR,
288
+ CONFIG_FILE_EXTENSIONS,
289
+ DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS,
290
+ DEFAULT_DEV_HOST,
291
+ DEFAULT_SERVER_CONFIG,
292
+ ENTRY_NAME_PATTERN,
293
+ INTERNAL_APP_TOOLS_PLUGINS,
294
+ INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
295
+ INTERNAL_CLI_PLUGINS,
296
+ INTERNAL_DOC_TOOLS_PLUGINS,
297
+ INTERNAL_MODULE_TOOLS_PLUGINS,
298
+ INTERNAL_MONOREPO_TOOLS_PLUGINS,
299
+ INTERNAL_SERVER_PLUGINS,
300
+ LAUNCH_EDITOR_ENDPOINT,
301
+ LOADABLE_STATS_FILE,
302
+ LOADER_ROUTES_DIR,
303
+ MAIN_ENTRY_NAME,
304
+ OUTPUT_CONFIG_FILE,
305
+ PLUGIN_SCHEMAS,
306
+ ROUTE_MANIFEST_FILE,
307
+ ROUTE_SPEC_FILE,
308
+ SERVER_BUNDLE_DIRECTORY,
309
+ SERVER_DIR,
310
+ SERVER_PLUGIN_BFF,
311
+ SERVER_PLUGIN_EGG,
312
+ SERVER_PLUGIN_EXPRESS,
313
+ SERVER_PLUGIN_KOA,
314
+ SERVER_PLUGIN_NEST,
315
+ SERVER_PLUGIN_POLYFILL,
316
+ SERVER_PLUGIN_SERVER,
317
+ SERVER_RENDER_FUNCTION_NAME,
318
+ SERVER_WORKER_BUNDLE_DIRECTORY,
319
+ SHARED_DIR
320
+ });
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Create debug function with unified namespace prefix.
3
+ * @param scope - Custom module name of your debug function.
4
+ * @returns Debug function which namespace start with modern-js:.
5
+ */
6
+ export declare const createDebugger: (scope: string) => import("../compiled/debug").Debugger;
package/dist/debug.js ADDED
@@ -0,0 +1,28 @@
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 debug_exports = {};
19
+ __export(debug_exports, {
20
+ createDebugger: () => createDebugger
21
+ });
22
+ module.exports = __toCommonJS(debug_exports);
23
+ var import_debug = require("../compiled/debug");
24
+ const createDebugger = (scope) => (0, import_debug.debug)(`modern-js:${scope}`);
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ createDebugger
28
+ });
@@ -0,0 +1 @@
1
+ export declare const emptyDir: (dir: string) => Promise<void>;
@@ -0,0 +1,52 @@
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 __async = (__this, __arguments, generator) => {
19
+ return new Promise((resolve, reject) => {
20
+ var fulfilled = (value) => {
21
+ try {
22
+ step(generator.next(value));
23
+ } catch (e) {
24
+ reject(e);
25
+ }
26
+ };
27
+ var rejected = (value) => {
28
+ try {
29
+ step(generator.throw(value));
30
+ } catch (e) {
31
+ reject(e);
32
+ }
33
+ };
34
+ var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
35
+ step((generator = generator.apply(__this, __arguments)).next());
36
+ });
37
+ };
38
+ var emptyDir_exports = {};
39
+ __export(emptyDir_exports, {
40
+ emptyDir: () => emptyDir
41
+ });
42
+ module.exports = __toCommonJS(emptyDir_exports);
43
+ var import_compiled = require("./compiled");
44
+ const emptyDir = (dir) => __async(void 0, null, function* () {
45
+ if (yield import_compiled.fs.pathExists(dir)) {
46
+ yield import_compiled.fs.emptyDir(dir);
47
+ }
48
+ });
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ emptyDir
52
+ });
@@ -0,0 +1,7 @@
1
+ /**
2
+ * ensure absolute file path.
3
+ * @param base - Base path to resolve relative from.
4
+ * @param filePath - Absolute or relative file path.
5
+ * @returns Resolved absolute file path.
6
+ */
7
+ export declare const ensureAbsolutePath: (base: string, filePath: string) => string;