@modern-js/core 0.0.0-canary-202111382413 → 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.
package/CHANGELOG.md CHANGED
@@ -1,13 +1,5 @@
1
1
  # @modern-js/core
2
2
 
3
- ## 0.0.0-canary-202111382413
4
-
5
- ### Patch Changes
6
-
7
- - fda2d7f0: support server runtime
8
- - Updated dependencies [fda2d7f0]
9
- - @modern-js/utils@0.0.0-canary-202111382413
10
-
11
3
  ## 1.1.2
12
4
 
13
5
  ### Patch Changes
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-canary-202111382413",
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",
@@ -35,12 +35,20 @@
35
35
  }
36
36
  },
37
37
  "bin": "./bin/modern-js.js",
38
+ "scripts": {
39
+ "prepare": "pnpm build",
40
+ "prepublishOnly": "pnpm build -- --platform",
41
+ "new": "modern new",
42
+ "build": "modern build",
43
+ "dev": "modern build --watch",
44
+ "test": "modern test --passWithNoTests"
45
+ },
38
46
  "dependencies": {
39
47
  "@babel/code-frame": "^7.14.5",
40
48
  "@babel/runtime": "^7",
41
49
  "@modern-js/load-config": "^1.1.1",
42
50
  "@modern-js/plugin": "^1.1.2",
43
- "@modern-js/utils": "^0.0.0-canary-202111382413",
51
+ "@modern-js/utils": "^1.1.2",
44
52
  "address": "^1.1.2",
45
53
  "ajv": "^8.6.2",
46
54
  "ajv-keywords": "^5.0.0",
@@ -78,11 +86,5 @@
78
86
  "publishConfig": {
79
87
  "registry": "https://registry.npmjs.org/",
80
88
  "access": "public"
81
- },
82
- "scripts": {
83
- "new": "modern new",
84
- "build": "modern build",
85
- "dev": "modern build --watch",
86
- "test": "modern test --passWithNoTests"
87
89
  }
88
- }
90
+ }
package/src/index.ts CHANGED
@@ -13,6 +13,8 @@ import {
13
13
  ParallelWorkflow,
14
14
  AsyncWorkflow,
15
15
  Progresses2Runners,
16
+ createAsyncWaterfall,
17
+ AsyncWaterfall,
16
18
  } from '@modern-js/plugin';
17
19
  import { enable } from '@modern-js/plugin/node';
18
20
 
@@ -53,6 +55,9 @@ program
53
55
 
54
56
  export type HooksRunner = Progresses2Runners<{
55
57
  config: ParallelWorkflow<void>;
58
+ resolvedConfig: AsyncWaterfall<{
59
+ resolved: NormalizedConfig;
60
+ }>;
56
61
  validateSchema: ParallelWorkflow<void>;
57
62
  prepare: AsyncWorkflow<void, void>;
58
63
  commands: AsyncWorkflow<
@@ -73,6 +78,9 @@ export type HooksRunner = Progresses2Runners<{
73
78
 
74
79
  const hooksMap = {
75
80
  config: createParallelWorkflow(),
81
+ resolvedConfig: createAsyncWaterfall<{
82
+ resolved: NormalizedConfig;
83
+ }>(),
76
84
  validateSchema: createParallelWorkflow(),
77
85
  // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
78
86
  prepare: createAsyncWorkflow<void, void>(),
@@ -131,7 +139,7 @@ const initAppDir = async (): Promise<string> => {
131
139
  };
132
140
 
133
141
  export interface CoreOptions {
134
- name?: string;
142
+ configFile?: string;
135
143
  plugins?: typeof INTERNAL_PLUGINS;
136
144
  beforeUsePlugins: (plugins: any, config: any) => { cli: any; server: any }[];
137
145
  }
@@ -149,9 +157,13 @@ const createCli = () => {
149
157
 
150
158
  loadEnv(appDirectory);
151
159
 
152
- const loaded = await loadUserConfig(appDirectory);
160
+ const loaded = await loadUserConfig(appDirectory, options?.configFile);
153
161
 
154
- let plugins = loadPlugins(appDirectory, loaded.config.plugins || []);
162
+ let plugins = loadPlugins(
163
+ appDirectory,
164
+ loaded.config.plugins || [],
165
+ options?.plugins,
166
+ );
155
167
 
156
168
  if (options?.beforeUsePlugins) {
157
169
  plugins = options.beforeUsePlugins(plugins, loaded.config);
@@ -187,7 +199,7 @@ const createCli = () => {
187
199
 
188
200
  const extraSchemas = await hooksRunner.validateSchema();
189
201
 
190
- const resolved = await resolveConfig(
202
+ const config = await resolveConfig(
191
203
  loaded,
192
204
  extraConfigs as any,
193
205
  extraSchemas as any,
@@ -195,6 +207,10 @@ const createCli = () => {
195
207
  argv,
196
208
  );
197
209
 
210
+ const { resolved } = await hooksRunner.resolvedConfig({
211
+ resolved: config,
212
+ });
213
+
198
214
  // update context value
199
215
  manager.run(() => {
200
216
  ConfigContext.set(loaded.config);