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

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 (54) hide show
  1. package/bin/modern.js +2 -2
  2. package/dist/cjs/index.js +142 -4
  3. package/dist/esm/index.js +248 -2
  4. package/dist/esm-node/index.js +130 -2
  5. package/dist/types/index.d.ts +6 -2
  6. package/package.json +18 -26
  7. package/dist/cjs/new/compat/hooks.js +0 -160
  8. package/dist/cjs/new/compat/index.js +0 -52
  9. package/dist/cjs/new/compat/utils.js +0 -95
  10. package/dist/cjs/new/constants.js +0 -37
  11. package/dist/cjs/new/context.js +0 -63
  12. package/dist/cjs/new/getConfigFile.js +0 -41
  13. package/dist/cjs/new/index.js +0 -76
  14. package/dist/cjs/new/loadPlugins.js +0 -57
  15. package/dist/cjs/new/run.js +0 -66
  16. package/dist/cjs/new/types/index.js +0 -16
  17. package/dist/cjs/new/utils/index.js +0 -34
  18. package/dist/cjs/old.js +0 -179
  19. package/dist/esm/new/compat/hooks.js +0 -418
  20. package/dist/esm/new/compat/index.js +0 -30
  21. package/dist/esm/new/compat/utils.js +0 -69
  22. package/dist/esm/new/constants.js +0 -10
  23. package/dist/esm/new/context.js +0 -30
  24. package/dist/esm/new/getConfigFile.js +0 -11
  25. package/dist/esm/new/index.js +0 -52
  26. package/dist/esm/new/loadPlugins.js +0 -94
  27. package/dist/esm/new/run.js +0 -79
  28. package/dist/esm/new/types/index.js +0 -0
  29. package/dist/esm/new/utils/index.js +0 -33
  30. package/dist/esm/old.js +0 -258
  31. package/dist/esm-node/new/compat/hooks.js +0 -135
  32. package/dist/esm-node/new/compat/index.js +0 -28
  33. package/dist/esm-node/new/compat/utils.js +0 -69
  34. package/dist/esm-node/new/constants.js +0 -10
  35. package/dist/esm-node/new/context.js +0 -29
  36. package/dist/esm-node/new/getConfigFile.js +0 -7
  37. package/dist/esm-node/new/index.js +0 -49
  38. package/dist/esm-node/new/loadPlugins.js +0 -33
  39. package/dist/esm-node/new/run.js +0 -42
  40. package/dist/esm-node/new/types/index.js +0 -0
  41. package/dist/esm-node/new/utils/index.js +0 -10
  42. package/dist/esm-node/old.js +0 -140
  43. package/dist/types/new/compat/hooks.d.ts +0 -8
  44. package/dist/types/new/compat/index.d.ts +0 -4
  45. package/dist/types/new/compat/utils.d.ts +0 -6
  46. package/dist/types/new/constants.d.ts +0 -4
  47. package/dist/types/new/context.d.ts +0 -32
  48. package/dist/types/new/getConfigFile.d.ts +0 -1
  49. package/dist/types/new/index.d.ts +0 -15
  50. package/dist/types/new/loadPlugins.d.ts +0 -9
  51. package/dist/types/new/run.d.ts +0 -13
  52. package/dist/types/new/types/index.d.ts +0 -89
  53. package/dist/types/new/utils/index.d.ts +0 -1
  54. package/dist/types/old.d.ts +0 -20
