@modern-js/utils 2.20.0 → 2.21.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.
@@ -4,56 +4,39 @@ export declare const CHAIN_ID: {
4
4
  /** Rule for .mjs */
5
5
  readonly MJS: "mjs";
6
6
  /** Rule for predefined loaders */
7
-
8
7
  readonly LOADERS: "loaders";
9
8
  /** Rule for fonts */
10
-
11
9
  readonly FONT: "font";
12
10
  /** Rule for images */
13
-
14
11
  readonly IMAGE: "image";
15
12
  /** Rule for media */
16
-
17
13
  readonly MEDIA: "media";
18
14
  /** Rule for js */
19
-
20
15
  readonly JS: "js";
21
16
  /** Rule for data uri encoded javascript */
22
-
23
17
  readonly JS_DATA_URI: "js-data-uri";
24
18
  /** Rule for ts */
25
-
26
19
  readonly TS: "ts";
27
20
  /** Rule for css */
28
-
29
21
  readonly CSS: "css";
30
22
  /** Rule for less */
31
-
32
23
  readonly LESS: "less";
33
24
  /** Rule for sass */
34
-
35
25
  readonly SASS: "sass";
36
26
  /** Rule for stylus */
37
-
38
27
  readonly STYLUS: "stylus";
39
28
  /** Rule for svg */
40
-
41
29
  readonly SVG: "svg";
42
30
  /** Rule for pug */
43
-
44
31
  readonly PUG: "pug";
45
32
  /** Rule for toml */
46
-
47
33
  readonly TOML: "toml";
48
34
  /** Rule for yaml */
49
-
50
35
  readonly YAML: "yaml";
51
36
  /** Rule for bff */
52
-
53
37
  readonly JS_BFF_API: "js-bff-api";
54
38
  };
55
39
  /** Predefined rule groups */
