@modern-js/module-tools 0.0.0-compat-202112171546 → 0.0.0-runtime-2021112193858

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,5 +1,46 @@
1
1
  # @modern-js/module-tools
2
2
 
3
+ ## 0.0.0-runtime-2021112193858
4
+
5
+ ### Patch Changes
6
+
7
+ - 8698465e: fix: dependence version
8
+ - Updated dependencies [8698465e]
9
+ - Updated dependencies [e04914ce]
10
+ - Updated dependencies [e04914ce]
11
+ - @modern-js/babel-preset-module@0.0.0-runtime-2021112193858
12
+ - @modern-js/core@0.0.0-runtime-2021112193858
13
+ - @modern-js/css-config@0.0.0-runtime-2021112193858
14
+ - @modern-js/i18n-cli-language-detector@0.0.0-runtime-2021112193858
15
+ - @modern-js/plugin-analyze@0.0.0-runtime-2021112193858
16
+ - @modern-js/plugin-changeset@0.0.0-runtime-2021112193858
17
+ - @modern-js/plugin-fast-refresh@0.0.0-runtime-2021112193858
18
+ - @modern-js/plugin-i18n@0.0.0-runtime-2021112193858
19
+ - @modern-js/new-action@0.0.0-runtime-2021112193858
20
+ - @modern-js/babel-compiler@0.0.0-runtime-2021112193858
21
+ - @modern-js/style-compiler@0.0.0-runtime-2021112193858
22
+ - @modern-js/utils@0.0.0-runtime-2021112193858
23
+ - @modern-js/module-tools-hooks@0.0.0-runtime-2021112193858
24
+
25
+ ## 1.1.2
26
+
27
+ ### Patch Changes
28
+
29
+ - d927bc83: add run platform task with RUN_PLATFORM env vars
30
+ - Updated dependencies [d927bc83]
31
+ - Updated dependencies [d73ff455]
32
+ - Updated dependencies [9c1ab865]
33
+ - Updated dependencies [c5e3d4ad]
34
+ - Updated dependencies [d73ff455]
35
+ - Updated dependencies [d73ff455]
36
+ - Updated dependencies [d73ff455]
37
+ - Updated dependencies [d73ff455]
38
+ - @modern-js/utils@1.1.4
39
+ - @modern-js/core@1.1.4
40
+ - @modern-js/style-compiler@1.1.3
41
+ - @modern-js/css-config@1.1.2
42
+ - @modern-js/module-tools-hooks@1.1.2
43
+
3
44
  ## 1.1.1
4
45
 
5
46
  ### Patch Changes
