@modern-js/module-tools 1.1.1 → 1.1.4-beta.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.
- package/CHANGELOG.md +47 -0
- package/dist/js/modern/cli/new.js +2 -2
- package/dist/js/modern/commands/dev.js +12 -5
- package/dist/js/modern/features/build/build-platform.js +21 -18
- package/dist/js/modern/features/build/build-watch.js +8 -1
- package/dist/js/modern/features/build/index.js +18 -8
- package/dist/js/modern/tasks/build-source-code.js +16 -21
- package/dist/js/modern/tasks/build-style.js +9 -1
- package/dist/js/modern/tasks/build-watch-source-code.js +11 -1
- package/dist/js/modern/tasks/build-watch-style.js +15 -2
- package/dist/js/modern/tasks/copy-assets.js +9 -1
- package/dist/js/modern/tasks/generator-dts.js +11 -3
- package/dist/js/modern/utils/babel.js +2 -2
- package/dist/js/modern/utils/init-env.js +14 -0
- package/dist/js/node/cli/new.js +2 -2
- package/dist/js/node/commands/dev.js +13 -6
- package/dist/js/node/features/build/build-platform.js +21 -18
- package/dist/js/node/features/build/build-watch.js +8 -1
- package/dist/js/node/features/build/index.js +18 -7
- package/dist/js/node/tasks/build-source-code.js +18 -24
- package/dist/js/node/tasks/build-style.js +9 -1
- package/dist/js/node/tasks/build-watch-source-code.js +12 -1
- package/dist/js/node/tasks/build-watch-style.js +16 -2
- package/dist/js/node/tasks/copy-assets.js +9 -1
- package/dist/js/node/tasks/generator-dts.js +11 -3
- package/dist/js/node/utils/babel.js +2 -2
- package/dist/js/node/utils/init-env.js +23 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/tasks/build-source-code.d.ts +0 -17
- package/dist/types/utils/init-env.d.ts +21 -0
- package/package.json +14 -13
- package/src/commands/dev.ts +5 -3
- package/src/features/build/build-platform.ts +27 -20
- package/src/features/build/build-watch.ts +7 -1
- package/src/features/build/index.ts +17 -7
- package/src/tasks/build-source-code.ts +10 -17
- package/src/tasks/build-style.ts +13 -2
- package/src/tasks/build-watch-source-code.ts +8 -2
- package/src/tasks/build-watch-style.ts +27 -9
- package/src/tasks/copy-assets.ts +13 -2
- package/src/tasks/generator-dts.ts +6 -2
- package/src/utils/init-env.ts +31 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,52 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 10676d31: fix build watch error
|
|
8
|
+
|
|
9
|
+
## 1.1.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- ca7dcb32: support BUILD_FORMAT env and fix watch feature not work
|
|
14
|
+
- Updated dependencies [90eeb72c]
|
|
15
|
+
- Updated dependencies [e04914ce]
|
|
16
|
+
- Updated dependencies [e12b3d0b]
|
|
17
|
+
- Updated dependencies [ca7dcb32]
|
|
18
|
+
- Updated dependencies [e12b3d0b]
|
|
19
|
+
- Updated dependencies [5a4c557e]
|
|
20
|
+
- Updated dependencies [e04914ce]
|
|
21
|
+
- Updated dependencies [0c81020f]
|
|
22
|
+
- Updated dependencies [ca7dcb32]
|
|
23
|
+
- Updated dependencies [ecb344dc]
|
|
24
|
+
- @modern-js/core@1.2.0
|
|
25
|
+
- @modern-js/new-action@1.2.0
|
|
26
|
+
- @modern-js/babel-preset-module@1.1.2
|
|
27
|
+
- @modern-js/plugin-analyze@1.1.2
|
|
28
|
+
- @modern-js/babel-compiler@1.1.3
|
|
29
|
+
- @modern-js/utils@1.1.5
|
|
30
|
+
|
|
31
|
+
## 1.1.2
|
|
32
|
+
|
|
33
|
+
### Patch Changes
|
|
34
|
+
|
|
35
|
+
- d927bc83: add run platform task with RUN_PLATFORM env vars
|
|
36
|
+
- Updated dependencies [d927bc83]
|
|
37
|
+
- Updated dependencies [d73ff455]
|
|
38
|
+
- Updated dependencies [9c1ab865]
|
|
39
|
+
- Updated dependencies [c5e3d4ad]
|
|
40
|
+
- Updated dependencies [d73ff455]
|
|
41
|
+
- Updated dependencies [d73ff455]
|
|
42
|
+
- Updated dependencies [d73ff455]
|
|
43
|
+
- Updated dependencies [d73ff455]
|
|
44
|
+
- @modern-js/utils@1.1.4
|
|
45
|
+
- @modern-js/core@1.1.4
|
|
46
|
+
- @modern-js/style-compiler@1.1.3
|
|
47
|
+
- @modern-js/css-config@1.1.2
|
|
48
|
+
- @modern-js/module-tools-hooks@1.1.2
|
|
49
|
+
|
|
3
50
|
## 1.1.1
|
|
4
51
|
|
|
5
52
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
@@ -20,10 +20,17 @@ export const dev = async option => {
|
|
|
20
20
|
modernConfig,
|
|
21
21
|
tsconfigPath
|
|
22
22
|
});
|
|
23
|
-
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
23
|
+
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
if (process.env.RUN_PLATFORM) {
|
|
26
|
+
await devFeature.showMenu({
|
|
27
|
+
isTsProject,
|
|
28
|
+
appDirectory
|
|
29
|
+
});
|
|
30
|
+
} else {
|
|
31
|
+
await devFeature.devStorybook({
|
|
32
|
+
isTsProject,
|
|
33
|
+
appDirectory
|
|
34
|
+
});
|
|
35
|
+
}
|
|
29
36
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
@@ -45,26 +45,29 @@ export const buildPlatform = async option => {
|
|
|
45
45
|
await pMap(taskMapper, async ({
|
|
46
46
|
taskPath,
|
|
47
47
|
params,
|
|
48
|
-
logger
|
|
48
|
+
logger: _
|
|
49
49
|
}) => {
|
|
50
50
|
const childProcess = execa.node(taskPath, params, {
|
|
51
|
-
stdio: '
|
|
51
|
+
stdio: 'inherit',
|
|
52
52
|
all: true
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
53
|
+
}); // lm.addStdout(logger, childProcess.stdout, {
|
|
54
|
+
// event: { data: true, error: true },
|
|
55
|
+
// });
|
|
56
|
+
// lm.addStderr(logger, childProcess.stderr);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
await childProcess;
|
|
60
|
+
} catch (_unused) {
|
|
61
|
+
// eslint-disable-next-line no-process-exit
|
|
62
|
+
process.exit(1);
|
|
63
|
+
} // lm.disappearCompiling();
|
|
62
64
|
// console.info(lg.colors.title(title));
|
|
63
65
|
// console.info(a.all);
|
|
64
|
-
});
|
|
65
|
-
lm.disappearCompiling();
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
67
|
+
}, {
|
|
68
|
+
concurrency: 1
|
|
69
|
+
}); // lm.disappearCompiling();
|
|
70
|
+
// for (const key of Object.keys(loggerMap)) {
|
|
71
|
+
// console.info(loggerMap[key].value);
|
|
72
|
+
// }
|
|
70
73
|
};
|
|
@@ -27,6 +27,9 @@ 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
|
+
});
|
|
30
33
|
const initCodeMapper = utils.getCodeInitMapper(config);
|
|
31
34
|
const taskMapper = [...utils.getCodeMapper({
|
|
32
35
|
logger: codeLog,
|
|
@@ -38,6 +41,10 @@ export const buildInWatchMode = async (config, _) => {
|
|
|
38
41
|
}), ...(enableTscCompiler ? utils.getDtsMapper(config, dtsLog) : []), {
|
|
39
42
|
logger: styleLog,
|
|
40
43
|
taskPath: require.resolve("../../tasks/build-watch-style")
|
|
44
|
+
}, {
|
|
45
|
+
logger: copyLog,
|
|
46
|
+
taskPath: require.resolve("../../tasks/copy-assets"),
|
|
47
|
+
params: ['--watch']
|
|
41
48
|
}];
|
|
42
49
|
lm.on('data', () => {
|
|
43
50
|
console.info(constants.clearFlag);
|
|
@@ -78,7 +85,7 @@ export const buildInWatchMode = async (config, _) => {
|
|
|
78
85
|
});
|
|
79
86
|
}
|
|
80
87
|
|
|
81
|
-
if (logger === styleLog) {
|
|
88
|
+
if (logger === styleLog || logger === copyLog) {
|
|
82
89
|
lm.addStdout(logger, childProcess.stdout, {
|
|
83
90
|
event: {
|
|
84
91
|
error: true,
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { Import, fs } from '@modern-js/utils';
|
|
3
3
|
const buildFeature = Import.lazy('./build', require);
|
|
4
|
-
const buildWatchFeature = Import.lazy('./build-watch', require);
|
|
5
|
-
|
|
6
|
-
// require,
|
|
7
|
-
// );
|
|
8
|
-
|
|
4
|
+
const buildWatchFeature = Import.lazy('./build-watch', require);
|
|
5
|
+
const bp = Import.lazy('./build-platform', require);
|
|
9
6
|
export const build = async (config, modernConfig) => {
|
|
10
7
|
const {
|
|
11
8
|
appDirectory,
|
|
12
9
|
enableWatchMode,
|
|
13
10
|
platform,
|
|
14
|
-
clear = true
|
|
11
|
+
clear = true,
|
|
12
|
+
isTsProject
|
|
15
13
|
} = config;
|
|
16
14
|
const {
|
|
17
15
|
output: {
|
|
@@ -20,12 +18,24 @@ export const build = async (config, modernConfig) => {
|
|
|
20
18
|
} = modernConfig; // TODO: maybe need watch mode in build platform
|
|
21
19
|
|
|
22
20
|
if (typeof platform === 'boolean' && platform) {
|
|
23
|
-
|
|
21
|
+
if (process.env.RUN_PLATFORM) {
|
|
22
|
+
await bp.buildPlatform({
|
|
23
|
+
platform: 'all',
|
|
24
|
+
isTsProject
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
return;
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
if (typeof platform === 'string') {
|
|
28
|
-
|
|
32
|
+
if (process.env.RUN_PLATFORM) {
|
|
33
|
+
await bp.buildPlatform({
|
|
34
|
+
platform,
|
|
35
|
+
isTsProject
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
29
39
|
return;
|
|
30
40
|
}
|
|
31
41
|
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
7
|
import { Import, fs } from '@modern-js/utils';
|
|
8
|
+
import { initEnv } from "../utils/init-env";
|
|
8
9
|
const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
|
|
9
10
|
const glob = Import.lazy('glob', require);
|
|
10
11
|
const argv = Import.lazy('process.argv', require);
|
|
@@ -113,20 +114,6 @@ const generatorRealFiles = virtualDists => {
|
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
|
|
116
|
-
export const initEnv = ({
|
|
117
|
-
syntax,
|
|
118
|
-
type
|
|
119
|
-
}) => {
|
|
120
|
-
if (syntax === 'es6+' && type === 'commonjs') {
|
|
121
|
-
return 'nodejs';
|
|
122
|
-
} else if (syntax === 'es6+' && type === 'module') {
|
|
123
|
-
return 'modern';
|
|
124
|
-
} else if (syntax === 'es5' && type === 'module') {
|
|
125
|
-
return 'legacy-browser';
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
return '';
|
|
129
|
-
};
|
|
130
117
|
const defaultConfig = {
|
|
131
118
|
srcRootDir: `${process.cwd()}/src`,
|
|
132
119
|
willCompilerDirOrFile: `${process.cwd()}/src`,
|
|
@@ -143,11 +130,11 @@ const defaultConfig = {
|
|
|
143
130
|
const taskMain = async ({
|
|
144
131
|
modernConfig
|
|
145
132
|
}) => {
|
|
146
|
-
//
|
|
133
|
+
// Execution of the script's parameter handling and related required configuration acquisition
|
|
147
134
|
const processArgv = argv(process.argv.slice(2));
|
|
148
|
-
const config = processArgv(defaultConfig);
|
|
149
|
-
|
|
150
|
-
const compiler = Compiler.babel; //
|
|
135
|
+
const config = processArgv(defaultConfig);
|
|
136
|
+
process.env.BUILD_FORMAT = initEnv(config);
|
|
137
|
+
const compiler = Compiler.babel; // Currently, only babel is supported.
|
|
151
138
|
|
|
152
139
|
const babelConfig = bc.resolveBabelConfig(config.appDirectory, modernConfig, {
|
|
153
140
|
sourceAbsDir: config.srcRootDir,
|
|
@@ -196,9 +183,17 @@ const taskMain = async ({
|
|
|
196
183
|
};
|
|
197
184
|
|
|
198
185
|
(async () => {
|
|
186
|
+
let options;
|
|
187
|
+
|
|
188
|
+
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
189
|
+
({
|
|
190
|
+
options
|
|
191
|
+
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
192
|
+
}
|
|
193
|
+
|
|
199
194
|
const {
|
|
200
195
|
resolved
|
|
201
|
-
} = await core.cli.init();
|
|
196
|
+
} = await core.cli.init([], options);
|
|
202
197
|
await core.manager.run(async () => {
|
|
203
198
|
try {
|
|
204
199
|
await taskMain({
|
|
@@ -143,11 +143,19 @@ 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
|
+
|
|
146
154
|
hooks.buildLifeCycle();
|
|
147
155
|
const {
|
|
148
156
|
resolved: modernConfig,
|
|
149
157
|
appContext
|
|
150
|
-
} = await core.cli.init();
|
|
158
|
+
} = await core.cli.init([], options);
|
|
151
159
|
await core.manager.run(async () => {
|
|
152
160
|
try {
|
|
153
161
|
await taskMain({
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Import, fs } from '@modern-js/utils';
|
|
2
|
+
import { initEnv } from "../utils/init-env";
|
|
2
3
|
const babelCompiler = Import.lazy('@modern-js/babel-compiler', require);
|
|
3
4
|
const logger = Import.lazy('../features/build/logger', require);
|
|
4
5
|
const ts = Import.lazy('../utils/tsconfig', require);
|
|
@@ -123,13 +124,22 @@ const taskMain = async ({
|
|
|
123
124
|
syntax: 'es5',
|
|
124
125
|
type: 'module'
|
|
125
126
|
});
|
|
127
|
+
process.env.BUILD_FORMAT = initEnv(config);
|
|
126
128
|
await buildSourceCode(config, modernConfig);
|
|
127
129
|
};
|
|
128
130
|
|
|
129
131
|
(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
|
+
|
|
130
140
|
const {
|
|
131
141
|
resolved
|
|
132
|
-
} = await core.cli.init();
|
|
142
|
+
} = await core.cli.init([], options);
|
|
133
143
|
await core.manager.run(async () => {
|
|
134
144
|
try {
|
|
135
145
|
await taskMain({
|
|
@@ -53,6 +53,7 @@ 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));
|
|
56
57
|
fs.copyFileSync(styleFile, path.join(outputDir, file));
|
|
57
58
|
}
|
|
58
59
|
};
|
|
@@ -77,9 +78,13 @@ const taskMain = async ({
|
|
|
77
78
|
appDirectory
|
|
78
79
|
} = appContext;
|
|
79
80
|
const lessOption = await core.mountHook().moduleLessConfig({
|
|
81
|
+
modernConfig
|
|
82
|
+
}, {
|
|
80
83
|
onLast: async _ => null
|
|
81
84
|
});
|
|
82
85
|
const sassOption = await core.mountHook().moduleSassConfig({
|
|
86
|
+
modernConfig
|
|
87
|
+
}, {
|
|
83
88
|
onLast: async _ => null
|
|
84
89
|
});
|
|
85
90
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
@@ -186,11 +191,19 @@ const taskMain = async ({
|
|
|
186
191
|
};
|
|
187
192
|
|
|
188
193
|
(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
|
+
|
|
189
202
|
hooks.buildLifeCycle();
|
|
190
203
|
const {
|
|
191
204
|
resolved: modernConfig,
|
|
192
205
|
appContext
|
|
193
|
-
} = await core.cli.init();
|
|
206
|
+
} = await core.cli.init([], options);
|
|
194
207
|
await core.manager.run(async () => {
|
|
195
208
|
try {
|
|
196
209
|
await taskMain({
|
|
@@ -198,7 +211,7 @@ const taskMain = async ({
|
|
|
198
211
|
appContext
|
|
199
212
|
});
|
|
200
213
|
} catch (e) {
|
|
201
|
-
console.error(e
|
|
214
|
+
console.error(e);
|
|
202
215
|
}
|
|
203
216
|
});
|
|
204
217
|
})();
|
|
@@ -89,10 +89,18 @@ 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
|
+
|
|
92
100
|
const {
|
|
93
101
|
resolved: modernConfig,
|
|
94
102
|
appContext
|
|
95
|
-
} = await core.cli.init();
|
|
103
|
+
} = await core.cli.init([], options);
|
|
96
104
|
core.manager.run(() => {
|
|
97
105
|
try {
|
|
98
106
|
taskMain({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
@@ -202,9 +202,17 @@ 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
|
+
|
|
205
213
|
const {
|
|
206
214
|
resolved
|
|
207
|
-
} = await core.cli.init();
|
|
215
|
+
} = await core.cli.init([], options);
|
|
208
216
|
await core.manager.run(async () => {
|
|
209
217
|
try {
|
|
210
218
|
await taskMain({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
2
|
|
|
3
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const initEnv = ({
|
|
2
|
+
syntax,
|
|
3
|
+
type
|
|
4
|
+
}) => {
|
|
5
|
+
if (syntax === 'es6+' && type === 'commonjs') {
|
|
6
|
+
return 'CJS_ES6';
|
|
7
|
+
} else if (syntax === 'es6+' && type === 'module') {
|
|
8
|
+
return 'ESM_ES6';
|
|
9
|
+
} else if (syntax === 'es5' && type === 'module') {
|
|
10
|
+
return 'ESM_ES5';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return '';
|
|
14
|
+
};
|
package/dist/js/node/cli/new.js
CHANGED
|
@@ -7,9 +7,9 @@ exports.newCli = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
11
|
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
13
|
|
|
14
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
15
|
|
|
@@ -38,12 +38,19 @@ const dev = async option => {
|
|
|
38
38
|
modernConfig,
|
|
39
39
|
tsconfigPath
|
|
40
40
|
});
|
|
41
|
-
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
42
|
+
|
|
43
|
+
if (process.env.RUN_PLATFORM) {
|
|
44
|
+
await devFeature.showMenu({
|
|
45
|
+
isTsProject,
|
|
46
|
+
appDirectory
|
|
47
|
+
});
|
|
48
|
+
} else {
|
|
49
|
+
await devFeature.devStorybook({
|
|
50
|
+
isTsProject,
|
|
51
|
+
appDirectory
|
|
52
|
+
});
|
|
53
|
+
}
|
|
47
54
|
};
|
|
48
55
|
|
|
49
56
|
exports.dev = dev;
|
|
@@ -7,9 +7,9 @@ exports.buildPlatform = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
10
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
11
|
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
12
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
13
|
|
|
14
14
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
15
|
|
|
@@ -57,28 +57,31 @@ const buildPlatform = async option => {
|
|
|
57
57
|
await pMap(taskMapper, async ({
|
|
58
58
|
taskPath,
|
|
59
59
|
params,
|
|
60
|
-
logger
|
|
60
|
+
logger: _
|
|
61
61
|
}) => {
|
|
62
62
|
const childProcess = execa.node(taskPath, params, {
|
|
63
|
-
stdio: '
|
|
63
|
+
stdio: 'inherit',
|
|
64
64
|
all: true
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
65
|
+
}); // lm.addStdout(logger, childProcess.stdout, {
|
|
66
|
+
// event: { data: true, error: true },
|
|
67
|
+
// });
|
|
68
|
+
// lm.addStderr(logger, childProcess.stderr);
|
|
69
|
+
|
|
70
|
+
try {
|
|
71
|
+
await childProcess;
|
|
72
|
+
} catch (_unused) {
|
|
73
|
+
// eslint-disable-next-line no-process-exit
|
|
74
|
+
process.exit(1);
|
|
75
|
+
} // lm.disappearCompiling();
|
|
74
76
|
// console.info(lg.colors.title(title));
|
|
75
77
|
// console.info(a.all);
|
|
76
|
-
});
|
|
77
|
-
lm.disappearCompiling();
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
79
|
+
}, {
|
|
80
|
+
concurrency: 1
|
|
81
|
+
}); // lm.disappearCompiling();
|
|
82
|
+
// for (const key of Object.keys(loggerMap)) {
|
|
83
|
+
// console.info(loggerMap[key].value);
|
|
84
|
+
// }
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
exports.buildPlatform = buildPlatform;
|
|
@@ -47,6 +47,9 @@ 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
|
+
});
|
|
50
53
|
const initCodeMapper = utils.getCodeInitMapper(config);
|
|
51
54
|
const taskMapper = [...utils.getCodeMapper({
|
|
52
55
|
logger: codeLog,
|
|
@@ -58,6 +61,10 @@ const buildInWatchMode = async (config, _) => {
|
|
|
58
61
|
}), ...(enableTscCompiler ? utils.getDtsMapper(config, dtsLog) : []), {
|
|
59
62
|
logger: styleLog,
|
|
60
63
|
taskPath: require.resolve("../../tasks/build-watch-style")
|
|
64
|
+
}, {
|
|
65
|
+
logger: copyLog,
|
|
66
|
+
taskPath: require.resolve("../../tasks/copy-assets"),
|
|
67
|
+
params: ['--watch']
|
|
61
68
|
}];
|
|
62
69
|
lm.on('data', () => {
|
|
63
70
|
console.info(constants.clearFlag);
|
|
@@ -98,7 +105,7 @@ const buildInWatchMode = async (config, _) => {
|
|
|
98
105
|
});
|
|
99
106
|
}
|
|
100
107
|
|
|
101
|
-
if (logger === styleLog) {
|
|
108
|
+
if (logger === styleLog || logger === copyLog) {
|
|
102
109
|
lm.addStdout(logger, childProcess.stdout, {
|
|
103
110
|
event: {
|
|
104
111
|
error: true,
|