56
-
57
40
  readonly ONE_OF: {
58
41
  readonly SVG: "svg";
59
42
  readonly SVG_URL: "svg-url";
@@ -61,183 +44,129 @@ export declare const CHAIN_ID: {
61
44
  readonly SVG_INLINE: "svg-inline";
62
45
  };
63
46
  /** Predefined loaders */
64
-
65
47
  readonly USE: {
66
48
  /** ts-loader */
67
49
  readonly TS: "ts";
68
50
  /** css-loader */
69
-
70
51
  readonly CSS: "css";
71
52
  /** sass-loader */
72
-
73
53
  readonly SASS: "sass";
74
54
  /** less-loader */
75
-
76
55
  readonly LESS: "less";
77
56
  /** stylus-loader */
78
-
79
57
  readonly STYLUS: "stylus";
80
58
  /** url-loader */
81
-
82
59
  readonly URL: "url";
83
60
  /** pug-loader */
84
-
85
61
  readonly PUG: "pug";
86
62
  /** file-loader */
87
-
88
63
  readonly FILE: "file";
89
64
  /** @svgr/webpack */
90
-
91
65
  readonly SVGR: "svgr";
92
66
  /** yaml-loader */
93
-
94
67
  readonly YAML: "yaml";
95
68
  /** toml-loader */
96
-
97
69
  readonly TOML: "toml";
98
70
  /** html-loader */
99
-
100
71
  readonly HTML: "html";
101
72
  /** babel-loader */
102
-
103
73
  readonly BABEL: "babel";
104
74
  /** esbuild-loader */
105
-
106
75
  readonly ESBUILD: "esbuild";
107
76
  /** swc-loader */
108
-
109
77
  readonly SWC: "swc";
110
78
  /** style-loader */
111
-
112
79
  readonly STYLE: "style-loader";
113
80
  /** postcss-loader */
114
-
115
81
  readonly POSTCSS: "postcss";
116
82
  /** markdown-loader */
117
-
118
83
  readonly MARKDOWN: "markdown";
119
84
  /** ignore-css-loader */
120
-
121
85
  readonly IGNORE_CSS: "ignore-css";
122
86
  /** css-modules-typescript-loader */
123
-
124
87
  readonly CSS_MODULES_TS: "css-modules-typescript";
125
88
  /** mini-css-extract-plugin.loader */
126
-
127
89
  readonly MINI_CSS_EXTRACT: "mini-css-extract";
128
90
  /** builder-plugin-image-compress.loader */
129
-
130
91
  readonly IMAGE_COMPRESS: "image-compress";
131
92
  /** builder-plugin-image-compress svgo-loader */
132
-
133
93
  readonly SVGO: "svgo";
134
94
  /** builder-plugin-imagex */
135
-
136
95
  readonly IMAGEX: "imagex";
137
96
  };
138
97
  /** Predefined plugins */
139
-
140
98
  readonly PLUGIN: {
141
99
  /** HotModuleReplacementPlugin */
142
100
  readonly HMR: "hmr";
143
101
  /** CopyWebpackPlugin */
144
-
145
102
  readonly COPY: "copy";
146
103
  /** HtmlWebpackPlugin */
147
-
148
104
  readonly HTML: "html";
149
105
  /** DefinePlugin */
150
-
151
106
  readonly DEFINE: "define";
152
107
  /** IgnorePlugin */
153
-
154
108
  readonly IGNORE: "ignore";
155
109
  /** BannerPlugin */
156
-
157
110
  readonly BANNER: "banner";
158
111
  /** Webpackbar */
159
-
160
112
  readonly PROGRESS: "progress";
161
113
  /** Inspector */
162
-
163
114
  readonly INSPECTOR: "inspector";
164
115
  /** AppIconPlugin */
165
-
166
116
  readonly APP_ICON: "app-icon";
167
117
  /** FaviconUrlPlugin */
168
-
169
118
  readonly FAVICON_URL: "favicon-url";
170
119
  /** LoadableWebpackPlugin */
171
-
172
120
  readonly LOADABLE: "loadable";
173
121
  /** WebpackManifestPlugin */
174
-
175
122
  readonly MANIFEST: "webpack-manifest";
176
123
  /** ForkTsCheckerWebpackPlugin */
177
-
178
124
  readonly TS_CHECKER: "ts-checker";
179
125
  /** InlineChunkHtmlPlugin */
180
-
181
126
  readonly INLINE_HTML: "inline-html";
182
127
  /** WebpackBundleAnalyzer */
183
-
184
128
  readonly BUNDLE_ANALYZER: "bundle-analyze";
185
129
  /** BottomTemplatePlugin */
186
-
187
130
  readonly BOTTOM_TEMPLATE: "bottom-template";
188
131
  /** HtmlCrossOriginPlugin */
189
-
190
132
  readonly HTML_CROSS_ORIGIN: "html-cross-origin";
133
+ /** HtmlNoncePlugin */
134
+ readonly HTML_NONCE: "html-nonce";
191
135
  /** MiniCssExtractPlugin */
192
-
193
136
  readonly MINI_CSS_EXTRACT: "mini-css-extract";
194
137
  /** ReactFastRefreshPlugin */
195
-
196
138
  readonly REACT_FAST_REFRESH: "react-fast-refresh";
197
139
  /** ProvidePlugin for node polyfill */
198
-
199
140
  readonly NODE_POLYFILL_PROVIDE: "node-polyfill-provide";
200
141
  /** WebpackSRIPlugin */
201
-
202
142
  readonly SUBRESOURCE_INTEGRITY: "subresource-integrity";
203
143
  /** WebpackAssetsRetryPlugin */
204
-
205
144
  readonly ASSETS_RETRY: "ASSETS_RETRY";
206
145
  /** AutoSetRootFontSizePlugin */
207
-
208
146
  readonly AUTO_SET_ROOT_SIZE: "auto-set-root-size";
209
147
  /** HtmlAsyncChunkPlugin */
210
-
211
148
  readonly HTML_ASYNC_CHUNK: "html-async-chunk";
212
149
  /** SWC_POLYFILL_CHECKER */
213
-
214
150
  readonly SWC_POLYFILL_CHECKER: "swc-polyfill-checker-plugin";
215
151
  /** HtmlTagsPlugin */
216
-
217
152
  readonly HTML_TAGS: "html-tags";
218
153
  };
219
154
  /** Predefined minimizers */
220
-
221
155
  readonly MINIMIZER: {
222
156
  /** TerserWebpackPlugin */
223
157
  readonly JS: "js";
224
158
  /** CssMinimizerWebpackPlugin */
225
-
226
159
  readonly CSS: "css";
227
160
  /** ESBuildPlugin */
228
-
229
161
  readonly ESBUILD: "js-css";
230
162
  /** SWCPlugin */
231
-
232
163
  readonly SWC: "swc";
233
164
  };
234
165
  /** Predefined resolve plugins */
235
-
236
166
  readonly RESOLVE_PLUGIN: {
237
167
  /** ModuleScopePlugin */
238
168
  readonly MODULE_SCOPE: "module-scope";
239
169
  /** TsConfigPathsPlugin */
240
-
241
170
  readonly TS_CONFIG_PATHS: "ts-config-paths";
242
171
  };
243
172
  };
