@modern-js/utils 2.0.0-beta.2 → 2.0.0-beta.4
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +162 -0
- package/compiled/browserslist/index.js +1 -1
- package/compiled/tsconfig-paths/index.js +1 -1
- package/compiled/tsconfig-paths/lib/config-loader.d.ts +3 -3
- package/compiled/tsconfig-paths/lib/filesystem.d.ts +2 -1
- package/compiled/tsconfig-paths/lib/mapping-entry.d.ts +1 -0
- package/compiled/tsconfig-paths/lib/match-path-async.d.ts +2 -2
- package/compiled/tsconfig-paths/lib/match-path-sync.d.ts +6 -4
- package/compiled/tsconfig-paths/lib/register.d.ts +7 -1
- package/compiled/tsconfig-paths/lib/tsconfig-loader.d.ts +1 -1
- package/compiled/tsconfig-paths/package.json +1 -1
- package/compiled/webpack-dev-middleware/index.js +2 -2
- package/compiled/webpack-dev-middleware/package.json +1 -1
- package/compiled/webpack-dev-middleware/types/index.d.ts +54 -49
- package/dist/chainId.d.ts +3 -0
- package/dist/chainId.js +3 -0
- package/dist/constants.d.ts +26 -0
- package/dist/constants.js +63 -3
- package/dist/getCoreJsVersion.d.ts +1 -0
- package/dist/getCoreJsVersion.js +38 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/routes.js +8 -1
- package/dist/test-utils.d.ts +5 -0
- package/dist/test-utils.js +26 -0
- package/package.json +5 -5
- package/compiled/tsconfig-paths/lib/options.d.ts +0 -4
@@ -1,4 +1,5 @@
|
|
1
1
|
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
2
3
|
export = wdm;
|
3
4
|
/** @typedef {import('../schema-utils3/declarations/validate').Schema} Schema */
|
4
5
|
/** @typedef {import('webpack').Compiler} Compiler */
|
@@ -35,31 +36,31 @@ export = wdm;
|
|
35
36
|
* @param {Stats | MultiStats} [stats]
|
36
37
|
*/
|
37
38
|
/**
|
38
|
-
* @template {IncomingMessage}
|
39
|
-
* @template {ServerResponse}
|
39
|
+
* @template {IncomingMessage} RequestInternal
|
40
|
+
* @template {ServerResponse} ResponseInternal
|
40
41
|
* @typedef {Object} Context
|
41
42
|
* @property {boolean} state
|
42
43
|
* @property {Stats | MultiStats | undefined} stats
|
43
44
|
* @property {Callback[]} callbacks
|
44
|
-
* @property {Options<
|
45
|
+
* @property {Options<RequestInternal, ResponseInternal>} options
|
45
46
|
* @property {Compiler | MultiCompiler} compiler
|
46
47
|
* @property {Watching | MultiWatching} watching
|
47
48
|
* @property {Logger} logger
|
48
49
|
* @property {OutputFileSystem} outputFileSystem
|
49
50
|
*/
|
50
51
|
/**
|
51
|
-
* @template {IncomingMessage}
|
52
|
-
* @template {ServerResponse}
|
53
|
-
* @typedef {Record<string, string | number> | Array<{ key: string, value: number | string }> | ((req:
|
52
|
+
* @template {IncomingMessage} RequestInternal
|
53
|
+
* @template {ServerResponse} ResponseInternal
|
54
|
+
* @typedef {Record<string, string | number> | Array<{ key: string, value: number | string }> | ((req: RequestInternal, res: ResponseInternal, context: Context<RequestInternal, ResponseInternal>) => void | undefined | Record<string, string | number>) | undefined} Headers
|
54
55
|
*/
|
55
56
|
/**
|
56
|
-
* @template {IncomingMessage}
|
57
|
-
* @template {ServerResponse}
|
57
|
+
* @template {IncomingMessage} RequestInternal
|
58
|
+
* @template {ServerResponse} ResponseInternal
|
58
59
|
* @typedef {Object} Options
|
59
60
|
* @property {{[key: string]: string}} [mimeTypes]
|
60
61
|
* @property {boolean | ((targetPath: string) => boolean)} [writeToDisk]
|
61
62
|
* @property {string} [methods]
|
62
|
-
* @property {Headers<
|
63
|
+
* @property {Headers<RequestInternal, ResponseInternal>} [headers]
|
63
64
|
* @property {NonNullable<Configuration["output"]>["publicPath"]} [publicPath]
|
64
65
|
* @property {Configuration["stats"]} [stats]
|
65
66
|
* @property {boolean} [serverSideRender]
|
@@ -67,11 +68,11 @@ export = wdm;
|
|
67
68
|
* @property {boolean | string} [index]
|
68
69
|
*/
|
69
70
|
/**
|
70
|
-
* @template {IncomingMessage}
|
71
|
-
* @template {ServerResponse}
|
71
|
+
* @template {IncomingMessage} RequestInternal
|
72
|
+
* @template {ServerResponse} ResponseInternal
|
72
73
|
* @callback Middleware
|
73
|
-
* @param {
|
74
|
-
* @param {
|
74
|
+
* @param {RequestInternal} req
|
75
|
+
* @param {ResponseInternal} res
|
75
76
|
* @param {NextFunction} next
|
76
77
|
* @return {Promise<void>}
|
77
78
|
*/
|
@@ -93,34 +94,34 @@ export = wdm;
|
|
93
94
|
* @param {(err: Error | null | undefined) => void} callback
|
94
95
|
*/
|
95
96
|
/**
|
96
|
-
* @template {IncomingMessage}
|
97
|
-
* @template {ServerResponse}
|
97
|
+
* @template {IncomingMessage} RequestInternal
|
98
|
+
* @template {ServerResponse} ResponseInternal
|
98
99
|
* @typedef {Object} AdditionalMethods
|
99
100
|
* @property {GetFilenameFromUrl} getFilenameFromUrl
|
100
101
|
* @property {WaitUntilValid} waitUntilValid
|
101
102
|
* @property {Invalidate} invalidate
|
102
103
|
* @property {Close} close
|
103
|
-
* @property {Context<
|
104
|
+
* @property {Context<RequestInternal, ResponseInternal>} context
|
104
105
|
*/
|
105
106
|
/**
|
106
|
-
* @template {IncomingMessage}
|
107
|
-
* @template {ServerResponse}
|
108
|
-
* @typedef {Middleware<
|
107
|
+
* @template {IncomingMessage} RequestInternal
|
108
|
+
* @template {ServerResponse} ResponseInternal
|
109
|
+
* @typedef {Middleware<RequestInternal, ResponseInternal> & AdditionalMethods<RequestInternal, ResponseInternal>} API
|
109
110
|
*/
|
110
111
|
/**
|
111
|
-
* @template {IncomingMessage}
|
112
|
-
* @template {ServerResponse}
|
112
|
+
* @template {IncomingMessage} RequestInternal
|
113
|
+
* @template {ServerResponse} ResponseInternal
|
113
114
|
* @param {Compiler | MultiCompiler} compiler
|
114
|
-
* @param {Options<
|
115
|
-
* @returns {API<
|
115
|
+
* @param {Options<RequestInternal, ResponseInternal>} [options]
|
116
|
+
* @returns {API<RequestInternal, ResponseInternal>}
|
116
117
|
*/
|
117
118
|
declare function wdm<
|
118
|
-
|
119
|
-
|
119
|
+
RequestInternal extends import('http').IncomingMessage,
|
120
|
+
ResponseInternal extends ServerResponse
|
120
121
|
>(
|
121
122
|
compiler: Compiler | MultiCompiler,
|
122
|
-
options?: Options<
|
123
|
-
): API<
|
123
|
+
options?: Options<RequestInternal, ResponseInternal> | undefined
|
124
|
+
): API<RequestInternal, ResponseInternal>;
|
124
125
|
declare namespace wdm {
|
125
126
|
export {
|
126
127
|
Schema,
|
@@ -155,8 +156,8 @@ type ServerResponse = import('http').ServerResponse & ExtendedServerResponse;
|
|
155
156
|
type Compiler = import('webpack').Compiler;
|
156
157
|
type MultiCompiler = import('webpack').MultiCompiler;
|
157
158
|
type Options<
|
158
|
-
|
159
|
-
|
159
|
+
RequestInternal extends import('http').IncomingMessage,
|
160
|
+
ResponseInternal extends ServerResponse
|
160
161
|
> = {
|
161
162
|
mimeTypes?:
|
162
163
|
| {
|
@@ -165,7 +166,7 @@ type Options<
|
|
165
166
|
| undefined;
|
166
167
|
writeToDisk?: boolean | ((targetPath: string) => boolean) | undefined;
|
167
168
|
methods?: string | undefined;
|
168
|
-
headers?: Headers<
|
169
|
+
headers?: Headers<RequestInternal, ResponseInternal>;
|
169
170
|
publicPath?: NonNullable<Configuration["output"]>["publicPath"];
|
170
171
|
stats?: Configuration["stats"];
|
171
172
|
serverSideRender?: boolean | undefined;
|
@@ -173,10 +174,10 @@ type Options<
|
|
173
174
|
index?: string | boolean | undefined;
|
174
175
|
};
|
175
176
|
type API<
|
176
|
-
|
177
|
-
|
178
|
-
> = Middleware<
|
179
|
-
AdditionalMethods<
|
177
|
+
RequestInternal extends import('http').IncomingMessage,
|
178
|
+
ResponseInternal extends ServerResponse
|
179
|
+
> = Middleware<RequestInternal, ResponseInternal> &
|
180
|
+
AdditionalMethods<RequestInternal, ResponseInternal>;
|
180
181
|
type Schema = import('../schema-utils3/declarations/validate').Schema;
|
181
182
|
type Configuration = import('webpack').Configuration;
|
182
183
|
type Stats = import('webpack').Stats;
|
@@ -201,7 +202,7 @@ type Watching = Compiler["watching"];
|
|
201
202
|
type MultiWatching = ReturnType<Compiler["watch"]>;
|
202
203
|
type OutputFileSystem = Compiler["outputFileSystem"] & {
|
203
204
|
createReadStream?: typeof import('fs').createReadStream;
|
204
|
-
statSync?:
|
205
|
+
statSync?: import('fs').StatSyncFn;
|
205
206
|
lstat?: typeof import('fs').lstat;
|
206
207
|
readFileSync?: typeof import('fs').readFileSync;
|
207
208
|
};
|
@@ -210,21 +211,21 @@ type Callback = (
|
|
210
211
|
stats?: import('webpack').Stats | import('webpack').MultiStats | undefined
|
211
212
|
) => any;
|
212
213
|
type Context<
|
213
|
-
|
214
|
-
|
214
|
+
RequestInternal extends import('http').IncomingMessage,
|
215
|
+
ResponseInternal extends ServerResponse
|
215
216
|
> = {
|
216
217
|
state: boolean;
|
217
218
|
stats: Stats | MultiStats | undefined;
|
218
219
|
callbacks: Callback[];
|
219
|
-
options: Options<
|
220
|
+
options: Options<RequestInternal, ResponseInternal>;
|
220
221
|
compiler: Compiler | MultiCompiler;
|
221
222
|
watching: Watching | MultiWatching;
|
222
223
|
logger: Logger;
|
223
224
|
outputFileSystem: OutputFileSystem;
|
224
225
|
};
|
225
226
|
type Headers<
|
226
|
-
|
227
|
-
|
227
|
+
RequestInternal extends import('http').IncomingMessage,
|
228
|
+
ResponseInternal extends ServerResponse
|
228
229
|
> =
|
229
230
|
| Record<string, string | number>
|
230
231
|
| {
|
@@ -232,26 +233,30 @@ type Headers<
|
|
232
233
|
value: number | string;
|
233
234
|
}[]
|
234
235
|
| ((
|
235
|
-
req:
|
236
|
-
res:
|
237
|
-
context: Context<
|
236
|
+
req: RequestInternal,
|
237
|
+
res: ResponseInternal,
|
238
|
+
context: Context<RequestInternal, ResponseInternal>
|
238
239
|
) => void | undefined | Record<string, string | number>)
|
239
240
|
| undefined;
|
240
241
|
type Middleware<
|
241
|
-
|
242
|
-
|
243
|
-
> = (
|
242
|
+
RequestInternal extends import('http').IncomingMessage,
|
243
|
+
ResponseInternal extends ServerResponse
|
244
|
+
> = (
|
245
|
+
req: RequestInternal,
|
246
|
+
res: ResponseInternal,
|
247
|
+
next: NextFunction
|
248
|
+
) => Promise<void>;
|
244
249
|
type GetFilenameFromUrl = (url: string) => string | undefined;
|
245
250
|
type WaitUntilValid = (callback: Callback) => any;
|
246
251
|
type Invalidate = (callback: Callback) => any;
|
247
252
|
type Close = (callback: (err: Error | null | undefined) => void) => any;
|
248
253
|
type AdditionalMethods<
|
249
|
-
|
250
|
-
|
254
|
+
RequestInternal extends import('http').IncomingMessage,
|
255
|
+
ResponseInternal extends ServerResponse
|
251
256
|
> = {
|
252
257
|
getFilenameFromUrl: GetFilenameFromUrl;
|
253
258
|
waitUntilValid: WaitUntilValid;
|
254
259
|
invalidate: Invalidate;
|
255
260
|
close: Close;
|
256
|
-
context: Context<
|
261
|
+
context: Context<RequestInternal, ResponseInternal>;
|
257
262
|
};
|
package/dist/chainId.d.ts
CHANGED
@@ -56,6 +56,7 @@ export declare const CHAIN_ID: {
|
|
56
56
|
readonly ASSETS: "assets";
|
57
57
|
readonly ASSETS_URL: "assets-url";
|
58
58
|
readonly ASSETS_INLINE: "assets-inline";
|
59
|
+
readonly IMAGE_COMPRESS: "image-compress";
|
59
60
|
};
|
60
61
|
/** Predefined loaders */
|
61
62
|
readonly USE: {
|
@@ -99,6 +100,8 @@ export declare const CHAIN_ID: {
|
|
99
100
|
readonly CSS_MODULES_TS: "css-modules-typescript";
|
100
101
|
/** mini-css-extract-plugin.loader */
|
101
102
|
readonly MINI_CSS_EXTRACT: "mini-css-extract";
|
103
|
+
/** builder-plugin-image-compress.loader */
|
104
|
+
readonly IMAGE_COMPRESS: "image-compress";
|
102
105
|
};
|
103
106
|
/** Predefined plugins */
|
104
107
|
readonly PLUGIN: {
|
package/dist/chainId.js
CHANGED
@@ -59,6 +59,7 @@ exports.CHAIN_ID = {
|
|
59
59
|
ASSETS: 'assets',
|
60
60
|
ASSETS_URL: 'assets-url',
|
61
61
|
ASSETS_INLINE: 'assets-inline',
|
62
|
+
IMAGE_COMPRESS: 'image-compress',
|
62
63
|
},
|
63
64
|
/** Predefined loaders */
|
64
65
|
USE: {
|
@@ -102,6 +103,8 @@ exports.CHAIN_ID = {
|
|
102
103
|
CSS_MODULES_TS: 'css-modules-typescript',
|
103
104
|
/** mini-css-extract-plugin.loader */
|
104
105
|
MINI_CSS_EXTRACT: 'mini-css-extract',
|
106
|
+
/** builder-plugin-image-compress.loader */
|
107
|
+
IMAGE_COMPRESS: 'image-compress',
|
105
108
|
},
|
106
109
|
/** Predefined plugins */
|
107
110
|
PLUGIN: {
|
package/dist/constants.d.ts
CHANGED
@@ -58,6 +58,26 @@ export declare const ROUTE_MINIFEST_FILE = "routes-manifest.json";
|
|
58
58
|
* Property mounted on window that describes route manifest
|
59
59
|
*/
|
60
60
|
export declare const ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
|
61
|
+
/**
|
62
|
+
* directory name for loader routes
|
63
|
+
*/
|
64
|
+
export declare const LOADER_ROUTES_DIR = "loader-routes";
|
65
|
+
/**
|
66
|
+
* Internal app-tools plugins that work as soon as they are installed.
|
67
|
+
*/
|
68
|
+
export declare const INTERNAL_APP_TOOLS_PLUGINS: InternalPlugins;
|
69
|
+
/**
|
70
|
+
* Internal module-tools plugins that work as soon as they are installed.
|
71
|
+
*/
|
72
|
+
export declare const INTERNAL_MODULE_TOOLS_PLUGINS: InternalPlugins;
|
73
|
+
/**
|
74
|
+
* Internal monorepo-tools plugins that work as soon as they are installed.
|
75
|
+
*/
|
76
|
+
export declare const INTERNAL_MONOREPO_TOOLS_PLUGINS: InternalPlugins;
|
77
|
+
/**
|
78
|
+
* Internal doc-tools plugins that work as soon as they are installed.
|
79
|
+
*/
|
80
|
+
export declare const INTERNAL_DOC_TOOLS_PLUGINS: InternalPlugins;
|
61
81
|
/**
|
62
82
|
* Internal plugins that work as soon as they are installed.
|
63
83
|
*/
|
@@ -86,6 +106,12 @@ export declare const PLUGIN_SCHEMAS: {
|
|
86
106
|
additionalProperties: boolean;
|
87
107
|
};
|
88
108
|
})[];
|
109
|
+
'@modern-js/plugin-swc': {
|
110
|
+
target: string;
|
111
|
+
schema: {
|
112
|
+
typeof: string[];
|
113
|
+
};
|
114
|
+
}[];
|
89
115
|
'@modern-js/plugin-bff': {
|
90
116
|
target: string;
|
91
117
|
schema: {
|
package/dist/constants.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.INTERNAL_CLI_PLUGINS = exports.ROUTE_MANIFEST = exports.ROUTE_MINIFEST_FILE = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
|
3
|
+
exports.PLUGIN_SCHEMAS = exports.INTERNAL_SERVER_PLUGINS = exports.INTERNAL_CLI_PLUGINS = exports.INTERNAL_DOC_TOOLS_PLUGINS = exports.INTERNAL_MONOREPO_TOOLS_PLUGINS = exports.INTERNAL_MODULE_TOOLS_PLUGINS = exports.INTERNAL_APP_TOOLS_PLUGINS = exports.LOADER_ROUTES_DIR = exports.ROUTE_MANIFEST = exports.ROUTE_MINIFEST_FILE = exports.DEFAULT_SERVER_CONFIG = exports.OUTPUT_CONFIG_FILE = exports.CONFIG_FILE_EXTENSIONS = exports.CONFIG_CACHE_DIR = exports.SHARED_DIR = exports.SERVER_DIR = exports.API_DIR = exports.LOADABLE_STATS_FILE = exports.SERVER_RENDER_FUNCTION_NAME = exports.ENTRY_NAME_PATTERN = exports.SERVER_BUNDLE_DIRECTORY = exports.LAUNCH_EDITOR_ENDPOINT = exports.MAIN_ENTRY_NAME = exports.ROUTE_SPEC_FILE = exports.HMR_SOCK_PATH = void 0;
|
4
4
|
/**
|
5
5
|
* hmr socket connect path
|
6
6
|
*/
|
@@ -60,14 +60,67 @@ exports.ROUTE_MINIFEST_FILE = 'routes-manifest.json';
|
|
60
60
|
* Property mounted on window that describes route manifest
|
61
61
|
*/
|
62
62
|
exports.ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
63
|
+
/**
|
64
|
+
* directory name for loader routes
|
65
|
+
*/
|
66
|
+
exports.LOADER_ROUTES_DIR = `loader-routes`;
|
67
|
+
/**
|
68
|
+
* Internal app-tools plugins that work as soon as they are installed.
|
69
|
+
*/
|
70
|
+
exports.INTERNAL_APP_TOOLS_PLUGINS = {
|
71
|
+
'@modern-js/app-tools': '@modern-js/app-tools/cli',
|
72
|
+
'@modern-js/runtime': '@modern-js/runtime/cli',
|
73
|
+
'@modern-js/plugin-proxy': '@modern-js/plugin-proxy/cli',
|
74
|
+
'@modern-js/plugin-ssg': '@modern-js/plugin-ssg/cli',
|
75
|
+
'@modern-js/plugin-bff': '@modern-js/plugin-bff/cli',
|
76
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
77
|
+
'@modern-js/plugin-storybook': '@modern-js/plugin-storybook/cli',
|
78
|
+
'@modern-js/plugin-express': '@modern-js/plugin-express/cli',
|
79
|
+
'@modern-js/plugin-egg': '@modern-js/plugin-egg/cli',
|
80
|
+
'@modern-js/plugin-koa': '@modern-js/plugin-koa/cli',
|
81
|
+
'@modern-js/plugin-nest': '@modern-js/plugin-nest/cli',
|
82
|
+
'@modern-js/plugin-server': '@modern-js/plugin-server/cli',
|
83
|
+
'@modern-js/plugin-garfish': '@modern-js/plugin-garfish/cli',
|
84
|
+
'@modern-js/plugin-tailwindcss': '@modern-js/plugin-tailwindcss/cli',
|
85
|
+
'@modern-js/plugin-polyfill': '@modern-js/plugin-polyfill/cli',
|
86
|
+
// legacy router (inner react-router-dom v5)
|
87
|
+
'@modern-js/plugin-router-legacy': '@modern-js/plugin-router-legacy/cli',
|
88
|
+
};
|
89
|
+
/**
|
90
|
+
* Internal module-tools plugins that work as soon as they are installed.
|
91
|
+
*/
|
92
|
+
exports.INTERNAL_MODULE_TOOLS_PLUGINS = {
|
93
|
+
'@modern-js/module-tools': '@modern-js/module-tools',
|
94
|
+
'@modern-js/doc-tools': '@modern-js/doc-tools',
|
95
|
+
'@modern-js/runtime': '@modern-js/runtime/cli',
|
96
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
97
|
+
'@modern-js/plugin-storybook': '@modern-js/plugin-storybook/cli',
|
98
|
+
'@modern-js/plugin-tailwindcss': '@modern-js/plugin-tailwindcss/cli',
|
99
|
+
// TODO: Maybe can remove it
|
100
|
+
'@modern-js/plugin-nocode': '@modern-js/plugin-nocode/cli',
|
101
|
+
};
|
102
|
+
/**
|
103
|
+
* Internal monorepo-tools plugins that work as soon as they are installed.
|
104
|
+
*/
|
105
|
+
exports.INTERNAL_MONOREPO_TOOLS_PLUGINS = {
|
106
|
+
'@modern-js/monorepo-tools': '@modern-js/monorepo-tools/cli',
|
107
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
108
|
+
};
|
109
|
+
/**
|
110
|
+
* Internal doc-tools plugins that work as soon as they are installed.
|
111
|
+
*/
|
112
|
+
exports.INTERNAL_DOC_TOOLS_PLUGINS = {
|
113
|
+
'@modern-js/doc-tools': '@modern-js/doc-tools',
|
114
|
+
'@modern-js/runtime': '@modern-js/runtime/cli',
|
115
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
116
|
+
};
|
63
117
|
/**
|
64
118
|
* Internal plugins that work as soon as they are installed.
|
65
119
|
*/
|
66
120
|
exports.INTERNAL_CLI_PLUGINS = {
|
67
121
|
'@modern-js/app-tools': '@modern-js/app-tools/cli',
|
68
122
|
'@modern-js/monorepo-tools': '@modern-js/monorepo-tools/cli',
|
69
|
-
'@modern-js/module-tools': '@modern-js/module-tools
|
70
|
-
'@modern-js/module-tools-v2': '@modern-js/module-tools-v2',
|
123
|
+
'@modern-js/module-tools': '@modern-js/module-tools',
|
71
124
|
'@modern-js/doc-tools': '@modern-js/doc-tools',
|
72
125
|
'@modern-js/runtime': '@modern-js/runtime/cli',
|
73
126
|
'@modern-js/plugin-proxy': '@modern-js/plugin-proxy/cli',
|
@@ -80,6 +133,7 @@ exports.INTERNAL_CLI_PLUGINS = {
|
|
80
133
|
'@modern-js/plugin-koa': '@modern-js/plugin-koa/cli',
|
81
134
|
'@modern-js/plugin-nest': '@modern-js/plugin-nest/cli',
|
82
135
|
'@modern-js/plugin-server': '@modern-js/plugin-server/cli',
|
136
|
+
'@modern-js/plugin-swc': '@modern-js/plugin-swc',
|
83
137
|
'@modern-js/plugin-garfish': '@modern-js/plugin-garfish/cli',
|
84
138
|
'@modern-js/plugin-tailwindcss': '@modern-js/plugin-tailwindcss/cli',
|
85
139
|
'@modern-js/plugin-polyfill': '@modern-js/plugin-polyfill/cli',
|
@@ -118,6 +172,12 @@ exports.PLUGIN_SCHEMAS = {
|
|
118
172
|
},
|
119
173
|
},
|
120
174
|
],
|
175
|
+
'@modern-js/plugin-swc': [
|
176
|
+
{
|
177
|
+
target: 'tools.swc',
|
178
|
+
schema: { typeof: ['object'] },
|
179
|
+
},
|
180
|
+
],
|
121
181
|
'@modern-js/plugin-bff': [
|
122
182
|
{
|
123
183
|
target: 'bff',
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const getCoreJsVersion: (corejsPkgPath: string) => string;
|
@@ -0,0 +1,38 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
19
|
+
if (mod && mod.__esModule) return mod;
|
20
|
+
var result = {};
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22
|
+
__setModuleDefault(result, mod);
|
23
|
+
return result;
|
24
|
+
};
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
26
|
+
exports.getCoreJsVersion = void 0;
|
27
|
+
const fs = __importStar(require("../compiled/fs-extra"));
|
28
|
+
const getCoreJsVersion = (corejsPkgPath) => {
|
29
|
+
try {
|
30
|
+
const { version } = fs.readJSONSync(corejsPkgPath);
|
31
|
+
const [major, minor] = version.split('.');
|
32
|
+
return `${major}.${minor}`;
|
33
|
+
}
|
34
|
+
catch (err) {
|
35
|
+
return '3';
|
36
|
+
}
|
37
|
+
};
|
38
|
+
exports.getCoreJsVersion = getCoreJsVersion;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
@@ -54,3 +54,5 @@ __exportStar(require("./chainId"), exports);
|
|
54
54
|
__exportStar(require("./version"), exports);
|
55
55
|
__exportStar(require("./plugin"), exports);
|
56
56
|
__exportStar(require("./routes"), exports);
|
57
|
+
__exportStar(require("./test-utils"), exports);
|
58
|
+
__exportStar(require("./getCoreJsVersion"), exports);
|
package/dist/routes.js
CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getRouteId = exports.getPathWithoutExt = void 0;
|
7
7
|
const path_1 = __importDefault(require("path"));
|
8
8
|
const path_2 = require("./path");
|
9
|
+
const constants_1 = require("./constants");
|
9
10
|
const getPathWithoutExt = (filename) => {
|
10
11
|
const extname = path_1.default.extname(filename);
|
11
12
|
return filename.slice(0, -extname.length);
|
@@ -14,7 +15,13 @@ exports.getPathWithoutExt = getPathWithoutExt;
|
|
14
15
|
const getRouteId = (componentPath, routesDir, entryName) => {
|
15
16
|
const relativePath = (0, path_2.normalizeToPosixPath)(path_1.default.relative(routesDir, componentPath));
|
16
17
|
const pathWithoutExt = (0, exports.getPathWithoutExt)(relativePath);
|
17
|
-
|
18
|
+
let id = ``;
|
19
|
+
if (entryName === constants_1.MAIN_ENTRY_NAME) {
|
20
|
+
id = pathWithoutExt;
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
id = `${entryName}_${pathWithoutExt}`;
|
24
|
+
}
|
18
25
|
return id;
|
19
26
|
};
|
20
27
|
exports.getRouteId = getRouteId;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.initSnapshotSerializer = void 0;
|
4
|
+
/**
|
5
|
+
*
|
6
|
+
* remove the path before "modern.js"
|
7
|
+
*/
|
8
|
+
const initSnapshotSerializer = (root) => {
|
9
|
+
expect.addSnapshotSerializer({
|
10
|
+
test: (val) => typeof val === 'string' &&
|
11
|
+
(val.includes('modern.js') ||
|
12
|
+
val.includes('node_modules') ||
|
13
|
+
val.includes(root)),
|
14
|
+
print: (val) =>
|
15
|
+
// eslint-disable-next-line no-nested-ternary
|
16
|
+
typeof val === 'string'
|
17
|
+
? // eslint-disable-next-line no-nested-ternary
|
18
|
+
val.includes('node_modules')
|
19
|
+
? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, '/')}"`
|
20
|
+
: val.includes('modern.js')
|
21
|
+
? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, '/')}"`
|
22
|
+
: `"${val.replace(root, '').replace(/\\/g, '/')}"`
|
23
|
+
: val,
|
24
|
+
});
|
25
|
+
};
|
26
|
+
exports.initSnapshotSerializer = initSnapshotSerializer;
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "2.0.0-beta.
|
14
|
+
"version": "2.0.0-beta.4",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -133,10 +133,10 @@
|
|
133
133
|
"@types/node": "^14",
|
134
134
|
"typescript": "^4",
|
135
135
|
"jest": "^27",
|
136
|
-
"webpack": "^5.
|
137
|
-
"@modern-js/types": "2.0.0-beta.
|
138
|
-
"@scripts/build": "2.0.0-beta.
|
139
|
-
"@scripts/jest-config": "2.0.0-beta.
|
136
|
+
"webpack": "^5.75.0",
|
137
|
+
"@modern-js/types": "2.0.0-beta.4",
|
138
|
+
"@scripts/build": "2.0.0-beta.4",
|
139
|
+
"@scripts/jest-config": "2.0.0-beta.4"
|
140
140
|
},
|
141
141
|
"sideEffects": false,
|
142
142
|
"scripts": {
|