@modern-js/app-tools 2.62.0 → 2.62.1-alpha.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 (54) hide show
  1. package/bin/modern.js +2 -2
  2. package/dist/cjs/index.js +4 -142
  3. package/dist/cjs/new/compat/hooks.js +160 -0
  4. package/dist/cjs/new/compat/index.js +52 -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 +76 -0
  10. package/dist/cjs/new/loadPlugins.js +57 -0
  11. package/dist/cjs/new/run.js +66 -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/esm/index.js +2 -248
  16. package/dist/esm/new/compat/hooks.js +418 -0
  17. package/dist/esm/new/compat/index.js +30 -0
  18. package/dist/esm/new/compat/utils.js +69 -0
  19. package/dist/esm/new/constants.js +10 -0
  20. package/dist/esm/new/context.js +30 -0
  21. package/dist/esm/new/getConfigFile.js +11 -0
  22. package/dist/esm/new/index.js +52 -0
  23. package/dist/esm/new/loadPlugins.js +94 -0
  24. package/dist/esm/new/run.js +79 -0
  25. package/dist/esm/new/types/index.js +0 -0
  26. package/dist/esm/new/utils/index.js +33 -0
  27. package/dist/esm/old.js +258 -0
  28. package/dist/esm-node/index.js +2 -130
  29. package/dist/esm-node/new/compat/hooks.js +135 -0
  30. package/dist/esm-node/new/compat/index.js +28 -0
  31. package/dist/esm-node/new/compat/utils.js +69 -0
  32. package/dist/esm-node/new/constants.js +10 -0
  33. package/dist/esm-node/new/context.js +29 -0
  34. package/dist/esm-node/new/getConfigFile.js +7 -0
  35. package/dist/esm-node/new/index.js +49 -0
  36. package/dist/esm-node/new/loadPlugins.js +33 -0
  37. package/dist/esm-node/new/run.js +42 -0
  38. package/dist/esm-node/new/types/index.js +0 -0
  39. package/dist/esm-node/new/utils/index.js +10 -0
  40. package/dist/esm-node/old.js +140 -0
  41. package/dist/types/index.d.ts +2 -6
  42. package/dist/types/new/compat/hooks.d.ts +8 -0
  43. package/dist/types/new/compat/index.d.ts +4 -0
  44. package/dist/types/new/compat/utils.d.ts +6 -0
  45. package/dist/types/new/constants.d.ts +4 -0
  46. package/dist/types/new/context.d.ts +32 -0
  47. package/dist/types/new/getConfigFile.d.ts +1 -0
  48. package/dist/types/new/index.d.ts +15 -0
  49. package/dist/types/new/loadPlugins.d.ts +9 -0
  50. package/dist/types/new/run.d.ts +13 -0
  51. package/dist/types/new/types/index.d.ts +89 -0
  52. package/dist/types/new/utils/index.d.ts +1 -0
  53. package/dist/types/old.d.ts +20 -0
  54. package/package.json +14 -6
package/dist/esm/index.js CHANGED
@@ -1,257 +1,11 @@
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";
1
+ import { appTools } from "./new/index";
2
+ export * from "./new/index";
19
3
  import { dev } from "./commands/dev";
20
4
  import { mergeConfig } from "@modern-js/core";
21
5
  export * from "./defineConfig";
22
6
  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",
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
7
  var src_default = appTools;