@@ -2,101 +2,82 @@ import { InternalPlugins } from '@modern-js/types';
2
2
  /**
3
3
  * route specification file
4
4
  */
5
-
6
5
  export declare const ROUTE_SPEC_FILE = "route.json";
7
6
  /**
8
7
  * main entry name
9
8
  */
10
-
11
9
  export declare const MAIN_ENTRY_NAME = "main";
12
10
  /**
13
11
  * server side bundles directory, which relative to dist.
14
12
  */
15
-
16
13
  export declare const SERVER_BUNDLE_DIRECTORY = "bundles";
17
14
  /**
18
15
  * server side bundles directory, which relative to dist.
19
16
  */
20
-
21
17
  export declare const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
22
18
  /**
23
19
  * entry name pattern used for ajv pattern properties.
24
20
  */
25
-
26
21
  export declare const ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
27
22
  /**
28
23
  * SSR server render function name
29
24
  */
30
-
31
25
  export declare const SERVER_RENDER_FUNCTION_NAME = "serverRender";
32
26
  /**
33
27
  * loadbale manifest json file
34
28
  */
35
-
36
29
  export declare const LOADABLE_STATS_FILE = "loadable-stats.json";
37
30
  /**
38
31
  * internal specified folder
39
32
  */
40
-
41
33
  export declare const API_DIR = "api";
42
34
  export declare const SERVER_DIR = "server";
43
35
  export declare const SHARED_DIR = "shared";
44
36
  /**
45
37
  * Modern.config.ts cached dir
46
38
  */
47
-
48
39
  export declare const CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
49
40
  export declare const CONFIG_FILE_EXTENSIONS: string[];
50
41
  /**
51
42
  * Serialized config path
52
43
  */
53
-
54
44
  export declare const OUTPUT_CONFIG_FILE = "modern.config.json";
55
45
  /**
56
46
  * Default server config basename
57
47
  */
58
-
59
48
  export declare const DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
60
49
  /**
61
50
  * Routes manifest filename
62
51
  */
63
-
64
52
  export declare const ROUTE_MANIFEST_FILE = "routes-manifest.json";
65
53
  /**
66
54
  * directory name for loader routes
67
55
  */
68
-
69
56
  export declare const LOADER_ROUTES_DIR = "loader-routes";
70
57
  /**
71
58
  * default host for dev
72
59
  */
73
-
74
60
  export declare const DEFAULT_DEV_HOST = "0.0.0.0";
75
61
  /**
76
62
  * Internal app-tools plugins that work as soon as they are installed.
77
63
  */
78
-
79
64
  export declare const INTERNAL_APP_TOOLS_PLUGINS: InternalPlugins;
80
65
  export declare const INTERNAL_APP_TOOLS_RUNTIME_PLUGINS: InternalPlugins;
81
66
  /**
82
67
  * Internal module-tools plugins that work as soon as they are installed.
83
68
  */
84
-
85
69
  export declare const INTERNAL_MODULE_TOOLS_PLUGINS: InternalPlugins;
86
70
  /**
87
71
  * Internal monorepo-tools plugins that work as soon as they are installed.
88
72
  */
89
-
90
73
  export declare const INTERNAL_MONOREPO_TOOLS_PLUGINS: InternalPlugins;
91
74
  /**
92
75
  * Internal doc-tools plugins that work as soon as they are installed.
93
76
  */
94
-
95
77
  export declare const INTERNAL_DOC_TOOLS_PLUGINS: InternalPlugins;
96
78
  /**
97
79
  * Internal plugins that work as soon as they are installed.
98
80
  */
99
-
100
81
  export declare const INTERNAL_CLI_PLUGINS: InternalPlugins;
101
82
  export declare const SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
102
83
  export declare const SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
@@ -107,7 +88,6 @@ export declare const INTERNAL_SERVER_PLUGINS: InternalPlugins;
107
88
  /**
108
89
  * The schema registered in the plugin.
109
90
  */