@@ -27,9 +27,6 @@ export const buildInWatchMode = async (config, _) => {
27
27
  const styleLog = lm.createLoggerText({
28
28
  title: constants.runStyleCompilerTitle
29
29
  });
30
- const copyLog = lm.createLoggerText({
31
- title: 'Copy Log:'
32
- });
33
30
  const initCodeMapper = utils.getCodeInitMapper(config);
34
31
  const taskMapper = [...utils.getCodeMapper({
35
32
  logger: codeLog,
@@ -41,10 +38,6 @@ export const buildInWatchMode = async (config, _) => {
41
38
  }), ...(enableTscCompiler ? utils.getDtsMapper(config, dtsLog) : []), {
42
39
  logger: styleLog,
43
40
  taskPath: require.resolve("../../tasks/build-watch-style")
44
- }, {
45
- logger: copyLog,
46
- taskPath: require.resolve("../../tasks/copy-assets"),
47
- params: ['--watch']
48
41
  }];
49
42
  lm.on('data', () => {
50
43
  console.info(constants.clearFlag);
@@ -85,7 +78,7 @@ export const buildInWatchMode = async (config, _) => {
85
78
  });
86
79
  }
87
80
 
88
- if (logger === styleLog || logger === copyLog) {
81
+ if (logger === styleLog) {
89
82
  lm.addStdout(logger, childProcess.stdout, {
90
83
  event: {
91
84
  error: true,
@@ -118,11 +118,11 @@ export const initEnv = ({
118
118
  type
119
119
  }) => {
120
120
  if (syntax === 'es6+' && type === 'commonjs') {
121
- return 'CJS_ES6';
121
+ return 'nodejs';
122
122
  } else if (syntax === 'es6+' && type === 'module') {
123
- return 'ESM+ES6';
123
+ return 'modern';
124
124
  } else if (syntax === 'es5' && type === 'module') {
125
- return 'ESM+ES5';
125
+ return 'legacy-browser';
126
126
  }
127
127
 
128
128
  return '';
@@ -143,11 +143,11 @@ const defaultConfig = {
143
143
  const taskMain = async ({
144
144
  modernConfig
145
145
  }) => {
146
- // Execution of the script's parameter handling and related required configuration acquisition
146
+ // 执行脚本的参数处理和相关需要配置的获取
147
147
  const processArgv = argv(process.argv.slice(2));
148
- const config = processArgv(defaultConfig);
149
- process.env.BUILD_FORMAT = initEnv(config);
150
- const compiler = Compiler.babel; // Currently, only babel is supported.
148
+ const config = processArgv(defaultConfig); // process.env.BUILD_MODE = initEnv(config);
149
+
150
+ const compiler = Compiler.babel; // 目前暂时只支持 babel
151
151
 
152
152
  const babelConfig = bc.resolveBabelConfig(config.appDirectory, modernConfig, {
153
153
  sourceAbsDir: config.srcRootDir,
@@ -196,17 +196,9 @@ const taskMain = async ({
196
196
  };
197
197
 
198
198
  (async () => {
199
- let options;
200
-
201
- if (process.env.CORE_INIT_OPTION_FILE) {
202
- ({
203
- options
204
- } = require(process.env.CORE_INIT_OPTION_FILE));
205
- }
206
-
207
199
  const {
208
200
  resolved
209
- } = await core.cli.init([], options);
201
+ } = await core.cli.init();
210
202
  await core.manager.run(async () => {
211
203
  try {
212
204
  await taskMain({
@@ -143,19 +143,11 @@ const taskMain = async ({
143
143
  };
144
144
 
145
145
  (async () => {
146
- let options;
147
-
148
- if (process.env.CORE_INIT_OPTION_FILE) {
149
- ({
150
- options
151
- } = require(process.env.CORE_INIT_OPTION_FILE));
152
- }
153
-
154
146
  hooks.buildLifeCycle();
155
147
  const {
156
148
  resolved: modernConfig,
157
149
  appContext
158
- } = await core.cli.init([], options);
150
+ } = await core.cli.init();
159
151
  await core.manager.run(async () => {
160
152
  try {
161
153
  await taskMain({
@@ -1,5 +1,4 @@
1
1
  import { Import, fs } from '@modern-js/utils';
2
- import { initEnv } from "./build-source-code";
3
2
  const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
4
3
  const logger = Import.lazy('../features/build/logger', require);
5
4
  const ts = Import.lazy('../utils/tsconfig', require);
@@ -124,22 +123,13 @@ const taskMain = async ({
124
123
  syntax: 'es5',
125
124
  type: 'module'
126
125
  });
127
- process.env.BUILD_FORMAT = initEnv(config);
128
126
  await buildSourceCode(config, modernConfig);
129
127
  };
130
128
 
131
129
  (async () => {
132
- let options;
133
-
134
- if (process.env.CORE_INIT_OPTION_FILE) {
135
- ({
136
- options
137
- } = require(process.env.CORE_INIT_OPTION_FILE));
138
- }
139
-
140
130
  const {
141
131
  resolved
142
- } = await core.cli.init([], options);
132
+ } = await core.cli.init();
143
133
  await core.manager.run(async () => {
144
134
  try {
145
135
  await taskMain({
@@ -53,7 +53,6 @@ const copyOriginStyleFiles = ({
53
53
 
54
54
  for (const styleFile of styleFiles) {
55
55
  const file = path.relative(targetDir, styleFile);
56
- fs.ensureFileSync(path.join(outputDir, file));
57
56
  fs.copyFileSync(styleFile, path.join(outputDir, file));
58
57
  }
59
58
  };
@@ -78,13 +77,9 @@ const taskMain = async ({
78
77
  appDirectory
79
78
  } = appContext;
80
79
  const lessOption = await core.mountHook().moduleLessConfig({
81
- modernConfig
82
- }, {
83
80
  onLast: async _ => null
84
81
  });
85
82
  const sassOption = await core.mountHook().moduleSassConfig({
86
- modernConfig
87
- }, {
88
83
  onLast: async _ => null
89
84
  });
90
85
  const postcssOption = getPostcssOption(appDirectory, modernConfig);
@@ -191,19 +186,11 @@ const taskMain = async ({
191
186
  };
192
187
 
193
188
  (async () => {
194
- let options;
195
-
196
- if (process.env.CORE_INIT_OPTION_FILE) {
197
- ({
198
- options
199
- } = require(process.env.CORE_INIT_OPTION_FILE));
200
- }
201
-
202
189
  hooks.buildLifeCycle();
203
190
  const {
204
191
  resolved: modernConfig,
205
192
  appContext
206
- } = await core.cli.init([], options);
193
+ } = await core.cli.init();
207
194
  await core.manager.run(async () => {
208
195
  try {
209
196
  await taskMain({
@@ -211,7 +198,7 @@ const taskMain = async ({
211
198
  appContext
212
199
  });
213
200
  } catch (e) {
214
- console.error(e);
201
+ console.error(e.message);
215
202
  }
216
203
  });
217
204
  })();
@@ -89,18 +89,10 @@ const taskMain = ({
89
89
  };
90
90
 
91
91
  (async () => {
92
- let options;
93
-
94
- if (process.env.CORE_INIT_OPTION_FILE) {
95
- ({
96
- options
97
- } = require(process.env.CORE_INIT_OPTION_FILE));
98
- }
99
-
100
92
  const {
101
93
  resolved: modernConfig,
102
94
  appContext
103
- } = await core.cli.init([], options);
95
+ } = await core.cli.init();
104
96
  core.manager.run(() => {
105
97
  try {
106
98
  taskMain({
@@ -202,17 +202,9 @@ const taskMain = async ({
202
202
  };
203
203
 
204
204
  (async () => {
205
- let options;
206
-
207
- if (process.env.CORE_INIT_OPTION_FILE) {
208
- ({
209
- options
210
- } = require(process.env.CORE_INIT_OPTION_FILE));
211
- }
212
-
213
205
  const {
214
206
  resolved
215
- } = await core.cli.init([], options);
207
+ } = await core.cli.init();
216
208
  await core.manager.run(async () => {
217
209
  try {
218
210
  await taskMain({
@@ -47,9 +47,6 @@ const buildInWatchMode = async (config, _) => {
47
47
  const styleLog = lm.createLoggerText({
48
48
  title: constants.runStyleCompilerTitle
49
49
  });
50
- const copyLog = lm.createLoggerText({
51
- title: 'Copy Log:'
52
- });
53
50
  const initCodeMapper = utils.getCodeInitMapper(config);
54
51
  const taskMapper = [...utils.getCodeMapper({
55
52
  logger: codeLog,
@@ -61,10 +58,6 @@ const buildInWatchMode = async (config, _) => {
61
58
  }), ...(enableTscCompiler ? utils.getDtsMapper(config, dtsLog) : []), {
62
59
  logger: styleLog,
63
60
  taskPath: require.resolve("../../tasks/build-watch-style")
64
- }, {
65
- logger: copyLog,
66
- taskPath: require.resolve("../../tasks/copy-assets"),
67
- params: ['--watch']
68
61
  }];
69
62
  lm.on('data', () => {
70
63
  console.info(constants.clearFlag);
@@ -105,7 +98,7 @@ const buildInWatchMode = async (config, _) => {
105
98
  });
106
99
  }
107
100
 
108
- if (logger === styleLog || logger === copyLog) {
101
+ if (logger === styleLog) {
109
102
  lm.addStdout(logger, childProcess.stdout, {
110
103
  event: {
111
104
  error: true,
@@ -141,11 +141,11 @@ const initEnv = ({
141
141
  type
142
142
  }) => {
143
143
  if (syntax === 'es6+' && type === 'commonjs') {
144
- return 'CJS_ES6';
144
+ return 'nodejs';
145
145
  } else if (syntax === 'es6+' && type === 'module') {
146
- return 'ESM+ES6';
146
+ return 'modern';
147
147
  } else if (syntax === 'es5' && type === 'module') {
148
- return 'ESM+ES5';
148
+ return 'legacy-browser';
149
149
  }
150
150
 
151
151
  return '';
@@ -168,11 +168,11 @@ const defaultConfig = {
168
168
  const taskMain = async ({
169
169
  modernConfig
170
170
  }) => {
171
- // Execution of the script's parameter handling and related required configuration acquisition
171
+ // 执行脚本的参数处理和相关需要配置的获取
172
172
  const processArgv = argv(process.argv.slice(2));
173
- const config = processArgv(defaultConfig);
174
- process.env.BUILD_FORMAT = initEnv(config);
175
- const compiler = Compiler.babel; // Currently, only babel is supported.
173
+ const config = processArgv(defaultConfig); // process.env.BUILD_MODE = initEnv(config);
174
+
175
+ const compiler = Compiler.babel; // 目前暂时只支持 babel
176
176
 
177
177
  const babelConfig = bc.resolveBabelConfig(config.appDirectory, modernConfig, {
178
178
  sourceAbsDir: config.srcRootDir,
@@ -222,17 +222,9 @@ const taskMain = async ({
222
222
  };
223
223
 
224
224
  (async () => {
225
- let options;
226
-
227
- if (process.env.CORE_INIT_OPTION_FILE) {
228
- ({
229
- options
230
- } = require(process.env.CORE_INIT_OPTION_FILE));
231
- }
232
-
233
225
  const {
234
226
  resolved
235
- } = await core.cli.init([], options);
227
+ } = await core.cli.init();
236
228
  await core.manager.run(async () => {
237
229
  try {
238
230
  await taskMain({
@@ -159,19 +159,11 @@ const taskMain = async ({
159
159
  };
160
160
 
161
161
  (async () => {
162
- let options;
163
-
164
- if (process.env.CORE_INIT_OPTION_FILE) {
165
- ({
166
- options
167
- } = require(process.env.CORE_INIT_OPTION_FILE));
168
- }
169
-
170
162
  hooks.buildLifeCycle();
171
163
  const {
172
164
  resolved: modernConfig,
173
165
  appContext
174
- } = await core.cli.init([], options);
166
+ } = await core.cli.init();
175
167
  await core.manager.run(async () => {
176
168
  try {
177
169
  await taskMain({
@@ -2,8 +2,6 @@
2
2
 
3
3
  var _utils = require("@modern-js/utils");
4
4
 
5
- var _buildSourceCode = require("./build-source-code");
6
-
7
5
  const babelCompiler = _utils.Import.lazy('@modern-js/babel-compiler', require);
8
6
 
9
7
  const logger = _utils.Import.lazy('../features/build/logger', require);
@@ -136,22 +134,13 @@ const taskMain = async ({
136
134
  syntax: 'es5',
137
135
  type: 'module'
138
136
  });
139
- process.env.BUILD_FORMAT = (0, _buildSourceCode.initEnv)(config);
140
137
  await buildSourceCode(config, modernConfig);
141
138
  };
142
139
 
143
140
  (async () => {
144
- let options;
145
-
146
- if (process.env.CORE_INIT_OPTION_FILE) {
147
- ({
148
- options
149
- } = require(process.env.CORE_INIT_OPTION_FILE));
150
- }
151
-
152
141
  const {
153
142
  resolved
154
- } = await core.cli.init([], options);
143
+ } = await core.cli.init();
155
144
  await core.manager.run(async () => {
156
145
  try {
157
146
  await taskMain({
@@ -69,8 +69,6 @@ const copyOriginStyleFiles = ({
69
69
  for (const styleFile of styleFiles) {
70
70
  const file = path.relative(targetDir, styleFile);
71
71
 
72
- _utils.fs.ensureFileSync(path.join(outputDir, file));
73
-
74
72
  _utils.fs.copyFileSync(styleFile, path.join(outputDir, file));
75
73
  }
76
74
  };
@@ -95,13 +93,9 @@ const taskMain = async ({
95
93
  appDirectory
96
94
  } = appContext;
97
95
  const lessOption = await core.mountHook().moduleLessConfig({
98
- modernConfig
99
- }, {
100
96
  onLast: async _ => null
101
97
  });
102
98
  const sassOption = await core.mountHook().moduleSassConfig({
103
- modernConfig
104
- }, {
105
99
  onLast: async _ => null
106
100
  });
107
101
  const postcssOption = getPostcssOption(appDirectory, modernConfig);
@@ -209,19 +203,11 @@ const taskMain = async ({
209
203
  };
210
204
 
211
205
  (async () => {
212
- let options;
213
-
214
- if (process.env.CORE_INIT_OPTION_FILE) {
215
- ({
216
- options
217
- } = require(process.env.CORE_INIT_OPTION_FILE));
218
- }
219
-
220
206
  hooks.buildLifeCycle();
221
207
  const {
222
208
  resolved: modernConfig,
223
209
  appContext
224
- } = await core.cli.init([], options);
210
+ } = await core.cli.init();
225
211
  await core.manager.run(async () => {
226
212
  try {
227
213
  await taskMain({
@@ -229,7 +215,7 @@ const taskMain = async ({
229
215
  appContext
230
216
  });
231
217
  } catch (e) {
232
- console.error(e);
218
+ console.error(e.message);
233
219
  }
234
220
  });
235
221
  })();
@@ -106,18 +106,10 @@ const taskMain = ({
106
106
  };
107
107
 
108
108
  (async () => {
109
- let options;
110
-
111
- if (process.env.CORE_INIT_OPTION_FILE) {
112
- ({
113
- options
114
- } = require(process.env.CORE_INIT_OPTION_FILE));
115
- }
116
-
117
109
  const {
118
110
  resolved: modernConfig,
119
111
  appContext
120
- } = await core.cli.init([], options);
112
+ } = await core.cli.init();
121
113
  core.manager.run(() => {
122
114
  try {
123
115
  taskMain({
@@ -223,17 +223,9 @@ const taskMain = async ({
223
223
  };
224
224
 
225
225
  (async () => {
226
- let options;
227
-
228
- if (process.env.CORE_INIT_OPTION_FILE) {
229
- ({
230
- options
231
- } = require(process.env.CORE_INIT_OPTION_FILE));
232
- }
233
-
234
226
  const {
235
227
  resolved
236
- } = await core.cli.init([], options);
228
+ } = await core.cli.init();
237
229
  await core.manager.run(async () => {
238
230
  try {
239
231
  await taskMain({
@@ -2,6 +2,9 @@ export declare const defineConfig: (config: import("@modern-js/core/config").Con
2
2
 
3
3
  declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
4
4
  config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
5
+ resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
6
+ resolved: import("@modern-js/core").NormalizedConfig;
7
+ }>;
5
8
  validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
6
9
  prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
7
10
  commands: import("@modern-js/core").AsyncWorkflow<{
@@ -25,10 +25,7 @@ export declare const buildSourceCode: (config: IBuildSourceCodeConfig) => Promis
25
25
  export declare const initEnv: ({
26
26
  syntax,
27
27
  type
28
- }: {
29
- syntax: ITaskConfig['syntax'];
30
- type: ITaskConfig['type'];
31
- }) => "" | "ESM+ES5" | "ESM+ES6" | "CJS_ES6";
28
+ }: ITaskConfig) => "" | "modern" | "nodejs" | "legacy-browser";
32
29
  interface ITaskConfig {
33
30
  srcRootDir: string;
34
31
  willCompilerDirOrFile: string;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "0.0.0-compat-202112171546",
14
+ "version": "0.0.0-runtime-2021112193858",
15
15
  "bin": {
16
16
  "modern": "./bin/modern.js"
17
17
  },
@@ -44,19 +44,19 @@
44
44
  "@babel/runtime": "^7",
45
45
  "@babel/traverse": "^7.15.0",
46
46
  "@babel/types": "^7.15.0",
47
- "@modern-js/babel-compiler": "^1.1.2",
48
- "@modern-js/babel-preset-module": "^1.1.1",
49
- "@modern-js/core": "^1.1.2",
50
- "@modern-js/css-config": "^1.1.1",
51
- "@modern-js/i18n-cli-language-detector": "^1.1.1",
52
- "@modern-js/module-tools-hooks": "^1.1.1",
53
- "@modern-js/new-action": "^1.1.2",
54
- "@modern-js/plugin-analyze": "^1.1.1",
55
- "@modern-js/plugin-changeset": "^1.1.1",
56
- "@modern-js/plugin-fast-refresh": "^1.1.1",
57
- "@modern-js/plugin-i18n": "^1.1.1",
58
- "@modern-js/style-compiler": "^1.1.1",
59
- "@modern-js/utils": "^1.1.2",
47
+ "@modern-js/babel-compiler": "^0.0.0-runtime-2021112193858",
48
+ "@modern-js/babel-preset-module": "^0.0.0-runtime-2021112193858",
49
+ "@modern-js/core": "^0.0.0-runtime-2021112193858",
50
+ "@modern-js/css-config": "^0.0.0-runtime-2021112193858",
51
+ "@modern-js/i18n-cli-language-detector": "^0.0.0-runtime-2021112193858",
52
+ "@modern-js/module-tools-hooks": "^0.0.0-runtime-2021112193858",
53
+ "@modern-js/new-action": "^0.0.0-runtime-2021112193858",
54
+ "@modern-js/plugin-analyze": "^0.0.0-runtime-2021112193858",
55
+ "@modern-js/plugin-changeset": "^0.0.0-runtime-2021112193858",
56
+ "@modern-js/plugin-fast-refresh": "^0.0.0-runtime-2021112193858",
57
+ "@modern-js/plugin-i18n": "^0.0.0-runtime-2021112193858",
58
+ "@modern-js/style-compiler": "^0.0.0-runtime-2021112193858",
59
+ "@modern-js/utils": "^0.0.0-runtime-2021112193858",
60
60
  "chalk": "^4.1.2",
61
61
  "chokidar": "^3.5.2",
62
62
  "dotenv": "^10.0.0",
@@ -75,7 +75,7 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@babel/preset-typescript": "^7.15.0",
78
- "@modern-js/babel-chain": "^1.1.1",
78
+ "@modern-js/babel-chain": "^0.0.0-runtime-2021112193858",
79
79
  "@types/babel__core": "^7.1.15",
80
80
  "@types/babel__generator": "^7.6.3",
81
81
  "@types/babel__traverse": "^7.14.2",
@@ -87,9 +87,9 @@
87
87
  "@types/normalize-path": "^3.0.0",
88
88
  "@types/signale": "^1.4.2",
89
89
  "commander": "^8.1.0",
90
- "typescript": "^4",
91
- "@modern-js/plugin-testing": "^1.1.1",
92
- "@modern-js/module-tools": "^1.1.1"
90
+ "typescript": "^4.4.4",
91
+ "@modern-js/plugin-testing": "^0.0.0-runtime-2021112193858",
92
+ "@modern-js/module-tools": "^0.0.0-runtime-2021112193858"
93
93
  },
94
94
  "sideEffects": false,
95
95
  "modernConfig": {
@@ -34,7 +34,6 @@ export const buildInWatchMode = async (
34
34
  const styleLog = lm.createLoggerText({
35
35
  title: constants.runStyleCompilerTitle,
36
36
  });
37
- const copyLog = lm.createLoggerText({ title: 'Copy Log:' });
38
37
  const initCodeMapper = utils.getCodeInitMapper(config);
39
38
  const taskMapper: ITaskMapper[] = [
40
39
  ...utils.getCodeMapper({
@@ -50,11 +49,6 @@ export const buildInWatchMode = async (
50
49
  logger: styleLog,
51
50
  taskPath: require.resolve('../../tasks/build-watch-style'),
52
51
  },
53
- {
54
- logger: copyLog,
55
- taskPath: require.resolve('../../tasks/copy-assets'),
56
- params: ['--watch'],
57
- },
58
52
  ];
59
53
  lm.on('data', () => {
60
54
  console.info(constants.clearFlag);
@@ -84,7 +78,7 @@ export const buildInWatchMode = async (
84
78
  });
85
79
  }
86
80
 
87
- if (logger === styleLog || logger === copyLog) {
81
+ if (logger === styleLog) {
88
82
  lm.addStdout(logger, childProcess.stdout, {
89
83
  event: { error: true, data: true },
90
84
  // colors: { data: s => s },
@@ -1,5 +1,5 @@
1
1
  import { Import, fs } from '@modern-js/utils';
2
- import type { NormalizedConfig, CoreOptions } from '@modern-js/core';
2
+ import type { NormalizedConfig } from '@modern-js/core';
3
3
  import type { BabelOptions, IVirtualDist } from '@modern-js/babel-compiler';
4
4
  import type { ITsconfig } from '../types';
5
5
 
@@ -138,19 +138,13 @@ const generatorRealFiles = (virtualDists: IVirtualDist[]) => {
138
138
  }
139
139
  };
140
140
 
141
- export const initEnv = ({
142
- syntax,
143
- type,
144
- }: {
145
- syntax: ITaskConfig['syntax'];
146
- type: ITaskConfig['type'];
147
- }) => {
141
+ export const initEnv = ({ syntax, type }: ITaskConfig) => {
148
142
  if (syntax === 'es6+' && type === 'commonjs') {
149
- return 'CJS_ES6';
143
+ return 'nodejs';
150
144
  } else if (syntax === 'es6+' && type === 'module') {
151
- return 'ESM+ES6';
145
+ return 'modern';
152
146
  } else if (syntax === 'es5' && type === 'module') {
153
- return 'ESM+ES5';
147
+ return 'legacy-browser';
154
148
  }
155
149
 
156
150
  return '';
@@ -186,11 +180,11 @@ const taskMain = async ({
186
180
  }: {
187
181
  modernConfig: NormalizedConfig;
188
182
  }) => {
189
- // Execution of the script's parameter handling and related required configuration acquisition
183
+ // 执行脚本的参数处理和相关需要配置的获取
190
184
  const processArgv = argv(process.argv.slice(2));
191
185
  const config = processArgv<ITaskConfig>(defaultConfig);
192
- process.env.BUILD_FORMAT = initEnv(config);
193
- const compiler = Compiler.babel; // Currently, only babel is supported.
186
+ // process.env.BUILD_MODE = initEnv(config);
187
+ const compiler = Compiler.babel; // 目前暂时只支持 babel
194
188
  const babelConfig = bc.resolveBabelConfig(config.appDirectory, modernConfig, {
195
189
  sourceAbsDir: config.srcRootDir,
196
190
  tsconfigPath: config.tsconfigPath,
@@ -235,11 +229,7 @@ const taskMain = async ({
235
229
  };
236
230
 
237
231
  (async () => {
238
- let options: CoreOptions | undefined;
239
- if (process.env.CORE_INIT_OPTION_FILE) {
240
- ({ options } = require(process.env.CORE_INIT_OPTION_FILE));
241
- }
242
- const { resolved } = await core.cli.init([], options);
232
+ const { resolved } = await core.cli.init();
243
233
  await core.manager.run(async () => {
244
234
  try {
245
235
  await taskMain({ modernConfig: resolved });
@@ -1,10 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import { fs, Import } from '@modern-js/utils';
3
- import type {
4
- NormalizedConfig,
5
- IAppContext,
6
- CoreOptions,
7
- } from '@modern-js/core';
3
+ import type { NormalizedConfig, IAppContext } from '@modern-js/core';
8
4
  import type { ICompilerResult, PostcssOption } from '@modern-js/style-compiler';
9
5
  import type { ModuleToolsOutput } from '../types';
10
6
 
@@ -175,15 +171,8 @@ const taskMain = async ({
175
171
  };
176
172
 
177
173
  (async () => {
178
- let options: CoreOptions | undefined;
179
- if (process.env.CORE_INIT_OPTION_FILE) {
180
- ({ options } = require(process.env.CORE_INIT_OPTION_FILE));
181
- }
182
174
  hooks.buildLifeCycle();
183
- const { resolved: modernConfig, appContext } = await core.cli.init(
184
- [],
185
- options,
186
- );
175
+ const { resolved: modernConfig, appContext } = await core.cli.init();
187
176
  await core.manager.run(async () => {
188
177
  try {
189
178
  await taskMain({ modernConfig, appContext });
@@ -1,8 +1,7 @@
1
1
  import { Import, fs } from '@modern-js/utils';
2
- import type { NormalizedConfig, CoreOptions } from '@modern-js/core';
2
+ import type { NormalizedConfig } from '@modern-js/core';
3
3
  import type { ICompilerResult, IVirtualDist } from '@modern-js/babel-compiler';
4
4
  import type { ITsconfig } from '../types';
5
- import { initEnv } from './build-source-code';
6
5
 
7
6
  const babelCompiler: typeof import('@modern-js/babel-compiler') = Import.lazy(
8
7
  '@modern-js/babel-compiler',
@@ -165,17 +164,12 @@ const taskMain = async ({
165
164
  syntax: 'es5',
166
165
  type: 'module',
167
166
  });
168
- process.env.BUILD_FORMAT = initEnv(config);
169
167
 
170
168
  await buildSourceCode(config, modernConfig);
171
169
  };
172
170
 
173
171
  (async () => {
174
- let options: CoreOptions | undefined;
175
- if (process.env.CORE_INIT_OPTION_FILE) {
176
- ({ options } = require(process.env.CORE_INIT_OPTION_FILE));
177
- }
178
- const { resolved } = await core.cli.init([], options);
172
+ const { resolved } = await core.cli.init();
179
173
  await core.manager.run(async () => {
180
174
  try {
181
175
  await taskMain({ modernConfig: resolved });
@@ -1,10 +1,6 @@
1
1
  /* eslint-disable max-statements */
2
2
  import * as path from 'path';
3
- import type {
4
- NormalizedConfig,
5
- IAppContext,
6
- CoreOptions,
7
- } from '@modern-js/core';
3
+ import type { NormalizedConfig, IAppContext } from '@modern-js/core';
8
4
  import type { ICompilerResult, PostcssOption } from '@modern-js/style-compiler';
9
5
  import { fs, watch, WatchChangeType, Import } from '@modern-js/utils';
10
6
  import type { ModuleToolsOutput } from '../types';
@@ -83,7 +79,6 @@ const copyOriginStyleFiles = ({
83
79
  }
84
80
  for (const styleFile of styleFiles) {
85
81
  const file = path.relative(targetDir, styleFile);
86
- fs.ensureFileSync(path.join(outputDir, file));
87
82
  fs.copyFileSync(styleFile, path.join(outputDir, file));
88
83
  }
89
84
  };
@@ -112,18 +107,12 @@ const taskMain = async ({
112
107
  } = modernConfig.output as ModuleToolsOutput;
113
108
  const { appDirectory } = appContext;
114
109
 
115
- const lessOption = await (core.mountHook() as any).moduleLessConfig(
116
- { modernConfig },
117
- {
118
- onLast: async (_: any) => null as any,
119
- },
120
- );
121
- const sassOption = await (core.mountHook() as any).moduleSassConfig(
122
- { modernConfig },
123
- {
124
- onLast: async (_: any) => null as any,
125
- },
126
- );
110
+ const lessOption = await (core.mountHook() as any).moduleLessConfig({
111
+ onLast: async (_: any) => null as any,
112
+ });
113
+ const sassOption = await (core.mountHook() as any).moduleSassConfig({
114
+ onLast: async (_: any) => null as any,
115
+ });
127
116
  const postcssOption = getPostcssOption(appDirectory, modernConfig);
128
117
  const existStylesDir = checkStylesDirExist({ appDirectory });
129
118
  const compilerMessage = {
@@ -251,20 +240,13 @@ const taskMain = async ({
251
240
  };
252
241
 
253
242
  (async () => {
254
- let options: CoreOptions | undefined;
255
- if (process.env.CORE_INIT_OPTION_FILE) {
256
- ({ options } = require(process.env.CORE_INIT_OPTION_FILE));
257
- }
258
243
  hooks.buildLifeCycle();
259
- const { resolved: modernConfig, appContext } = await core.cli.init(
260
- [],
261
- options,
262
- );
244
+ const { resolved: modernConfig, appContext } = await core.cli.init();
263
245
  await core.manager.run(async () => {
264
246
  try {
265
247
  await taskMain({ modernConfig, appContext });
266
248
  } catch (e: any) {
267
- console.error(e);
249
+ console.error(e.message);
268
250
  }
269
251
  });
270
252
  })();
@@ -1,10 +1,6 @@
1
1
  import * as path from 'path';
2
2
  import { fs, watch, WatchChangeType, Import } from '@modern-js/utils';
3
- import type {
4
- NormalizedConfig,
5
- IAppContext,
6
- CoreOptions,
7
- } from '@modern-js/core';
3
+ import type { NormalizedConfig, IAppContext } from '@modern-js/core';
8
4
  import type { ModuleToolsOutput } from '../types';
9
5
 
10
6
  const argv: typeof import('process.argv').default = Import.lazy(
@@ -105,14 +101,7 @@ const taskMain = ({
105
101
  };
106
102
 
107
103
  (async () => {
108
- let options: CoreOptions | undefined;
109
- if (process.env.CORE_INIT_OPTION_FILE) {
110
- ({ options } = require(process.env.CORE_INIT_OPTION_FILE));
111
- }
112
- const { resolved: modernConfig, appContext } = await core.cli.init(
113
- [],
114
- options,
115
- );
104
+ const { resolved: modernConfig, appContext } = await core.cli.init();
116
105
  core.manager.run(() => {
117
106
  try {
118
107
  taskMain({ modernConfig, appContext });
@@ -2,7 +2,7 @@ import type { ChildProcess } from 'child_process';
2
2
  import * as path from 'path';
3
3
  import * as os from 'os';
4
4
  import { Import, fs } from '@modern-js/utils';
5
- import type { NormalizedConfig, CoreOptions } from '@modern-js/core';
5
+ import type { NormalizedConfig } from '@modern-js/core';
6
6
  import type { ITsconfig } from '@/types';
7
7
 
8
8
  const tsPathsTransform: typeof import('../utils/tspaths-transform') =
@@ -261,11 +261,7 @@ const taskMain = async ({
261
261
  };
262
262
 
263
263
  (async () => {
264
- let options: CoreOptions | undefined;
265
- if (process.env.CORE_INIT_OPTION_FILE) {
266
- ({ options } = require(process.env.CORE_INIT_OPTION_FILE));
267
- }
268
- const { resolved } = await core.cli.init([], options);
264
+ const { resolved } = await core.cli.init();
269
265
  await core.manager.run(async () => {
270
266
  try {
271
267
  await taskMain({ modernConfig: resolved });