@modern-js/core 0.0.0-options-202112031520 → 0.0.0-options-202112061443

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.
@@ -165,6 +165,9 @@ export const server = {
165
165
  },
166
166
  enableMicroFrontendDebug: {
167
167
  type: 'boolean'
168
+ },
169
+ disableUserExtension: {
170
+ type: 'boolean'
168
171
  }
169
172
  }
170
173
  };
@@ -6,7 +6,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
6
6
 
7
7
  import path from 'path';
8
8
  import { compatRequire, pkgUp, ensureAbsolutePath, logger } from '@modern-js/utils';
9
- import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow, createAsyncWaterfall } from '@modern-js/plugin';
9
+ import { createAsyncManager, createAsyncWorkflow, createParallelWorkflow } from '@modern-js/plugin';
10
10
  import { enable } from '@modern-js/plugin/node';
11
11
  import { program } from "./utils/commander";
12
12
  import { resolveConfig, defineConfig, loadUserConfig } from "./config";
@@ -20,7 +20,6 @@ export * from '@modern-js/plugin/node';
20
20
  program.name('modern').usage('<command> [options]').version(process.env.MODERN_JS_VERSION || '0.1.0');
21
21
  const hooksMap = {
22
22
  config: createParallelWorkflow(),
23
- resolvedConfig: createAsyncWaterfall(),
24
23
  validateSchema: createParallelWorkflow(),
25
24
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
26
25
  prepare: createAsyncWorkflow(),
@@ -60,8 +59,8 @@ const createCli = () => {
60
59
  manager.clear();
61
60
  const appDirectory = await initAppDir();
62
61
  loadEnv(appDirectory);
63
- const loaded = await loadUserConfig(appDirectory, options === null || options === void 0 ? void 0 : options.configFile);
64
- let plugins = loadPlugins(appDirectory, loaded.config.plugins || [], options === null || options === void 0 ? void 0 : options.plugins);
62
+ const loaded = await loadUserConfig(appDirectory);
63
+ let plugins = loadPlugins(appDirectory, loaded.config.plugins || []);
65
64
 
66
65
  if (options !== null && options !== void 0 && options.beforeUsePlugins) {
67
66
  plugins = options.beforeUsePlugins(plugins, loaded.config);
@@ -90,12 +89,7 @@ const createCli = () => {
90
89
  });
91
90
  const extraConfigs = await hooksRunner.config();
92
91
  const extraSchemas = await hooksRunner.validateSchema();
93
- const config = await resolveConfig(loaded, extraConfigs, extraSchemas, isRestart, argv);
94
- const {
95
- resolved
96
- } = await hooksRunner.resolvedConfig({
97
- resolved: config
98
- }); // update context value
92
+ const resolved = await resolveConfig(loaded, extraConfigs, extraSchemas, isRestart, argv); // update context value
99
93
 
100
94
  manager.run(() => {
101
95
  ConfigContext.set(loaded.config);
@@ -150,4 +144,5 @@ const createCli = () => {
150
144
  };
151
145
  };
152
146
 
153
- export const cli = createCli();
147
+ export const cli = createCli();
148
+ export { loadUserConfig, initAppDir, initAppContext };
@@ -173,6 +173,9 @@ const server = {
173
173
  },
174
174
  enableMicroFrontendDebug: {
175
175
  type: 'boolean'
176
+ },
177
+ disableUserExtension: {
178
+ type: 'boolean'
176
179
  }
177
180
  }
178
181
  };
@@ -10,10 +10,13 @@ var _exportNames = {
10
10
  mountHook: true,
11
11
  usePlugins: true,
12
12
  cli: true,
13
+ initAppDir: true,
13
14
  defineConfig: true,
15
+ loadUserConfig: true,
14
16
  defaultsConfig: true,
15
17
  mergeConfig: true,
16
18
  AppContext: true,
19
+ initAppContext: true,
17
20
  useAppContext: true,
18
21
  useConfigContext: true,
19
22
  useResolvedConfigContext: true
@@ -37,6 +40,19 @@ Object.defineProperty(exports, "defineConfig", {
37
40
  return _config.defineConfig;
38
41
  }
39
42
  });
43
+ Object.defineProperty(exports, "initAppContext", {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _context.initAppContext;
47
+ }
48
+ });
49
+ exports.initAppDir = void 0;
50
+ Object.defineProperty(exports, "loadUserConfig", {
51
+ enumerable: true,
52
+ get: function () {
53
+ return _config.loadUserConfig;
54
+ }
55
+ });
40
56
  exports.manager = void 0;
