@modern-js/app-tools 2.61.0 → 2.62.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +2 -2
- package/dist/cjs/index.js +4 -142
- package/dist/cjs/new/compat/hooks.js +160 -0
- package/dist/cjs/new/compat/index.js +52 -0
- package/dist/cjs/new/compat/utils.js +95 -0
- package/dist/cjs/new/constants.js +37 -0
- package/dist/cjs/new/context.js +63 -0
- package/dist/cjs/new/getConfigFile.js +41 -0
- package/dist/cjs/new/index.js +76 -0
- package/dist/cjs/new/loadPlugins.js +57 -0
- package/dist/cjs/new/run.js +66 -0
- package/dist/cjs/new/types/index.js +16 -0
- package/dist/cjs/new/utils/index.js +34 -0
- package/dist/cjs/old.js +179 -0
- package/dist/esm/index.js +2 -248
- package/dist/esm/new/compat/hooks.js +418 -0
- package/dist/esm/new/compat/index.js +30 -0
- package/dist/esm/new/compat/utils.js +69 -0
- package/dist/esm/new/constants.js +10 -0
- package/dist/esm/new/context.js +30 -0
- package/dist/esm/new/getConfigFile.js +11 -0
- package/dist/esm/new/index.js +52 -0
- package/dist/esm/new/loadPlugins.js +94 -0
- package/dist/esm/new/run.js +79 -0
- package/dist/esm/new/types/index.js +0 -0
- package/dist/esm/new/utils/index.js +33 -0
- package/dist/esm/old.js +258 -0
- package/dist/esm-node/index.js +2 -130
- package/dist/esm-node/new/compat/hooks.js +135 -0
- package/dist/esm-node/new/compat/index.js +28 -0
- package/dist/esm-node/new/compat/utils.js +69 -0
- package/dist/esm-node/new/constants.js +10 -0
- package/dist/esm-node/new/context.js +29 -0
- package/dist/esm-node/new/getConfigFile.js +7 -0
- package/dist/esm-node/new/index.js +49 -0
- package/dist/esm-node/new/loadPlugins.js +33 -0
- package/dist/esm-node/new/run.js +42 -0
- package/dist/esm-node/new/types/index.js +0 -0
- package/dist/esm-node/new/utils/index.js +10 -0
- package/dist/esm-node/old.js +140 -0
- package/dist/types/index.d.ts +2 -6
- package/dist/types/new/compat/hooks.d.ts +8 -0
- package/dist/types/new/compat/index.d.ts +4 -0
- package/dist/types/new/compat/utils.d.ts +6 -0
- package/dist/types/new/constants.d.ts +4 -0
- package/dist/types/new/context.d.ts +32 -0
- package/dist/types/new/getConfigFile.d.ts +1 -0
- package/dist/types/new/index.d.ts +15 -0
- package/dist/types/new/loadPlugins.d.ts +9 -0
- package/dist/types/new/run.d.ts +13 -0
- package/dist/types/new/types/index.d.ts +89 -0
- package/dist/types/new/utils/index.d.ts +1 -0
- package/dist/types/old.d.ts +20 -0
- package/package.json +27 -19
package/bin/modern.js
CHANGED
@@ -10,10 +10,10 @@ if (!process.env.MODERN_JS_VERSION) {
|
|
10
10
|
process.env.MODERN_JS_VERSION = version;
|
11
11
|
}
|
12
12
|
|
13
|
-
require('
|
13
|
+
require('../dist/cjs/new/run.js').run({
|
14
14
|
internalPlugins: {
|
15
15
|
cli: INTERNAL_APP_TOOLS_PLUGINS,
|
16
16
|
autoLoad: INTERNAL_APP_TOOLS_RUNTIME_PLUGINS,
|
17
17
|
},
|
18
|
-
|
18
|
+
version,
|
19
19
|
});
|
package/dist/cjs/index.js
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
"use strict";
|
2
|
-
var __create = Object.create;
|
3
2
|
var __defProp = Object.defineProperty;
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
6
|
var __export = (target, all) => {
|
9
7
|
for (var name in all)
|
@@ -18,162 +16,26 @@ var __copyProps = (to, from, except, desc) => {
|
|
18
16
|
return to;
|
19
17
|
};
|
20
18
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
27
|
-
mod
|
28
|
-
));
|
29
19
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
20
|
var src_exports = {};
|
31
21
|
__export(src_exports, {
|
32
|
-
appTools: () => appTools,
|
33
22
|
default: () => src_default,
|
34
23
|
dev: () => import_dev.dev,
|
35
24
|
mergeConfig: () => import_core.mergeConfig
|
36
25
|
});
|
37
26
|
module.exports = __toCommonJS(src_exports);
|
38
|
-
var
|
39
|
-
|
40
|
-
var import_uni_builder = require("@modern-js/uni-builder");
|
41
|
-
var import_utils = require("@modern-js/utils");
|
42
|
-
var import_hooks = require("./hooks");
|
43
|
-
var import_locale = require("./locale");
|
44
|
-
var import_analyze = __toESM(require("./plugins/analyze"));
|
45
|
-
var import_deploy = __toESM(require("./plugins/deploy"));
|
46
|
-
var import_initialize = __toESM(require("./plugins/initialize"));
|
47
|
-
var import_serverBuild = __toESM(require("./plugins/serverBuild"));
|
48
|
-
var import_commands = require("./commands");
|
49
|
-
var import_generateWatchFiles = require("./utils/generateWatchFiles");
|
50
|
-
var import_restart = require("./utils/restart");
|
27
|
+
var import_new = require("./new/index");
|
28
|
+
__reExport(src_exports, require("./new/index"), module.exports);
|
51
29
|
var import_dev = require("./commands/dev");
|
52
30
|
var import_core = require("@modern-js/core");
|
53
31
|
__reExport(src_exports, require("./defineConfig"), module.exports);
|
54
32
|
__reExport(src_exports, require("./types"), module.exports);
|
55
|
-
|
56
|
-
// default webpack to be compatible with original projects
|
57
|
-
bundler: "webpack"
|
58
|
-
}) => ({
|
59
|
-
name: "@modern-js/app-tools",
|
60
|
-
post: [
|
61
|
-
"@modern-js/plugin-initialize",
|
62
|
-
"@modern-js/plugin-analyze",
|
63
|
-
"@modern-js/plugin-ssr",
|
64
|
-
"@modern-js/plugin-document",
|
65
|
-
"@modern-js/plugin-state",
|
66
|
-
"@modern-js/plugin-router",
|
67
|
-
"@modern-js/plugin-router-v5",
|
68
|
-
"@modern-js/plugin-polyfill"
|
69
|
-
],
|
70
|
-
registerHook: import_hooks.hooks,
|
71
|
-
usePlugins: [
|
72
|
-
(0, import_initialize.default)({
|
73
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
|
74
|
-
"rspack",
|
75
|
-
"experimental-rspack"
|
76
|
-
].includes(options.bundler) ? "rspack" : "webpack"
|
77
|
-
}),
|
78
|
-
(0, import_analyze.default)({
|
79
|
-
bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
|
80
|
-
"rspack",
|
81
|
-
"experimental-rspack"
|
82
|
-
].includes(options.bundler) ? "rspack" : "webpack"
|
83
|
-
}),
|
84
|
-
(0, import_serverBuild.default)(),
|
85
|
-
(0, import_deploy.default)()
|
86
|
-
],
|
87
|
-
setup: (api) => {
|
88
|
-
const appContext = api.useAppContext();
|
89
|
-
api.setAppContext({
|
90
|
-
...appContext,
|
91
|
-
toolsType: "app-tools"
|
92
|
-
});
|
93
|
-
const locale = (0, import_language_detector.getLocaleLanguage)();
|
94
|
-
import_locale.i18n.changeLanguage({
|
95
|
-
locale
|
96
|
-
});
|
97
|
-
return {
|
98
|
-
async beforeConfig() {
|
99
|
-
var _userConfig_output;
|
100
|
-
const userConfig = api.useConfigContext();
|
101
|
-
const appContext2 = api.useAppContext();
|
102
|
-
if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
|
103
|
-
api.setAppContext({
|
104
|
-
...appContext2,
|
105
|
-
internalDirectory: import_path.default.resolve(appContext2.appDirectory, userConfig.output.tempDir)
|
106
|
-
});
|
107
|
-
}
|
108
|
-
},
|
109
|
-
async commands({ program }) {
|
110
|
-
await (0, import_commands.devCommand)(program, api);
|
111
|
-
await (0, import_commands.buildCommand)(program, api);
|
112
|
-
(0, import_commands.serverCommand)(program, api);
|
113
|
-
(0, import_commands.deployCommand)(program, api);
|
114
|
-
(0, import_commands.newCommand)(program, locale);
|
115
|
-
(0, import_commands.inspectCommand)(program, api);
|
116
|
-
(0, import_commands.upgradeCommand)(program);
|
117
|
-
(0, import_utils.deprecatedCommands)(program);
|
118
|
-
},
|
119
|
-
async prepare() {
|
120
|
-
const command = (0, import_utils.getCommand)();
|
121
|
-
if (command === "deploy") {
|
122
|
-
const isSkipBuild = [
|
123
|
-
"-s",
|
124
|
-
"--skip-build"
|
125
|
-
].some((tag) => {
|
126
|
-
return (0, import_utils.getArgv)().includes(tag);
|
127
|
-
});
|
128
|
-
if (isSkipBuild) {
|
129
|
-
return;
|
130
|
-
}
|
131
|
-
}
|
132
|
-
if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
|
133
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
134
|
-
if (resolvedConfig.output.cleanDistPath) {
|
135
|
-
const appContext2 = api.useAppContext();
|
136
|
-
await (0, import_utils.emptyDir)(appContext2.distDirectory);
|
137
|
-
}
|
138
|
-
}
|
139
|
-
},
|
140
|
-
async watchFiles() {
|
141
|
-
const appContext2 = api.useAppContext();
|
142
|
-
const config = api.useResolvedConfigContext();
|
143
|
-
const files = await (0, import_generateWatchFiles.generateWatchFiles)(appContext2, config.source.configDir);
|
144
|
-
const watchFiles = (0, import_uni_builder.castArray)(config.dev.watchFiles);
|
145
|
-
watchFiles.forEach(({ type, paths }) => {
|
146
|
-
if (type === "reload-server") {
|
147
|
-
files.push(...Array.isArray(paths) ? paths : [
|
148
|
-
paths
|
149
|
-
]);
|
150
|
-
}
|
151
|
-
});
|
152
|
-
return files;
|
153
|
-
},
|
154
|
-
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
155
|
-
async fileChange(e) {
|
156
|
-
const { filename, eventType, isPrivate } = e;
|
157
|
-
if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
|
158
|
-
const { closeServer } = await import("./utils/createServer.js");
|
159
|
-
await closeServer();
|
160
|
-
await (0, import_restart.restart)(api.useHookRunners(), filename);
|
161
|
-
}
|
162
|
-
},
|
163
|
-
async beforeRestart() {
|
164
|
-
(0, import_utils.cleanRequireCache)([
|
165
|
-
require.resolve("./plugins/analyze")
|
166
|
-
]);
|
167
|
-
}
|
168
|
-
};
|
169
|
-
}
|
170
|
-
});
|
171
|
-
var src_default = appTools;
|
33
|
+
var src_default = import_new.appTools;
|
172
34
|
// Annotate the CommonJS export names for ESM import in node:
|
173
35
|
0 && (module.exports = {
|
174
|
-
appTools,
|
175
36
|
dev,
|
176
37
|
mergeConfig,
|
38
|
+
...require("./new/index"),
|
177
39
|
...require("./defineConfig"),
|
178
40
|
...require("./types")
|
179
41
|
});
|
@@ -0,0 +1,160 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var hooks_exports = {};
|
20
|
+
__export(hooks_exports, {
|
21
|
+
getHookRunners: () => getHookRunners,
|
22
|
+
handleSetupResult: () => handleSetupResult
|
23
|
+
});
|
24
|
+
module.exports = __toCommonJS(hooks_exports);
|
25
|
+
var import_utils = require("./utils");
|
26
|
+
function getHookRunners(context) {
|
27
|
+
const { hooks } = context;
|
28
|
+
return {
|
29
|
+
/**
|
30
|
+
* app tools hooks
|
31
|
+
*/
|
32
|
+
beforeConfig: async () => {
|
33
|
+
return hooks.onBeforeConfig.call();
|
34
|
+
},
|
35
|
+
afterPrepare: async () => {
|
36
|
+
return hooks.onAfterPrepare.call();
|
37
|
+
},
|
38
|
+
deploy: async () => {
|
39
|
+
return hooks.deploy.call();
|
40
|
+
},
|
41
|
+
_internalRuntimePlugins: async (params) => {
|
42
|
+
return hooks._internalRuntimePlugins.call(params);
|
43
|
+
},
|
44
|
+
_internalServerPlugins: async (params) => {
|
45
|
+
return hooks._internalServerPlugins.call(params);
|
46
|
+
},
|
47
|
+
checkEntryPoint: async (params) => {
|
48
|
+
return hooks.checkEntryPoint.call(params);
|
49
|
+
},
|
50
|
+
modifyEntrypoints: async (params) => {
|
51
|
+
return hooks.modifyEntrypoints.call(params);
|
52
|
+
},
|
53
|
+
modifyFileSystemRoutes: async (params) => {
|
54
|
+
return hooks.modifyFileSystemRoutes.call(params);
|
55
|
+
},
|
56
|
+
modifyServerRoutes: async (params) => {
|
57
|
+
return hooks.modifyServerRoutes.call(params);
|
58
|
+
},
|
59
|
+
generateEntryCode: async (params) => {
|
60
|
+
return hooks.generateEntryCode.call(params);
|
61
|
+
},
|
62
|
+
beforeGenerateRoutes: async (params) => {
|
63
|
+
return hooks.onBeforeGenerateRoutes.call(params);
|
64
|
+
},
|
65
|
+
beforePrintInstructions: async (params) => {
|
66
|
+
return hooks.onBeforePrintInstructions.call(params);
|
67
|
+
},
|
68
|
+
/**
|
69
|
+
* common hooks
|
70
|
+
*/
|
71
|
+
config: async () => {
|
72
|
+
return hooks.config.call();
|
73
|
+
},
|
74
|
+
resolvedConfig: (params) => {
|
75
|
+
return hooks.modifyResolvedConfig.call(params);
|
76
|
+
},
|
77
|
+
htmlPartials: async (params) => {
|
78
|
+
return hooks.modifyHtmlPartials.call(params);
|
79
|
+
},
|
80
|
+
commands: async (params) => {
|
81
|
+
return hooks.addCommand.call(params);
|
82
|
+
},
|
83
|
+
watchFiles: async () => {
|
84
|
+
return hooks.addWatchFiles.call();
|
85
|
+
},
|
86
|
+
prepare: async () => {
|
87
|
+
return hooks.onPrepare.call();
|
88
|
+
},
|
89
|
+
filedChange: async (params) => {
|
90
|
+
return hooks.onFileChanged.call(params);
|
91
|
+
},
|
92
|
+
beforeCreateCompiler: async (params) => {
|
93
|
+
return hooks.onBeforeCreateCompiler.call(params);
|
94
|
+
},
|
95
|
+
afterCreateCompiler: async (params) => {
|
96
|
+
return hooks.onAfterCreateCompiler.call(params);
|
97
|
+
},
|
98
|
+
beforeBuild: async (params) => {
|
99
|
+
return hooks.onBeforeBuild.call(params);
|
100
|
+
},
|
101
|
+
afterBuild: async (params) => {
|
102
|
+
return hooks.onAfterBuild.call(params);
|
103
|
+
},
|
104
|
+
beforeDev: async () => {
|
105
|
+
return hooks.onBeforeDev.call();
|
106
|
+
},
|
107
|
+
afterDev: async (params) => {
|
108
|
+
return hooks.onAfterDev.call(params);
|
109
|
+
},
|
110
|
+
beforeDeploy: async () => {
|
111
|
+
return hooks.onBeforeDeploy.call();
|
112
|
+
},
|
113
|
+
afterDeploy: async () => {
|
114
|
+
return hooks.onAfterDeploy.call();
|
115
|
+
},
|
116
|
+
beforeExit: async () => {
|
117
|
+
return hooks.onBeforeExit.call();
|
118
|
+
},
|
119
|
+
beforeRestart: async () => {
|
120
|
+
return hooks.onBeforeRestart.call();
|
121
|
+
},
|
122
|
+
/**
|
123
|
+
* @deprecated
|
124
|
+
*/
|
125
|
+
registerDev: async (params) => {
|
126
|
+
return hooks.registerDev.call(params);
|
127
|
+
},
|
128
|
+
/**
|
129
|
+
* @deprecated
|
130
|
+
*/
|
131
|
+
registerBuildPlatform: async (params) => {
|
132
|
+
return hooks.registerBuildPlatform.call(params);
|
133
|
+
},
|
134
|
+
/**
|
135
|
+
* @deprecated
|
136
|
+
*/
|
137
|
+
addRuntimeExports: async (params) => {
|
138
|
+
return hooks.addRuntimeExports.call(params);
|
139
|
+
}
|
140
|
+
};
|
141
|
+
}
|
142
|
+
function handleSetupResult(setupResult, api) {
|
143
|
+
if (!setupResult) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
Object.keys(setupResult).forEach((key) => {
|
147
|
+
const fn = setupResult[key];
|
148
|
+
if (typeof fn === "function") {
|
149
|
+
const newAPI = (0, import_utils.transformHookRunner)(key);
|
150
|
+
if (api[newAPI]) {
|
151
|
+
api[newAPI](async (params) => (0, import_utils.transformHookResult)(key, await fn((0, import_utils.transformHookParams)(key, params))));
|
152
|
+
}
|
153
|
+
}
|
154
|
+
});
|
155
|
+
}
|
156
|
+
// Annotate the CommonJS export names for ESM import in node:
|
157
|
+
0 && (module.exports = {
|
158
|
+
getHookRunners,
|
159
|
+
handleSetupResult
|
160
|
+
});
|
@@ -0,0 +1,52 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var compat_exports = {};
|
20
|
+
__export(compat_exports, {
|
21
|
+
compatPlugin: () => compatPlugin
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(compat_exports);
|
24
|
+
var import_hooks = require("./hooks");
|
25
|
+
const compatPlugin = () => ({
|
26
|
+
name: "@modern-js/app-tools-compat",
|
27
|
+
registryApi: (context, updateAppContext) => {
|
28
|
+
return {
|
29
|
+
useAppContext: () => {
|
30
|
+
return context;
|
31
|
+
},
|
32
|
+
setAppContext: (context2) => {
|
33
|
+
return updateAppContext(context2);
|
34
|
+
},
|
35
|
+
useConfigContext: () => {
|
36
|
+
return context.config;
|
37
|
+
},
|
38
|
+
useResolvedConfigContext: () => {
|
39
|
+
return context.normalizedConfig;
|
40
|
+
},
|
41
|
+
useHookRunners: () => {
|
42
|
+
return (0, import_hooks.getHookRunners)(context);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
},
|
46
|
+
setup: (_api) => {
|
47
|
+
}
|
48
|
+
});
|
49
|
+
// Annotate the CommonJS export names for ESM import in node:
|
50
|
+
0 && (module.exports = {
|
51
|
+
compatPlugin
|
52
|
+
});
|
@@ -0,0 +1,95 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var utils_exports = {};
|
20
|
+
__export(utils_exports, {
|
21
|
+
transformHookParams: () => transformHookParams,
|
22
|
+
transformHookResult: () => transformHookResult,
|
23
|
+
transformHookRunner: () => transformHookRunner
|
24
|
+
});
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
26
|
+
function transformHookRunner(hookRunnerName) {
|
27
|
+
switch (hookRunnerName) {
|
28
|
+
case "beforeConfig":
|
29
|
+
return "onBeforeConfig";
|
30
|
+
case "prepare":
|
31
|
+
return "onPrepare";
|
32
|
+
case "afterPrepare":
|
33
|
+
return "onAfterPrepare";
|
34
|
+
case "beforeGenerateRoutes":
|
35
|
+
return "onBeforeGenerateRoutes";
|
36
|
+
case "beforePrintInstructions":
|
37
|
+
return "onBeforePrintInstructions";
|
38
|
+
case "resolvedConfig":
|
39
|
+
return "modifyResolvedConfig";
|
40
|
+
case "commands":
|
41
|
+
return "addCommand";
|
42
|
+
case "watchFiles":
|
43
|
+
return "addWatchFiles";
|
44
|
+
case "filedChange":
|
45
|
+
return "onFileChanged";
|
46
|
+
case "beforeCreateCompiler":
|
47
|
+
return "onBeforeCreateCompiler";
|
48
|
+
case "afterCreateCompiler":
|
49
|
+
return "onAfterCreateCompiler";
|
50
|
+
case "beforeBuild":
|
51
|
+
return "onBeforeBuild";
|
52
|
+
case "afterBuild":
|
53
|
+
return "onAfterBuild";
|
54
|
+
case "beforeDev":
|
55
|
+
return "onBeforeDev";
|
56
|
+
case "afterDev":
|
57
|
+
return "onAfterDev";
|
58
|
+
case "beforeDeploy":
|
59
|
+
return "onBeforeDeploy";
|
60
|
+
case "afterDeploy":
|
61
|
+
return "onAfterDeploy";
|
62
|
+
case "beforeExit":
|
63
|
+
return "onBeforeExit";
|
64
|
+
case "beforeRestart":
|
65
|
+
return "onBeforeRestart";
|
66
|
+
case "htmlPartials":
|
67
|
+
return "modifyHtmlPartials";
|
68
|
+
default:
|
69
|
+
return hookRunnerName;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
function transformHookParams(hookRunnerName, params) {
|
73
|
+
switch (hookRunnerName) {
|
74
|
+
case "resolvedConfig":
|
75
|
+
return {
|
76
|
+
resolved: params
|
77
|
+
};
|
78
|
+
default:
|
79
|
+
return params;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
function transformHookResult(hookRunnerName, result) {
|
83
|
+
switch (hookRunnerName) {
|
84
|
+
case "resolvedConfig":
|
85
|
+
return result.resolved;
|
86
|
+
default:
|
87
|
+
return result;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
// Annotate the CommonJS export names for ESM import in node:
|
91
|
+
0 && (module.exports = {
|
92
|
+
transformHookParams,
|
93
|
+
transformHookResult,
|
94
|
+
transformHookRunner
|
95
|
+
});
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var constants_exports = {};
|
20
|
+
__export(constants_exports, {
|
21
|
+
DEFAULT_CONFIG_FILE: () => DEFAULT_CONFIG_FILE,
|
22
|
+
DEFAULT_RUNTIME_CONFIG_FILE: () => DEFAULT_RUNTIME_CONFIG_FILE,
|
23
|
+
DEFAULT_SERVER_CONFIG_FILE: () => DEFAULT_SERVER_CONFIG_FILE,
|
24
|
+
PACKAGE_JSON_CONFIG_NAME: () => PACKAGE_JSON_CONFIG_NAME
|
25
|
+
});
|
26
|
+
module.exports = __toCommonJS(constants_exports);
|
27
|
+
const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
28
|
+
const DEFAULT_CONFIG_FILE = "modern.config";
|
29
|
+
const DEFAULT_SERVER_CONFIG_FILE = "modern.server-runtime.config";
|
30
|
+
const DEFAULT_RUNTIME_CONFIG_FILE = "modern.runtime";
|
31
|
+
// Annotate the CommonJS export names for ESM import in node:
|
32
|
+
0 && (module.exports = {
|
33
|
+
DEFAULT_CONFIG_FILE,
|
34
|
+
DEFAULT_RUNTIME_CONFIG_FILE,
|
35
|
+
DEFAULT_SERVER_CONFIG_FILE,
|
36
|
+
PACKAGE_JSON_CONFIG_NAME
|
37
|
+
});
|
@@ -0,0 +1,63 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var context_exports = {};
|
30
|
+
__export(context_exports, {
|
31
|
+
initAppContext: () => initAppContext
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(context_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
const initAppContext = ({ appDirectory, runtimeConfigFile, options, serverConfigFile }) => {
|
37
|
+
const { metaName = "modern-js", apiDir = "api", distDir = "", sharedDir = "shared" } = options || {};
|
38
|
+
return {
|
39
|
+
metaName,
|
40
|
+
runtimeConfigFile,
|
41
|
+
serverConfigFile,
|
42
|
+
ip: import_utils.address.ip(),
|
43
|
+
port: 0,
|
44
|
+
moduleType: require(import_path.default.resolve(appDirectory, "./package.json")).type || "commonjs",
|
45
|
+
apiDirectory: import_path.default.resolve(appDirectory, apiDir),
|
46
|
+
lambdaDirectory: import_path.default.resolve(appDirectory, apiDir, "lambda"),
|
47
|
+
sharedDirectory: import_path.default.resolve(appDirectory, sharedDir),
|
48
|
+
distDirectory: distDir,
|
49
|
+
serverPlugins: [],
|
50
|
+
internalDirectory: import_path.default.resolve(appDirectory, `./node_modules/.${metaName}`),
|
51
|
+
htmlTemplates: {},
|
52
|
+
serverRoutes: [],
|
53
|
+
entrypoints: [],
|
54
|
+
checkedEntries: [],
|
55
|
+
apiOnly: false,
|
56
|
+
internalDirAlias: `@_${metaName.replace(/-/g, "_")}_internal`,
|
57
|
+
internalSrcAlias: `@_${metaName.replace(/-/g, "_")}_src`
|
58
|
+
};
|
59
|
+
};
|
60
|
+
// Annotate the CommonJS export names for ESM import in node:
|
61
|
+
0 && (module.exports = {
|
62
|
+
initAppContext
|
63
|
+
});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var getConfigFile_exports = {};
|
30
|
+
__export(getConfigFile_exports, {
|
31
|
+
getConfigFile: () => getConfigFile
|
32
|
+
});
|
33
|
+
module.exports = __toCommonJS(getConfigFile_exports);
|
34
|
+
var import_path = __toESM(require("path"));
|
35
|
+
var import_utils = require("@modern-js/utils");
|
36
|
+
var import_constants = require("./constants");
|
37
|
+
const getConfigFile = (configFile) => (0, import_utils.findExists)(import_utils.CONFIG_FILE_EXTENSIONS.map((extension) => import_path.default.resolve(process.cwd(), `${configFile || import_constants.DEFAULT_CONFIG_FILE}${extension}`)));
|
38
|
+
// Annotate the CommonJS export names for ESM import in node:
|
39
|
+
0 && (module.exports = {
|
40
|
+
getConfigFile
|
41
|
+
});
|