@modern-js/utils 2.26.0 → 2.27.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/universal/formatWebpack.js +0 -4
- package/dist/esm/cli/alias.js +26 -22
- package/dist/esm/cli/applyOptionsChain.js +8 -6
- package/dist/esm/cli/babel.js +50 -35
- package/dist/esm/cli/commands.js +7 -7
- package/dist/esm/cli/common.js +10 -5
- package/dist/esm/cli/constants/chainId.js +1 -1
- package/dist/esm/cli/constants/index.js +33 -37
- package/dist/esm/cli/ensure.js +4 -2
- package/dist/esm/cli/fs.js +56 -9
- package/dist/esm/cli/get/config.js +7 -7
- package/dist/esm/cli/get/data.js +93 -55
- package/dist/esm/cli/get/index.js +21 -6
- package/dist/esm/cli/is/config.js +33 -14
- package/dist/esm/cli/is/env.js +18 -6
- package/dist/esm/cli/is/platform.js +6 -2
- package/dist/esm/cli/is/project.js +73 -36
- package/dist/esm/cli/is/type.js +3 -1
- package/dist/esm/cli/logger.js +49 -38
- package/dist/esm/cli/monorepo.js +49 -36
- package/dist/esm/cli/package.js +156 -38
- package/dist/esm/cli/path.js +44 -20
- package/dist/esm/cli/pathSerializer.js +29 -15
- package/dist/esm/cli/port.js +89 -40
- package/dist/esm/cli/prettyInstructions.js +42 -31
- package/dist/esm/cli/require.js +21 -16
- package/dist/esm/cli/runtimeExports.js +21 -15
- package/dist/esm/cli/watch.js +94 -27
- package/dist/esm/compiled.js +3 -3
- package/dist/esm/import.js +4 -4
- package/dist/esm/runtime/nestedRoutes.js +42 -29
- package/dist/esm/runtime-browser/parsed.js +5 -5
- package/dist/esm/runtime-node/index.js +1 -1
- package/dist/esm/runtime-node/nestedRoutes.js +6 -4
- package/dist/esm/runtime-node/serialize.js +1 -1
- package/dist/esm/runtime-node/storage.js +12 -14
- package/dist/esm/universal/constants.js +3 -3
- package/dist/esm/universal/formatWebpack.js +20 -26
- package/dist/esm/universal/pluginDagSort.js +49 -26
- package/dist/esm-node/cli/alias.js +51 -0
- package/dist/esm-node/cli/applyOptionsChain.js +24 -0
- package/dist/esm-node/cli/babel.js +103 -0
- package/dist/esm-node/cli/commands.js +16 -0
- package/dist/esm-node/cli/common.js +10 -0
- package/dist/esm-node/cli/constants/chainId.js +180 -0
- package/dist/esm-node/cli/constants/index.js +103 -0
- package/dist/esm-node/cli/ensure.js +10 -0
- package/dist/esm-node/cli/fs.js +14 -0
- package/dist/esm-node/cli/get/config.js +16 -0
- package/dist/esm-node/cli/get/data.js +86 -0
- package/dist/esm-node/cli/get/index.js +13 -0
- package/dist/esm-node/cli/index.js +20 -0
- package/dist/esm-node/cli/is/config.js +40 -0
- package/dist/esm-node/cli/is/env.js +6 -0
- package/dist/esm-node/cli/is/index.js +5 -0
- package/dist/esm-node/cli/is/platform.js +2 -0
- package/dist/esm-node/cli/is/project.js +73 -0
- package/dist/esm-node/cli/is/type.js +25 -0
- package/dist/esm-node/cli/logger.js +103 -0
- package/dist/esm-node/cli/monorepo.js +70 -0
- package/dist/esm-node/cli/package.js +43 -0
- package/dist/esm-node/cli/path.js +49 -0
- package/dist/esm-node/cli/pathSerializer.js +46 -0
- package/dist/esm-node/cli/port.js +44 -0
- package/dist/esm-node/cli/prettyInstructions.js +77 -0
- package/dist/esm-node/cli/require.js +52 -0
- package/dist/esm-node/cli/runtimeExports.js +35 -0
- package/dist/esm-node/cli/watch.js +41 -0
- package/dist/esm-node/compiled.js +33 -0
- package/dist/esm-node/import.js +8 -0
- package/dist/esm-node/index.js +3 -0
- package/dist/esm-node/runtime/nestedRoutes.js +112 -0
- package/dist/esm-node/runtime/remixRouter.js +1 -0
- package/dist/esm-node/runtime/router.js +1 -0
- package/dist/esm-node/runtime-browser/index.js +1 -0
- package/dist/esm-node/runtime-browser/parsed.js +17 -0
- package/dist/esm-node/runtime-node/index.js +5 -0
- package/dist/esm-node/runtime-node/nestedRoutes.js +18 -0
- package/dist/esm-node/runtime-node/router.js +1 -0
- package/dist/esm-node/runtime-node/serialize.js +6 -0
- package/dist/esm-node/runtime-node/storage.js +38 -0
- package/dist/esm-node/universal/constants.js +3 -0
- package/dist/esm-node/universal/formatWebpack.js +61 -0
- package/dist/esm-node/universal/pluginDagSort.js +50 -0
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 2.27.0
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 91d14b8: fix(utils): using universal build config and fix compatibility issue
|
8
|
+
|
9
|
+
fix(utils): 使用 universal 构建配置,修复兼容性问题
|
10
|
+
|
11
|
+
- 6d7104d: fix(builder): should not strip error stacks
|
12
|
+
|
13
|
+
fix(builder): 不应该移除错误堆栈
|
14
|
+
|
3
15
|
## 2.26.0
|
4
16
|
|
5
17
|
## 2.25.2
|
@@ -48,10 +48,6 @@ ${stats.stack}` : "";
|
|
48
48
|
if (lines[1] && lines[1].indexOf("Module not found:") !== -1) {
|
49
49
|
lines[1] = lines[1].replace("Error: ", "");
|
50
50
|
}
|
51
|
-
message = lines.join("\n");
|
52
|
-
message = message.replace(/^\s*at\s((?!webpack:).)*:\d+:\d+[\s)]*(\n|$)/gm, "");
|
53
|
-
message = message.replace(/^\s*at\s<anonymous>(\n|$)/gm, "");
|
54
|
-
lines = message.split("\n");
|
55
51
|
lines = lines.filter((line, index, arr) => index === 0 || line.trim() !== "" || line.trim() !== arr[index - 1].trim());
|
56
52
|
message = lines.join("\n");
|
57
53
|
return message.trim();
|
package/dist/esm/cli/alias.js
CHANGED
@@ -1,51 +1,55 @@
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
1
2
|
import fs from "fs";
|
2
3
|
import path from "path";
|
3
4
|
import { chalk } from "../compiled";
|
4
5
|
import { readTsConfigByFile } from "./get";
|
5
6
|
import { applyOptionsChain } from "./applyOptionsChain";
|
6
|
-
export
|
7
|
-
|
7
|
+
export var validAlias = function(modernConfig, param) {
|
8
|
+
var tsconfigPath = param.tsconfigPath;
|
9
|
+
var alias = modernConfig.source.alias;
|
8
10
|
if (!alias) {
|
9
11
|
return null;
|
10
12
|
}
|
11
|
-
|
13
|
+
var isTsProject = fs.existsSync(tsconfigPath);
|
12
14
|
if (!isTsProject) {
|
13
15
|
return null;
|
14
16
|
}
|
15
|
-
|
17
|
+
var userAlias = getUserAlias(alias);
|
16
18
|
if (Object.keys(userAlias).length > 0) {
|
17
19
|
return chalk.red('Note: Please use `compilerOptions.paths` in "tsconfig.json" file replace `source.alias` config in "modern.config.js/ts" when project is typescript');
|
18
20
|
}
|
19
21
|
return null;
|
20
22
|
};
|
21
|
-
export
|
22
|
-
|
23
|
+
export var mergeAlias = function(alias) {
|
24
|
+
return applyOptionsChain({}, alias);
|
25
|
+
};
|
26
|
+
export var getAliasConfig = function(aliasOption, option) {
|
23
27
|
var _tsconfig_compilerOptions, _tsconfig_compilerOptions1;
|
24
|
-
|
25
|
-
|
28
|
+
var isTsProject = fs.existsSync(option.tsconfigPath);
|
29
|
+
var alias = mergeAlias(aliasOption);
|
26
30
|
if (!isTsProject) {
|
27
31
|
return {
|
28
32
|
absoluteBaseUrl: option.appDirectory,
|
29
33
|
paths: alias,
|
30
34
|
isTsPath: false,
|
31
|
-
isTsProject
|
35
|
+
isTsProject: isTsProject
|
32
36
|
};
|
33
37
|
}
|
34
|
-
|
35
|
-
|
38
|
+
var tsconfig = readTsConfigByFile(option.tsconfigPath);
|
39
|
+
var baseUrl = tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions === void 0 ? void 0 : _tsconfig_compilerOptions.baseUrl;
|
36
40
|
return {
|
37
41
|
absoluteBaseUrl: baseUrl ? path.join(option.appDirectory, baseUrl) : option.appDirectory,
|
38
|
-
paths: {
|
39
|
-
...alias,
|
40
|
-
...tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths
|
41
|
-
},
|
42
|
+
paths: _object_spread({}, alias, tsconfig === null || tsconfig === void 0 ? void 0 : (_tsconfig_compilerOptions1 = tsconfig.compilerOptions) === null || _tsconfig_compilerOptions1 === void 0 ? void 0 : _tsconfig_compilerOptions1.paths),
|
42
43
|
isTsPath: true,
|
43
|
-
isTsProject
|
44
|
+
isTsProject: isTsProject
|
44
45
|
};
|
45
46
|
};
|
46
|
-
export
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
}
|
47
|
+
export var getUserAlias = function() {
|
48
|
+
var alias = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
49
|
+
return Object.keys(alias).reduce(function(o, k) {
|
50
|
+
if (Array.isArray(alias[k])) {
|
51
|
+
o[k] = alias[k];
|
52
|
+
}
|
53
|
+
return o;
|
54
|
+
}, {});
|
55
|
+
};
|
@@ -1,24 +1,26 @@
|
|
1
1
|
import { isFunction, isPlainObject } from "./is";
|
2
2
|
import { logger } from "./logger";
|
3
|
-
export function applyOptionsChain(defaults, options, utils
|
3
|
+
export function applyOptionsChain(defaults, options, utils) {
|
4
|
+
var mergeFn = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : Object.assign;
|
4
5
|
if (!options) {
|
5
6
|
return defaults;
|
6
7
|
}
|
7
8
|
if (isPlainObject(options)) {
|
8
9
|
return mergeFn(defaults, options);
|
9
10
|
} else if (isFunction(options)) {
|
10
|
-
|
11
|
+
var ret = options(defaults, utils);
|
11
12
|
if (ret) {
|
12
13
|
if (!isPlainObject(ret)) {
|
13
|
-
logger.warn(
|
14
|
+
logger.warn("".concat(options.name, ": Function should mutate the config and return nothing, Or return a cloned or merged version of config object."));
|
14
15
|
}
|
15
16
|
return ret;
|
16
17
|
}
|
17
18
|
} else if (Array.isArray(options)) {
|
18
|
-
return options.reduce((memo, cur)
|
19
|
+
return options.reduce(function(memo, cur) {
|
20
|
+
return applyOptionsChain(memo, cur, utils, mergeFn);
|
21
|
+
}, defaults);
|
19
22
|
} else {
|
20
|
-
throw new Error(
|
21
|
-
default options is: ${JSON.stringify(defaults)}`);
|
23
|
+
throw new Error("applyOptionsChain error:\ndefault options is: ".concat(JSON.stringify(defaults)));
|
22
24
|
}
|
23
25
|
return defaults;
|
24
26
|
}
|
package/dist/esm/cli/babel.js
CHANGED
@@ -1,14 +1,16 @@
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
2
|
+
import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
|
1
3
|
import { isAbsolute, sep } from "path";
|
2
4
|
import { applyOptionsChain } from "./applyOptionsChain";
|
3
5
|
import { ensureArray } from "./ensure";
|
4
6
|
import { normalizeToPosixPath } from "./path";
|
5
|
-
|
7
|
+
var formatPath = function(originPath) {
|
6
8
|
if (isAbsolute(originPath)) {
|
7
9
|
return originPath.split(sep).join("/");
|
8
10
|
}
|
9
11
|
return originPath;
|
10
12
|
};
|
11
|
-
|
13
|
+
var getPluginItemName = function(item) {
|
12
14
|
if (typeof item === "string") {
|
13
15
|
return formatPath(item);
|
14
16
|
}
|
@@ -17,54 +19,58 @@ const getPluginItemName = (item) => {
|
|
17
19
|
}
|
18
20
|
return null;
|
19
21
|
};
|
20
|
-
|
22
|
+
var addPlugins = function(plugins, config) {
|
21
23
|
if (config.plugins) {
|
22
|
-
|
24
|
+
var _config_plugins;
|
25
|
+
(_config_plugins = config.plugins).push.apply(_config_plugins, _to_consumable_array(plugins));
|
23
26
|
} else {
|
24
27
|
config.plugins = plugins;
|
25
28
|
}
|
26
29
|
};
|
27
|
-
|
30
|
+
var addPresets = function(presets, config) {
|
28
31
|
if (config.presets) {
|
29
|
-
|
32
|
+
var _config_presets;
|
33
|
+
(_config_presets = config.presets).push.apply(_config_presets, _to_consumable_array(presets));
|
30
34
|
} else {
|
31
35
|
config.presets = presets;
|
32
36
|
}
|
33
37
|
};
|
34
|
-
|
38
|
+
var removePlugins = function(plugins, config) {
|
35
39
|
if (!config.plugins) {
|
36
40
|
return;
|
37
41
|
}
|
38
|
-
|
39
|
-
config.plugins = config.plugins.filter((item)
|
40
|
-
|
42
|
+
var removeList = ensureArray(plugins);
|
43
|
+
config.plugins = config.plugins.filter(function(item) {
|
44
|
+
var name = getPluginItemName(item);
|
41
45
|
if (name) {
|
42
|
-
return !removeList.find((removeItem)
|
46
|
+
return !removeList.find(function(removeItem) {
|
47
|
+
return name.includes(removeItem);
|
48
|
+
});
|
43
49
|
}
|
44
50
|
return true;
|
45
51
|
});
|
46
52
|
};
|
47
|
-
|
53
|
+
var removePresets = function(presets, config) {
|
48
54
|
if (!config.presets) {
|
49
55
|
return;
|
50
56
|
}
|
51
|
-
|
52
|
-
config.presets = config.presets.filter((item)
|
53
|
-
|
57
|
+
var removeList = ensureArray(presets);
|
58
|
+
config.presets = config.presets.filter(function(item) {
|
59
|
+
var name = getPluginItemName(item);
|
54
60
|
if (name) {
|
55
|
-
return !removeList.find((removeItem)
|
61
|
+
return !removeList.find(function(removeItem) {
|
62
|
+
return name.includes(removeItem);
|
63
|
+
});
|
56
64
|
}
|
57
65
|
return true;
|
58
66
|
});
|
59
67
|
};
|
60
|
-
|
61
|
-
presets.
|
68
|
+
var modifyPresetOptions = function(presetName, options) {
|
69
|
+
var presets = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
70
|
+
presets.forEach(function(preset, index) {
|
62
71
|
if (Array.isArray(preset)) {
|
63
72
|
if (typeof preset[0] === "string" && normalizeToPosixPath(preset[0]).includes(presetName)) {
|
64
|
-
preset[1] = {
|
65
|
-
...preset[1] || {},
|
66
|
-
...options
|
67
|
-
};
|
73
|
+
preset[1] = _object_spread({}, preset[1] || {}, options);
|
68
74
|
}
|
69
75
|
} else if (typeof preset === "string" && normalizeToPosixPath(preset).includes(presetName)) {
|
70
76
|
presets[index] = [
|
@@ -74,29 +80,38 @@ const modifyPresetOptions = (presetName, options, presets = []) => {
|
|
74
80
|
}
|
75
81
|
});
|
76
82
|
};
|
77
|
-
export
|
78
|
-
|
83
|
+
export var getBabelUtils = function(config) {
|
84
|
+
var noop = function() {
|
79
85
|
};
|
80
86
|
return {
|
81
|
-
addPlugins: (plugins)
|
82
|
-
|
83
|
-
|
84
|
-
|
87
|
+
addPlugins: function(plugins) {
|
88
|
+
return addPlugins(plugins, config);
|
89
|
+
},
|
90
|
+
addPresets: function(presets) {
|
91
|
+
return addPresets(presets, config);
|
92
|
+
},
|
93
|
+
removePlugins: function(plugins) {
|
94
|
+
return removePlugins(plugins, config);
|
95
|
+
},
|
96
|
+
removePresets: function(presets) {
|
97
|
+
return removePresets(presets, config);
|
98
|
+
},
|
85
99
|
// `addIncludes` and `addExcludes` are noop functions by default,
|
86
100
|
// It can be overridden by `extraBabelUtils`.
|
87
101
|
addIncludes: noop,
|
88
102
|
addExcludes: noop,
|
89
103
|
// Compat `presetEnvOptions` and `presetReactOptions` in Eden.
|
90
|
-
modifyPresetEnvOptions: (options)
|
91
|
-
|
104
|
+
modifyPresetEnvOptions: function(options) {
|
105
|
+
return modifyPresetOptions("@babel/preset-env", options, config.presets || []);
|
106
|
+
},
|
107
|
+
modifyPresetReactOptions: function(options) {
|
108
|
+
return modifyPresetOptions("@babel/preset-react", options, config.presets || []);
|
109
|
+
}
|
92
110
|
};
|
93
111
|
};
|
94
|
-
export
|
112
|
+
export var applyUserBabelConfig = function(defaultOptions, userBabelConfig, extraBabelUtils) {
|
95
113
|
if (userBabelConfig) {
|
96
|
-
|
97
|
-
...getBabelUtils(defaultOptions),
|
98
|
-
...extraBabelUtils
|
99
|
-
};
|
114
|
+
var babelUtils = _object_spread({}, getBabelUtils(defaultOptions), extraBabelUtils);
|
100
115
|
return applyOptionsChain(defaultOptions, userBabelConfig || {}, babelUtils);
|
101
116
|
}
|
102
117
|
return defaultOptions;
|
package/dist/esm/cli/commands.js
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
export
|
1
|
+
export var getFullArgv = function() {
|
2
2
|
var _process_env_MODERN_ARGV;
|
3
3
|
return ((_process_env_MODERN_ARGV = process.env.MODERN_ARGV) === null || _process_env_MODERN_ARGV === void 0 ? void 0 : _process_env_MODERN_ARGV.split(" ")) || process.argv;
|
4
4
|
};
|
5
|
-
export
|
5
|
+
export var getArgv = function() {
|
6
6
|
return getFullArgv().slice(2);
|
7
7
|
};
|
8
|
-
export
|
9
|
-
|
10
|
-
|
8
|
+
export var getCommand = function() {
|
9
|
+
var args = getArgv();
|
10
|
+
var command = args[0];
|
11
11
|
return command;
|
12
12
|
};
|
13
|
-
export
|
14
|
-
|
13
|
+
export var isDevCommand = function() {
|
14
|
+
var command = getCommand();
|
15
15
|
return command === "dev" || command === "start";
|
16
16
|
};
|
package/dist/esm/cli/common.js
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
import { debug } from "../../compiled/debug";
|
2
|
-
export
|
3
|
-
|
2
|
+
export var createDebugger = function(scope) {
|
3
|
+
return debug("modern-js:".concat(scope));
|
4
|
+
};
|
5
|
+
export var clearConsole = function() {
|
4
6
|
if (process.stdout.isTTY && !process.env.DEBUG) {
|
5
7
|
process.stdout.write("\x1B[H\x1B[2J");
|
6
8
|
}
|
7
9
|
};
|
8
|
-
export
|
9
|
-
|
10
|
-
|
10
|
+
export var wait = function() {
|
11
|
+
var time = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 0;
|
12
|
+
return new Promise(function(resolve) {
|
13
|
+
setTimeout(resolve, time);
|
14
|
+
});
|
15
|
+
};
|
@@ -1,26 +1,27 @@
|
|
1
|
-
|
2
|
-
export
|
3
|
-
export
|
4
|
-
export
|
5
|
-
export
|
6
|
-
export
|
7
|
-
export
|
8
|
-
export
|
9
|
-
export
|
10
|
-
export
|
11
|
-
export
|
12
|
-
export
|
13
|
-
export
|
1
|
+
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
2
|
+
export var ROUTE_SPEC_FILE = "route.json";
|
3
|
+
export var NESTED_ROUTE_SPEC_FILE = "nestedRoutes.json";
|
4
|
+
export var MAIN_ENTRY_NAME = "main";
|
5
|
+
export var SERVER_BUNDLE_DIRECTORY = "bundles";
|
6
|
+
export var SERVER_WORKER_BUNDLE_DIRECTORY = "worker";
|
7
|
+
export var ENTRY_NAME_PATTERN = "^[a-zA-Z0-9_-]+$";
|
8
|
+
export var SERVER_RENDER_FUNCTION_NAME = "serverRender";
|
9
|
+
export var LOADABLE_STATS_FILE = "loadable-stats.json";
|
10
|
+
export var API_DIR = "api";
|
11
|
+
export var SERVER_DIR = "server";
|
12
|
+
export var SHARED_DIR = "shared";
|
13
|
+
export var CONFIG_CACHE_DIR = "./node_modules/.cache/node-bundle-require";
|
14
|
+
export var CONFIG_FILE_EXTENSIONS = [
|
14
15
|
".js",
|
15
16
|
".ts",
|
16
17
|
".mjs"
|
17
18
|
];
|
18
|
-
export
|
19
|
-
export
|
20
|
-
export
|
21
|
-
export
|
22
|
-
export
|
23
|
-
export
|
19
|
+
export var OUTPUT_CONFIG_FILE = "modern.config.json";
|
20
|
+
export var DEFAULT_SERVER_CONFIG = "modern.server-runtime.config";
|
21
|
+
export var ROUTE_MANIFEST_FILE = "routes-manifest.json";
|
22
|
+
export var LOADER_ROUTES_DIR = "loader-routes";
|
23
|
+
export var DEFAULT_DEV_HOST = "0.0.0.0";
|
24
|
+
export var INTERNAL_APP_TOOLS_PLUGINS = {
|
24
25
|
"@modern-js/app-tools": "@modern-js/app-tools/cli",
|
25
26
|
"@modern-js/plugin-proxy": "@modern-js/plugin-proxy/cli",
|
26
27
|
"@modern-js/plugin-ssg": "@modern-js/plugin-ssg/cli",
|
@@ -36,10 +37,10 @@ export const INTERNAL_APP_TOOLS_PLUGINS = {
|
|
36
37
|
// legacy router (inner react-router-dom v5)
|
37
38
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
38
39
|
};
|
39
|
-
export
|
40
|
+
export var INTERNAL_APP_TOOLS_RUNTIME_PLUGINS = {
|
40
41
|
"@modern-js/runtime": "@modern-js/runtime/cli"
|
41
42
|
};
|
42
|
-
export
|
43
|
+
export var INTERNAL_MODULE_TOOLS_PLUGINS = {
|
43
44
|
"@modern-js/module-tools": "@modern-js/module-tools",
|
44
45
|
"@modern-js/doc-tools": "@modern-js/doc-tools",
|
45
46
|
"@modern-js/runtime": "@modern-js/runtime/cli",
|
@@ -49,16 +50,16 @@ export const INTERNAL_MODULE_TOOLS_PLUGINS = {
|
|
49
50
|
// legacy router (inner react-router-dom v5)
|
50
51
|
"@modern-js/plugin-router-legacy": "@modern-js/plugin-router-legacy/cli"
|
51
52
|
};
|
52
|
-
export
|
53
|
+
export var INTERNAL_MONOREPO_TOOLS_PLUGINS = {
|
53
54
|
"@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
|
54
55
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
|
55
56
|
};
|
56
|
-
export
|
57
|
+
export var INTERNAL_DOC_TOOLS_PLUGINS = {
|
57
58
|
"@modern-js/doc-tools": "@modern-js/doc-tools",
|
58
59
|
"@modern-js/runtime": "@modern-js/runtime/cli",
|
59
60
|
"@modern-js/plugin-testing": "@modern-js/plugin-testing/cli"
|
60
61
|
};
|
61
|
-
export
|
62
|
+
export var INTERNAL_CLI_PLUGINS = {
|
62
63
|
"@modern-js/app-tools": "@modern-js/app-tools/cli",
|
63
64
|
"@modern-js/monorepo-tools": "@modern-js/monorepo-tools/cli",
|
64
65
|
"@modern-js/module-tools": "@modern-js/module-tools",
|
@@ -79,19 +80,14 @@ export const INTERNAL_CLI_PLUGINS = {
|
|
79
80
|
// legacy router (inner react-router-dom v5)
|
80
81
|
"@modern-js/plugin-router-v5": "@modern-js/plugin-router-v5/cli"
|
81
82
|
};
|
82
|
-
export
|
83
|
-
export
|
84
|
-
export
|
85
|
-
export
|
86
|
-
export
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
[SERVER_PLUGIN_KOA]: "@modern-js/plugin-koa/server",
|
91
|
-
[SERVER_PLUGIN_SERVER]: "@modern-js/plugin-server/server",
|
92
|
-
[SERVER_PLUGIN_POLYFILL]: "@modern-js/plugin-polyfill/server"
|
93
|
-
};
|
94
|
-
export const DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
83
|
+
export var SERVER_PLUGIN_BFF = "@modern-js/plugin-bff";
|
84
|
+
export var SERVER_PLUGIN_EXPRESS = "@modern-js/plugin-express";
|
85
|
+
export var SERVER_PLUGIN_KOA = "@modern-js/plugin-koa";
|
86
|
+
export var SERVER_PLUGIN_SERVER = "@modern-js/plugin-server";
|
87
|
+
export var SERVER_PLUGIN_POLYFILL = "@modern-js/plugin-polyfill";
|
88
|
+
var _obj;
|
89
|
+
export var INTERNAL_SERVER_PLUGINS = (_obj = {}, _define_property(_obj, SERVER_PLUGIN_BFF, "@modern-js/plugin-bff/server"), _define_property(_obj, SERVER_PLUGIN_EXPRESS, "@modern-js/plugin-express/server"), _define_property(_obj, SERVER_PLUGIN_KOA, "@modern-js/plugin-koa/server"), _define_property(_obj, SERVER_PLUGIN_SERVER, "@modern-js/plugin-server/server"), _define_property(_obj, SERVER_PLUGIN_POLYFILL, "@modern-js/plugin-polyfill/server"), _obj);
|
90
|
+
export var DEFAULT_BABEL_PRESET_TYPESCRIPT_OPTIONS = {
|
95
91
|
allowNamespaces: true,
|
96
92
|
allExtensions: true,
|
97
93
|
allowDeclareFields: true,
|
package/dist/esm/cli/ensure.js
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
import path from "path";
|
2
|
-
export
|
3
|
-
|
2
|
+
export var ensureAbsolutePath = function(base, filePath) {
|
3
|
+
return path.isAbsolute(filePath) ? filePath : path.resolve(base, filePath);
|
4
|
+
};
|
5
|
+
export var ensureArray = function(params) {
|
4
6
|
if (Array.isArray(params)) {
|
5
7
|
return params;
|
6
8
|
}
|
package/dist/esm/cli/fs.js
CHANGED
@@ -1,14 +1,61 @@
|
|
1
|
+
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
+
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
1
3
|
import { fs } from "../compiled";
|
2
|
-
export
|
3
|
-
|
4
|
-
|
5
|
-
|
4
|
+
export var findExists = function(files) {
|
5
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
6
|
+
try {
|
7
|
+
for (var _iterator = files[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
8
|
+
var file = _step.value;
|
9
|
+
if (fs.existsSync(file) && fs.statSync(file).isFile()) {
|
10
|
+
return file;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
} catch (err) {
|
14
|
+
_didIteratorError = true;
|
15
|
+
_iteratorError = err;
|
16
|
+
} finally {
|
17
|
+
try {
|
18
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
19
|
+
_iterator.return();
|
20
|
+
}
|
21
|
+
} finally {
|
22
|
+
if (_didIteratorError) {
|
23
|
+
throw _iteratorError;
|
24
|
+
}
|
6
25
|
}
|
7
26
|
}
|
8
27
|
return false;
|
9
28
|
};
|
10
|
-
export
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
29
|
+
export var emptyDir = function() {
|
30
|
+
var _ref = _async_to_generator(function(dir) {
|
31
|
+
return _ts_generator(this, function(_state) {
|
32
|
+
switch (_state.label) {
|
33
|
+
case 0:
|
34
|
+
return [
|
35
|
+
4,
|
36
|
+
fs.pathExists(dir)
|
37
|
+
];
|
38
|
+
case 1:
|
39
|
+
if (!_state.sent())
|
40
|
+
return [
|
41
|
+
3,
|
42
|
+
3
|
43
|
+
];
|
44
|
+
return [
|
45
|
+
4,
|
46
|
+
fs.emptyDir(dir)
|
47
|
+
];
|
48
|
+
case 2:
|
49
|
+
_state.sent();
|
50
|
+
_state.label = 3;
|
51
|
+
case 3:
|
52
|
+
return [
|
53
|
+
2
|
54
|
+
];
|
55
|
+
}
|
56
|
+
});
|
57
|
+
});
|
58
|
+
return function emptyDir2(dir) {
|
59
|
+
return _ref.apply(this, arguments);
|
60
|
+
};
|
61
|
+
}();
|
@@ -1,16 +1,16 @@
|
|
1
|
+
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
1
2
|
import { isPlainObject } from "../is";
|
2
|
-
export
|
3
|
+
export var getEntryOptions = function(name, isMainEntry, baseOptions, optionsByEntries, packageName) {
|
3
4
|
if (optionsByEntries) {
|
4
|
-
|
5
|
+
var optionsByEntry = getOptionsByEntryName(name, optionsByEntries);
|
5
6
|
if (optionsByEntry === void 0 && isMainEntry && packageName) {
|
6
7
|
optionsByEntry = getOptionsByEntryName(packageName, optionsByEntries);
|
7
8
|
}
|
8
|
-
return optionsByEntry !== void 0 ? isPlainObject(optionsByEntry) && isPlainObject(baseOptions) ? {
|
9
|
-
...baseOptions,
|
10
|
-
...optionsByEntry
|
11
|
-
} : optionsByEntry : baseOptions;
|
9
|
+
return optionsByEntry !== void 0 ? isPlainObject(optionsByEntry) && isPlainObject(baseOptions) ? _object_spread({}, baseOptions, optionsByEntry) : optionsByEntry : baseOptions;
|
12
10
|
} else {
|
13
11
|
return baseOptions;
|
14
12
|
}
|
15
13
|
};
|
16
|
-
|
14
|
+
var getOptionsByEntryName = function(name, optionsByEntries) {
|
15
|
+
return optionsByEntries.hasOwnProperty(name) ? optionsByEntries[name] : void 0;
|
16
|
+
};
|