@modern-js/app-tools 2.62.1 → 2.63.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.
Files changed (66) hide show
  1. package/bin/modern.js +2 -2
  2. package/dist/cjs/index.js +12 -144
  3. package/dist/cjs/new/compat/hooks.js +165 -0
  4. package/dist/cjs/new/compat/index.js +60 -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 +64 -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/utils/index.js +34 -0
  13. package/dist/cjs/old.js +179 -0
  14. package/dist/cjs/plugins/initialize/index.js +44 -50
  15. package/dist/cjs/types/new.js +16 -0
  16. package/dist/cjs/utils/restart.js +2 -2
  17. package/dist/esm/index.js +7 -249
  18. package/dist/esm/new/compat/hooks.js +452 -0
  19. package/dist/esm/new/compat/index.js +41 -0
  20. package/dist/esm/new/compat/utils.js +69 -0
  21. package/dist/esm/new/constants.js +10 -0
  22. package/dist/esm/new/context.js +31 -0
  23. package/dist/esm/new/getConfigFile.js +11 -0
  24. package/dist/esm/new/index.js +55 -0
  25. package/dist/esm/new/loadPlugins.js +94 -0
  26. package/dist/esm/new/run.js +80 -0
  27. package/dist/esm/new/utils/index.js +33 -0
  28. package/dist/esm/old.js +258 -0
  29. package/dist/esm/plugins/initialize/index.js +61 -64
  30. package/dist/esm/types/new.js +0 -0
  31. package/dist/esm/utils/restart.js +1 -1
  32. package/dist/esm-node/index.js +7 -131
  33. package/dist/esm-node/new/compat/hooks.js +140 -0
  34. package/dist/esm-node/new/compat/index.js +36 -0
  35. package/dist/esm-node/new/compat/utils.js +69 -0
  36. package/dist/esm-node/new/constants.js +10 -0
  37. package/dist/esm-node/new/context.js +30 -0
  38. package/dist/esm-node/new/getConfigFile.js +7 -0
  39. package/dist/esm-node/new/index.js +52 -0
  40. package/dist/esm-node/new/loadPlugins.js +33 -0
  41. package/dist/esm-node/new/run.js +43 -0
  42. package/dist/esm-node/new/utils/index.js +10 -0
  43. package/dist/esm-node/old.js +140 -0
  44. package/dist/esm-node/plugins/initialize/index.js +44 -50
  45. package/dist/esm-node/types/new.js +0 -0
  46. package/dist/esm-node/utils/restart.js +1 -1
  47. package/dist/types/config/default.d.ts +4 -3
  48. package/dist/types/index.d.ts +6 -16
  49. package/dist/types/new/compat/hooks.d.ts +7 -0
  50. package/dist/types/new/compat/index.d.ts +2 -0
  51. package/dist/types/new/compat/utils.d.ts +6 -0
  52. package/dist/types/new/constants.d.ts +4 -0
  53. package/dist/types/new/context.d.ts +33 -0
  54. package/dist/types/new/getConfigFile.d.ts +1 -0
  55. package/dist/types/new/index.d.ts +6 -0
  56. package/dist/types/new/loadPlugins.d.ts +9 -0
  57. package/dist/types/new/run.d.ts +13 -0
  58. package/dist/types/new/utils/index.d.ts +1 -0
  59. package/dist/types/old.d.ts +13 -0
  60. package/dist/types/plugins/initialize/index.d.ts +2 -2
  61. package/dist/types/types/index.d.ts +12 -3
  62. package/dist/types/types/new.d.ts +145 -0
  63. package/dist/types/utils/env.d.ts +2 -2
  64. package/dist/types/utils/restart.d.ts +1 -1
  65. package/lib/types.d.ts +82 -61
  66. package/package.json +27 -18
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_new.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");
51
- var import_dev = require("./commands/dev");
31
+ var import_new = require("./new/index");
32
+ var import_new2 = require("./new/index");
33
+ var import_defineConfig = require("./defineConfig");
52
34
  var import_core = require("@modern-js/core");