@@ -1,94 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
3
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
4
- import { compatibleRequire, createDebugger, dynamicImport, getInternalPlugins, tryResolve } from "@modern-js/utils";
5
- var debug = createDebugger("load-plugins");
6
- var resolveCliPlugin = function() {
7
- var _ref = _async_to_generator(function(p, appDirectory) {
8
- var pkg, pluginOptions, path, module, e, ref, result;
9
- return _ts_generator(this, function(_state) {
10
- switch (_state.label) {
11
- case 0:
12
- pkg = typeof p === "string" ? p : p[0];
13
- pluginOptions = typeof p === "string" ? void 0 : p[1];
14
- path = tryResolve(pkg, appDirectory);
15
- _state.label = 1;
16
- case 1:
17
- _state.trys.push([
18
- 1,
19
- 3,
20
- ,
21
- 5
22
- ]);
23
- return [
24
- 4,
25
- compatibleRequire(path)
26
- ];
27
- case 2:
28
- module = _state.sent();
29
- return [
30
- 3,
31
- 5
32
- ];
33
- case 3:
34
- e = _state.sent();
35
- return [
36
- 4,
37
- dynamicImport(path)
38
- ];
39
- case 4:
40
- ref = _state.sent(), module = ref.default, ref;
41
- return [
42
- 3,
43
- 5
44
- ];
45
- case 5:
46
- if (typeof module === "function") {
47
- result = module(pluginOptions);
48
- return [
49
- 2,
50
- result
51
- ];
52
- }
53
- return [
54
- 2,
55
- module
56
- ];
57
- }
58
- });
59
- });
60
- return function resolveCliPlugin2(p, appDirectory) {
61
- return _ref.apply(this, arguments);
62
- };
63
- }();
64
- var loadInternalPlugins = function() {
65
- var _ref = _async_to_generator(function(appDirectory, internalPlugins, autoLoad, autoLoadPlugins, forceAutoLoadPlugins) {
66
- var plugins, loadedPlugins;
67
- return _ts_generator(this, function(_state) {
68
- switch (_state.label) {
69
- case 0:
70
- plugins = _to_consumable_array(forceAutoLoadPlugins || autoLoadPlugins ? getInternalPlugins(appDirectory, internalPlugins) : []).concat(_to_consumable_array(autoLoad ? getInternalPlugins(appDirectory, autoLoad) : []));
71
- return [
72
- 4,
73
- Promise.all(plugins.map(function(plugin) {
74
- var loadedPlugin = resolveCliPlugin(plugin, appDirectory);
75
- debug("resolve plugin %s: %s", plugin, loadedPlugin);
76
- return loadedPlugin;
77
- }))
78
- ];
79
- case 1:
80
- loadedPlugins = _state.sent();
81
- return [
82
- 2,
83
- loadedPlugins
84
- ];
85
- }
86
- });
87
- });
88
- return function loadInternalPlugins2(appDirectory, internalPlugins, autoLoad, autoLoadPlugins, forceAutoLoadPlugins) {
89
- return _ref.apply(this, arguments);
90
- };
91
- }();
92
- export {
93
- loadInternalPlugins
94
- };
@@ -1,79 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { initAppDir } from "@modern-js/plugin-v2/cli";
4
- import { run as CLIPluginRun } from "@modern-js/plugin-v2/run";
5
- import { minimist } from "@modern-js/utils";
6
- import { handleSetupResult } from "./compat/hooks";
7
- import { PACKAGE_JSON_CONFIG_NAME } from "./constants";
8
- import { getConfigFile } from "./getConfigFile";
9
- import { loadInternalPlugins } from "./loadPlugins";
10
- import { getIsAutoLoadPlugins } from "./utils";
11
- function run(_) {
12
- return _run.apply(this, arguments);
13
- }
14
- function _run() {
15
- _run = _async_to_generator(function(param) {
16
- var cwd, version, internalPlugins, forceAutoLoadPlugins, packageJsonConfig, configFile, command, cliParams, SUPPORT_CONFIG_PARAM_COMMANDS, customConfigFile, appDirectory, autoLoadPlugins, plugins;
17
- return _ts_generator(this, function(_state) {
18
- switch (_state.label) {
19
- case 0:
20
- cwd = param.cwd, version = param.version, internalPlugins = param.internalPlugins, forceAutoLoadPlugins = param.forceAutoLoadPlugins, packageJsonConfig = param.packageJsonConfig, configFile = param.configFile;
21
- command = process.argv[2];
22
- cliParams = minimist(process.argv.slice(2));
23
- SUPPORT_CONFIG_PARAM_COMMANDS = [
24
- "dev",
25
- "build",
26
- "deploy",
27
- "start",
28
- "serve",
29
- "inspect",
30
- "upgrade"
31
- ];
32
- if (SUPPORT_CONFIG_PARAM_COMMANDS.includes(command)) {
33
- customConfigFile = cliParams.config || cliParams.c;
34
- }
35
- if (command === "new") {
36
- customConfigFile = cliParams["config-file"];
37
- }
38
- return [
39
- 4,
40
- initAppDir(cwd)
41
- ];
42
- case 1:
43
- appDirectory = _state.sent();
44
- return [
45
- 4,
46
- getIsAutoLoadPlugins(appDirectory, customConfigFile || getConfigFile(configFile))
47
- ];
48
- case 2:
49
- autoLoadPlugins = _state.sent();
50
- return [
51
- 4,
52
- loadInternalPlugins(appDirectory, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.cli, internalPlugins === null || internalPlugins === void 0 ? void 0 : internalPlugins.autoLoad, autoLoadPlugins, forceAutoLoadPlugins)
53
- ];
54
- case 3:
55
- plugins = _state.sent();
56
- return [
57
- 4,
58
- CLIPluginRun({
59
- cwd,
60
- initialLog: "Modern.js Framework v".concat(version),
61
- configFile: customConfigFile || getConfigFile(configFile),
62
- packageJsonConfig: packageJsonConfig || PACKAGE_JSON_CONFIG_NAME,
63
- internalPlugins: plugins,
64
- handleSetupResult
65
- })
66
- ];
67
- case 4:
68
- _state.sent();
69
- return [
70
- 2
71
- ];
72
- }
73
- });
74
- });
75
- return _run.apply(this, arguments);
76
- }
77
- export {
78
- run
79
- };
File without changes
@@ -1,33 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
- import { createLoadedConfig } from "@modern-js/plugin-v2/cli";
4
- function getIsAutoLoadPlugins(appDirectory) {
5
- return _getIsAutoLoadPlugins.apply(this, arguments);
6
- }
7
- function _getIsAutoLoadPlugins() {
8
- _getIsAutoLoadPlugins = _async_to_generator(function(appDirectory) {
9
- var configFile, packageJsonConfig, _loaded_config, loaded, autoLoadPlugins;
10
- var _arguments = arguments;
11
- return _ts_generator(this, function(_state) {
12
- switch (_state.label) {
13
- case 0:
14
- configFile = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : "modern.config.ts", packageJsonConfig = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : "ModernConfig";
15
- return [
16
- 4,
17
- createLoadedConfig(appDirectory, configFile, packageJsonConfig)
18
- ];
19
- case 1:
20
- loaded = _state.sent();
21
- autoLoadPlugins = (_loaded_config = loaded.config) === null || _loaded_config === void 0 ? void 0 : _loaded_config.autoLoadPlugins;
22
- return [
23
- 2,
24
- autoLoadPlugins || false
25
- ];
26
- }
27
- });
28
- });
29
- return _getIsAutoLoadPlugins.apply(this, arguments);
30
- }
31
- export {
32
- getIsAutoLoadPlugins
33
- };
package/dist/esm/old.js DELETED
@@ -1,258 +0,0 @@
1
- import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
- import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
3
- import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
4
- import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array";
5
- import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
6
- import path from "path";
7
- import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
8
- import { castArray } from "@modern-js/uni-builder";
9
- import { cleanRequireCache, deprecatedCommands, emptyDir, getArgv, getCommand } from "@modern-js/utils";
10
- import { hooks } from "./hooks";
11
- import { i18n } from "./locale";
12
- import analyzePlugin from "./plugins/analyze";
13
- import deployPlugin from "./plugins/deploy";
14
- import initializePlugin from "./plugins/initialize";
15
- import serverBuildPlugin from "./plugins/serverBuild";
16
- import { buildCommand, deployCommand, devCommand, inspectCommand, newCommand, serverCommand, upgradeCommand } from "./commands";
17
- import { generateWatchFiles } from "./utils/generateWatchFiles";
18
- import { restart } from "./utils/restart";
19
- import { dev } from "./commands/dev";
20
- import { mergeConfig } from "@modern-js/core";
21
- export * from "./defineConfig";
22
- export * from "./types";
23
- var appTools = function() {
24
- var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
25
- // default webpack to be compatible with original projects
26
- bundler: "webpack"
27
- };
28
- return {
29
- name: "@modern-js/app-tools-old",
30
- post: [
31
- "@modern-js/plugin-initialize",
32
- "@modern-js/plugin-analyze",
33
- "@modern-js/plugin-ssr",
34
- "@modern-js/plugin-document",
35
- "@modern-js/plugin-state",
36
- "@modern-js/plugin-router",
37
- "@modern-js/plugin-router-v5",
38
- "@modern-js/plugin-polyfill"
39
- ],
40
- registerHook: hooks,
41
- usePlugins: [
42
- initializePlugin({
43
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
44
- "rspack",
45
- "experimental-rspack"
46
- ].includes(options.bundler) ? "rspack" : "webpack"
47
- }),
48
- analyzePlugin({
49
- bundler: (options === null || options === void 0 ? void 0 : options.bundler) && [
50
- "rspack",
51
- "experimental-rspack"
52
- ].includes(options.bundler) ? "rspack" : "webpack"
53
- }),
54
- serverBuildPlugin(),
55
- deployPlugin()
56
- ],
57
- setup: function(api) {
58
- var appContext = api.useAppContext();
59
- api.setAppContext(_object_spread_props(_object_spread({}, appContext), {
60
- toolsType: "app-tools"
61
- }));
62
- var locale = getLocaleLanguage();
63
- i18n.changeLanguage({
64
- locale
65
- });
66
- return {
67
- beforeConfig: function beforeConfig() {
68
- return _async_to_generator(function() {
69
- var _userConfig_output, userConfig, appContext2;
70
- return _ts_generator(this, function(_state) {
71
- userConfig = api.useConfigContext();
72
- appContext2 = api.useAppContext();
73
- if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
74
- api.setAppContext(_object_spread_props(_object_spread({}, appContext2), {
75
- internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
76
- }));
77
- }
78
- return [
79
- 2
80
- ];
81
- });
82
- })();
83
- },
84
- commands: function commands(param) {
85
- var program = param.program;
86
- return _async_to_generator(function() {
87
- return _ts_generator(this, function(_state) {
88
- switch (_state.label) {
89
- case 0:
90
- return [
91
- 4,
92
- devCommand(program, api)
93
- ];
94
- case 1:
95
- _state.sent();
96
- return [
97
- 4,
98
- buildCommand(program, api)
99
- ];
100
- case 2:
101
- _state.sent();
102
- serverCommand(program, api);
103
- deployCommand(program, api);
104
- newCommand(program, locale);
105
- inspectCommand(program, api);
106
- upgradeCommand(program);
107
- deprecatedCommands(program);
108
- return [
109
- 2
110
- ];
111
- }
112
- });
113
- })();
114
- },
115
- prepare: function prepare() {
116
- return _async_to_generator(function() {
117
- var command, isSkipBuild, resolvedConfig, appContext2;
118
- return _ts_generator(this, function(_state) {
119
- switch (_state.label) {
120
- case 0:
121
- command = getCommand();
122
- if (command === "deploy") {
123
- isSkipBuild = [
124
- "-s",
125
- "--skip-build"
126
- ].some(function(tag) {
127
- return getArgv().includes(tag);
128
- });
129
- if (isSkipBuild) {
130
- return [
131
- 2
132
- ];
133
- }
134
- }
135
- if (!(command === "dev" || command === "start" || command === "build" || command === "deploy"))
136
- return [
137
- 3,
138
- 2
139
- ];
140
- resolvedConfig = api.useResolvedConfigContext();
141
- if (!resolvedConfig.output.cleanDistPath)
142
- return [
143
- 3,
144
- 2
145
- ];
146
- appContext2 = api.useAppContext();
147
- return [
148
- 4,
149
- emptyDir(appContext2.distDirectory)
150
- ];
151
- case 1:
152
- _state.sent();
153
- _state.label = 2;
154
- case 2:
155
- return [
156
- 2
157
- ];
158
- }
159
- });
160
- })();
161
- },
162
- watchFiles: function watchFiles() {
163
- return _async_to_generator(function() {
164
- var appContext2, config, files, watchFiles2;
165
- return _ts_generator(this, function(_state) {
166
- switch (_state.label) {
167
- case 0:
168
- appContext2 = api.useAppContext();
169
- config = api.useResolvedConfigContext();
170
- return [
171
- 4,
172
- generateWatchFiles(appContext2, config.source.configDir)
173
- ];
174
- case 1:
175
- files = _state.sent();
176
- watchFiles2 = castArray(config.dev.watchFiles);
177
- watchFiles2.forEach(function(param) {
178
- var type = param.type, paths = param.paths;
179
- if (type === "reload-server") {
180
- var _files;
181
- (_files = files).push.apply(_files, _to_consumable_array(Array.isArray(paths) ? paths : [
182
- paths
183
- ]));
184
- }
185
- });
186
- return [
187
- 2,
188
- files
189
- ];
190
- }
191
- });
192
- })();
193
- },
194
- fileChange: (
195
- // 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
196
- function fileChange(e) {
197
- return _async_to_generator(function() {
198
- var filename, eventType, isPrivate, closeServer;
199
- return _ts_generator(this, function(_state) {
200
- switch (_state.label) {
201
- case 0:
202
- filename = e.filename, eventType = e.eventType, isPrivate = e.isPrivate;
203
- if (!(!isPrivate && (eventType === "change" || eventType === "unlink")))
204
- return [
205
- 3,
206
- 4
207
- ];
208
- return [
209
- 4,
210
- import("./utils/createServer.js")
211
- ];
212
- case 1:
213
- closeServer = _state.sent().closeServer;
214
- return [
215
- 4,
216
- closeServer()
217
- ];
218
- case 2:
219
- _state.sent();
220
- return [
221
- 4,
222
- restart(api.useHookRunners(), filename)
223
- ];
224
- case 3:
225
- _state.sent();
226
- _state.label = 4;
227
- case 4:
228
- return [
229
- 2
230
- ];
231
- }
232
- });
233
- })();
234
- }
235
- ),
236
- beforeRestart: function beforeRestart() {
237
- return _async_to_generator(function() {
238
- return _ts_generator(this, function(_state) {
239
- cleanRequireCache([
240
- require.resolve("./plugins/analyze")
241
- ]);
242
- return [
243
- 2
244
- ];
245
- });
246
- })();
247
- }
248
- };
249
- }
250
- };
251
- };
252
- var old_default = appTools;
253
- export {
254
- appTools,
255
- old_default as default,
256
- dev,
257
- mergeConfig
258
- };
@@ -1,135 +0,0 @@
1
- import { transformHookParams, transformHookResult, transformHookRunner } from "./utils";
2
- function getHookRunners(context) {
3
- const { hooks } = context;
4
- return {
5
- /**
6
- * app tools hooks
7
- */
8
- beforeConfig: async () => {
9
- return hooks.onBeforeConfig.call();
10
- },
11
- afterPrepare: async () => {
12
- return hooks.onAfterPrepare.call();
13
- },
14
- deploy: async () => {
15
- return hooks.deploy.call();
16
- },
17
- _internalRuntimePlugins: async (params) => {
18
- return hooks._internalRuntimePlugins.call(params);
19
- },
20
- _internalServerPlugins: async (params) => {
21
- return hooks._internalServerPlugins.call(params);
22
- },
23
- checkEntryPoint: async (params) => {
24
- return hooks.checkEntryPoint.call(params);
25
- },
26
- modifyEntrypoints: async (params) => {
27
- return hooks.modifyEntrypoints.call(params);
28
- },
29
- modifyFileSystemRoutes: async (params) => {
30
- return hooks.modifyFileSystemRoutes.call(params);
31
- },
32
- modifyServerRoutes: async (params) => {
33
- return hooks.modifyServerRoutes.call(params);
34
- },
35
- generateEntryCode: async (params) => {
36
- return hooks.generateEntryCode.call(params);
37
- },
38
- beforeGenerateRoutes: async (params) => {
39
- return hooks.onBeforeGenerateRoutes.call(params);
40
- },
41
- beforePrintInstructions: async (params) => {
42
- return hooks.onBeforePrintInstructions.call(params);
43
- },
44
- /**
45
- * common hooks
46
- */
47
- config: async () => {
48
- return hooks.config.call();
49
- },
50
- resolvedConfig: (params) => {
51
- return hooks.modifyResolvedConfig.call(params);
52
- },
53
- htmlPartials: async (params) => {
54
- return hooks.modifyHtmlPartials.call(params);
55
- },
56
- commands: async (params) => {
57
- return hooks.addCommand.call(params);
58
- },
59
- watchFiles: async () => {
60
- return hooks.addWatchFiles.call();
61
- },
62
- prepare: async () => {
63
- return hooks.onPrepare.call();
64
- },
65
- filedChange: async (params) => {
66
- return hooks.onFileChanged.call(params);
67
- },
68
- beforeCreateCompiler: async (params) => {
69
- return hooks.onBeforeCreateCompiler.call(params);
70
- },
71
- afterCreateCompiler: async (params) => {
72
- return hooks.onAfterCreateCompiler.call(params);
73
- },
74
- beforeBuild: async (params) => {
75
- return hooks.onBeforeBuild.call(params);
76
- },
77
- afterBuild: async (params) => {
78
- return hooks.onAfterBuild.call(params);
79
- },
80
- beforeDev: async () => {
81
- return hooks.onBeforeDev.call();
82
- },
83
- afterDev: async (params) => {
84
- return hooks.onAfterDev.call(params);
85
- },
86
- beforeDeploy: async () => {
87
- return hooks.onBeforeDeploy.call();
88
- },
89
- afterDeploy: async () => {
90
- return hooks.onAfterDeploy.call();
91
- },
92
- beforeExit: async () => {
93
- return hooks.onBeforeExit.call();
94
- },
95
- beforeRestart: async () => {
96
- return hooks.onBeforeRestart.call();
97
- },
98
- /**
99
- * @deprecated
100
- */
101
- registerDev: async (params) => {
102
- return hooks.registerDev.call(params);
103
- },
104
- /**
105
- * @deprecated
106
- */
107
- registerBuildPlatform: async (params) => {
108
- return hooks.registerBuildPlatform.call(params);
109
- },
110
- /**
111
- * @deprecated
112
- */
113
- addRuntimeExports: async (params) => {
114
- return hooks.addRuntimeExports.call(params);
115
- }
116
- };
117
- }
118
- function handleSetupResult(setupResult, api) {
119
- if (!setupResult) {
120
- return;
121
- }
122
- Object.keys(setupResult).forEach((key) => {
123
- const fn = setupResult[key];
124
- if (typeof fn === "function") {
125
- const newAPI = transformHookRunner(key);
126
- if (api[newAPI]) {
127
- api[newAPI](async (params) => transformHookResult(key, await fn(transformHookParams(key, params))));
128
- }
129
- }
130
- });
131
- }
132
- export {
133
- getHookRunners,
134
- handleSetupResult
135
- };
@@ -1,28 +0,0 @@
1
- import { getHookRunners } from "./hooks";
2
- const compatPlugin = () => ({
3
- name: "@modern-js/app-tools-compat",
4
- registryApi: (context, updateAppContext) => {
5
- return {
6
- useAppContext: () => {
7
- return context;
8
- },
9
- setAppContext: (context2) => {
10
- return updateAppContext(context2);
11
- },
12
- useConfigContext: () => {
13
- return context.config;
14
- },
15
- useResolvedConfigContext: () => {
16
- return context.normalizedConfig;
17
- },
18
- useHookRunners: () => {
19
- return getHookRunners(context);
20
- }
21
- };
22
- },
23
- setup: (_api) => {
24
- }
25
- });
26
- export {
27
- compatPlugin
28
- };
@@ -1,69 +0,0 @@
1
- function transformHookRunner(hookRunnerName) {
2
- switch (hookRunnerName) {
3
- case "beforeConfig":
4
- return "onBeforeConfig";
5
- case "prepare":
6
- return "onPrepare";
7
- case "afterPrepare":
8
- return "onAfterPrepare";
9
- case "beforeGenerateRoutes":
10
- return "onBeforeGenerateRoutes";
11
- case "beforePrintInstructions":
12
- return "onBeforePrintInstructions";
13
- case "resolvedConfig":
14
- return "modifyResolvedConfig";
15
- case "commands":
16
- return "addCommand";
17
- case "watchFiles":
18
- return "addWatchFiles";
19
- case "filedChange":
20
- return "onFileChanged";
21
- case "beforeCreateCompiler":
22
- return "onBeforeCreateCompiler";
23
- case "afterCreateCompiler":
24
- return "onAfterCreateCompiler";
25
- case "beforeBuild":
26
- return "onBeforeBuild";
27
- case "afterBuild":
28
- return "onAfterBuild";
29
- case "beforeDev":
30
- return "onBeforeDev";
31
- case "afterDev":
32
- return "onAfterDev";
33
- case "beforeDeploy":
34
- return "onBeforeDeploy";
35
- case "afterDeploy":
36
- return "onAfterDeploy";
37
- case "beforeExit":
38
- return "onBeforeExit";
39
- case "beforeRestart":
40
- return "onBeforeRestart";
41
- case "htmlPartials":
42
- return "modifyHtmlPartials";
43
- default:
44
- return hookRunnerName;
45
- }
46
- }
47
- function transformHookParams(hookRunnerName, params) {
48
- switch (hookRunnerName) {
49
- case "resolvedConfig":
50
- return {
51
- resolved: params
52
- };
53
- default:
54
- return params;
55
- }
56
- }
57
- function transformHookResult(hookRunnerName, result) {
58
- switch (hookRunnerName) {
59
- case "resolvedConfig":
60
- return result.resolved;
61
- default:
62
- return result;
63
- }
64
- }
65
- export {
66
- transformHookParams,
67
- transformHookResult,
68
- transformHookRunner
69
- };