110
-
111
91
  export declare const PLUGIN_SCHEMAS: {
112
92
  '@modern-js/runtime': ({
113
93
  target: string;
@@ -233,7 +213,6 @@ export declare const PLUGIN_SCHEMAS: {
233
213
  * - `@modern-js/builder-rspack-provider`
234
214
  * - `@modern-js/babel-preset-base`
235
215
  */
236
-
237
216
  export declare const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: {
238
217
  allowNamespaces: boolean;
239
218
  allExtensions: boolean;
@@ -7,7 +7,6 @@ interface EntryPoint {
7
7
  * @param config - User config.
8
8
  * @returns Whether to use server side render.
9
9
  */
10
-
11
10
  export declare const isSSR: (config: any) => boolean;
12
11
  export declare const isUseSSRBundle: (config: any) => boolean;
13
12
  /**
@@ -16,7 +15,6 @@ export declare const isUseSSRBundle: (config: any) => boolean;
16
15
  * @param config - User config.
17
16
  * @returns Whether to use worker deploy.
18
17
  */
19
-
20
18
  export declare const isServiceWorker: (config: any) => boolean;
21
19
  export declare const isRouterV5: (config: {
22
20
  runtime?: {
@@ -9,7 +9,6 @@ export declare const isDepExists: (appDirectory: string, name: string) => boolea
9
9
  /**
10
10
  * Try to resolve npm package, return true if package is installed.
11
11
  */
12
-
13
12
  export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
14
13
  export declare const isApiOnly: (appDirectory: string, entryDir?: string) => Promise<boolean>;
15
14
  export declare const isWebOnly: () => Promise<boolean>;
@@ -21,5 +20,4 @@ export declare const isReact18: (cwd: string) => boolean;
21
20
  * @param root - App directory.
22
21
  * @returns Whether to use typescript.
23
22
  */
24
-
25
23
  export declare const isTypescript: (root: string) => boolean;
@@ -12,5 +12,4 @@ export declare function isRegExp(obj: any): obj is RegExp;
12
12
  * @param o - Any object.
13
13
  * @returns Whether it is empty object.
14
14
  */
15
-
16
15
  export declare const isEmpty: (o: Record<string, unknown>) => boolean;
@@ -46,7 +46,6 @@ declare const LOG_TYPES: {
46
46
  level: string;
47
47
  };
48
48
  };
49
-
50
49
  declare class Logger {
51
50
  private readonly level;
52
51
  private readonly config;
@@ -57,7 +56,6 @@ declare class Logger {
57
56
  private _log;
58
57
  private getLongestLabel;
59
58
  }
60
-
61
59
  type LoggerInterface = { [key in keyof typeof LOG_TYPES]: LoggerFunction };
62
60
  declare const logger: Logger & LoggerInterface;
63
61
  export { Logger };
@@ -8,10 +8,8 @@ export declare const getTemplatePath: (prefix?: string) => string;
8
8
  * Compile path string to RegExp.
9
9
  * @note Only support posix path.
10
10
  */
11
-
12
11
  export declare function compilePathMatcherRegExp(match: string | RegExp): RegExp;
13
12
  /** @internal @see {@link upwardPaths} */
14
-
15
13
  export declare const _joinPathParts: (_part: unknown, i: number, parts: _.List<string>) => string;
16
14
  export declare function upwardPaths(start: string): string[];
17
15
  export declare function getRealTemporaryDirectory(): string | null;
@@ -17,5 +17,4 @@ export declare function deleteRequireCache(path: string): void;
17
17
  * @param resolvePath - Path to resolve dependencies.
18
18
  * @returns Resolved file path.
19
19
  */
20
-
21
20
  export declare const tryResolve: (name: string, resolvePath: string) => string;
@@ -37,7 +37,6 @@ export type { default as WebpackChain } from '../compiled/webpack-chain';
37
37
  * Lazy import some expensive modules that will slow down startup speed.
38
38
  * Notice that `csmith-tools build` can not bundle lazy imported modules.
39
39
  */
40
-
41
40
  export declare const mime: typeof import('../compiled/mime-types');
42
41
  export declare const chokidar: typeof import('../compiled/chokidar');
43
42
  export declare const inquirer: typeof import('../compiled/inquirer');
@@ -1,2 +1 @@
1
- export * from './nestedRoutes';
2
- export * from './remixRouter';
1
+ export * from 'react-router-dom';
@@ -1,5 +1,4 @@
1
1
  /// <reference types="node" />
2
-
3
2
  /**
4
3
  * ssr helpers
5
4
  */
@@ -0,0 +1 @@
1
+ export * from 'react-router-dom/server';
@@ -5,5 +5,4 @@ export declare const ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
5
5
  /**
6
6
  * hmr socket connect path
7
7
  */
8
-
9
8
  export declare const HMR_SOCK_PATH = "/webpack-hmr";
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "2.20.0",
18
+ "version": "2.21.1",
19
19
  "jsnext:source": "./src/index.ts",
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "main": "./dist/cjs/index.js",
@@ -38,6 +38,14 @@
38
38
  "types": "./dist/types/runtime/router.d.ts",
39
39
  "default": "./dist/esm/runtime/router.js"
40
40
  },
41
+ "./runtime/remix-router": {
42
+ "types": "./dist/types/runtime/remixRouter.d.ts",
43
+ "default": "./dist/esm/runtime/remixRouter.js"
44
+ },
45
+ "./runtime/nested-routes": {
46
+ "types": "./dist/types/runtime/nestedRoutes.d.ts",
47
+ "default": "./dist/esm/runtime/nestedRoutes.js"
48
+ },
41
49
  "./runtime-browser": {
42
50
  "jsnext:source": "./src/runtime-browser/index.d.ts",
43
51
  "default": "./dist/esm/runtime-browser/index.js"
@@ -46,6 +54,10 @@
46
54
  "types": "./dist/types/runtime-node/index.d.ts",
47
55
  "default": "./dist/esm/runtime-node/index.js"
48
56
  },
57
+ "./runtime-node/router": {
58
+ "types": "./dist/types/runtime-node/router.d.ts",
59
+ "default": "./dist/esm/runtime-node/router.js"
60
+ },
49
61
  "./universal/constants": {
50
62
  "types": "./dist/types/universal/constants.d.ts",
51
63
  "import": "./dist/esm/universal/constants.js",
@@ -98,12 +110,21 @@
98
110
  "runtime/router": [
99
111
  "./dist/types/runtime/router.d.ts"
100
112
  ],
113
+ "runtime/remix-router": [
114
+ "./dist/types/runtime/remixRouter.d.ts"
115
+ ],
116
+ "runtime/nested-routes": [
117
+ "./dist/types/runtime/nestedRoutes.d.ts"
118
+ ],
101
119
  "runtime-browser": [
102
120
  "./dist/types/runtime-browser/index.d.ts"
103
121
  ],
104
122
  "runtime-node": [
105
123
  "./dist/types/runtime-node/index.d.ts"
106
124
  ],
125
+ "runtime-node/router": [
126
+ "./dist/types/runtime-node/router.d.ts"
127
+ ],
107
128
  "universal/constants": [
108
129
  "./dist/types/universal/constants.d.ts"
109
130
  ],
@@ -185,13 +206,13 @@
185
206
  "caniuse-lite": "^1.0.30001451",
186
207
  "lodash": "^4.17.21",
187
208
  "serialize-javascript": "^6.0.0",
188
- "@remix-run/router": "^1.3.2",
209
+ "react-router-dom": "6.11.2",
210
+ "@remix-run/router": "1.6.2",
189
211
  "@swc/helpers": "0.5.1"
190
212
  },
191
213
  "peerDependencies": {
192
214
  "react": ">=17.0.0",
193
- "react-dom": ">=17.0.0",
194
- "react-router-dom": "^6.8.1"
215
+ "react-dom": ">=17.0.0"
195
216
  },
196
217
  "peerDependenciesMeta": {
197
218
  "react": {
@@ -199,24 +220,20 @@
199
220
  },
200
221
  "react-dom": {
201
222
  "optional": true
202
- },
203
- "react-router-dom": {
204
- "optional": true
205
223
  }
206
224
  },
207
225
  "devDependencies": {
208
226
  "react": ">=17.0.0",
209
227
  "react-dom": ">=17.0.0",
210
- "react-router-dom": "^6.8.1",
211
228
  "@types/jest": "^29",
212
229
  "@types/node": "^14",
213
230
  "jest": "^29",
214
- "typescript": "^4",
231
+ "typescript": "^5",
215
232
  "webpack": "^5.82.1",
216
233
  "@types/serialize-javascript": "^5.0.1",
217
- "@modern-js/types": "2.20.0",
218
- "@scripts/build": "2.20.0",
219
- "@scripts/jest-config": "2.20.0"
234
+ "@modern-js/types": "2.21.1",
235
+ "@scripts/jest-config": "2.21.1",
236
+ "@scripts/build": "2.21.1"
220
237
  },
221
238
  "sideEffects": false,
222
239
  "scripts": {