53
- __reExport(src_exports, require("./defineConfig"), module.exports);
35
+ var import_dev = require("./commands/dev");
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,165 @@
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
+ // garfish plugin hooks
69
+ appendEntryCode: async (params) => {
70
+ const result = await (hooks === null || hooks === void 0 ? void 0 : hooks.appendEntryCode.call(params));
71
+ return result;
72
+ },
73
+ /**
74
+ * common hooks
75
+ */
76
+ config: async () => {
77
+ return hooks.config.call();
78
+ },
79
+ resolvedConfig: (params) => {
80
+ return hooks.modifyResolvedConfig.call(params);
81
+ },
82
+ htmlPartials: async (params) => {
83
+ return hooks.modifyHtmlPartials.call(params);
84
+ },
85
+ commands: async (params) => {
86
+ return hooks.addCommand.call(params);
87
+ },
88
+ watchFiles: async () => {
89
+ return hooks.addWatchFiles.call();
90
+ },
91
+ prepare: async () => {
92
+ return hooks.onPrepare.call();
93
+ },
94
+ filedChange: async (params) => {
95
+ return hooks.onFileChanged.call(params);
96
+ },
97
+ beforeCreateCompiler: async (params) => {
98
+ return hooks.onBeforeCreateCompiler.call(params);
99
+ },
100
+ afterCreateCompiler: async (params) => {
101
+ return hooks.onAfterCreateCompiler.call(params);
102
+ },
103
+ beforeBuild: async (params) => {
104
+ return hooks.onBeforeBuild.call(params);
105
+ },
106
+ afterBuild: async (params) => {
107
+ return hooks.onAfterBuild.call(params);
108
+ },
109
+ beforeDev: async () => {
110
+ return hooks.onBeforeDev.call();
111
+ },
112
+ afterDev: async (params) => {
113
+ return hooks.onAfterDev.call(params);
114
+ },
115
+ beforeDeploy: async (options) => {
116
+ return hooks.onBeforeDeploy.call(options);
117
+ },
118
+ afterDeploy: async (options) => {
119
+ return hooks.onAfterDeploy.call(options);
120
+ },
121
+ beforeExit: async () => {
122
+ return hooks.onBeforeExit.call();
123
+ },
124
+ beforeRestart: async () => {
125
+ return hooks.onBeforeRestart.call();
126
+ },
127
+ /**
128
+ * @deprecated
129
+ */
130
+ registerDev: async (params) => {
131
+ return hooks.registerDev.call(params);
132
+ },
133
+ /**
134
+ * @deprecated
135
+ */
136
+ registerBuildPlatform: async (params) => {
137
+ return hooks.registerBuildPlatform.call(params);
138
+ },
139
+ /**
140
+ * @deprecated
141
+ */
142
+ addRuntimeExports: async (params) => {
143
+ return hooks.addRuntimeExports.call(params);
144
+ }
145
+ };
146
+ }
147
+ function handleSetupResult(setupResult, api) {
148
+ if (!setupResult) {
149
+ return;
150
+ }
151
+ Object.keys(setupResult).forEach((key) => {
152
+ const fn = setupResult[key];
153
+ if (typeof fn === "function") {
154
+ const newAPI = (0, import_utils.transformHookRunner)(key);
155
+ if (api[newAPI]) {
156
+ api[newAPI](async (params) => (0, import_utils.transformHookResult)(key, await fn((0, import_utils.transformHookParams)(key, params))));
157
+ }
158
+ }
159
+ });
160
+ }
161
+ // Annotate the CommonJS export names for ESM import in node:
162
+ 0 && (module.exports = {
163
+ getHookRunners,
164
+ handleSetupResult
165
+ });
@@ -0,0 +1,60 @@
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_plugin_v2 = require("@modern-js/plugin-v2");
25
+ var import_hooks = require("./hooks");
26
+ const compatPlugin = () => ({
27
+ name: "@modern-js/app-tools-compat",
28
+ _registryApi: (getAppContext, updateAppContext) => {
29
+ const getInternalContext = () => {
30
+ return getAppContext()._internalContext;
31
+ };
32
+ return {
33
+ useAppContext: () => {
34
+ const { _internalContext, ...appContext } = getAppContext();
35
+ return appContext;
36
+ },
37
+ setAppContext: (context) => {
38
+ return updateAppContext(context);
39
+ },
40
+ useConfigContext: () => {
41
+ return getInternalContext().config;
42
+ },
43
+ useResolvedConfigContext: () => {
44
+ return getInternalContext().normalizedConfig;
45
+ },
46
+ useHookRunners: () => {
47
+ return (0, import_hooks.getHookRunners)(getInternalContext());
48
+ }
49
+ };
50
+ },
51
+ registryHooks: {
52
+ appendEntryCode: (0, import_plugin_v2.createCollectAsyncHook)()
53
+ },
54
+ setup: (_api) => {
55
+ }
56
+ });
57
+ // Annotate the CommonJS export names for ESM import in node:
58
+ 0 && (module.exports = {
59
+ compatPlugin
60
+ });
@@ -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,64 @@
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
+ const pkgPath = import_path.default.resolve(appDirectory, "./package.json");
39
+ return {
40
+ metaName,
41
+ runtimeConfigFile,
42
+ serverConfigFile,
43
+ ip: import_utils.address.ip(),
44
+ port: 0,
45
+ moduleType: import_utils.fs.existsSync(pkgPath) ? require(pkgPath).type || "commonjs" : "commonjs",
46
+ apiDirectory: import_path.default.resolve(appDirectory, apiDir),
47
+ lambdaDirectory: import_path.default.resolve(appDirectory, apiDir, "lambda"),
48
+ sharedDirectory: import_path.default.resolve(appDirectory, sharedDir),
49
+ distDirectory: distDir,
50
+ serverPlugins: [],
51
+ internalDirectory: import_path.default.resolve(appDirectory, tempDir || `./node_modules/.${metaName}`),
52
+ htmlTemplates: {},
53
+ serverRoutes: [],
54
+ entrypoints: [],
55
+ checkedEntries: [],
56
+ apiOnly: false,
57
+ internalDirAlias: `@_${metaName.replace(/-/g, "_")}_internal`,
58
+ internalSrcAlias: `@_${metaName.replace(/-/g, "_")}_src`
59
+ };
60
+ };
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ initAppContext
64
+ });
@@ -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
+ });