@modern-js/utils 2.22.1 → 2.23.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +18 -0
- package/dist/cjs/cli/constants/index.js +4 -215
- package/dist/cjs/cli/index.js +0 -1
- package/dist/cjs/cli/is/project.js +7 -4
- package/dist/cjs/cli/logger.js +0 -5
- package/dist/cjs/runtime-node/index.js +2 -0
- package/dist/cjs/runtime-node/nestedRoutes.js +28 -0
- package/dist/cjs/universal/constants.js +4 -0
- package/dist/esm/cli/constants/index.js +1 -212
- package/dist/esm/cli/index.js +0 -1
- package/dist/esm/cli/is/project.js +7 -4
- package/dist/esm/cli/logger.js +0 -5
- package/dist/esm/runtime-node/index.js +1 -0
- package/dist/esm/runtime-node/nestedRoutes.js +18 -0
- package/dist/esm/universal/constants.js +1 -0
- package/dist/types/cli/constants/index.d.ts +4 -121
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/is/project.d.ts +11 -1
- package/dist/types/runtime-node/index.d.ts +2 -1
- package/dist/types/runtime-node/nestedRoutes.d.ts +3 -0
- package/dist/types/universal/constants.d.ts +5 -1
- package/package.json +9 -5
- package/dist/cjs/cli/test.js +0 -19
- package/dist/esm/cli/test.js +0 -9
- package/dist/types/cli/test.d.ts +0 -5
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,23 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.23.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 7e6fb5f: chore: publishConfig add provenance config
|
8
|
+
|
9
|
+
chore: publishConfig 增加 provenance 配置
|
10
|
+
|
11
|
+
- a7a7ad7: chore: move some public code to the utils package
|
12
|
+
chore: 移动一些公共的代码到 utils 包
|
13
|
+
- 6dec7c2: test(utils): reuse the snapshot serializer of vitest config
|
14
|
+
|
15
|
+
test(utils): 复用 vitest 的 snapshot serializer
|
16
|
+
|
17
|
+
- c3216b5: chore: split the scheme into the plugin
|
18
|
+
|
19
|
+
chore: 拆分 scheme 到插件内部
|
20
|
+
|
3
21
|
## 2.22.1
|
4
22
|
|
5
23
|
### Patch Changes
|
@@ -13,6 +13,9 @@ _export(exports, {
|
|
13
13
|
ROUTE_SPEC_FILE: function() {
|
14
14
|
return ROUTE_SPEC_FILE;
|
15
15
|
},
|
16
|
+
NESTED_ROUTE_SPEC_FILE: function() {
|
17
|
+
return NESTED_ROUTE_SPEC_FILE;
|
18
|
+
},
|
16
19
|
MAIN_ENTRY_NAME: function() {
|
17
20
|
return MAIN_ENTRY_NAME;
|
18
21
|
},
|
@@ -97,9 +100,6 @@ _export(exports, {
|
|
97
100
|
INTERNAL_SERVER_PLUGINS: function() {
|
98
101
|
return INTERNAL_SERVER_PLUGINS;
|
99
102
|
},
|
100
|
-
PLUGIN_SCHEMAS: function() {
|
101
|
-
return PLUGIN_SCHEMAS;
|
102
|
-
},
|
103
103
|
DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS: function() {
|
104
104
|
return DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS;
|
105
105
|
}
|
@@ -107,6 +107,7 @@ _export(exports, {
|
|
107
107
|
const _export_star = require("@swc/helpers/_/_export_star");
|
108
108
|
_export_star._(require("./chainId"), exports);
|
109
109
|
const ROUTE_SPEC_FILE = "route.json";
|
110
|
+
const NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
|
110
111
|
const MAIN_ENTRY_NAME = "main";
|
111
112
|
const SERVER_BUNDLE_DIRECTORY = "bundles";
|
112
113
|
const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
|
@@ -153,8 +154,6 @@ const INTERNAL_MODULE_TOOLS_PLUGINS = {
|
|
153
154
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
|
154
155
|
"@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
|
155
156
|
"@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
|
156
|
-
// TODO: Maybe can remove it
|
157
|
-
"@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
|
158
157
|
// legacy router (inner react-router-dom v5)
|
159
158
|
"@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
|
160
159
|
};
|
@@ -185,8 +184,6 @@ const INTERNAL_CLI_PLUGINS = {
|
|
185
184
|
"@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
|
186
185
|
"@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
|
187
186
|
"@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
|
188
|
-
// TODO: Maybe can remove it
|
189
|
-
"@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
|
190
187
|
// legacy router (inner react-router-dom v5)
|
191
188
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
192
189
|
};
|
@@ -202,214 +199,6 @@ const INTERNAL_SERVER_PLUGINS = {
|
|
202
199
|
[SERVER_PLUGIN_SERVER]: "@modern-js/plugin-server/server",
|
203
200
|
[SERVER_PLUGIN_POLYFILL]: "@modern-js/plugin-polyfill/server"
|
204
201
|
};
|
205
|
-
const PLUGIN_SCHEMAS = {
|
206
|
-
"@modern-js/runtime": [
|
207
|
-
{
|
208
|
-
target: "runtime",
|
209
|
-
schema: {
|
210
|
-
type: "object",
|
211
|
-
additionalProperties: false
|
212
|
-
}
|
213
|
-
},
|
214
|
-
{
|
215
|
-
target: "runtimeByEntries",
|
216
|
-
schema: {
|
217
|
-
type: "object",
|
218
|
-
patternProperties: {
|
219
|
-
[ENTRY_NAME_PATTERN]: {
|
220
|
-
type: "object"
|
221
|
-
}
|
222
|
-
},
|
223
|
-
additionalProperties: false
|
224
|
-
}
|
225
|
-
}
|
226
|
-
],
|
227
|
-
"@modern-js/plugin-swc": [
|
228
|
-
{
|
229
|
-
target: "tools.swc",
|
230
|
-
schema: {
|
231
|
-
typeof: [
|
232
|
-
"object"
|
233
|
-
]
|
234
|
-
}
|
235
|
-
}
|
236
|
-
],
|
237
|
-
"@modern-js/plugin-bff": [
|
238
|
-
{
|
239
|
-
target: "bff",
|
240
|
-
schema: {
|
241
|
-
type: "object",
|
242
|
-
properties: {
|
243
|
-
prefix: {
|
244
|
-
type: [
|
245
|
-
"string",
|
246
|
-
"array"
|
247
|
-
],
|
248
|
-
items: {
|
249
|
-
type: "string"
|
250
|
-
}
|
251
|
-
},
|
252
|
-
fetcher: {
|
253
|
-
type: "string"
|
254
|
-
},
|
255
|
-
proxy: {
|
256
|
-
type: "object"
|
257
|
-
},
|
258
|
-
requestCreator: {
|
259
|
-
type: "string"
|
260
|
-
}
|
261
|
-
}
|
262
|
-
}
|
263
|
-
}
|
264
|
-
],
|
265
|
-
"@modern-js/plugin-tailwindcss": [
|
266
|
-
{
|
267
|
-
target: "tools.tailwindcss",
|
268
|
-
schema: {
|
269
|
-
typeof: [
|
270
|
-
"object",
|
271
|
-
"function"
|
272
|
-
]
|
273
|
-
}
|
274
|
-
}
|
275
|
-
],
|
276
|
-
"@modern-js/plugin-proxy": [
|
277
|
-
{
|
278
|
-
target: "dev.proxy",
|
279
|
-
schema: {
|
280
|
-
typeof: [
|
281
|
-
"string",
|
282
|
-
"object"
|
283
|
-
]
|
284
|
-
}
|
285
|
-
}
|
286
|
-
],
|
287
|
-
"@modern-js/plugin-ssg": [
|
288
|
-
{
|
289
|
-
target: "output.ssg",
|
290
|
-
schema: {
|
291
|
-
oneOf: [
|
292
|
-
{
|
293
|
-
type: "boolean"
|
294
|
-
},
|
295
|
-
{
|
296
|
-
type: "object"
|
297
|
-
},
|
298
|
-
{
|
299
|
-
instanceof: "Function"
|
300
|
-
}
|
301
|
-
]
|
302
|
-
}
|
303
|
-
}
|
304
|
-
],
|
305
|
-
"@modern-js/plugin-state": [
|
306
|
-
{
|
307
|
-
target: "runtime.state",
|
308
|
-
schema: {
|
309
|
-
type: [
|
310
|
-
"boolean",
|
311
|
-
"object"
|
312
|
-
]
|
313
|
-
}
|
314
|
-
}
|
315
|
-
],
|
316
|
-
"@modern-js/plugin-design-token": [
|
317
|
-
// Legacy Features
|
318
|
-
{
|
319
|
-
target: "source.designSystem",
|
320
|
-
schema: {
|
321
|
-
typeof: [
|
322
|
-
"object"
|
323
|
-
]
|
324
|
-
}
|
325
|
-
},
|
326
|
-
{
|
327
|
-
target: "source.designSystem.supportStyledComponents",
|
328
|
-
schema: {
|
329
|
-
type: [
|
330
|
-
"boolean"
|
331
|
-
]
|
332
|
-
}
|
333
|
-
},
|
334
|
-
{
|
335
|
-
target: "designSystem",
|
336
|
-
schema: {
|
337
|
-
typeof: [
|
338
|
-
"object"
|
339
|
-
]
|
340
|
-
}
|
341
|
-
}
|
342
|
-
],
|
343
|
-
"@modern-js/plugin-router": [
|
344
|
-
{
|
345
|
-
target: "runtime.router",
|
346
|
-
schema: {
|
347
|
-
type: [
|
348
|
-
"boolean",
|
349
|
-
"object"
|
350
|
-
]
|
351
|
-
}
|
352
|
-
}
|
353
|
-
],
|
354
|
-
"@modern-js/plugin-testing": [
|
355
|
-
{
|
356
|
-
target: "testing",
|
357
|
-
schema: {
|
358
|
-
typeof: [
|
359
|
-
"object"
|
360
|
-
]
|
361
|
-
}
|
362
|
-
},
|
363
|
-
{
|
364
|
-
target: "tools.jest",
|
365
|
-
schema: {
|
366
|
-
typeof: [
|
367
|
-
"object",
|
368
|
-
"function"
|
369
|
-
]
|
370
|
-
}
|
371
|
-
}
|
372
|
-
],
|
373
|
-
"@modern-js/plugin-garfish": [
|
374
|
-
{
|
375
|
-
target: "runtime.masterApp",
|
376
|
-
schema: {
|
377
|
-
type: [
|
378
|
-
"boolean",
|
379
|
-
"object"
|
380
|
-
]
|
381
|
-
}
|
382
|
-
},
|
383
|
-
{
|
384
|
-
target: "dev.withMasterApp",
|
385
|
-
schema: {
|
386
|
-
type: [
|
387
|
-
"object"
|
388
|
-
]
|
389
|
-
}
|
390
|
-
},
|
391
|
-
{
|
392
|
-
target: "deploy.microFrontend",
|
393
|
-
schema: {
|
394
|
-
type: [
|
395
|
-
"boolean",
|
396
|
-
"object"
|
397
|
-
]
|
398
|
-
}
|
399
|
-
}
|
400
|
-
],
|
401
|
-
"@modern-js/plugin-nocode": [],
|
402
|
-
"@modern-js/plugin-worker": [
|
403
|
-
{
|
404
|
-
target: "deploy.worker.ssr",
|
405
|
-
schema: {
|
406
|
-
type: [
|
407
|
-
"boolean"
|
408
|
-
]
|
409
|
-
}
|
410
|
-
}
|
411
|
-
]
|
412
|
-
};
|
413
202
|
const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
414
203
|
allowNamespaces: true,
|
415
204
|
allExtensions: true,
|
package/dist/cjs/cli/index.js
CHANGED
@@ -24,5 +24,4 @@ _export_star._(require("./print"), exports);
|
|
24
24
|
_export_star._(require("./require"), exports);
|
25
25
|
_export_star._(require("./routes"), exports);
|
26
26
|
_export_star._(require("./runtimeExports"), exports);
|
27
|
-
_export_star._(require("./test"), exports);
|
28
27
|
_export_star._(require("./watch"), exports);
|
@@ -59,11 +59,14 @@ const isPackageInstalled = (name, resolvePaths) => {
|
|
59
59
|
return false;
|
60
60
|
}
|
61
61
|
};
|
62
|
-
const isApiOnly = async (appDirectory, entryDir) => {
|
63
|
-
const
|
64
|
-
const existSrc = await _compiled.fs.pathExists(
|
62
|
+
const isApiOnly = async (appDirectory, entryDir, apiDir) => {
|
63
|
+
const existApi = await _compiled.fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : _path.default.join(appDirectory, "api"));
|
64
|
+
const existSrc = await _compiled.fs.pathExists(_path.default.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"));
|
65
65
|
const options = (0, _compiled.minimist)((0, _commands.getArgv)());
|
66
|
-
|
66
|
+
if (options["api-only"]) {
|
67
|
+
return true;
|
68
|
+
}
|
69
|
+
return existApi && !existSrc;
|
67
70
|
};
|
68
71
|
const isWebOnly = async () => {
|
69
72
|
const options = (0, _compiled.minimist)((0, _commands.getArgv)());
|
package/dist/cjs/cli/logger.js
CHANGED
@@ -17,7 +17,6 @@ _export(exports, {
|
|
17
17
|
return logger;
|
18
18
|
}
|
19
19
|
});
|
20
|
-
const _define_property = require("@swc/helpers/_/_define_property");
|
21
20
|
const _interop_require_default = require("@swc/helpers/_/_interop_require_default");
|
22
21
|
const _chalk = /* @__PURE__ */ _interop_require_default._(require("../../compiled/chalk"));
|
23
22
|
const LOG_LEVEL = {
|
@@ -103,10 +102,6 @@ ${_chalk.default.grey(rest.join("\n"))}`;
|
|
103
102
|
return longestLabel;
|
104
103
|
}
|
105
104
|
constructor(options = {}) {
|
106
|
-
_define_property._(this, "level", void 0);
|
107
|
-
_define_property._(this, "config", void 0);
|
108
|
-
_define_property._(this, "types", void 0);
|
109
|
-
_define_property._(this, "longestLabel", void 0);
|
110
105
|
this.level = options.level || LOG_TYPES.log.level;
|
111
106
|
this.config = {
|
112
107
|
...DEFAULT_CONFIG,
|
@@ -20,6 +20,8 @@ _export(exports, {
|
|
20
20
|
return _serialize.serializeJson;
|
21
21
|
}
|
22
22
|
});
|
23
|
+
const _export_star = require("@swc/helpers/_/_export_star");
|
23
24
|
const _storage = require("./storage");
|
24
25
|
const _serialize = require("./serialize");
|
26
|
+
_export_star._(require("./nestedRoutes"), exports);
|
25
27
|
const { run, useContext: useHeaders } = (0, _storage.createStorage)();
|
@@ -0,0 +1,28 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
3
|
+
value: true
|
4
|
+
});
|
5
|
+
Object.defineProperty(exports, "matchEntry", {
|
6
|
+
enumerable: true,
|
7
|
+
get: function() {
|
8
|
+
return matchEntry;
|
9
|
+
}
|
10
|
+
});
|
11
|
+
function sortByUrlPath(entries) {
|
12
|
+
entries.sort(function(a, b) {
|
13
|
+
const length1 = a.urlPath.length;
|
14
|
+
const length2 = b.urlPath.length;
|
15
|
+
if (length1 < length2) {
|
16
|
+
return 1;
|
17
|
+
}
|
18
|
+
if (length1 > length2) {
|
19
|
+
return -1;
|
20
|
+
}
|
21
|
+
return 0;
|
22
|
+
});
|
23
|
+
return entries;
|
24
|
+
}
|
25
|
+
const matchEntry = (pathname, entries) => {
|
26
|
+
sortByUrlPath(entries);
|
27
|
+
return entries.find((entry) => pathname.startsWith(entry.urlPath));
|
28
|
+
};
|
@@ -15,7 +15,11 @@ _export(exports, {
|
|
15
15
|
},
|
16
16
|
HMR_SOCK_PATH: function() {
|
17
17
|
return HMR_SOCK_PATH;
|
18
|
+
},
|
19
|
+
HTML_CHUNKSMAP_SEPARATOR: function() {
|
20
|
+
return HTML_CHUNKSMAP_SEPARATOR;
|
18
21
|
}
|
19
22
|
});
|
20
23
|
const ROUTE_MANIFEST = `_MODERNJS_ROUTE_MANIFEST`;
|
21
24
|
const HMR_SOCK_PATH = "/webpack-hmr";
|
25
|
+
const HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export const ROUTE_SPEC_FILE = "route.json";
|
2
|
+
export const NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
|
2
3
|
export const MAIN_ENTRY_NAME = "main";
|
3
4
|
export const SERVER_BUNDLE_DIRECTORY = "bundles";
|
4
5
|
export const SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
|
@@ -45,8 +46,6 @@ export const INTERNAL_MODULE_TOOLS_PLUGINS = {
|
|
45
46
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli",
|
46
47
|
"@modern-js/plugin-storybook": "@modern-js/plugin-storybook/cli",
|
47
48
|
"@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
|
48
|
-
// TODO: Maybe can remove it
|
49
|
-
"@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
|
50
49
|
// legacy router (inner react-router-dom v5)
|
51
50
|
"@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
|
52
51
|
};
|
@@ -77,8 +76,6 @@ export const INTERNAL_CLI_PLUGINS = {
|
|
77
76
|
"@modern-js/plugin-garfish": "@modern-js/plugin-garfish/cli",
|
78
77
|
"@modern-js/plugin-tailwindcss": "@modern-js/plugin-tailwindcss/cli",
|
79
78
|
"@modern-js/plugin-polyfill": "@modern-js/plugin-polyfill/cli",
|
80
|
-
// TODO: Maybe can remove it
|
81
|
-
"@modern-js/plugin-nocode": "@modern-js/plugin-nocode/cli",
|
82
79
|
// legacy router (inner react-router-dom v5)
|
83
80
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
84
81
|
};
|
@@ -94,214 +91,6 @@ export const INTERNAL_SERVER_PLUGINS = {
|
|
94
91
|
[SERVER_PLUGIN_SERVER]: "@modern-js/plugin-server/server",
|
95
92
|
[SERVER_PLUGIN_POLYFILL]: "@modern-js/plugin-polyfill/server"
|
96
93
|
};
|
97
|
-
export const PLUGIN_SCHEMAS = {
|
98
|
-
"@modern-js/runtime": [
|
99
|
-
{
|
100
|
-
target: "runtime",
|
101
|
-
schema: {
|
102
|
-
type: "object",
|
103
|
-
additionalProperties: false
|
104
|
-
}
|
105
|
-
},
|
106
|
-
{
|
107
|
-
target: "runtimeByEntries",
|
108
|
-
schema: {
|
109
|
-
type: "object",
|
110
|
-
patternProperties: {
|
111
|
-
[ENTRY_NAME_PATTERN]: {
|
112
|
-
type: "object"
|
113
|
-
}
|
114
|
-
},
|
115
|
-
additionalProperties: false
|
116
|
-
}
|
117
|
-
}
|
118
|
-
],
|
119
|
-
"@modern-js/plugin-swc": [
|
120
|
-
{
|
121
|
-
target: "tools.swc",
|
122
|
-
schema: {
|
123
|
-
typeof: [
|
124
|
-
"object"
|
125
|
-
]
|
126
|
-
}
|
127
|
-
}
|
128
|
-
],
|
129
|
-
"@modern-js/plugin-bff": [
|
130
|
-
{
|
131
|
-
target: "bff",
|
132
|
-
schema: {
|
133
|
-
type: "object",
|
134
|
-
properties: {
|
135
|
-
prefix: {
|
136
|
-
type: [
|
137
|
-
"string",
|
138
|
-
"array"
|
139
|
-
],
|
140
|
-
items: {
|
141
|
-
type: "string"
|
142
|
-
}
|
143
|
-
},
|
144
|
-
fetcher: {
|
145
|
-
type: "string"
|
146
|
-
},
|
147
|
-
proxy: {
|
148
|
-
type: "object"
|
149
|
-
},
|
150
|
-
requestCreator: {
|
151
|
-
type: "string"
|
152
|
-
}
|
153
|
-
}
|
154
|
-
}
|
155
|
-
}
|
156
|
-
],
|
157
|
-
"@modern-js/plugin-tailwindcss": [
|
158
|
-
{
|
159
|
-
target: "tools.tailwindcss",
|
160
|
-
schema: {
|
161
|
-
typeof: [
|
162
|
-
"object",
|
163
|
-
"function"
|
164
|
-
]
|
165
|
-
}
|
166
|
-
}
|
167
|
-
],
|
168
|
-
"@modern-js/plugin-proxy": [
|
169
|
-
{
|
170
|
-
target: "dev.proxy",
|
171
|
-
schema: {
|
172
|
-
typeof: [
|
173
|
-
"string",
|
174
|
-
"object"
|
175
|
-
]
|
176
|
-
}
|
177
|
-
}
|
178
|
-
],
|
179
|
-
"@modern-js/plugin-ssg": [
|
180
|
-
{
|
181
|
-
target: "output.ssg",
|
182
|
-
schema: {
|
183
|
-
oneOf: [
|
184
|
-
{
|
185
|
-
type: "boolean"
|
186
|
-
},
|
187
|
-
{
|
188
|
-
type: "object"
|
189
|
-
},
|
190
|
-
{
|
191
|
-
instanceof: "Function"
|
192
|
-
}
|
193
|
-
]
|
194
|
-
}
|
195
|
-
}
|
196
|
-
],
|
197
|
-
"@modern-js/plugin-state": [
|
198
|
-
{
|
199
|
-
target: "runtime.state",
|
200
|
-
schema: {
|
201
|
-
type: [
|
202
|
-
"boolean",
|
203
|
-
"object"
|
204
|
-
]
|
205
|
-
}
|
206
|
-
}
|
207
|
-
],
|
208
|
-
"@modern-js/plugin-design-token": [
|
209
|
-
// Legacy Features
|
210
|
-
{
|
211
|
-
target: "source.designSystem",
|
212
|
-
schema: {
|
213
|
-
typeof: [
|
214
|
-
"object"
|
215
|
-
]
|
216
|
-
}
|
217
|
-
},
|
218
|
-
{
|
219
|
-
target: "source.designSystem.supportStyledComponents",
|
220
|
-
schema: {
|
221
|
-
type: [
|
222
|
-
"boolean"
|
223
|
-
]
|
224
|
-
}
|
225
|
-
},
|
226
|
-
{
|
227
|
-
target: "designSystem",
|
228
|
-
schema: {
|
229
|
-
typeof: [
|
230
|
-
"object"
|
231
|
-
]
|
232
|
-
}
|
233
|
-
}
|
234
|
-
],
|
235
|
-
"@modern-js/plugin-router": [
|
236
|
-
{
|
237
|
-
target: "runtime.router",
|
238
|
-
schema: {
|
239
|
-
type: [
|
240
|
-
"boolean",
|
241
|
-
"object"
|
242
|
-
]
|
243
|
-
}
|
244
|
-
}
|
245
|
-
],
|
246
|
-
"@modern-js/plugin-testing": [
|
247
|
-
{
|
248
|
-
target: "testing",
|
249
|
-
schema: {
|
250
|
-
typeof: [
|
251
|
-
"object"
|
252
|
-
]
|
253
|
-
}
|
254
|
-
},
|
255
|
-
{
|
256
|
-
target: "tools.jest",
|
257
|
-
schema: {
|
258
|
-
typeof: [
|
259
|
-
"object",
|
260
|
-
"function"
|
261
|
-
]
|
262
|
-
}
|
263
|
-
}
|
264
|
-
],
|
265
|
-
"@modern-js/plugin-garfish": [
|
266
|
-
{
|
267
|
-
target: "runtime.masterApp",
|
268
|
-
schema: {
|
269
|
-
type: [
|
270
|
-
"boolean",
|
271
|
-
"object"
|
272
|
-
]
|
273
|
-
}
|
274
|
-
},
|
275
|
-
{
|
276
|
-
target: "dev.withMasterApp",
|
277
|
-
schema: {
|
278
|
-
type: [
|
279
|
-
"object"
|
280
|
-
]
|
281
|
-
}
|
282
|
-
},
|
283
|
-
{
|
284
|
-
target: "deploy.microFrontend",
|
285
|
-
schema: {
|
286
|
-
type: [
|
287
|
-
"boolean",
|
288
|
-
"object"
|
289
|
-
]
|
290
|
-
}
|
291
|
-
}
|
292
|
-
],
|
293
|
-
"@modern-js/plugin-nocode": [],
|
294
|
-
"@modern-js/plugin-worker": [
|
295
|
-
{
|
296
|
-
target: "deploy.worker.ssr",
|
297
|
-
schema: {
|
298
|
-
type: [
|
299
|
-
"boolean"
|
300
|
-
]
|
301
|
-
}
|
302
|
-
}
|
303
|
-
]
|
304
|
-
};
|
305
94
|
export const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
306
95
|
allowNamespaces: true,
|
307
96
|
allExtensions: true,
|
package/dist/esm/cli/index.js
CHANGED
@@ -24,11 +24,14 @@ export const isPackageInstalled = (name, resolvePaths) => {
|
|
24
24
|
return false;
|
25
25
|
}
|
26
26
|
};
|
27
|
-
export const isApiOnly = async (appDirectory, entryDir) => {
|
28
|
-
const
|
29
|
-
const existSrc = await fs.pathExists(
|
27
|
+
export const isApiOnly = async (appDirectory, entryDir, apiDir) => {
|
28
|
+
const existApi = await fs.pathExists(apiDir !== null && apiDir !== void 0 ? apiDir : path.join(appDirectory, "api"));
|
29
|
+
const existSrc = await fs.pathExists(path.join(appDirectory, entryDir !== null && entryDir !== void 0 ? entryDir : "src"));
|
30
30
|
const options = minimist(getArgv());
|
31
|
-
|
31
|
+
if (options["api-only"]) {
|
32
|
+
return true;
|
33
|
+
}
|
34
|
+
return existApi && !existSrc;
|
32
35
|
};
|
33
36
|
export const isWebOnly = async () => {
|
34
37
|
const options = minimist(getArgv());
|
package/dist/esm/cli/logger.js
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
2
1
|
import chalk from "../../compiled/chalk";
|
3
2
|
const LOG_LEVEL = {
|
4
3
|
error: 0,
|
@@ -83,10 +82,6 @@ ${chalk.grey(rest.join("\n"))}`;
|
|
83
82
|
return longestLabel;
|
84
83
|
}
|
85
84
|
constructor(options = {}) {
|
86
|
-
_define_property(this, "level", void 0);
|
87
|
-
_define_property(this, "config", void 0);
|
88
|
-
_define_property(this, "types", void 0);
|
89
|
-
_define_property(this, "longestLabel", void 0);
|
90
85
|
this.level = options.level || LOG_TYPES.log.level;
|
91
86
|
this.config = {
|
92
87
|
...DEFAULT_CONFIG,
|
@@ -0,0 +1,18 @@
|
|
1
|
+
function sortByUrlPath(entries) {
|
2
|
+
entries.sort(function(a, b) {
|
3
|
+
const length1 = a.urlPath.length;
|
4
|
+
const length2 = b.urlPath.length;
|
5
|
+
if (length1 < length2) {
|
6
|
+
return 1;
|
7
|
+
}
|
8
|
+
if (length1 > length2) {
|
9
|
+
return -1;
|
10
|
+
}
|
11
|
+
return 0;
|
12
|
+
});
|
13
|
+
return entries;
|
14
|
+
}
|
15
|
+
export const matchEntry = (pathname, entries) => {
|
16
|
+
sortByUrlPath(entries);
|
17
|
+
return entries.find((entry) => pathname.startsWith(entry.urlPath));
|
18
|
+
};
|
@@ -3,6 +3,10 @@ import { InternalPlugins } from '@modern-js/types';
|
|
3
3
|
* route specification file
|
4
4
|
*/
|
5
5
|
export declare const ROUTE_SPEC_FILE = "route.json";
|
6
|
+
/**
|
7
|
+
* Front-end routing metadata
|
8
|
+
*/
|
9
|
+
export declare const NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
|
6
10
|
/**
|
7
11
|
* main entry name
|
8
12
|
*/
|
@@ -85,127 +89,6 @@ export declare const SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
|
|
85
89
|
export declare const SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
|
86
90
|
export declare const SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
|
87
91
|
export declare const INTERNAL_SERVER_PLUGINS: InternalPlugins;
|
88
|
-
/**
|
89
|
-
* The schema registered in the plugin.
|
90
|
-
*/
|
91
|
-
export declare const PLUGIN_SCHEMAS: {
|
92
|
-
'@modern-js/runtime': ({
|
93
|
-
target: string;
|
94
|
-
schema: {
|
95
|
-
type: string;
|
96
|
-
additionalProperties: boolean;
|
97
|
-
patternProperties?: undefined;
|
98
|
-
};
|
99
|
-
} | {
|
100
|
-
target: string;
|
101
|
-
schema: {
|
102
|
-
type: string;
|
103
|
-
patternProperties: {
|
104
|
-
"^[a-zA-Z0-9_-]+$": {
|
105
|
-
type: string;
|
106
|
-
};
|
107
|
-
};
|
108
|
-
additionalProperties: boolean;
|
109
|
-
};
|
110
|
-
})[];
|
111
|
-
'@modern-js/plugin-swc': {
|
112
|
-
target: string;
|
113
|
-
schema: {
|
114
|
-
typeof: string[];
|
115
|
-
};
|
116
|
-
}[];
|
117
|
-
'@modern-js/plugin-bff': {
|
118
|
-
target: string;
|
119
|
-
schema: {
|
120
|
-
type: string;
|
121
|
-
properties: {
|
122
|
-
prefix: {
|
123
|
-
type: string[];
|
124
|
-
items: {
|
125
|
-
type: string;
|
126
|
-
};
|
127
|
-
};
|
128
|
-
fetcher: {
|
129
|
-
type: string;
|
130
|
-
};
|
131
|
-
proxy: {
|
132
|
-
type: string;
|
133
|
-
};
|
134
|
-
requestCreator: {
|
135
|
-
type: string;
|
136
|
-
};
|
137
|
-
};
|
138
|
-
};
|
139
|
-
}[];
|
140
|
-
'@modern-js/plugin-tailwindcss': {
|
141
|
-
target: string;
|
142
|
-
schema: {
|
143
|
-
typeof: string[];
|
144
|
-
};
|
145
|
-
}[];
|
146
|
-
'@modern-js/plugin-proxy': {
|
147
|
-
target: string;
|
148
|
-
schema: {
|
149
|
-
typeof: string[];
|
150
|
-
};
|
151
|
-
}[];
|
152
|
-
'@modern-js/plugin-ssg': {
|
153
|
-
target: string;
|
154
|
-
schema: {
|
155
|
-
oneOf: ({
|
156
|
-
type: string;
|
157
|
-
instanceof?: undefined;
|
158
|
-
} | {
|
159
|
-
instanceof: string;
|
160
|
-
type?: undefined;
|
161
|
-
})[];
|
162
|
-
};
|
163
|
-
}[];
|
164
|
-
'@modern-js/plugin-state': {
|
165
|
-
target: string;
|
166
|
-
schema: {
|
167
|
-
type: string[];
|
168
|
-
};
|
169
|
-
}[];
|
170
|
-
'@modern-js/plugin-design-token': ({
|
171
|
-
target: string;
|
172
|
-
schema: {
|
173
|
-
typeof: string[];
|
174
|
-
type?: undefined;
|
175
|
-
};
|
176
|
-
} | {
|
177
|
-
target: string;
|
178
|
-
schema: {
|
179
|
-
type: string[];
|
180
|
-
typeof?: undefined;
|
181
|
-
};
|
182
|
-
})[];
|
183
|
-
'@modern-js/plugin-router': {
|
184
|
-
target: string;
|
185
|
-
schema: {
|
186
|
-
type: string[];
|
187
|
-
};
|
188
|
-
}[];
|
189
|
-
'@modern-js/plugin-testing': {
|
190
|
-
target: string;
|
191
|
-
schema: {
|
192
|
-
typeof: string[];
|
193
|
-
};
|
194
|
-
}[];
|
195
|
-
'@modern-js/plugin-garfish': {
|
196
|
-
target: string;
|
197
|
-
schema: {
|
198
|
-
type: string[];
|
199
|
-
};
|
200
|
-
}[];
|
201
|
-
'@modern-js/plugin-nocode': never[];
|
202
|
-
'@modern-js/plugin-worker': {
|
203
|
-
target: string;
|
204
|
-
schema: {
|
205
|
-
type: string[];
|
206
|
-
};
|
207
|
-
}[];
|
208
|
-
};
|
209
92
|
/**
|
210
93
|
* The `@babel/preset-typescript` default options.
|
211
94
|
*
|
@@ -10,7 +10,17 @@ export declare const isDepExists: (appDirectory: string, name: string) => boolea
|
|
10
10
|
* Try to resolve npm package, return true if package is installed.
|
11
11
|
*/
|
12
12
|
export declare const isPackageInstalled: (name: string, resolvePaths: string | string[]) => boolean;
|
13
|
-
|
13
|
+
/**
|
14
|
+
* Check is api only project
|
15
|
+
* 1. env --api-only
|
16
|
+
* 2. exist ${apiDir}/ && not exist ${entryDir}/
|
17
|
+
*
|
18
|
+
* @param appDirectory
|
19
|
+
* @param entryDir default 'src'
|
20
|
+
* @param apiDir default 'api'
|
21
|
+
* @returns boolean
|
22
|
+
*/
|
23
|
+
export declare const isApiOnly: (appDirectory: string, entryDir?: string, apiDir?: string) => Promise<boolean>;
|
14
24
|
export declare const isWebOnly: () => Promise<boolean>;
|
15
25
|
export declare const isBeyondReact17: (cwd: string) => boolean;
|
16
26
|
export declare const isReact18: (cwd: string) => boolean;
|
@@ -5,4 +5,5 @@
|
|
5
5
|
import type { IncomingHttpHeaders } from 'http';
|
6
6
|
declare const run: <O>(context: IncomingHttpHeaders, cb: () => O | Promise<O>) => Promise<O>, useHeaders: () => IncomingHttpHeaders;
|
7
7
|
export { run, useHeaders };
|
8
|
-
export { serializeJson } from './serialize';
|
8
|
+
export { serializeJson } from './serialize';
|
9
|
+
export * from './nestedRoutes';
|
@@ -0,0 +1,3 @@
|
|
1
|
+
import type { ModernServerContext, ServerRoute } from '@modern-js/types';
|
2
|
+
export type ServerContext = Pick<ModernServerContext, 'logger' | 'req' | 'res' | 'params' | 'headers' | 'method' | 'url' | 'host' | 'protocol' | 'origin' | 'href' | 'path' | 'query'>;
|
3
|
+
export declare const matchEntry: (pathname: string, entries: ServerRoute[]) => ServerRoute | undefined;
|
@@ -5,4 +5,8 @@ export declare const ROUTE_MANIFEST = "_MODERNJS_ROUTE_MANIFEST";
|
|
5
5
|
/**
|
6
6
|
* hmr socket connect path
|
7
7
|
*/
|
8
|
-
export declare const HMR_SOCK_PATH = "/webpack-hmr";
|
8
|
+
export declare const HMR_SOCK_PATH = "/webpack-hmr";
|
9
|
+
/**
|
10
|
+
* html placeholder
|
11
|
+
*/
|
12
|
+
export declare const HTML_CHUNKSMAP_SEPARATOR = "<!--<?- chunksMap.js ?>-->";
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.23.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -36,6 +36,7 @@
|
|
36
36
|
},
|
37
37
|
"./runtime/router": {
|
38
38
|
"types": "./dist/types/runtime/router.d.ts",
|
39
|
+
"require": "./dist/cjs/runtime/router.js",
|
39
40
|
"default": "./dist/esm/runtime/router.js"
|
40
41
|
},
|
41
42
|
"./runtime/remix-router": {
|
@@ -52,10 +53,12 @@
|
|
52
53
|
},
|
53
54
|
"./runtime-node": {
|
54
55
|
"types": "./dist/types/runtime-node/index.d.ts",
|
56
|
+
"require": "./dist/cjs/runtime-node/index.js",
|
55
57
|
"default": "./dist/esm/runtime-node/index.js"
|
56
58
|
},
|
57
59
|
"./runtime-node/router": {
|
58
60
|
"types": "./dist/types/runtime-node/router.d.ts",
|
61
|
+
"require": "./dist/cjs/runtime-node/router.js",
|
59
62
|
"default": "./dist/esm/runtime-node/router.js"
|
60
63
|
},
|
61
64
|
"./universal/constants": {
|
@@ -97,7 +100,8 @@
|
|
97
100
|
},
|
98
101
|
"publishConfig": {
|
99
102
|
"registry": "https://registry.npmjs.org/",
|
100
|
-
"access": "public"
|
103
|
+
"access": "public",
|
104
|
+
"provenance": true
|
101
105
|
},
|
102
106
|
"typesVersions": {
|
103
107
|
"*": {
|
@@ -231,9 +235,9 @@
|
|
231
235
|
"typescript": "^5",
|
232
236
|
"webpack": "^5.82.1",
|
233
237
|
"@types/serialize-javascript": "^5.0.1",
|
234
|
-
"@modern-js/types": "2.
|
235
|
-
"@scripts/build": "2.
|
236
|
-
"@scripts/jest-config": "2.
|
238
|
+
"@modern-js/types": "2.23.0",
|
239
|
+
"@scripts/build": "2.23.0",
|
240
|
+
"@scripts/jest-config": "2.23.0"
|
237
241
|
},
|
238
242
|
"sideEffects": false,
|
239
243
|
"scripts": {
|
package/dist/cjs/cli/test.js
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
3
|
-
value: true
|
4
|
-
});
|
5
|
-
Object.defineProperty(exports, "initSnapshotSerializer", {
|
6
|
-
enumerable: true,
|
7
|
-
get: function() {
|
8
|
-
return initSnapshotSerializer;
|
9
|
-
}
|
10
|
-
});
|
11
|
-
const initSnapshotSerializer = (root) => {
|
12
|
-
expect.addSnapshotSerializer({
|
13
|
-
test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
|
14
|
-
print: (val) => (
|
15
|
-
// eslint-disable-next-line no-nested-ternary
|
16
|
-
typeof val === "string" ? val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"` : val
|
17
|
-
)
|
18
|
-
});
|
19
|
-
};
|
package/dist/esm/cli/test.js
DELETED
@@ -1,9 +0,0 @@
|
|
1
|
-
export const initSnapshotSerializer = (root) => {
|
2
|
-
expect.addSnapshotSerializer({
|
3
|
-
test: (val) => typeof val === "string" && (val.includes("modern.js") || val.includes("node_modules") || val.includes(root)),
|
4
|
-
print: (val) => (
|
5
|
-
// eslint-disable-next-line no-nested-ternary
|
6
|
-
typeof val === "string" ? val.includes("node_modules") ? `"${val.replace(/.+node_modules/, ``).replace(/\\/g, "/")}"` : val.includes("modern.js") ? `"${val.replace(/.+modern\.js/, ``).replace(/\\/g, "/")}"` : `"${val.replace(root, "").replace(/\\/g, "/")}"` : val
|
7
|
-
)
|
8
|
-
});
|
9
|
-
};
|