@modern-js/plugin 2.69.5 → 3.0.0-alpha.0
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/dist/cjs/cli/api.js +119 -0
- package/dist/cjs/cli/context.js +85 -0
- package/dist/cjs/cli/hooks.js +65 -0
- package/dist/cjs/cli/index.js +68 -0
- package/dist/cjs/cli/run/config/createLoadedConfig.js +87 -0
- package/dist/cjs/cli/run/config/createResolvedConfig.js +48 -0
- package/dist/cjs/cli/run/config/loadConfig.js +113 -0
- package/dist/cjs/cli/run/create.js +187 -0
- package/dist/cjs/cli/run/index.js +56 -0
- package/dist/cjs/cli/run/run.js +57 -0
- package/dist/cjs/cli/run/types.js +18 -0
- package/dist/cjs/cli/run/utils/checkIsDuplicationPlugin.js +45 -0
- package/dist/cjs/cli/run/utils/commander.js +56 -0
- package/dist/cjs/cli/run/utils/createFileWatcher.js +112 -0
- package/dist/cjs/cli/run/utils/debug.js +37 -0
- package/dist/cjs/cli/run/utils/initAppDir.js +55 -0
- package/dist/cjs/cli/run/utils/mergeConfig.js +66 -0
- package/dist/cjs/hooks.js +169 -0
- package/dist/cjs/index.js +53 -26
- package/dist/cjs/manager.js +135 -0
- package/dist/cjs/runtime/api.js +95 -0
- package/dist/cjs/runtime/context.js +60 -0
- package/dist/cjs/runtime/hooks.js +46 -0
- package/dist/cjs/runtime/index.js +51 -0
- package/dist/cjs/runtime/run/create.js +79 -0
- package/dist/cjs/runtime/run/index.js +37 -0
- package/dist/cjs/runtime/run/types.js +18 -0
- package/dist/cjs/server/api.js +96 -0
- package/dist/cjs/server/context.js +75 -0
- package/dist/cjs/server/hooks.js +43 -0
- package/dist/cjs/server/index.js +54 -0
- package/dist/cjs/server/run/create.js +79 -0
- package/dist/cjs/server/run/index.js +40 -0
- package/dist/cjs/server/run/types.js +18 -0
- package/dist/cjs/types/cli/api.js +18 -0
- package/dist/cjs/types/cli/context.js +18 -0
- package/dist/cjs/types/cli/hooks.js +18 -0
- package/dist/cjs/types/cli/index.js +18 -0
- package/dist/cjs/types/cli/plugin.js +18 -0
- package/dist/cjs/types/hooks.js +18 -0
- package/dist/cjs/types/index.js +18 -0
- package/dist/cjs/types/plugin.js +18 -0
- package/dist/cjs/types/runtime/api.js +18 -0
- package/dist/cjs/types/runtime/context.js +18 -0
- package/dist/cjs/types/runtime/hooks.js +18 -0
- package/dist/cjs/types/runtime/index.js +18 -0
- package/dist/cjs/types/runtime/plugin.js +18 -0
- package/dist/cjs/types/server/api.js +18 -0
- package/dist/cjs/types/server/context.js +18 -0
- package/dist/cjs/types/server/hooks.js +18 -0
- package/dist/cjs/types/server/index.js +18 -0
- package/dist/cjs/types/server/plugin.js +18 -0
- package/dist/cjs/types/utils.js +18 -0
- package/dist/esm/cli/api.mjs +85 -0
- package/dist/esm/cli/context.mjs +38 -0
- package/dist/esm/cli/hooks.mjs +31 -0
- package/dist/esm/cli/index.mjs +7 -0
- package/dist/esm/cli/run/config/createLoadedConfig.mjs +53 -0
- package/dist/esm/cli/run/config/createResolvedConfig.mjs +14 -0
- package/dist/esm/cli/run/config/loadConfig.mjs +59 -0
- package/dist/esm/cli/run/create.mjs +150 -0
- package/dist/esm/cli/run/index.mjs +7 -0
- package/dist/esm/cli/run/run.mjs +23 -0
- package/dist/esm/cli/run/types.mjs +0 -0
- package/dist/esm/cli/run/utils/checkIsDuplicationPlugin.mjs +11 -0
- package/dist/esm/cli/run/utils/commander.mjs +16 -0
- package/dist/esm/cli/run/utils/createFileWatcher.mjs +68 -0
- package/dist/esm/cli/run/utils/debug.mjs +3 -0
- package/dist/esm/cli/run/utils/initAppDir.mjs +11 -0
- package/dist/esm/cli/run/utils/mergeConfig.mjs +32 -0
- package/dist/esm/hooks.mjs +120 -0
- package/dist/esm/index.mjs +3 -0
- package/dist/esm/manager.mjs +101 -0
- package/dist/esm/runtime/api.mjs +61 -0
- package/dist/esm/runtime/context.mjs +23 -0
- package/dist/esm/runtime/hooks.mjs +12 -0
- package/dist/esm/runtime/index.mjs +5 -0
- package/dist/esm/runtime/run/create.mjs +45 -0
- package/dist/esm/runtime/run/index.mjs +3 -0
- package/dist/esm/runtime/run/types.mjs +0 -0
- package/dist/esm/server/api.mjs +59 -0
- package/dist/esm/server/context.mjs +38 -0
- package/dist/esm/server/hooks.mjs +9 -0
- package/dist/esm/server/index.mjs +5 -0
- package/dist/esm/server/run/create.mjs +45 -0
- package/dist/esm/server/run/index.mjs +3 -0
- package/dist/esm/server/run/types.mjs +0 -0
- package/dist/esm/types/cli/api.mjs +0 -0
- package/dist/esm/types/cli/context.mjs +0 -0
- package/dist/esm/types/cli/hooks.mjs +0 -0
- package/dist/esm/types/cli/index.mjs +0 -0
- package/dist/esm/types/cli/plugin.mjs +0 -0
- package/dist/esm/types/hooks.mjs +0 -0
- package/dist/esm/types/index.mjs +0 -0
- package/dist/esm/types/plugin.mjs +0 -0
- package/dist/esm/types/runtime/api.mjs +0 -0
- package/dist/esm/types/runtime/context.mjs +0 -0
- package/dist/esm/types/runtime/hooks.mjs +0 -0
- package/dist/esm/types/runtime/index.mjs +0 -0
- package/dist/esm/types/runtime/plugin.mjs +0 -0
- package/dist/esm/types/server/api.mjs +0 -0
- package/dist/esm/types/server/context.mjs +0 -0
- package/dist/esm/types/server/hooks.mjs +0 -0
- package/dist/esm/types/server/index.mjs +0 -0
- package/dist/esm/types/server/plugin.mjs +0 -0
- package/dist/esm/types/utils.mjs +0 -0
- package/dist/esm-node/cli/api.mjs +85 -0
- package/dist/esm-node/cli/context.mjs +38 -0
- package/dist/esm-node/cli/hooks.mjs +31 -0
- package/dist/esm-node/cli/index.mjs +7 -0
- package/dist/esm-node/cli/run/config/createLoadedConfig.mjs +53 -0
- package/dist/esm-node/cli/run/config/createResolvedConfig.mjs +14 -0
- package/dist/esm-node/cli/run/config/loadConfig.mjs +59 -0
- package/dist/esm-node/cli/run/create.mjs +150 -0
- package/dist/esm-node/cli/run/index.mjs +7 -0
- package/dist/esm-node/cli/run/run.mjs +23 -0
- package/dist/esm-node/cli/run/utils/checkIsDuplicationPlugin.mjs +11 -0
- package/dist/esm-node/cli/run/utils/commander.mjs +16 -0
- package/dist/esm-node/cli/run/utils/createFileWatcher.mjs +68 -0
- package/dist/esm-node/cli/run/utils/debug.mjs +3 -0
- package/dist/esm-node/cli/run/utils/initAppDir.mjs +11 -0
- package/dist/esm-node/cli/run/utils/mergeConfig.mjs +32 -0
- package/dist/esm-node/hooks.mjs +120 -0
- package/dist/esm-node/index.mjs +3 -0
- package/dist/esm-node/manager.mjs +101 -0
- package/dist/esm-node/runtime/api.mjs +61 -0
- package/dist/esm-node/runtime/context.mjs +23 -0
- package/dist/esm-node/runtime/hooks.mjs +12 -0
- package/dist/esm-node/runtime/index.mjs +5 -0
- package/dist/esm-node/runtime/run/create.mjs +45 -0
- package/dist/esm-node/runtime/run/index.mjs +3 -0
- package/dist/esm-node/runtime/run/types.mjs +0 -0
- package/dist/esm-node/server/api.mjs +59 -0
- package/dist/esm-node/server/context.mjs +38 -0
- package/dist/esm-node/server/hooks.mjs +9 -0
- package/dist/esm-node/server/index.mjs +5 -0
- package/dist/esm-node/server/run/create.mjs +45 -0
- package/dist/esm-node/server/run/index.mjs +3 -0
- package/dist/esm-node/server/run/types.mjs +0 -0
- package/dist/esm-node/types/cli/api.mjs +0 -0
- package/dist/esm-node/types/cli/context.mjs +0 -0
- package/dist/esm-node/types/cli/hooks.mjs +0 -0
- package/dist/esm-node/types/cli/index.mjs +0 -0
- package/dist/esm-node/types/cli/plugin.mjs +0 -0
- package/dist/esm-node/types/hooks.mjs +0 -0
- package/dist/esm-node/types/index.mjs +0 -0
- package/dist/esm-node/types/plugin.mjs +0 -0
- package/dist/esm-node/types/runtime/api.mjs +0 -0
- package/dist/esm-node/types/runtime/context.mjs +0 -0
- package/dist/esm-node/types/runtime/hooks.mjs +0 -0
- package/dist/esm-node/types/runtime/index.mjs +0 -0
- package/dist/esm-node/types/runtime/plugin.mjs +0 -0
- package/dist/esm-node/types/server/api.mjs +0 -0
- package/dist/esm-node/types/server/context.mjs +0 -0
- package/dist/esm-node/types/server/hooks.mjs +0 -0
- package/dist/esm-node/types/server/index.mjs +0 -0
- package/dist/esm-node/types/server/plugin.mjs +0 -0
- package/dist/esm-node/types/utils.mjs +0 -0
- package/dist/types/cli/api.d.ts +8 -0
- package/dist/types/cli/context.d.ts +19 -0
- package/dist/types/cli/hooks.d.ts +42 -0
- package/dist/types/cli/index.d.ts +6 -0
- package/dist/types/cli/run/config/createLoadedConfig.d.ts +2 -0
- package/dist/types/cli/run/config/createResolvedConfig.d.ts +3 -0
- package/dist/types/cli/run/config/loadConfig.d.ts +25 -0
- package/dist/types/cli/run/create.d.ts +16 -0
- package/dist/types/cli/run/index.d.ts +13 -0
- package/dist/types/cli/run/run.d.ts +2 -0
- package/dist/types/cli/run/types.d.ts +32 -0
- package/dist/types/cli/run/utils/checkIsDuplicationPlugin.d.ts +1 -0
- package/dist/types/cli/run/utils/commander.d.ts +5 -0
- package/dist/types/cli/run/utils/createFileWatcher.d.ts +3 -0
- package/dist/types/cli/run/utils/debug.d.ts +1 -0
- package/dist/types/cli/run/utils/initAppDir.d.ts +1 -0
- package/dist/types/cli/run/utils/mergeConfig.d.ts +2 -0
- package/dist/types/hooks.d.ts +7 -0
- package/dist/types/index.d.ts +7 -4
- package/dist/types/manager.d.ts +5 -0
- package/dist/types/runtime/api.d.ts +9 -0
- package/dist/types/runtime/context.d.ts +11 -0
- package/dist/types/runtime/hooks.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/run/create.d.ts +7 -0
- package/dist/types/runtime/run/index.d.ts +5 -0
- package/dist/types/runtime/run/types.d.ts +6 -0
- package/dist/types/server/api.d.ts +9 -0
- package/dist/types/server/context.d.ts +13 -0
- package/dist/types/server/hooks.d.ts +9 -0
- package/dist/types/server/index.d.ts +4 -0
- package/dist/types/server/run/create.d.ts +7 -0
- package/dist/types/server/run/index.d.ts +8 -0
- package/dist/types/server/run/types.d.ts +22 -0
- package/dist/types/types/cli/api.d.ts +49 -0
- package/dist/types/types/cli/context.d.ts +42 -0
- package/dist/types/types/cli/hooks.d.ts +72 -0
- package/dist/types/types/cli/index.d.ts +4 -0
- package/dist/types/types/cli/plugin.d.ts +17 -0
- package/dist/types/types/hooks.d.ts +27 -0
- package/dist/types/types/index.d.ts +4 -0
- package/dist/types/types/plugin.d.ts +46 -0
- package/dist/types/types/runtime/api.d.ts +22 -0
- package/dist/types/types/runtime/context.d.ts +13 -0
- package/dist/types/types/runtime/hooks.d.ts +39 -0
- package/dist/types/types/runtime/index.d.ts +4 -0
- package/dist/types/types/runtime/plugin.d.ts +14 -0
- package/dist/types/types/server/api.d.ts +19 -0
- package/dist/types/types/server/context.d.ts +28 -0
- package/dist/types/types/server/hooks.d.ts +24 -0
- package/dist/types/types/server/index.d.ts +4 -0
- package/dist/types/types/server/plugin.d.ts +14 -0
- package/dist/types/types/utils.d.ts +7 -0
- package/package.json +68 -14
- package/rslib.config.mts +4 -0
- package/rstest.config.ts +5 -0
- package/dist/cjs/farrow-pipeline/context.js +0 -44
- package/dist/cjs/farrow-pipeline/counter.js +0 -37
- package/dist/cjs/farrow-pipeline/index.js +0 -87
- package/dist/cjs/manager/async.js +0 -124
- package/dist/cjs/manager/index.js +0 -26
- package/dist/cjs/manager/shared.js +0 -60
- package/dist/cjs/manager/sync.js +0 -194
- package/dist/cjs/manager/types.js +0 -16
- package/dist/cjs/waterfall/async.js +0 -68
- package/dist/cjs/waterfall/index.js +0 -24
- package/dist/cjs/waterfall/sync.js +0 -67
- package/dist/cjs/workflow/async.js +0 -60
- package/dist/cjs/workflow/index.js +0 -30
- package/dist/cjs/workflow/interrupt.js +0 -64
- package/dist/cjs/workflow/parallel.js +0 -53
- package/dist/cjs/workflow/sync.js +0 -56
- package/dist/cjs/workflow/syncParallel.js +0 -55
- package/dist/esm/index.js +0 -882
- package/dist/esm-node/farrow-pipeline/context.js +0 -20
- package/dist/esm-node/farrow-pipeline/counter.js +0 -13
- package/dist/esm-node/farrow-pipeline/index.js +0 -60
- package/dist/esm-node/index.js +0 -4
- package/dist/esm-node/manager/async.js +0 -106
- package/dist/esm-node/manager/index.js +0 -3
- package/dist/esm-node/manager/shared.js +0 -32
- package/dist/esm-node/manager/sync.js +0 -172
- package/dist/esm-node/waterfall/async.js +0 -42
- package/dist/esm-node/waterfall/index.js +0 -2
- package/dist/esm-node/waterfall/sync.js +0 -41
- package/dist/esm-node/workflow/async.js +0 -35
- package/dist/esm-node/workflow/index.js +0 -5
- package/dist/esm-node/workflow/interrupt.js +0 -39
- package/dist/esm-node/workflow/parallel.js +0 -28
- package/dist/esm-node/workflow/sync.js +0 -31
- package/dist/esm-node/workflow/syncParallel.js +0 -30
- package/dist/types/farrow-pipeline/context.d.ts +0 -12
- package/dist/types/farrow-pipeline/counter.d.ts +0 -11
- package/dist/types/farrow-pipeline/index.d.ts +0 -29
- package/dist/types/manager/async.d.ts +0 -54
- package/dist/types/manager/index.d.ts +0 -3
- package/dist/types/manager/shared.d.ts +0 -12
- package/dist/types/manager/sync.d.ts +0 -66
- package/dist/types/manager/types.d.ts +0 -33
- package/dist/types/waterfall/async.d.ts +0 -21
- package/dist/types/waterfall/index.d.ts +0 -2
- package/dist/types/waterfall/sync.d.ts +0 -20
- package/dist/types/workflow/async.d.ts +0 -12
- package/dist/types/workflow/index.d.ts +0 -5
- package/dist/types/workflow/interrupt.d.ts +0 -12
- package/dist/types/workflow/parallel.d.ts +0 -10
- package/dist/types/workflow/sync.d.ts +0 -11
- package/dist/types/workflow/syncParallel.d.ts +0 -10
- /package/dist/esm-node/{manager/types.js → cli/run/types.mjs} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
initPluginAPI: ()=>initPluginAPI
|
|
28
|
+
});
|
|
29
|
+
const lodash_namespaceObject = require("@modern-js/utils/lodash");
|
|
30
|
+
const debug_js_namespaceObject = require("./run/utils/debug.js");
|
|
31
|
+
function initPluginAPI({ context, pluginManager }) {
|
|
32
|
+
const { hooks, extendsHooks, plugins } = context;
|
|
33
|
+
function getAppContext() {
|
|
34
|
+
if (context) {
|
|
35
|
+
const { hooks, extendsHooks, config, normalizedConfig, pluginAPI, ...appContext } = context;
|
|
36
|
+
appContext._internalContext = context;
|
|
37
|
+
return appContext;
|
|
38
|
+
}
|
|
39
|
+
throw new Error('Cannot access context');
|
|
40
|
+
}
|
|
41
|
+
function getConfig() {
|
|
42
|
+
if (context.config) return context.config;
|
|
43
|
+
throw new Error('Cannot access config');
|
|
44
|
+
}
|
|
45
|
+
function getNormalizedConfig() {
|
|
46
|
+
if (context.normalizedConfig) return context.normalizedConfig;
|
|
47
|
+
throw new Error('Cannot access normalized config');
|
|
48
|
+
}
|
|
49
|
+
function getHooks() {
|
|
50
|
+
return context.hooks;
|
|
51
|
+
}
|
|
52
|
+
const extendsPluginApi = {};
|
|
53
|
+
plugins.forEach((plugin)=>{
|
|
54
|
+
const { _registryApi } = plugin;
|
|
55
|
+
if (_registryApi) {
|
|
56
|
+
const apis = _registryApi(getAppContext, updateAppContext);
|
|
57
|
+
Object.keys(apis).forEach((apiName)=>{
|
|
58
|
+
extendsPluginApi[apiName] = apis[apiName];
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
if (extendsHooks) Object.keys(extendsHooks).forEach((hookName)=>{
|
|
63
|
+
extendsPluginApi[hookName] = extendsHooks[hookName].tap;
|
|
64
|
+
});
|
|
65
|
+
function updateAppContext(updateContext) {
|
|
66
|
+
context = (0, lodash_namespaceObject.assign)(context, updateContext);
|
|
67
|
+
}
|
|
68
|
+
const pluginAPI = {
|
|
69
|
+
isPluginExists: pluginManager.isPluginExists,
|
|
70
|
+
getAppContext,
|
|
71
|
+
getConfig,
|
|
72
|
+
getNormalizedConfig,
|
|
73
|
+
getHooks,
|
|
74
|
+
updateAppContext,
|
|
75
|
+
config: hooks.config.tap,
|
|
76
|
+
modifyConfig: hooks.modifyConfig.tap,
|
|
77
|
+
modifyResolvedConfig: hooks.modifyResolvedConfig.tap,
|
|
78
|
+
modifyRsbuildConfig: hooks.modifyRsbuildConfig.tap,
|
|
79
|
+
modifyBundlerChain: hooks.modifyBundlerChain.tap,
|
|
80
|
+
modifyRspackConfig: hooks.modifyRspackConfig.tap,
|
|
81
|
+
modifyHtmlPartials: hooks.modifyHtmlPartials.tap,
|
|
82
|
+
addCommand: hooks.addCommand.tap,
|
|
83
|
+
onPrepare: hooks.onPrepare.tap,
|
|
84
|
+
addWatchFiles: hooks.addWatchFiles.tap,
|
|
85
|
+
onFileChanged: hooks.onFileChanged.tap,
|
|
86
|
+
onBeforeRestart: hooks.onBeforeRestart.tap,
|
|
87
|
+
onBeforeCreateCompiler: hooks.onBeforeCreateCompiler.tap,
|
|
88
|
+
onDevCompileDone: hooks.onDevCompileDone.tap,
|
|
89
|
+
onAfterCreateCompiler: hooks.onAfterCreateCompiler.tap,
|
|
90
|
+
onBeforeBuild: hooks.onBeforeBuild.tap,
|
|
91
|
+
onAfterBuild: hooks.onAfterBuild.tap,
|
|
92
|
+
onBeforeDev: hooks.onBeforeDev.tap,
|
|
93
|
+
onAfterDev: hooks.onAfterDev.tap,
|
|
94
|
+
onBeforeDeploy: hooks.onBeforeDeploy.tap,
|
|
95
|
+
onAfterDeploy: hooks.onAfterDeploy.tap,
|
|
96
|
+
onBeforeExit: hooks.onBeforeExit.tap,
|
|
97
|
+
_internalRuntimePlugins: hooks._internalRuntimePlugins.tap,
|
|
98
|
+
_internalServerPlugins: hooks._internalServerPlugins.tap,
|
|
99
|
+
modifyServerRoutes: hooks.modifyServerRoutes.tap,
|
|
100
|
+
...extendsPluginApi
|
|
101
|
+
};
|
|
102
|
+
if ("u" < typeof Proxy) return pluginAPI;
|
|
103
|
+
return new Proxy(pluginAPI, {
|
|
104
|
+
get (target, prop) {
|
|
105
|
+
if ('then' === prop) return;
|
|
106
|
+
if (prop in target) return target[prop];
|
|
107
|
+
return ()=>{
|
|
108
|
+
(0, debug_js_namespaceObject.debug)(`api.${prop.toString()} not exist`);
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
exports.initPluginAPI = __webpack_exports__.initPluginAPI;
|
|
114
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
115
|
+
"initPluginAPI"
|
|
116
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
117
|
+
Object.defineProperty(exports, '__esModule', {
|
|
118
|
+
value: true
|
|
119
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
initAppContext: ()=>initAppContext,
|
|
37
|
+
createContext: ()=>createContext
|
|
38
|
+
});
|
|
39
|
+
const external_path_namespaceObject = require("path");
|
|
40
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
41
|
+
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
42
|
+
function initAppContext(params) {
|
|
43
|
+
const { appDirectory, srcDir = 'src', distDir = 'dist' } = params;
|
|
44
|
+
return {
|
|
45
|
+
metaName: params.metaName,
|
|
46
|
+
packageName: params.packageName,
|
|
47
|
+
configFile: params.configFile,
|
|
48
|
+
command: params.command,
|
|
49
|
+
isProd: 'production' === process.env.NODE_ENV,
|
|
50
|
+
appDirectory: appDirectory,
|
|
51
|
+
srcDirectory: external_path_default().resolve(appDirectory, srcDir),
|
|
52
|
+
distDirectory: '',
|
|
53
|
+
nodeModulesDirectory: external_path_default().resolve(appDirectory, 'node_modules'),
|
|
54
|
+
plugins: params.plugins
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
async function createContext({ appContext, config, normalizedConfig }) {
|
|
58
|
+
const { plugins } = appContext;
|
|
59
|
+
const extendsHooks = {};
|
|
60
|
+
plugins.forEach((plugin)=>{
|
|
61
|
+
const { registryHooks = {} } = plugin;
|
|
62
|
+
Object.keys(registryHooks).forEach((hookName)=>{
|
|
63
|
+
extendsHooks[hookName] = registryHooks[hookName];
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
return {
|
|
67
|
+
...appContext,
|
|
68
|
+
hooks: {
|
|
69
|
+
...(0, external_hooks_js_namespaceObject.initHooks)(),
|
|
70
|
+
...extendsHooks
|
|
71
|
+
},
|
|
72
|
+
extendsHooks,
|
|
73
|
+
config,
|
|
74
|
+
normalizedConfig
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
exports.createContext = __webpack_exports__.createContext;
|
|
78
|
+
exports.initAppContext = __webpack_exports__.initAppContext;
|
|
79
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
80
|
+
"createContext",
|
|
81
|
+
"initAppContext"
|
|
82
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
83
|
+
Object.defineProperty(exports, '__esModule', {
|
|
84
|
+
value: true
|
|
85
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
initHooks: ()=>initHooks
|
|
28
|
+
});
|
|
29
|
+
const external_hooks_js_namespaceObject = require("../hooks.js");
|
|
30
|
+
function initHooks() {
|
|
31
|
+
return {
|
|
32
|
+
config: (0, external_hooks_js_namespaceObject.createCollectAsyncHook)(),
|
|
33
|
+
modifyConfig: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
34
|
+
modifyResolvedConfig: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
35
|
+
modifyRsbuildConfig: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
36
|
+
modifyBundlerChain: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
37
|
+
modifyRspackConfig: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
38
|
+
modifyHtmlPartials: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
39
|
+
addCommand: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
40
|
+
addWatchFiles: (0, external_hooks_js_namespaceObject.createCollectAsyncHook)(),
|
|
41
|
+
onPrepare: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
42
|
+
onFileChanged: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
43
|
+
onBeforeRestart: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
44
|
+
onBeforeCreateCompiler: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
45
|
+
onAfterCreateCompiler: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
46
|
+
onDevCompileDone: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
47
|
+
onBeforeBuild: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
48
|
+
onAfterBuild: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
49
|
+
onBeforeDev: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
50
|
+
onAfterDev: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
51
|
+
onBeforeDeploy: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
52
|
+
onAfterDeploy: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
53
|
+
onBeforeExit: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
54
|
+
_internalRuntimePlugins: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
55
|
+
_internalServerPlugins: (0, external_hooks_js_namespaceObject.createAsyncHook)(),
|
|
56
|
+
modifyServerRoutes: (0, external_hooks_js_namespaceObject.createAsyncHook)()
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
exports.initHooks = __webpack_exports__.initHooks;
|
|
60
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
61
|
+
"initHooks"
|
|
62
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
63
|
+
Object.defineProperty(exports, '__esModule', {
|
|
64
|
+
value: true
|
|
65
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
cli: ()=>index_js_namespaceObject.cli,
|
|
28
|
+
mergeConfig: ()=>mergeConfig_js_namespaceObject.mergeConfig,
|
|
29
|
+
createContext: ()=>external_context_js_namespaceObject.createContext,
|
|
30
|
+
createStorybookOptions: ()=>create_js_namespaceObject.createStorybookOptions,
|
|
31
|
+
createCli: ()=>index_js_namespaceObject.createCli,
|
|
32
|
+
initAppContext: ()=>external_context_js_namespaceObject.initAppContext,
|
|
33
|
+
initHooks: ()=>external_hooks_js_namespaceObject.initHooks,
|
|
34
|
+
initPluginAPI: ()=>external_api_js_namespaceObject.initPluginAPI,
|
|
35
|
+
initAppDir: ()=>index_js_namespaceObject.initAppDir,
|
|
36
|
+
createLoadedConfig: ()=>index_js_namespaceObject.createLoadedConfig
|
|
37
|
+
});
|
|
38
|
+
const external_api_js_namespaceObject = require("./api.js");
|
|
39
|
+
const external_context_js_namespaceObject = require("./context.js");
|
|
40
|
+
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
41
|
+
const index_js_namespaceObject = require("./run/index.js");
|
|
42
|
+
const create_js_namespaceObject = require("./run/create.js");
|
|
43
|
+
const mergeConfig_js_namespaceObject = require("./run/utils/mergeConfig.js");
|
|
44
|
+
exports.cli = __webpack_exports__.cli;
|
|
45
|
+
exports.createCli = __webpack_exports__.createCli;
|
|
46
|
+
exports.createContext = __webpack_exports__.createContext;
|
|
47
|
+
exports.createLoadedConfig = __webpack_exports__.createLoadedConfig;
|
|
48
|
+
exports.createStorybookOptions = __webpack_exports__.createStorybookOptions;
|
|
49
|
+
exports.initAppContext = __webpack_exports__.initAppContext;
|
|
50
|
+
exports.initAppDir = __webpack_exports__.initAppDir;
|
|
51
|
+
exports.initHooks = __webpack_exports__.initHooks;
|
|
52
|
+
exports.initPluginAPI = __webpack_exports__.initPluginAPI;
|
|
53
|
+
exports.mergeConfig = __webpack_exports__.mergeConfig;
|
|
54
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
55
|
+
"cli",
|
|
56
|
+
"createCli",
|
|
57
|
+
"createContext",
|
|
58
|
+
"createLoadedConfig",
|
|
59
|
+
"createStorybookOptions",
|
|
60
|
+
"initAppContext",
|
|
61
|
+
"initAppDir",
|
|
62
|
+
"initHooks",
|
|
63
|
+
"initPluginAPI",
|
|
64
|
+
"mergeConfig"
|
|
65
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
66
|
+
Object.defineProperty(exports, '__esModule', {
|
|
67
|
+
value: true
|
|
68
|
+
});
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createLoadedConfig: ()=>createLoadedConfig
|
|
28
|
+
});
|
|
29
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
30
|
+
const mergeConfig_js_namespaceObject = require("../utils/mergeConfig.js");
|
|
31
|
+
const external_loadConfig_js_namespaceObject = require("./loadConfig.js");
|
|
32
|
+
async function getConfigObject(config) {
|
|
33
|
+
if ('function' == typeof config) return await config({
|
|
34
|
+
env: (0, utils_namespaceObject.getNodeEnv)(),
|
|
35
|
+
command: (0, utils_namespaceObject.getCommand)()
|
|
36
|
+
}) || {};
|
|
37
|
+
return config || {};
|
|
38
|
+
}
|
|
39
|
+
async function loadLocalConfig(appDirectory, configFile) {
|
|
40
|
+
let localConfigFile = false;
|
|
41
|
+
if ('string' == typeof configFile) {
|
|
42
|
+
for (const ext of utils_namespaceObject.CONFIG_FILE_EXTENSIONS)if (configFile.endsWith(ext)) {
|
|
43
|
+
const replacedPath = configFile.replace(ext, `.local${ext}`);
|
|
44
|
+
if (utils_namespaceObject.fs.existsSync(replacedPath)) localConfigFile = replacedPath;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (localConfigFile) {
|
|
48
|
+
const loaded = await (0, external_loadConfig_js_namespaceObject.loadConfig)(appDirectory, localConfigFile);
|
|
49
|
+
return getConfigObject(loaded.config);
|
|
50
|
+
}
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
async function createLoadedConfig(appDirectory, configFilePath, otherConfig) {
|
|
54
|
+
const configFile = (0, external_loadConfig_js_namespaceObject.getConfigFilePath)(appDirectory, configFilePath);
|
|
55
|
+
const loaded = await (0, external_loadConfig_js_namespaceObject.loadConfig)(appDirectory, configFile);
|
|
56
|
+
if (!loaded.config && !loaded.pkgConfig) {
|
|
57
|
+
utils_namespaceObject.logger.warn("Can not find any config file in the current project, please check if you have a correct config file.");
|
|
58
|
+
utils_namespaceObject.logger.warn(`Current project path: ${utils_namespaceObject.chalk.yellow(appDirectory)}`);
|
|
59
|
+
}
|
|
60
|
+
const config = await getConfigObject(loaded.config);
|
|
61
|
+
let mergedConfig = config;
|
|
62
|
+
if ((0, utils_namespaceObject.isDevCommand)()) {
|
|
63
|
+
const localConfig = await loadLocalConfig(appDirectory, configFile);
|
|
64
|
+
if (localConfig) mergedConfig = (0, mergeConfig_js_namespaceObject.mergeConfig)([
|
|
65
|
+
mergedConfig,
|
|
66
|
+
localConfig
|
|
67
|
+
]);
|
|
68
|
+
}
|
|
69
|
+
if (otherConfig) mergedConfig = (0, mergeConfig_js_namespaceObject.mergeConfig)([
|
|
70
|
+
mergedConfig,
|
|
71
|
+
otherConfig
|
|
72
|
+
]);
|
|
73
|
+
return {
|
|
74
|
+
packageName: loaded.packageName,
|
|
75
|
+
config: mergedConfig,
|
|
76
|
+
configFile: loaded.configFile,
|
|
77
|
+
pkgConfig: loaded.pkgConfig,
|
|
78
|
+
jsConfig: loaded.config
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
exports.createLoadedConfig = __webpack_exports__.createLoadedConfig;
|
|
82
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
83
|
+
"createLoadedConfig"
|
|
84
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
85
|
+
Object.defineProperty(exports, '__esModule', {
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
createResolveConfig: ()=>createResolveConfig
|
|
28
|
+
});
|
|
29
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
30
|
+
const mergeConfig_js_namespaceObject = require("../utils/mergeConfig.js");
|
|
31
|
+
const debug = (0, utils_namespaceObject.createDebugger)('resolve-config');
|
|
32
|
+
const createResolveConfig = async (loaded, configs)=>{
|
|
33
|
+
const { config: userConfig } = loaded;
|
|
34
|
+
const resolved = (0, mergeConfig_js_namespaceObject.mergeConfig)([
|
|
35
|
+
{},
|
|
36
|
+
...configs,
|
|
37
|
+
userConfig
|
|
38
|
+
]);
|
|
39
|
+
debug('resolved %o', resolved);
|
|
40
|
+
return resolved;
|
|
41
|
+
};
|
|
42
|
+
exports.createResolveConfig = __webpack_exports__.createResolveConfig;
|
|
43
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
44
|
+
"createResolveConfig"
|
|
45
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
46
|
+
Object.defineProperty(exports, '__esModule', {
|
|
47
|
+
value: true
|
|
48
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
|
+
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
14
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: definition[key]
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
})();
|
|
20
|
+
(()=>{
|
|
21
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
22
|
+
})();
|
|
23
|
+
(()=>{
|
|
24
|
+
__webpack_require__.r = (exports1)=>{
|
|
25
|
+
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
26
|
+
value: 'Module'
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
29
|
+
value: true
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
})();
|
|
33
|
+
var __webpack_exports__ = {};
|
|
34
|
+
__webpack_require__.r(__webpack_exports__);
|
|
35
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
36
|
+
loadConfig: ()=>loadConfig,
|
|
37
|
+
getConfigFilePath: ()=>getConfigFilePath,
|
|
38
|
+
clearFilesOverTime: ()=>clearFilesOverTime,
|
|
39
|
+
loadTypeScriptFile: ()=>loadTypeScriptFile
|
|
40
|
+
});
|
|
41
|
+
const external_path_namespaceObject = require("path");
|
|
42
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
43
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
44
|
+
const external_jiti_namespaceObject = require("jiti");
|
|
45
|
+
var external_jiti_default = /*#__PURE__*/ __webpack_require__.n(external_jiti_namespaceObject);
|
|
46
|
+
const getConfigFilePath = (appDirectory, configFilePath)=>{
|
|
47
|
+
if (external_path_default().isAbsolute(configFilePath)) return configFilePath;
|
|
48
|
+
return external_path_default().resolve(appDirectory, configFilePath);
|
|
49
|
+
};
|
|
50
|
+
const clearFilesOverTime = async (targetDir, overtime)=>{
|
|
51
|
+
try {
|
|
52
|
+
const files = await (0, utils_namespaceObject.globby)(`${targetDir}/**/*`, {
|
|
53
|
+
stats: true,
|
|
54
|
+
absolute: true
|
|
55
|
+
});
|
|
56
|
+
const currentTime = Date.now();
|
|
57
|
+
if (files.length > 0) {
|
|
58
|
+
for (const file of files)if (currentTime - file.stats.birthtimeMs >= 1000 * overtime) utils_namespaceObject.fs.unlinkSync(file.path);
|
|
59
|
+
}
|
|
60
|
+
} catch (err) {}
|
|
61
|
+
};
|
|
62
|
+
function loadConfigContent(configFile) {
|
|
63
|
+
const _require = external_jiti_default()(__filename, {
|
|
64
|
+
esmResolve: true,
|
|
65
|
+
requireCache: false,
|
|
66
|
+
interopDefault: true
|
|
67
|
+
});
|
|
68
|
+
if (!utils_namespaceObject.fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
69
|
+
try {
|
|
70
|
+
const config = _require(configFile);
|
|
71
|
+
return config.default || config;
|
|
72
|
+
} catch (e) {
|
|
73
|
+
if (e instanceof Error) e.message = `Get Error while loading config file: ${configFile}, please check it and retry.\n${e.message || ''}`;
|
|
74
|
+
throw e;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
const loadTypeScriptFile = (filePath)=>{
|
|
78
|
+
const _require = external_jiti_default()(__filename, {
|
|
79
|
+
esmResolve: true,
|
|
80
|
+
requireCache: false,
|
|
81
|
+
interopDefault: true
|
|
82
|
+
});
|
|
83
|
+
if (!utils_namespaceObject.fs.existsSync(filePath)) throw new Error(`TypeScript file does not exist: ${filePath}`);
|
|
84
|
+
try {
|
|
85
|
+
return _require(filePath);
|
|
86
|
+
} catch (e) {
|
|
87
|
+
if (e instanceof Error) e.message = `Get Error while loading TypeScript file: ${filePath}, please check it and retry.\n${e.message || ''}`;
|
|
88
|
+
throw e;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const loadConfig = async (appDirectory, configFile)=>{
|
|
92
|
+
const packageName = require(external_path_default().resolve(appDirectory, './package.json')).name;
|
|
93
|
+
let config;
|
|
94
|
+
if (configFile) config = loadConfigContent(configFile);
|
|
95
|
+
return {
|
|
96
|
+
packageName,
|
|
97
|
+
configFile,
|
|
98
|
+
config
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
exports.clearFilesOverTime = __webpack_exports__.clearFilesOverTime;
|
|
102
|
+
exports.getConfigFilePath = __webpack_exports__.getConfigFilePath;
|
|
103
|
+
exports.loadConfig = __webpack_exports__.loadConfig;
|
|
104
|
+
exports.loadTypeScriptFile = __webpack_exports__.loadTypeScriptFile;
|
|
105
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
106
|
+
"clearFilesOverTime",
|
|
107
|
+
"getConfigFilePath",
|
|
108
|
+
"loadConfig",
|
|
109
|
+
"loadTypeScriptFile"
|
|
110
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
111
|
+
Object.defineProperty(exports, '__esModule', {
|
|
112
|
+
value: true
|
|
113
|
+
});
|