@modern-js/app-tools 2.62.1 → 2.62.2-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. package/bin/modern.js +2 -2
  2. package/dist/cjs/index.js +11 -143
  3. package/dist/cjs/new/compat/hooks.js +160 -0
  4. package/dist/cjs/new/compat/index.js +55 -0
  5. package/dist/cjs/new/compat/utils.js +95 -0
  6. package/dist/cjs/new/constants.js +37 -0
  7. package/dist/cjs/new/context.js +63 -0
  8. package/dist/cjs/new/getConfigFile.js +41 -0
  9. package/dist/cjs/new/index.js +79 -0
  10. package/dist/cjs/new/loadPlugins.js +57 -0
  11. package/dist/cjs/new/run.js +67 -0
  12. package/dist/cjs/new/types/index.js +16 -0
  13. package/dist/cjs/new/utils/index.js +34 -0
  14. package/dist/cjs/old.js +179 -0
  15. package/dist/cjs/utils/restart.js +2 -2
  16. package/dist/esm/index.js +7 -249
  17. package/dist/esm/new/compat/hooks.js +428 -0
  18. package/dist/esm/new/compat/index.js +33 -0
  19. package/dist/esm/new/compat/utils.js +69 -0
  20. package/dist/esm/new/constants.js +10 -0
  21. package/dist/esm/new/context.js +30 -0
  22. package/dist/esm/new/getConfigFile.js +11 -0
  23. package/dist/esm/new/index.js +55 -0
  24. package/dist/esm/new/loadPlugins.js +94 -0
  25. package/dist/esm/new/run.js +80 -0
  26. package/dist/esm/new/types/index.js +0 -0
  27. package/dist/esm/new/utils/index.js +33 -0
  28. package/dist/esm/old.js +258 -0
  29. package/dist/esm/utils/restart.js +1 -1
  30. package/dist/esm-node/index.js +7 -131
  31. package/dist/esm-node/new/compat/hooks.js +135 -0
  32. package/dist/esm-node/new/compat/index.js +31 -0
  33. package/dist/esm-node/new/compat/utils.js +69 -0
  34. package/dist/esm-node/new/constants.js +10 -0
  35. package/dist/esm-node/new/context.js +29 -0
  36. package/dist/esm-node/new/getConfigFile.js +7 -0
  37. package/dist/esm-node/new/index.js +52 -0
  38. package/dist/esm-node/new/loadPlugins.js +33 -0
  39. package/dist/esm-node/new/run.js +43 -0
  40. package/dist/esm-node/new/types/index.js +0 -0
  41. package/dist/esm-node/new/utils/index.js +10 -0
  42. package/dist/esm-node/old.js +140 -0
  43. package/dist/esm-node/utils/restart.js +1 -1
  44. package/dist/types/index.d.ts +3 -14
  45. package/dist/types/new/compat/hooks.d.ts +8 -0
  46. package/dist/types/new/compat/index.d.ts +4 -0
  47. package/dist/types/new/compat/utils.d.ts +6 -0
  48. package/dist/types/new/constants.d.ts +4 -0
  49. package/dist/types/new/context.d.ts +33 -0
  50. package/dist/types/new/getConfigFile.d.ts +1 -0
  51. package/dist/types/new/index.d.ts +9 -0
  52. package/dist/types/new/loadPlugins.d.ts +9 -0
  53. package/dist/types/new/run.d.ts +13 -0
  54. package/dist/types/new/types/index.d.ts +90 -0
  55. package/dist/types/new/utils/index.d.ts +1 -0
  56. package/dist/types/old.d.ts +13 -0
  57. package/dist/types/types/index.d.ts +7 -0
  58. package/dist/types/utils/restart.d.ts +1 -1
  59. package/package.json +20 -12
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('@modern-js/core/runBin').run({
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
- initialLog: `Modern.js Framework v${version}`,
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,32 @@ 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,
22
+ appTools: () => import_new2.appTools,
33
23
  default: () => src_default,
24
+ defineConfig: () => import_defineConfig.defineConfig,
25
+ defineLegacyConfig: () => import_defineConfig.defineLegacyConfig,
34
26
  dev: () => import_dev.dev,
27
+ initAppContext: () => import_new2.initAppContext,
35
28
  mergeConfig: () => import_core.mergeConfig
36
29
  });
37
30
  module.exports = __toCommonJS(src_exports);
38
- var import_path = __toESM(require("path"));
39
- var import_language_detector = require("@modern-js/plugin-i18n/language-detector");
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");
31
+ var import_new = require("./new/index");
32
+ var import_new2 = require("./new/index");
51
33
  var import_dev = require("./commands/dev");
52
34
  var import_core = require("@modern-js/core");
53
- __reExport(src_exports, require("./defineConfig"), module.exports);
35
+ var import_defineConfig = require("./defineConfig");
54
36
  __reExport(src_exports, require("./types"), module.exports);
55
- const appTools = (options = {
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;
37
+ var src_default = import_new.appTools;
172
38
  // Annotate the CommonJS export names for ESM import in node:
173
39
  0 && (module.exports = {
174
40
  appTools,
41
+ defineConfig,
42
+ defineLegacyConfig,
175
43
  dev,
44
+ initAppContext,
176
45
  mergeConfig,
177
- ...require("./defineConfig"),
178
46
  ...require("./types")
179
47
  });
@@ -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 (options) => {
111
+ return hooks.onBeforeDeploy.call(options);
112
+ },
113
+ afterDeploy: async (options) => {
114
+ return hooks.onAfterDeploy.call(options);
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,55 @@
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: (getAppContext, updateAppContext) => {
28
+ const getInternalContext = () => {
29
+ return getAppContext()._internalContext;
30
+ };
31
+ return {
32
+ useAppContext: () => {
33
+ return getAppContext();
34
+ },
35
+ setAppContext: (context) => {
36
+ return updateAppContext(context);
37
+ },
38
+ useConfigContext: () => {
39
+ return getInternalContext().config;
40
+ },
41
+ useResolvedConfigContext: () => {
42
+ return getInternalContext().normalizedConfig;
43
+ },
44
+ useHookRunners: () => {
45
+ return (0, import_hooks.getHookRunners)(getInternalContext());
46
+ }
47
+ };
48
+ },
49
+ setup: (_api) => {
50
+ }
51
+ });
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ compatPlugin
55
+ });
@@ -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, tempDir }) => {
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, tempDir || `./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
+ });