253
8
  export {
254
- appTools,
255
9
  src_default as default,
256
10
  dev,
257
11
  mergeConfig
@@ -0,0 +1,418 @@
1
+ import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
2
+ import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
3
+ import { transformHookParams, transformHookResult, transformHookRunner } from "./utils";
4
+ function getHookRunners(context) {
5
+ var hooks = context.hooks;
6
+ return {
7
+ /**
8
+ * app tools hooks
9
+ */
10
+ beforeConfig: /* @__PURE__ */ _async_to_generator(function() {
11
+ return _ts_generator(this, function(_state) {
12
+ return [
13
+ 2,
14
+ hooks.onBeforeConfig.call()
15
+ ];
16
+ });
17
+ }),
18
+ afterPrepare: /* @__PURE__ */ _async_to_generator(function() {
19
+ return _ts_generator(this, function(_state) {
20
+ return [
21
+ 2,
22
+ hooks.onAfterPrepare.call()
23
+ ];
24
+ });
25
+ }),
26
+ deploy: /* @__PURE__ */ _async_to_generator(function() {
27
+ return _ts_generator(this, function(_state) {
28
+ return [
29
+ 2,
30
+ hooks.deploy.call()
31
+ ];
32
+ });
33
+ }),
34
+ _internalRuntimePlugins: function() {
35
+ var _ref = _async_to_generator(function(params) {
36
+ return _ts_generator(this, function(_state) {
37
+ return [
38
+ 2,
39
+ hooks._internalRuntimePlugins.call(params)
40
+ ];
41
+ });
42
+ });
43
+ return function(params) {
44
+ return _ref.apply(this, arguments);
45
+ };
46
+ }(),
47
+ _internalServerPlugins: function() {
48
+ var _ref = _async_to_generator(function(params) {
49
+ return _ts_generator(this, function(_state) {
50
+ return [
51
+ 2,
52
+ hooks._internalServerPlugins.call(params)
53
+ ];
54
+ });
55
+ });
56
+ return function(params) {
57
+ return _ref.apply(this, arguments);
58
+ };
59
+ }(),
60
+ checkEntryPoint: function() {
61
+ var _ref = _async_to_generator(function(params) {
62
+ return _ts_generator(this, function(_state) {
63
+ return [
64
+ 2,
65
+ hooks.checkEntryPoint.call(params)
66
+ ];
67
+ });
68
+ });
69
+ return function(params) {
70
+ return _ref.apply(this, arguments);
71
+ };
72
+ }(),
73
+ modifyEntrypoints: function() {
74
+ var _ref = _async_to_generator(function(params) {
75
+ return _ts_generator(this, function(_state) {
76
+ return [
77
+ 2,
78
+ hooks.modifyEntrypoints.call(params)
79
+ ];
80
+ });
81
+ });
82
+ return function(params) {
83
+ return _ref.apply(this, arguments);
84
+ };
85
+ }(),
86
+ modifyFileSystemRoutes: function() {
87
+ var _ref = _async_to_generator(function(params) {
88
+ return _ts_generator(this, function(_state) {
89
+ return [
90
+ 2,
91
+ hooks.modifyFileSystemRoutes.call(params)
92
+ ];
93
+ });
94
+ });
95
+ return function(params) {
96
+ return _ref.apply(this, arguments);
97
+ };
98
+ }(),
99
+ modifyServerRoutes: function() {
100
+ var _ref = _async_to_generator(function(params) {
101
+ return _ts_generator(this, function(_state) {
102
+ return [
103
+ 2,
104
+ hooks.modifyServerRoutes.call(params)
105
+ ];
106
+ });
107
+ });
108
+ return function(params) {
109
+ return _ref.apply(this, arguments);
110
+ };
111
+ }(),
112
+ generateEntryCode: function() {
113
+ var _ref = _async_to_generator(function(params) {
114
+ return _ts_generator(this, function(_state) {
115
+ return [
116
+ 2,
117
+ hooks.generateEntryCode.call(params)
118
+ ];
119
+ });
120
+ });
121
+ return function(params) {
122
+ return _ref.apply(this, arguments);
123
+ };
124
+ }(),
125
+ beforeGenerateRoutes: function() {
126
+ var _ref = _async_to_generator(function(params) {
127
+ return _ts_generator(this, function(_state) {
128
+ return [
129
+ 2,
130
+ hooks.onBeforeGenerateRoutes.call(params)
131
+ ];
132
+ });
133
+ });
134
+ return function(params) {
135
+ return _ref.apply(this, arguments);
136
+ };
137
+ }(),
138
+ beforePrintInstructions: function() {
139
+ var _ref = _async_to_generator(function(params) {
140
+ return _ts_generator(this, function(_state) {
141
+ return [
142
+ 2,
143
+ hooks.onBeforePrintInstructions.call(params)
144
+ ];
145
+ });
146
+ });
147
+ return function(params) {
148
+ return _ref.apply(this, arguments);
149
+ };
150
+ }(),
151
+ /**
152
+ * common hooks
153
+ */
154
+ config: /* @__PURE__ */ _async_to_generator(function() {
155
+ return _ts_generator(this, function(_state) {
156
+ return [
157
+ 2,
158
+ hooks.config.call()
159
+ ];
160
+ });
161
+ }),
162
+ resolvedConfig: function(params) {
163
+ return hooks.modifyResolvedConfig.call(params);
164
+ },
165
+ htmlPartials: function() {
166
+ var _ref = _async_to_generator(function(params) {
167
+ return _ts_generator(this, function(_state) {
168
+ return [
169
+ 2,
170
+ hooks.modifyHtmlPartials.call(params)
171
+ ];
172
+ });
173
+ });
174
+ return function(params) {
175
+ return _ref.apply(this, arguments);
176
+ };
177
+ }(),
178
+ commands: function() {
179
+ var _ref = _async_to_generator(function(params) {
180
+ return _ts_generator(this, function(_state) {
181
+ return [
182
+ 2,
183
+ hooks.addCommand.call(params)
184
+ ];
185
+ });
186
+ });
187
+ return function(params) {
188
+ return _ref.apply(this, arguments);
189
+ };
190
+ }(),
191
+ watchFiles: /* @__PURE__ */ _async_to_generator(function() {
192
+ return _ts_generator(this, function(_state) {
193
+ return [
194
+ 2,
195
+ hooks.addWatchFiles.call()
196
+ ];
197
+ });
198
+ }),
199
+ prepare: /* @__PURE__ */ _async_to_generator(function() {
200
+ return _ts_generator(this, function(_state) {
201
+ return [
202
+ 2,
203
+ hooks.onPrepare.call()
204
+ ];
205
+ });
206
+ }),
207
+ filedChange: function() {
208
+ var _ref = _async_to_generator(function(params) {
209
+ return _ts_generator(this, function(_state) {
210
+ return [
211
+ 2,
212
+ hooks.onFileChanged.call(params)
213
+ ];
214
+ });
215
+ });
216
+ return function(params) {
217
+ return _ref.apply(this, arguments);
218
+ };
219
+ }(),
220
+ beforeCreateCompiler: function() {
221
+ var _ref = _async_to_generator(function(params) {
222
+ return _ts_generator(this, function(_state) {
223
+ return [
224
+ 2,
225
+ hooks.onBeforeCreateCompiler.call(params)
226
+ ];
227
+ });
228
+ });
229
+ return function(params) {
230
+ return _ref.apply(this, arguments);
231
+ };
232
+ }(),
233
+ afterCreateCompiler: function() {
234
+ var _ref = _async_to_generator(function(params) {
235
+ return _ts_generator(this, function(_state) {
236
+ return [
237
+ 2,
238
+ hooks.onAfterCreateCompiler.call(params)
239
+ ];
240
+ });
241
+ });
242
+ return function(params) {
243
+ return _ref.apply(this, arguments);
244
+ };
245
+ }(),
246
+ beforeBuild: function() {
247
+ var _ref = _async_to_generator(function(params) {
248
+ return _ts_generator(this, function(_state) {
249
+ return [
250
+ 2,
251
+ hooks.onBeforeBuild.call(params)
252
+ ];
253
+ });
254
+ });
255
+ return function(params) {
256
+ return _ref.apply(this, arguments);
257
+ };
258
+ }(),
259
+ afterBuild: function() {
260
+ var _ref = _async_to_generator(function(params) {
261
+ return _ts_generator(this, function(_state) {
262
+ return [
263
+ 2,
264
+ hooks.onAfterBuild.call(params)
265
+ ];
266
+ });
267
+ });
268
+ return function(params) {
269
+ return _ref.apply(this, arguments);
270
+ };
271
+ }(),
272
+ beforeDev: /* @__PURE__ */ _async_to_generator(function() {
273
+ return _ts_generator(this, function(_state) {
274
+ return [
275
+ 2,
276
+ hooks.onBeforeDev.call()
277
+ ];
278
+ });
279
+ }),
280
+ afterDev: function() {
281
+ var _ref = _async_to_generator(function(params) {
282
+ return _ts_generator(this, function(_state) {
283
+ return [
284
+ 2,
285
+ hooks.onAfterDev.call(params)
286
+ ];
287
+ });
288
+ });
289
+ return function(params) {
290
+ return _ref.apply(this, arguments);
291
+ };
292
+ }(),
293
+ beforeDeploy: /* @__PURE__ */ _async_to_generator(function() {
294
+ return _ts_generator(this, function(_state) {
295
+ return [
296
+ 2,
297
+ hooks.onBeforeDeploy.call()
298
+ ];
299
+ });
300
+ }),
301
+ afterDeploy: /* @__PURE__ */ _async_to_generator(function() {
302
+ return _ts_generator(this, function(_state) {
303
+ return [
304
+ 2,
305
+ hooks.onAfterDeploy.call()
306
+ ];
307
+ });
308
+ }),
309
+ beforeExit: /* @__PURE__ */ _async_to_generator(function() {
310
+ return _ts_generator(this, function(_state) {
311
+ return [
312
+ 2,
313
+ hooks.onBeforeExit.call()
314
+ ];
315
+ });
316
+ }),
317
+ beforeRestart: /* @__PURE__ */ _async_to_generator(function() {
318
+ return _ts_generator(this, function(_state) {
319
+ return [
320
+ 2,
321
+ hooks.onBeforeRestart.call()
322
+ ];
323
+ });
324
+ }),
325
+ /**
326
+ * @deprecated
327
+ */
328
+ registerDev: function() {
329
+ var _ref = _async_to_generator(function(params) {
330
+ return _ts_generator(this, function(_state) {
331
+ return [
332
+ 2,
333
+ hooks.registerDev.call(params)
334
+ ];
335
+ });
336
+ });
337
+ return function(params) {
338
+ return _ref.apply(this, arguments);
339
+ };
340
+ }(),
341
+ /**
342
+ * @deprecated
343
+ */
344
+ registerBuildPlatform: function() {
345
+ var _ref = _async_to_generator(function(params) {
346
+ return _ts_generator(this, function(_state) {
347
+ return [
348
+ 2,
349
+ hooks.registerBuildPlatform.call(params)
350
+ ];
351
+ });
352
+ });
353
+ return function(params) {
354
+ return _ref.apply(this, arguments);
355
+ };
356
+ }(),
357
+ /**
358
+ * @deprecated
359
+ */
360
+ addRuntimeExports: function() {
361
+ var _ref = _async_to_generator(function(params) {
362
+ return _ts_generator(this, function(_state) {
363
+ return [
364
+ 2,
365
+ hooks.addRuntimeExports.call(params)
366
+ ];
367
+ });
368
+ });
369
+ return function(params) {
370
+ return _ref.apply(this, arguments);
371
+ };
372
+ }()
373
+ };
374
+ }
375
+ function handleSetupResult(setupResult, api) {
376
+ if (!setupResult) {
377
+ return;
378
+ }
379
+ Object.keys(setupResult).forEach(function(key) {
380
+ var fn = setupResult[key];
381
+ if (typeof fn === "function") {
382
+ var newAPI = transformHookRunner(key);
383
+ if (api[newAPI]) {
384
+ api[newAPI](function() {
385
+ var _ref = _async_to_generator(function(params) {
386
+ var _tmp;
387
+ return _ts_generator(this, function(_state) {
388
+ switch (_state.label) {
389
+ case 0:
390
+ _tmp = [
391
+ key
392
+ ];
393
+ return [
394
+ 4,
395
+ fn(transformHookParams(key, params))
396
+ ];
397
+ case 1:
398
+ return [
399
+ 2,
400
+ transformHookResult.apply(void 0, _tmp.concat([
401
+ _state.sent()
402
+ ]))
403
+ ];
404
+ }
405
+ });
406
+ });
407
+ return function(params) {
408
+ return _ref.apply(this, arguments);
409
+ };
410
+ }());
411
+ }
412
+ }
413
+ });
414
+ }
415
+ export {
416
+ getHookRunners,
417
+ handleSetupResult
418
+ };
@@ -0,0 +1,30 @@
1
+ import { getHookRunners } from "./hooks";
2
+ var compatPlugin = function() {
3
+ return {
4
+ name: "@modern-js/app-tools-compat",
5
+ registryApi: function(context, updateAppContext) {
6
+ return {
7
+ useAppContext: function() {
8
+ return context;
9
+ },
10
+ setAppContext: function(context2) {
11
+ return updateAppContext(context2);
12
+ },
13
+ useConfigContext: function() {
14
+ return context.config;
15
+ },
16
+ useResolvedConfigContext: function() {
17
+ return context.normalizedConfig;
18
+ },
19
+ useHookRunners: function() {
20
+ return getHookRunners(context);
21
+ }
22
+ };
23
+ },
24
+ setup: function(_api) {
25
+ }
26
+ };
27
+ };
28
+ export {
29
+ compatPlugin
30
+ };