@modern-js/utils 2.0.0-beta.1 → 2.0.0-beta.3
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.
- package/CHANGELOG.md +129 -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/compatRequire.d.ts +1 -0
- package/dist/compatRequire.js +4 -1
- package/dist/constants.d.ts +26 -0
- package/dist/constants.js +64 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -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 +6 -6
- 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/compatRequire.d.ts
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
* @returns module export object.
|
5
5
|
*/
|
6
6
|
export declare const compatRequire: (filePath: string, interop?: boolean) => any;
|
7
|
+
export declare const dynamicImport: Function;
|
7
8
|
export declare const requireExistModule: (filename: string, opt?: {
|
8
9
|
extensions?: string[];
|
9
10
|
interop?: boolean;
|
package/dist/compatRequire.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.cleanRequireCache = exports.requireExistModule = exports.compatRequire = void 0;
|
3
|
+
exports.cleanRequireCache = exports.requireExistModule = exports.dynamicImport = exports.compatRequire = void 0;
|
4
4
|
const findExists_1 = require("./findExists");
|
5
5
|
/**
|
6
6
|
* Require function compatible with esm and cjs module.
|
@@ -13,6 +13,9 @@ const compatRequire = (filePath, interop = true) => {
|
|
13
13
|
return rtnESMDefault ? mod.default : mod;
|
14
14
|
};
|
15
15
|
exports.compatRequire = compatRequire;
|
16
|
+
// Avoid `import` to be tranpiled to `require` by babel/tsc/rollup
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-implied-eval, no-new-func
|
18
|
+
exports.dynamicImport = new Function('modulePath', 'return import(modulePath)');
|
16
19
|
const requireExistModule = (filename, opt) => {
|
17
20
|
const final = {
|
18
21
|
extensions: ['.ts', '.js'],
|
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 module-tools plugins that work as soon as they are installed.
|
75
|
+
*/
|
76
|
+
export declare const INTERNAL_MONOREPO_TOOLS_PLUGINS: InternalPlugins;
|
77
|
+
/**
|
78
|
+
* Internal module-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,6 +60,61 @@ 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/cli',
|
94
|
+
'@modern-js/module-tools-v2': '@modern-js/module-tools-v2',
|
95
|
+
'@modern-js/doc-tools': '@modern-js/doc-tools',
|
96
|
+
'@modern-js/runtime': '@modern-js/runtime/cli',
|
97
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
98
|
+
'@modern-js/plugin-storybook': '@modern-js/plugin-storybook/cli',
|
99
|
+
'@modern-js/plugin-tailwindcss': '@modern-js/plugin-tailwindcss/cli',
|
100
|
+
// TODO: Maybe can remove it
|
101
|
+
'@modern-js/plugin-nocode': '@modern-js/plugin-nocode/cli',
|
102
|
+
};
|
103
|
+
/**
|
104
|
+
* Internal module-tools plugins that work as soon as they are installed.
|
105
|
+
*/
|
106
|
+
exports.INTERNAL_MONOREPO_TOOLS_PLUGINS = {
|
107
|
+
'@modern-js/monorepo-tools': '@modern-js/monorepo-tools/cli',
|
108
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
109
|
+
};
|
110
|
+
/**
|
111
|
+
* Internal module-tools plugins that work as soon as they are installed.
|
112
|
+
*/
|
113
|
+
exports.INTERNAL_DOC_TOOLS_PLUGINS = {
|
114
|
+
'@modern-js/doc-tools': '@modern-js/doc-tools',
|
115
|
+
'@modern-js/runtime': '@modern-js/runtime/cli',
|
116
|
+
'@modern-js/plugin-testing': '@modern-js/plugin-testing/cli',
|
117
|
+
};
|
63
118
|
/**
|
64
119
|
* Internal plugins that work as soon as they are installed.
|
65
120
|
*/
|
@@ -68,6 +123,7 @@ exports.INTERNAL_CLI_PLUGINS = {
|
|
68
123
|
'@modern-js/monorepo-tools': '@modern-js/monorepo-tools/cli',
|
69
124
|
'@modern-js/module-tools': '@modern-js/module-tools/cli',
|
70
125
|
'@modern-js/module-tools-v2': '@modern-js/module-tools-v2',
|
126
|
+
'@modern-js/doc-tools': '@modern-js/doc-tools',
|
71
127
|
'@modern-js/runtime': '@modern-js/runtime/cli',
|
72
128
|
'@modern-js/plugin-proxy': '@modern-js/plugin-proxy/cli',
|
73
129
|
'@modern-js/plugin-ssg': '@modern-js/plugin-ssg/cli',
|
@@ -79,6 +135,7 @@ exports.INTERNAL_CLI_PLUGINS = {
|
|
79
135
|
'@modern-js/plugin-koa': '@modern-js/plugin-koa/cli',
|
80
136
|
'@modern-js/plugin-nest': '@modern-js/plugin-nest/cli',
|
81
137
|
'@modern-js/plugin-server': '@modern-js/plugin-server/cli',
|
138
|
+
'@modern-js/plugin-swc': '@modern-js/plugin-swc',
|
82
139
|
'@modern-js/plugin-garfish': '@modern-js/plugin-garfish/cli',
|
83
140
|
'@modern-js/plugin-tailwindcss': '@modern-js/plugin-tailwindcss/cli',
|
84
141
|
'@modern-js/plugin-polyfill': '@modern-js/plugin-polyfill/cli',
|
@@ -117,6 +174,12 @@ exports.PLUGIN_SCHEMAS = {
|
|
117
174
|
},
|
118
175
|
},
|
119
176
|
],
|
177
|
+
'@modern-js/plugin-swc': [
|
178
|
+
{
|
179
|
+
target: 'tools.swc',
|
180
|
+
schema: { typeof: ['object'] },
|
181
|
+
},
|
182
|
+
],
|
120
183
|
'@modern-js/plugin-bff': [
|
121
184
|
{
|
122
185
|
target: 'bff',
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
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/, ``)}"`
|
20
|
+
: val.includes('modern.js')
|
21
|
+
? `"${val.replace(/.+modern\.js/, ``)}"`
|
22
|
+
: `"${val.replace(root, '')}"`
|
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.3",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/index.d.ts",
|
17
17
|
"main": "./dist/index.js",
|
@@ -133,14 +133,14 @@
|
|
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.3",
|
138
|
+
"@scripts/build": "2.0.0-beta.3",
|
139
|
+
"@scripts/jest-config": "2.0.0-beta.3"
|
140
140
|
},
|
141
141
|
"sideEffects": false,
|
142
142
|
"scripts": {
|
143
|
-
"new": "modern new",
|
143
|
+
"new": "modern-lib new",
|
144
144
|
"dev": "tsc --watch",
|
145
145
|
"build": "tsc",
|
146
146
|
"test": "jest --passWithNoTests"
|