@bleedingdev/modern-js-plugin 3.2.0-ultramodern.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/LICENSE +21 -0
- package/README.md +26 -0
- 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 +71 -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 +198 -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 +55 -0
- 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 +6 -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 +60 -0
- package/dist/esm/cli/run/create.mjs +158 -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 +2 -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 +4 -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 +4 -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 +86 -0
- package/dist/esm-node/cli/context.mjs +39 -0
- package/dist/esm-node/cli/hooks.mjs +32 -0
- package/dist/esm-node/cli/index.mjs +7 -0
- package/dist/esm-node/cli/run/config/createLoadedConfig.mjs +54 -0
- package/dist/esm-node/cli/run/config/createResolvedConfig.mjs +15 -0
- package/dist/esm-node/cli/run/config/loadConfig.mjs +63 -0
- package/dist/esm-node/cli/run/create.mjs +159 -0
- package/dist/esm-node/cli/run/index.mjs +8 -0
- package/dist/esm-node/cli/run/run.mjs +24 -0
- package/dist/esm-node/cli/run/types.mjs +1 -0
- package/dist/esm-node/cli/run/utils/checkIsDuplicationPlugin.mjs +12 -0
- package/dist/esm-node/cli/run/utils/commander.mjs +17 -0
- package/dist/esm-node/cli/run/utils/createFileWatcher.mjs +69 -0
- package/dist/esm-node/cli/run/utils/debug.mjs +4 -0
- package/dist/esm-node/cli/run/utils/initAppDir.mjs +12 -0
- package/dist/esm-node/cli/run/utils/mergeConfig.mjs +33 -0
- package/dist/esm-node/hooks.mjs +121 -0
- package/dist/esm-node/index.mjs +3 -0
- package/dist/esm-node/manager.mjs +102 -0
- package/dist/esm-node/runtime/api.mjs +62 -0
- package/dist/esm-node/runtime/context.mjs +24 -0
- package/dist/esm-node/runtime/hooks.mjs +13 -0
- package/dist/esm-node/runtime/index.mjs +5 -0
- package/dist/esm-node/runtime/run/create.mjs +46 -0
- package/dist/esm-node/runtime/run/index.mjs +4 -0
- package/dist/esm-node/runtime/run/types.mjs +1 -0
- package/dist/esm-node/server/api.mjs +60 -0
- package/dist/esm-node/server/context.mjs +39 -0
- package/dist/esm-node/server/hooks.mjs +10 -0
- package/dist/esm-node/server/index.mjs +5 -0
- package/dist/esm-node/server/run/create.mjs +46 -0
- package/dist/esm-node/server/run/index.mjs +4 -0
- package/dist/esm-node/server/run/types.mjs +1 -0
- package/dist/esm-node/types/cli/api.mjs +1 -0
- package/dist/esm-node/types/cli/context.mjs +1 -0
- package/dist/esm-node/types/cli/hooks.mjs +1 -0
- package/dist/esm-node/types/cli/index.mjs +1 -0
- package/dist/esm-node/types/cli/plugin.mjs +1 -0
- package/dist/esm-node/types/hooks.mjs +1 -0
- package/dist/esm-node/types/index.mjs +1 -0
- package/dist/esm-node/types/plugin.mjs +1 -0
- package/dist/esm-node/types/runtime/api.mjs +1 -0
- package/dist/esm-node/types/runtime/context.mjs +1 -0
- package/dist/esm-node/types/runtime/hooks.mjs +1 -0
- package/dist/esm-node/types/runtime/index.mjs +1 -0
- package/dist/esm-node/types/runtime/plugin.mjs +1 -0
- package/dist/esm-node/types/server/api.mjs +1 -0
- package/dist/esm-node/types/server/context.mjs +1 -0
- package/dist/esm-node/types/server/hooks.mjs +1 -0
- package/dist/esm-node/types/server/index.mjs +1 -0
- package/dist/esm-node/types/server/plugin.mjs +1 -0
- package/dist/esm-node/types/utils.mjs +1 -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 +24 -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 -0
- 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 +45 -0
- package/dist/types/types/runtime/api.d.ts +21 -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 +111 -0
- package/rslib.config.mts +4 -0
- package/rstest.config.mts +5 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present Modern.js
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://modernjs.dev" target="blank"><img src="https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png" width="300" alt="Modern.js Logo" /></a>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">Modern.js</h1>
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
A Progressive React Framework for modern web development.
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
## Getting Started
|
|
12
|
+
|
|
13
|
+
Please follow [Quick Start](https://modernjs.dev/en/guides/get-started/quick-start) to get started with Modern.js.
|
|
14
|
+
|
|
15
|
+
## Documentation
|
|
16
|
+
|
|
17
|
+
- [English Documentation](https://modernjs.dev/en/)
|
|
18
|
+
- [中文文档](https://modernjs.dev)
|
|
19
|
+
|
|
20
|
+
## Contributing
|
|
21
|
+
|
|
22
|
+
Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/blob/main/CONTRIBUTING.md).
|
|
23
|
+
|
|
24
|
+
## License
|
|
25
|
+
|
|
26
|
+
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
|
@@ -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
|
+
createContext: ()=>createContext,
|
|
37
|
+
initAppContext: ()=>initAppContext
|
|
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,71 @@
|
|
|
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
|
+
createCli: ()=>index_js_namespaceObject.createCli,
|
|
29
|
+
createConfigOptions: ()=>create_js_namespaceObject.createConfigOptions,
|
|
30
|
+
createContext: ()=>external_context_js_namespaceObject.createContext,
|
|
31
|
+
createLoadedConfig: ()=>index_js_namespaceObject.createLoadedConfig,
|
|
32
|
+
createStorybookOptions: ()=>create_js_namespaceObject.createStorybookOptions,
|
|
33
|
+
initAppContext: ()=>external_context_js_namespaceObject.initAppContext,
|
|
34
|
+
initAppDir: ()=>index_js_namespaceObject.initAppDir,
|
|
35
|
+
initHooks: ()=>external_hooks_js_namespaceObject.initHooks,
|
|
36
|
+
initPluginAPI: ()=>external_api_js_namespaceObject.initPluginAPI,
|
|
37
|
+
mergeConfig: ()=>mergeConfig_js_namespaceObject.mergeConfig
|
|
38
|
+
});
|
|
39
|
+
const external_api_js_namespaceObject = require("./api.js");
|
|
40
|
+
const external_context_js_namespaceObject = require("./context.js");
|
|
41
|
+
const external_hooks_js_namespaceObject = require("./hooks.js");
|
|
42
|
+
const index_js_namespaceObject = require("./run/index.js");
|
|
43
|
+
const create_js_namespaceObject = require("./run/create.js");
|
|
44
|
+
const mergeConfig_js_namespaceObject = require("./run/utils/mergeConfig.js");
|
|
45
|
+
exports.cli = __webpack_exports__.cli;
|
|
46
|
+
exports.createCli = __webpack_exports__.createCli;
|
|
47
|
+
exports.createConfigOptions = __webpack_exports__.createConfigOptions;
|
|
48
|
+
exports.createContext = __webpack_exports__.createContext;
|
|
49
|
+
exports.createLoadedConfig = __webpack_exports__.createLoadedConfig;
|
|
50
|
+
exports.createStorybookOptions = __webpack_exports__.createStorybookOptions;
|
|
51
|
+
exports.initAppContext = __webpack_exports__.initAppContext;
|
|
52
|
+
exports.initAppDir = __webpack_exports__.initAppDir;
|
|
53
|
+
exports.initHooks = __webpack_exports__.initHooks;
|
|
54
|
+
exports.initPluginAPI = __webpack_exports__.initPluginAPI;
|
|
55
|
+
exports.mergeConfig = __webpack_exports__.mergeConfig;
|
|
56
|
+
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
57
|
+
"cli",
|
|
58
|
+
"createCli",
|
|
59
|
+
"createConfigOptions",
|
|
60
|
+
"createContext",
|
|
61
|
+
"createLoadedConfig",
|
|
62
|
+
"createStorybookOptions",
|
|
63
|
+
"initAppContext",
|
|
64
|
+
"initAppDir",
|
|
65
|
+
"initHooks",
|
|
66
|
+
"initPluginAPI",
|
|
67
|
+
"mergeConfig"
|
|
68
|
+
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
69
|
+
Object.defineProperty(exports, '__esModule', {
|
|
70
|
+
value: true
|
|
71
|
+
});
|
|
@@ -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
|
+
clearFilesOverTime: ()=>clearFilesOverTime,
|
|
37
|
+
getConfigFilePath: ()=>getConfigFilePath,
|
|
38
|
+
loadConfig: ()=>loadConfig,
|
|
39
|
+
loadTypeScriptFile: ()=>loadTypeScriptFile
|
|
40
|
+
});
|
|
41
|
+
const utils_namespaceObject = require("@modern-js/utils");
|
|
42
|
+
const external_jiti_namespaceObject = require("jiti");
|
|
43
|
+
const external_path_namespaceObject = require("path");
|
|
44
|
+
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
45
|
+
const getConfigFilePath = (appDirectory, configFilePath)=>{
|
|
46
|
+
if (external_path_default().isAbsolute(configFilePath)) return configFilePath;
|
|
47
|
+
return external_path_default().resolve(appDirectory, configFilePath);
|
|
48
|
+
};
|
|
49
|
+
const clearFilesOverTime = async (targetDir, overtime)=>{
|
|
50
|
+
try {
|
|
51
|
+
const files = await (0, utils_namespaceObject.globby)(`${targetDir}/**/*`, {
|
|
52
|
+
stats: true,
|
|
53
|
+
absolute: true
|
|
54
|
+
});
|
|
55
|
+
const currentTime = Date.now();
|
|
56
|
+
if (files.length > 0) {
|
|
57
|
+
for (const file of files)if (currentTime - file.stats.birthtimeMs >= 1000 * overtime) utils_namespaceObject.fs.unlinkSync(file.path);
|
|
58
|
+
}
|
|
59
|
+
} catch (err) {}
|
|
60
|
+
};
|
|
61
|
+
async function loadConfigContent(configFile) {
|
|
62
|
+
const jitiFrom = __filename;
|
|
63
|
+
const jiti = (0, external_jiti_namespaceObject.createJiti)(jitiFrom, {
|
|
64
|
+
requireCache: false,
|
|
65
|
+
interopDefault: true
|
|
66
|
+
});
|
|
67
|
+
if (!utils_namespaceObject.fs.existsSync(configFile)) throw new Error(`Configuration file does not exist: ${configFile}`);
|
|
68
|
+
try {
|
|
69
|
+
let config;
|
|
70
|
+
config = jiti(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 jiti = (0, external_jiti_namespaceObject.createJiti)(__filename, {
|
|
79
|
+
requireCache: false,
|
|
80
|
+
interopDefault: true
|
|
81
|
+
});
|
|
82
|
+
if (!utils_namespaceObject.fs.existsSync(filePath)) throw new Error(`TypeScript file does not exist: ${filePath}`);
|
|
83
|
+
try {
|
|
84
|
+
return jiti(filePath);
|
|
85
|
+
} catch (e) {
|
|
86
|
+
if (e instanceof Error) e.message = `Get Error while loading TypeScript file: ${filePath}, please check it and retry.\n${e.message || ''}`;
|
|
87
|
+
throw e;
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const loadConfig = async (appDirectory, configFile)=>{
|
|
91
|
+
const pkg = await (0, utils_namespaceObject.compatibleRequire)(external_path_default().resolve(appDirectory, './package.json'));
|
|
92
|
+
const packageName = pkg.name;
|
|
93
|
+
let config;
|
|
94
|
+
if (configFile) config = await 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
|
+
});
|