41
57
  Object.defineProperty(exports, "mergeConfig", {
42
58
  enumerable: true,
@@ -121,7 +137,6 @@ _commander.program.name('modern').usage('<command> [options]').version(process.e
121
137
 
122
138
  const hooksMap = {
123
139
  config: (0, _plugin.createParallelWorkflow)(),
124
- resolvedConfig: (0, _plugin.createAsyncWaterfall)(),
125
140
  validateSchema: (0, _plugin.createParallelWorkflow)(),
126
141
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
127
142
  prepare: (0, _plugin.createAsyncWorkflow)(),
@@ -158,6 +173,8 @@ const initAppDir = async () => {
158
173
  return _path.default.dirname(pkg);
159
174
  };
160
175
 
176
+ exports.initAppDir = initAppDir;
177
+
161
178
  const createCli = () => {
162
179
  let hooksRunner;
163
180
  let isRestart = false;
@@ -167,8 +184,8 @@ const createCli = () => {
167
184
  manager.clear();
168
185
  const appDirectory = await initAppDir();
169
186
  (0, _loadEnv.loadEnv)(appDirectory);
170
- const loaded = await (0, _config.loadUserConfig)(appDirectory, options === null || options === void 0 ? void 0 : options.configFile);
171
- let plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config.plugins || [], options === null || options === void 0 ? void 0 : options.plugins);
187
+ const loaded = await (0, _config.loadUserConfig)(appDirectory);
188
+ let plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config.plugins || []);
172
189
 
173
190
  if (options !== null && options !== void 0 && options.beforeUsePlugins) {
174
191
  plugins = options.beforeUsePlugins(plugins, loaded.config);
@@ -198,12 +215,7 @@ const createCli = () => {
198
215
  });
199
216
  const extraConfigs = await hooksRunner.config();
200
217
  const extraSchemas = await hooksRunner.validateSchema();
201
- const config = await (0, _config.resolveConfig)(loaded, extraConfigs, extraSchemas, isRestart, argv);
202
- const {
203
- resolved
204
- } = await hooksRunner.resolvedConfig({
205
- resolved: config
206
- }); // update context value
218
+ const resolved = await (0, _config.resolveConfig)(loaded, extraConfigs, extraSchemas, isRestart, argv); // update context value
207
219
 
208
220
  manager.run(() => {
209
221
  _context.ConfigContext.set(loaded.config);
@@ -75,6 +75,7 @@ export interface ServerConfig {
75
75
  logger?: Record<string, string>;
76
76
  measure?: Record<string, string>;
77
77
  enableMicroFrontendDebug?: boolean;
78
+ disableUserExtension?: boolean;
78
79
  }
79
80
  export interface DevConfig {
80
81
  assetPrefix?: string | boolean;
@@ -391,6 +391,9 @@ export declare const patchSchema: (pluginSchemas: Array<PluginValidateSchema | P
391
391
  enableMicroFrontendDebug: {
392
392
  type: string;
393
393
  };
394
+ disableUserExtension: {
395
+ type: string;
396
+ };
394
397
  };
395
398
  };
396
399
  deploy: {
@@ -178,5 +178,8 @@ export declare const server: {
178
178
  enableMicroFrontendDebug: {
179
179
  type: string;
180
180
  };
181
+ disableUserExtension: {
182
+ type: string;
183
+ };
181
184
  };
182
185
  };
@@ -1,9 +1,9 @@
1
1
  import { INTERNAL_PLUGINS } from '@modern-js/utils';
2
- import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners, AsyncWaterfall } from '@modern-js/plugin';
2
+ import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners } from '@modern-js/plugin';
3
3
  import type { Hooks } from '@modern-js/types';
4
4
  import { Command } from './utils/commander';
5
- import { defineConfig, UserConfig, ToolsConfig } from './config';
6
- import { AppContext, IAppContext, useAppContext, useConfigContext, useResolvedConfigContext } from './context';
5
+ import { defineConfig, loadUserConfig, UserConfig, ToolsConfig } from './config';
6
+ import { AppContext, IAppContext, initAppContext, useAppContext, useConfigContext, useResolvedConfigContext } from './context';
7
7
  import { NormalizedConfig } from './config/mergeConfig';
8
8
  export type { Hooks };
9
9
  export { defaultsConfig, mergeConfig } from './config';
@@ -11,9 +11,6 @@ export * from '@modern-js/plugin';
11
11
  export * from '@modern-js/plugin/node';
12
12
  export declare type HooksRunner = Progresses2Runners<{
13
13
  config: ParallelWorkflow<void>;
14
- resolvedConfig: AsyncWaterfall<{
15
- resolved: NormalizedConfig;
16
- }>;
17
14
  validateSchema: ParallelWorkflow<void>;
18
15
  prepare: AsyncWorkflow<void, void>;
19
16
  commands: AsyncWorkflow<{
@@ -27,9 +24,6 @@ export declare type HooksRunner = Progresses2Runners<{
27
24
  }>;
28
25
  export declare const manager: import("@modern-js/plugin").AsyncManager<Hooks, {
29
26
  config: ParallelWorkflow<void, unknown>;
30
- resolvedConfig: AsyncWaterfall<{
31
- resolved: NormalizedConfig;
32
- }>;
33
27
  validateSchema: ParallelWorkflow<void, unknown>;
34
28
  prepare: AsyncWorkflow<void, void>;
35
29
  commands: AsyncWorkflow<{
@@ -43,9 +37,6 @@ export declare const manager: import("@modern-js/plugin").AsyncManager<Hooks, {
43
37
  }>;
44
38
  export declare const createPlugin: (initializer: import("@modern-js/plugin").AsyncInitializer<Partial<import("@modern-js/plugin").Progresses2Threads<{
45
39
  config: ParallelWorkflow<void, unknown>;
46
- resolvedConfig: AsyncWaterfall<{
47
- resolved: NormalizedConfig;
48
- }>;
49
40
  validateSchema: ParallelWorkflow<void, unknown>;
50
41
  prepare: AsyncWorkflow<void, void>;
51
42
  commands: AsyncWorkflow<{
@@ -58,9 +49,6 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
58
49
  beforeExit: AsyncWorkflow<void, void>;
59
50
  } & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, options?: import("@modern-js/plugin").PluginOptions | undefined) => import("@modern-js/plugin").AsyncPlugin<Partial<import("@modern-js/plugin").Progresses2Threads<{
60
51
  config: ParallelWorkflow<void, unknown>;
61
- resolvedConfig: AsyncWaterfall<{
62
- resolved: NormalizedConfig;
63
- }>;
64
52
  validateSchema: ParallelWorkflow<void, unknown>;
65
53
  prepare: AsyncWorkflow<void, void>;
66
54
  commands: AsyncWorkflow<{
@@ -73,9 +61,6 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
73
61
  beforeExit: AsyncWorkflow<void, void>;
74
62
  } & import("@modern-js/plugin").ClearDraftProgress<Hooks>>>>, registerHook: (newShape: Partial<Hooks>) => void, mountHook: () => Progresses2Runners<{
75
63
  config: ParallelWorkflow<void, unknown>;
76
- resolvedConfig: AsyncWaterfall<{
77
- resolved: NormalizedConfig;
78
- }>;
79
64
  validateSchema: ParallelWorkflow<void, unknown>;
80
65
  prepare: AsyncWorkflow<void, void>;
81
66
  commands: AsyncWorkflow<{
@@ -90,8 +75,9 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
90
75
  export declare const usePlugins: (plugins: string[]) => void;
91
76
  export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedConfigContext };
92
77
  export type { NormalizedConfig, IAppContext, UserConfig, ToolsConfig };
78
+ declare const initAppDir: () => Promise<string>;
93
79
  export interface CoreOptions {
94
- configFile?: string;
80
+ name?: string;
95
81
  plugins?: typeof INTERNAL_PLUGINS;
96
82
  beforeUsePlugins: (plugins: any, config: any) => {
97
83
  cli: any;
@@ -106,4 +92,5 @@ export declare const cli: {
106
92
  }>;
107
93
  run: (argv: string[], options?: CoreOptions | undefined) => Promise<void>;
108
94
  restart: () => Promise<void>;
109
- };
95
+ };
96
+ export { loadUserConfig, initAppDir, initAppContext };
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-options-202112031520",
14
+ "version": "0.0.0-options-202112061443",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -109,6 +109,7 @@ export interface ServerConfig {
109
109
  logger?: Record<string, string>;
110
110
  measure?: Record<string, string>;
111
111
  enableMicroFrontendDebug?: boolean;
112
+ disableUserExtension?: boolean;
112
113
  }
113
114
 
114
115
  export interface DevConfig {
@@ -102,5 +102,6 @@ export const server = {
102
102
  measure: { type: 'object' },
103
103
  proxy: { type: 'object' },
104
104
  enableMicroFrontendDebug: { type: 'boolean' },
105
+ disableUserExtension: { type: 'boolean' },
105
106
  },
106
107
  };
package/src/index.ts CHANGED
@@ -268,3 +268,5 @@ const createCli = () => {
268
268
  };
269
269
 
270
270
  export const cli = createCli();
271
+
272
+ export { loadUserConfig, initAppDir, initAppContext };