@modern-js/core 0.0.0-options-202112031440 → 0.0.0-options-202112061451

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.
@@ -60,7 +60,7 @@ const createCli = () => {
60
60
  manager.clear();
61
61
  const appDirectory = await initAppDir();
62
62
  loadEnv(appDirectory);
63
- const loaded = await loadUserConfig(appDirectory);
63
+ const loaded = await loadUserConfig(appDirectory, options === null || options === void 0 ? void 0 : options.configFile);
64
64
  let plugins = loadPlugins(appDirectory, loaded.config.plugins || [], options === null || options === void 0 ? void 0 : options.plugins);
65
65
 
66
66
  if (options !== null && options !== void 0 && options.beforeUsePlugins) {
@@ -150,4 +150,5 @@ const createCli = () => {
150
150
  };
151
151
  };
152
152
 
153
- export const cli = createCli();
153
+ export const cli = createCli();
154
+ export { loadUserConfig, initAppDir, initAppContext };
@@ -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,
@@ -158,6 +174,8 @@ const initAppDir = async () => {
158
174
  return _path.default.dirname(pkg);
159
175
  };
160
176
 
177
+ exports.initAppDir = initAppDir;
178
+
161
179
  const createCli = () => {
162
180
  let hooksRunner;
163
181
  let isRestart = false;
@@ -167,7 +185,7 @@ const createCli = () => {
167
185
  manager.clear();
168
186
  const appDirectory = await initAppDir();
169
187
  (0, _loadEnv.loadEnv)(appDirectory);
170
- const loaded = await (0, _config.loadUserConfig)(appDirectory);
188
+ const loaded = await (0, _config.loadUserConfig)(appDirectory, options === null || options === void 0 ? void 0 : options.configFile);
171
189
  let plugins = (0, _loadPlugins.loadPlugins)(appDirectory, loaded.config.plugins || [], options === null || options === void 0 ? void 0 : options.plugins);
172
190
 
173
191
  if (options !== null && options !== void 0 && options.beforeUsePlugins) {
@@ -2,8 +2,8 @@ import { INTERNAL_PLUGINS } from '@modern-js/utils';
2
2
  import { ParallelWorkflow, AsyncWorkflow, Progresses2Runners, AsyncWaterfall } 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';
@@ -90,8 +90,9 @@ export declare const createPlugin: (initializer: import("@modern-js/plugin").Asy
90
90
  export declare const usePlugins: (plugins: string[]) => void;
91
91
  export { defineConfig, AppContext, useAppContext, useConfigContext, useResolvedConfigContext };
92
92
  export type { NormalizedConfig, IAppContext, UserConfig, ToolsConfig };
93
+ declare const initAppDir: () => Promise<string>;
93
94
  export interface CoreOptions {
94
- name?: string;
95
+ configFile?: string;
95
96
  plugins?: typeof INTERNAL_PLUGINS;
96
97
  beforeUsePlugins: (plugins: any, config: any) => {
97
98
  cli: any;
@@ -106,4 +107,5 @@ export declare const cli: {
106
107
  }>;
107
108
  run: (argv: string[], options?: CoreOptions | undefined) => Promise<void>;
108
109
  restart: () => Promise<void>;
109
- };
110
+ };
111
+ 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-202112031440",
14
+ "version": "0.0.0-options-202112061451",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
package/src/index.ts CHANGED
@@ -139,7 +139,7 @@ const initAppDir = async (): Promise<string> => {
139
139
  };
140
140
 
141
141
  export interface CoreOptions {
142
- name?: string;
142
+ configFile?: string;
143
143
  plugins?: typeof INTERNAL_PLUGINS;
144
144
  beforeUsePlugins: (plugins: any, config: any) => { cli: any; server: any }[];
145
145
  }
@@ -157,7 +157,7 @@ const createCli = () => {
157
157
 
158
158
  loadEnv(appDirectory);
159
159
 
160
- const loaded = await loadUserConfig(appDirectory);
160
+ const loaded = await loadUserConfig(appDirectory, options?.configFile);
161
161
 
162
162
  let plugins = loadPlugins(
163
163
  appDirectory,
@@ -268,3 +268,5 @@ const createCli = () => {
268
268
  };
269
269
 
270
270
  export const cli = createCli();
271
+
272
+ export { loadUserConfig, initAppDir, initAppContext };