@modern-js/module-tools 1.0.0 → 1.1.1-jupiter.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/.eslintrc.js +7 -0
- package/CHANGELOG.md +55 -0
- package/README.md +1 -4
- package/dist/js/modern/cli/new.js +2 -2
- package/dist/js/modern/commands/build.js +4 -12
- 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/index.js +32 -10
- package/dist/js/modern/features/build/utils.js +0 -3
- package/dist/js/modern/index.js +2 -2
- package/dist/js/modern/tasks/build-source-code.js +2 -2
- package/dist/js/modern/tasks/build-style.js +3 -6
- package/dist/js/modern/tasks/build-watch-style.js +0 -6
- package/dist/js/modern/tasks/generator-dts.js +2 -2
- package/dist/js/modern/utils/babel.js +2 -2
- package/dist/js/modern/utils/logger.js +1 -3
- package/dist/js/node/cli/new.js +2 -2
- package/dist/js/node/commands/build.js +4 -12
- 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/index.js +34 -8
- package/dist/js/node/features/build/utils.js +0 -3
- package/dist/js/node/index.js +1 -1
- package/dist/js/node/tasks/build-source-code.js +2 -2
- package/dist/js/node/tasks/build-style.js +3 -6
- package/dist/js/node/tasks/build-watch-style.js +0 -6
- package/dist/js/node/tasks/generator-dts.js +2 -2
- package/dist/js/node/utils/babel.js +2 -2
- package/dist/js/node/utils/logger.js +0 -3
- package/dist/types/index.d.ts +3 -0
- package/dist/types/types.d.ts +2 -0
- package/package.json +17 -17
- package/src/commands/build.ts +2 -7
- package/src/commands/dev.ts +5 -3
- package/src/features/build/build-platform.ts +27 -20
- package/src/features/build/index.ts +26 -8
- package/src/features/build/utils.ts +0 -3
- package/src/index.ts +3 -3
- package/src/tasks/build-style.ts +18 -15
- package/src/tasks/build-watch-style.ts +6 -8
- package/src/types.ts +2 -0
- package/src/utils/logger.ts +0 -3
package/.eslintrc.js
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,60 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.1.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0fa83663: support more .env files
|
|
8
|
+
- Updated dependencies [6f7fe574]
|
|
9
|
+
- Updated dependencies [0fa83663]
|
|
10
|
+
- Updated dependencies [f594fbc8]
|
|
11
|
+
- @modern-js/core@1.1.2
|
|
12
|
+
- @modern-js/babel-preset-module@1.1.1
|
|
13
|
+
- @modern-js/css-config@1.1.1
|
|
14
|
+
- @modern-js/i18n-cli-language-detector@1.1.1
|
|
15
|
+
- @modern-js/plugin-analyze@1.1.1
|
|
16
|
+
- @modern-js/plugin-changeset@1.1.1
|
|
17
|
+
- @modern-js/plugin-fast-refresh@1.1.1
|
|
18
|
+
- @modern-js/plugin-i18n@1.1.1
|
|
19
|
+
- @modern-js/new-action@1.1.2
|
|
20
|
+
- @modern-js/babel-compiler@1.1.2
|
|
21
|
+
- @modern-js/style-compiler@1.1.1
|
|
22
|
+
- @modern-js/module-tools-hooks@1.1.1
|
|
23
|
+
- @modern-js/utils@1.1.2
|
|
24
|
+
|
|
25
|
+
## 1.1.0
|
|
26
|
+
|
|
27
|
+
### Minor Changes
|
|
28
|
+
|
|
29
|
+
- 96119db2: Relese v1.1.0
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Updated dependencies [96119db2]
|
|
34
|
+
- Updated dependencies [6b802b2a]
|
|
35
|
+
- Updated dependencies [eb00b569]
|
|
36
|
+
- @modern-js/babel-preset-module@1.1.0
|
|
37
|
+
- @modern-js/core@1.1.0
|
|
38
|
+
- @modern-js/css-config@1.1.0
|
|
39
|
+
- @modern-js/i18n-cli-language-detector@1.1.0
|
|
40
|
+
- @modern-js/plugin-analyze@1.1.0
|
|
41
|
+
- @modern-js/plugin-changeset@1.1.0
|
|
42
|
+
- @modern-js/plugin-fast-refresh@1.1.0
|
|
43
|
+
- @modern-js/plugin-i18n@1.1.0
|
|
44
|
+
- @modern-js/new-action@1.1.0
|
|
45
|
+
- @modern-js/babel-compiler@1.1.0
|
|
46
|
+
- @modern-js/style-compiler@1.1.0
|
|
47
|
+
- @modern-js/module-tools-hooks@1.1.0
|
|
48
|
+
- @modern-js/utils@1.1.0
|
|
49
|
+
|
|
50
|
+
## 1.0.1
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- feat: update generator template
|
|
55
|
+
- Updated dependencies [undefined]
|
|
56
|
+
- @modern-js/new-action@1.0.1
|
|
57
|
+
|
|
3
58
|
## 1.0.0
|
|
4
59
|
|
|
5
60
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -17,10 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
- [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
|
|
22
|
-
- [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
|
|
23
|
-
- [字节跳动是如何落地微前端的](https://mp.weixin.qq.com/s/L9wbfNG5fTXF5bx7dcgj4Q)
|
|
20
|
+
- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)
|
|
24
21
|
|
|
25
22
|
## Getting Started
|
|
26
23
|
|
|
@@ -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
|
|
|
@@ -16,11 +16,6 @@ export const build = async ({
|
|
|
16
16
|
appDirectory
|
|
17
17
|
} = core.useAppContext();
|
|
18
18
|
const modernConfig = core.useResolvedConfigContext();
|
|
19
|
-
const {
|
|
20
|
-
output: {
|
|
21
|
-
path: outputPath = 'dist'
|
|
22
|
-
}
|
|
23
|
-
} = modernConfig;
|
|
24
19
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
25
20
|
dotenv.config();
|
|
26
21
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
@@ -28,20 +23,17 @@ export const build = async ({
|
|
|
28
23
|
valid.valideBeforeTask({
|
|
29
24
|
modernConfig,
|
|
30
25
|
tsconfigPath
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
if (_clear) {
|
|
34
|
-
fs.removeSync(path.join(appDirectory, outputPath));
|
|
35
|
-
} // TODO: 一些配置只需要从modernConfig中获取
|
|
36
|
-
|
|
26
|
+
}); // TODO: 一些配置只需要从modernConfig中获取
|
|
37
27
|
|
|
38
28
|
await buildFeature.build({
|
|
29
|
+
appDirectory,
|
|
39
30
|
enableWatchMode: _watch,
|
|
40
31
|
isTsProject,
|
|
41
32
|
platform,
|
|
42
33
|
sourceDir: 'src',
|
|
43
34
|
tsconfigName,
|
|
44
|
-
enableTscCompiler
|
|
35
|
+
enableTscCompiler,
|
|
36
|
+
clear: _clear
|
|
45
37
|
}, modernConfig);
|
|
46
38
|
process.on('SIGBREAK', () => {
|
|
47
39
|
console.info('exit');
|
|
@@ -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
|
};
|
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Import, fs } from '@modern-js/utils';
|
|
2
3
|
const buildFeature = Import.lazy('./build', require);
|
|
3
|
-
const buildWatchFeature = Import.lazy('./build-watch', require);
|
|
4
|
-
|
|
5
|
-
// require,
|
|
6
|
-
// );
|
|
7
|
-
|
|
4
|
+
const buildWatchFeature = Import.lazy('./build-watch', require);
|
|
5
|
+
const bp = Import.lazy('./build-platform', require);
|
|
8
6
|
export const build = async (config, modernConfig) => {
|
|
9
7
|
const {
|
|
8
|
+
appDirectory,
|
|
10
9
|
enableWatchMode,
|
|
11
|
-
platform
|
|
12
|
-
|
|
10
|
+
platform,
|
|
11
|
+
clear = true,
|
|
12
|
+
isTsProject
|
|
13
|
+
} = config;
|
|
14
|
+
const {
|
|
15
|
+
output: {
|
|
16
|
+
path: outputPath = 'dist'
|
|
17
|
+
}
|
|
18
|
+
} = modernConfig; // TODO: maybe need watch mode in build platform
|
|
13
19
|
|
|
14
20
|
if (typeof platform === 'boolean' && platform) {
|
|
15
|
-
|
|
21
|
+
if (process.env.RUN_PLATFORM) {
|
|
22
|
+
await bp.buildPlatform({
|
|
23
|
+
platform: 'all',
|
|
24
|
+
isTsProject
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
return;
|
|
17
29
|
}
|
|
18
30
|
|
|
19
31
|
if (typeof platform === 'string') {
|
|
20
|
-
|
|
32
|
+
if (process.env.RUN_PLATFORM) {
|
|
33
|
+
await bp.buildPlatform({
|
|
34
|
+
platform,
|
|
35
|
+
isTsProject
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
21
39
|
return;
|
|
22
40
|
}
|
|
23
41
|
|
|
42
|
+
if (clear) {
|
|
43
|
+
fs.removeSync(path.join(appDirectory, outputPath));
|
|
44
|
+
}
|
|
45
|
+
|
|
24
46
|
if (enableWatchMode) {
|
|
25
47
|
await buildWatchFeature.buildInWatchMode(config, modernConfig);
|
|
26
48
|
} else {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
1
|
import * as path from 'path';
|
|
3
2
|
import * as os from 'os';
|
|
4
3
|
import { Import, chalk } from '@modern-js/utils';
|
|
@@ -189,6 +188,4 @@ export class TimeCounter {
|
|
|
189
188
|
}
|
|
190
189
|
|
|
191
190
|
}
|
|
192
|
-
/* eslint-enable max-classes-per-file */
|
|
193
|
-
|
|
194
191
|
TimeCounter._now = void 0;
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Import
|
|
1
|
+
import { Import } from '@modern-js/utils';
|
|
2
2
|
const core = Import.lazy('@modern-js/core', require); // const { createPlugin, usePlugins, defineConfig } = core;
|
|
3
3
|
|
|
4
4
|
const hooks = Import.lazy('@modern-js/module-tools-hooks', require);
|
|
@@ -9,7 +9,7 @@ const lang = Import.lazy('./utils/language', require);
|
|
|
9
9
|
export const {
|
|
10
10
|
defineConfig
|
|
11
11
|
} = core;
|
|
12
|
-
core.usePlugins([
|
|
12
|
+
core.usePlugins([require.resolve('@modern-js/plugin-changeset/cli'), require.resolve('@modern-js/plugin-analyze/cli')]);
|
|
13
13
|
export default core.createPlugin(() => {
|
|
14
14
|
const locale = lang.getLocaleLanguage();
|
|
15
15
|
local.i18n.changeLanguage({
|
|
@@ -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
|
|
|
@@ -74,20 +74,17 @@ const taskMain = async ({
|
|
|
74
74
|
} = appContext;
|
|
75
75
|
const lessOption = await core.mountHook().moduleLessConfig({
|
|
76
76
|
modernConfig
|
|
77
|
-
},
|
|
78
|
-
{
|
|
77
|
+
}, {
|
|
79
78
|
onLast: async _ => undefined
|
|
80
79
|
});
|
|
81
80
|
const sassOption = await core.mountHook().moduleSassConfig({
|
|
82
81
|
modernConfig
|
|
83
|
-
},
|
|
84
|
-
{
|
|
82
|
+
}, {
|
|
85
83
|
onLast: async _ => undefined
|
|
86
84
|
});
|
|
87
85
|
const tailwindPlugin = await core.mountHook().moduleTailwindConfig({
|
|
88
86
|
modernConfig
|
|
89
|
-
},
|
|
90
|
-
{
|
|
87
|
+
}, {
|
|
91
88
|
onLast: async _ => undefined
|
|
92
89
|
});
|
|
93
90
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
@@ -77,15 +77,9 @@ const taskMain = async ({
|
|
|
77
77
|
appDirectory
|
|
78
78
|
} = appContext;
|
|
79
79
|
const lessOption = await core.mountHook().moduleLessConfig({
|
|
80
|
-
modernConfig
|
|
81
|
-
}, // eslint-disable-next-line @typescript-eslint/require-await
|
|
82
|
-
{
|
|
83
80
|
onLast: async _ => null
|
|
84
81
|
});
|
|
85
82
|
const sassOption = await core.mountHook().moduleSassConfig({
|
|
86
|
-
modernConfig
|
|
87
|
-
}, // eslint-disable-next-line @typescript-eslint/require-await
|
|
88
|
-
{
|
|
89
83
|
onLast: async _ => null
|
|
90
84
|
});
|
|
91
85
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
@@ -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
|
|
|
@@ -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
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
1
|
import EventEmitter from 'events';
|
|
3
2
|
import { Import } from '@modern-js/utils';
|
|
4
3
|
const chalk = Import.lazy('chalk', require);
|
|
@@ -106,5 +105,4 @@ export class LoggerManager extends EventEmitter {
|
|
|
106
105
|
console.info(loggerText.value);
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
}
|
|
110
|
-
/* eslint-enable max-classes-per-file */
|
|
108
|
+
}
|
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
|
|
|
@@ -34,11 +34,6 @@ const build = async ({
|
|
|
34
34
|
appDirectory
|
|
35
35
|
} = core.useAppContext();
|
|
36
36
|
const modernConfig = core.useResolvedConfigContext();
|
|
37
|
-
const {
|
|
38
|
-
output: {
|
|
39
|
-
path: outputPath = 'dist'
|
|
40
|
-
}
|
|
41
|
-
} = modernConfig;
|
|
42
37
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
43
38
|
dotenv.config();
|
|
44
39
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
@@ -46,20 +41,17 @@ const build = async ({
|
|
|
46
41
|
valid.valideBeforeTask({
|
|
47
42
|
modernConfig,
|
|
48
43
|
tsconfigPath
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (_clear) {
|
|
52
|
-
_utils.fs.removeSync(path.join(appDirectory, outputPath));
|
|
53
|
-
} // TODO: 一些配置只需要从modernConfig中获取
|
|
54
|
-
|
|
44
|
+
}); // TODO: 一些配置只需要从modernConfig中获取
|
|
55
45
|
|
|
56
46
|
await buildFeature.build({
|
|
47
|
+
appDirectory,
|
|
57
48
|
enableWatchMode: _watch,
|
|
58
49
|
isTsProject,
|
|
59
50
|
platform,
|
|
60
51
|
sourceDir: 'src',
|
|
61
52
|
tsconfigName,
|
|
62
|
-
enableTscCompiler
|
|
53
|
+
enableTscCompiler,
|
|
54
|
+
clear: _clear
|
|
63
55
|
}, modernConfig);
|
|
64
56
|
process.on('SIGBREAK', () => {
|
|
65
57
|
console.info('exit');
|
|
@@ -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;
|
|
@@ -5,32 +5,58 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.build = void 0;
|
|
7
7
|
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
8
10
|
var _utils = require("@modern-js/utils");
|
|
9
11
|
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
10
14
|
const buildFeature = _utils.Import.lazy('./build', require);
|
|
11
15
|
|
|
12
|
-
const buildWatchFeature = _utils.Import.lazy('./build-watch', require);
|
|
13
|
-
// './build-platform',
|
|
14
|
-
// require,
|
|
15
|
-
// );
|
|
16
|
+
const buildWatchFeature = _utils.Import.lazy('./build-watch', require);
|
|
16
17
|
|
|
18
|
+
const bp = _utils.Import.lazy('./build-platform', require);
|
|
17
19
|
|
|
18
20
|
const build = async (config, modernConfig) => {
|
|
19
21
|
const {
|
|
22
|
+
appDirectory,
|
|
20
23
|
enableWatchMode,
|
|
21
|
-
platform
|
|
22
|
-
|
|
24
|
+
platform,
|
|
25
|
+
clear = true,
|
|
26
|
+
isTsProject
|
|
27
|
+
} = config;
|
|
28
|
+
const {
|
|
29
|
+
output: {
|
|
30
|
+
path: outputPath = 'dist'
|
|
31
|
+
}
|
|
32
|
+
} = modernConfig; // TODO: maybe need watch mode in build platform
|
|
23
33
|
|
|
24
34
|
if (typeof platform === 'boolean' && platform) {
|
|
25
|
-
|
|
35
|
+
if (process.env.RUN_PLATFORM) {
|
|
36
|
+
await bp.buildPlatform({
|
|
37
|
+
platform: 'all',
|
|
38
|
+
isTsProject
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
26
42
|
return;
|
|
27
43
|
}
|
|
28
44
|
|
|
29
45
|
if (typeof platform === 'string') {
|
|
30
|
-
|
|
46
|
+
if (process.env.RUN_PLATFORM) {
|
|
47
|
+
await bp.buildPlatform({
|
|
48
|
+
platform,
|
|
49
|
+
isTsProject
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
31
53
|
return;
|
|
32
54
|
}
|
|
33
55
|
|
|
56
|
+
if (clear) {
|
|
57
|
+
_utils.fs.removeSync(_path.default.join(appDirectory, outputPath));
|
|
58
|
+
}
|
|
59
|
+
|
|
34
60
|
if (enableWatchMode) {
|
|
35
61
|
await buildWatchFeature.buildInWatchMode(config, modernConfig);
|
|
36
62
|
} else {
|
|
@@ -15,7 +15,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
17
|
|
|
18
|
-
/* eslint-disable max-classes-per-file */
|
|
19
18
|
const constants = _utils.Import.lazy('./constants', require);
|
|
20
19
|
|
|
21
20
|
const core = _utils.Import.lazy('@modern-js/core', require); // 硬解字符串返回相应格式的对象
|
|
@@ -220,8 +219,6 @@ class TimeCounter {
|
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
}
|
|
223
|
-
/* eslint-enable max-classes-per-file */
|
|
224
|
-
|
|
225
222
|
|
|
226
223
|
exports.TimeCounter = TimeCounter;
|
|
227
224
|
TimeCounter._now = void 0;
|
package/dist/js/node/index.js
CHANGED
|
@@ -24,7 +24,7 @@ const {
|
|
|
24
24
|
defineConfig
|
|
25
25
|
} = core;
|
|
26
26
|
exports.defineConfig = defineConfig;
|
|
27
|
-
core.usePlugins([
|
|
27
|
+
core.usePlugins([require.resolve('@modern-js/plugin-changeset/cli'), require.resolve('@modern-js/plugin-analyze/cli')]);
|
|
28
28
|
|
|
29
29
|
var _default = core.createPlugin(() => {
|
|
30
30
|
const locale = lang.getLocaleLanguage();
|
|
@@ -7,9 +7,9 @@ exports.initEnv = exports.getWillCompilerCode = exports.buildSourceCode = export
|
|
|
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
|
|
|
@@ -90,20 +90,17 @@ const taskMain = async ({
|
|
|
90
90
|
} = appContext;
|
|
91
91
|
const lessOption = await core.mountHook().moduleLessConfig({
|
|
92
92
|
modernConfig
|
|
93
|
-
},
|
|
94
|
-
{
|
|
93
|
+
}, {
|
|
95
94
|
onLast: async _ => undefined
|
|
96
95
|
});
|
|
97
96
|
const sassOption = await core.mountHook().moduleSassConfig({
|
|
98
97
|
modernConfig
|
|
99
|
-
},
|
|
100
|
-
{
|
|
98
|
+
}, {
|
|
101
99
|
onLast: async _ => undefined
|
|
102
100
|
});
|
|
103
101
|
const tailwindPlugin = await core.mountHook().moduleTailwindConfig({
|
|
104
102
|
modernConfig
|
|
105
|
-
},
|
|
106
|
-
{
|
|
103
|
+
}, {
|
|
107
104
|
onLast: async _ => undefined
|
|
108
105
|
});
|
|
109
106
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
@@ -93,15 +93,9 @@ const taskMain = async ({
|
|
|
93
93
|
appDirectory
|
|
94
94
|
} = appContext;
|
|
95
95
|
const lessOption = await core.mountHook().moduleLessConfig({
|
|
96
|
-
modernConfig
|
|
97
|
-
}, // eslint-disable-next-line @typescript-eslint/require-await
|
|
98
|
-
{
|
|
99
96
|
onLast: async _ => null
|
|
100
97
|
});
|
|
101
98
|
const sassOption = await core.mountHook().moduleSassConfig({
|
|
102
|
-
modernConfig
|
|
103
|
-
}, // eslint-disable-next-line @typescript-eslint/require-await
|
|
104
|
-
{
|
|
105
99
|
onLast: async _ => null
|
|
106
100
|
});
|
|
107
101
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
@@ -10,9 +10,9 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
10
10
|
|
|
11
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
12
12
|
|
|
13
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
13
|
+
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; }
|
|
14
14
|
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
15
|
+
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; }
|
|
16
16
|
|
|
17
17
|
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; }
|
|
18
18
|
|
|
@@ -9,9 +9,9 @@ var _babelPresetModule = require("@modern-js/babel-preset-module");
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
|
11
11
|
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
12
|
+
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; }
|
|
13
13
|
|
|
14
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
14
|
+
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; }
|
|
15
15
|
|
|
16
16
|
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; }
|
|
17
17
|
|
|
@@ -11,7 +11,6 @@ var _utils = require("@modern-js/utils");
|
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
14
|
-
/* eslint-disable max-classes-per-file */
|
|
15
14
|
const chalk = _utils.Import.lazy('chalk', require);
|
|
16
15
|
|
|
17
16
|
const clearFlag = '\x1Bc';
|
|
@@ -127,7 +126,5 @@ class LoggerManager extends _events.default {
|
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
}
|
|
130
|
-
/* eslint-enable max-classes-per-file */
|
|
131
|
-
|
|
132
129
|
|
|
133
130
|
exports.LoggerManager = LoggerManager;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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<{
|
package/dist/types/types.d.ts
CHANGED
|
@@ -18,12 +18,14 @@ export interface IPackageFields {
|
|
|
18
18
|
module?: JsSyntaxType;
|
|
19
19
|
}
|
|
20
20
|
export interface IBuildConfig {
|
|
21
|
+
appDirectory: string;
|
|
21
22
|
platform: boolean | Exclude<Platform, 'all'>;
|
|
22
23
|
enableTscCompiler: boolean;
|
|
23
24
|
enableWatchMode?: boolean;
|
|
24
25
|
isTsProject: boolean;
|
|
25
26
|
sourceDir: string;
|
|
26
27
|
tsconfigName?: string;
|
|
28
|
+
clear?: boolean;
|
|
27
29
|
}
|
|
28
30
|
export interface IPackageModeValue {
|
|
29
31
|
type: 'module' | 'commonjs';
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.1.1-jupiter.0",
|
|
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.
|
|
48
|
-
"@modern-js/babel-preset-module": "^1.
|
|
49
|
-
"@modern-js/core": "^1.
|
|
50
|
-
"@modern-js/css-config": "^1.
|
|
51
|
-
"@modern-js/i18n-cli-language-detector": "^1.
|
|
52
|
-
"@modern-js/module-tools-hooks": "^1.
|
|
53
|
-
"@modern-js/new-action": "^1.
|
|
54
|
-
"@modern-js/plugin-analyze": "^1.
|
|
55
|
-
"@modern-js/plugin-changeset": "^1.
|
|
56
|
-
"@modern-js/plugin-fast-refresh": "^1.
|
|
57
|
-
"@modern-js/plugin-i18n": "^1.
|
|
58
|
-
"@modern-js/style-compiler": "^1.
|
|
59
|
-
"@modern-js/utils": "^1.
|
|
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",
|
|
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.
|
|
78
|
+
"@modern-js/babel-chain": "^1.1.1",
|
|
79
79
|
"@types/babel__core": "^7.1.15",
|
|
80
80
|
"@types/babel__generator": "^7.6.3",
|
|
81
81
|
"@types/babel__traverse": "^7.14.2",
|
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
"@types/signale": "^1.4.2",
|
|
89
89
|
"commander": "^8.1.0",
|
|
90
90
|
"typescript": "^4",
|
|
91
|
-
"@modern-js/plugin-testing": "^1.
|
|
92
|
-
"@modern-js/module-tools": "^1.
|
|
91
|
+
"@modern-js/plugin-testing": "^1.1.1",
|
|
92
|
+
"@modern-js/module-tools": "^1.1.1"
|
|
93
93
|
},
|
|
94
94
|
"sideEffects": false,
|
|
95
95
|
"modernConfig": {
|
package/src/commands/build.ts
CHANGED
|
@@ -39,9 +39,6 @@ export const build = async ({
|
|
|
39
39
|
}: IBuildOption) => {
|
|
40
40
|
const { appDirectory } = core.useAppContext();
|
|
41
41
|
const modernConfig = core.useResolvedConfigContext();
|
|
42
|
-
const {
|
|
43
|
-
output: { path: outputPath = 'dist' },
|
|
44
|
-
} = modernConfig;
|
|
45
42
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
46
43
|
dotenv.config();
|
|
47
44
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
@@ -49,19 +46,17 @@ export const build = async ({
|
|
|
49
46
|
|
|
50
47
|
valid.valideBeforeTask({ modernConfig, tsconfigPath });
|
|
51
48
|
|
|
52
|
-
if (clear) {
|
|
53
|
-
fs.removeSync(path.join(appDirectory, outputPath));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
49
|
// TODO: 一些配置只需要从modernConfig中获取
|
|
57
50
|
await buildFeature.build(
|
|
58
51
|
{
|
|
52
|
+
appDirectory,
|
|
59
53
|
enableWatchMode: watch,
|
|
60
54
|
isTsProject,
|
|
61
55
|
platform,
|
|
62
56
|
sourceDir: 'src',
|
|
63
57
|
tsconfigName,
|
|
64
58
|
enableTscCompiler,
|
|
59
|
+
clear,
|
|
65
60
|
},
|
|
66
61
|
modernConfig,
|
|
67
62
|
);
|
package/src/commands/dev.ts
CHANGED
|
@@ -35,7 +35,9 @@ export const dev = async (option: IDevOption) => {
|
|
|
35
35
|
valid.valideBeforeTask({ modernConfig, tsconfigPath });
|
|
36
36
|
|
|
37
37
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
if (process.env.RUN_PLATFORM) {
|
|
39
|
+
await devFeature.showMenu({ isTsProject, appDirectory });
|
|
40
|
+
} else {
|
|
41
|
+
await devFeature.devStorybook({ isTsProject, appDirectory });
|
|
42
|
+
}
|
|
41
43
|
};
|
|
@@ -44,33 +44,40 @@ export const buildPlatform = async (option: IBuildPlatformOption) => {
|
|
|
44
44
|
...params,
|
|
45
45
|
};
|
|
46
46
|
});
|
|
47
|
-
|
|
48
47
|
if (taskMapper.length <= 0) {
|
|
49
48
|
console.info(chalk.yellow(`'${platform}' is undefined task`));
|
|
50
49
|
return;
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
lm.showCompiling();
|
|
54
|
-
await pMap(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
event: { data: true, error: true },
|
|
62
|
-
});
|
|
53
|
+
await pMap(
|
|
54
|
+
taskMapper,
|
|
55
|
+
async ({ taskPath, params, logger: _ }: any) => {
|
|
56
|
+
const childProcess = execa.node(taskPath, params, {
|
|
57
|
+
stdio: 'inherit',
|
|
58
|
+
all: true,
|
|
59
|
+
});
|
|
63
60
|
|
|
64
|
-
|
|
61
|
+
// lm.addStdout(logger, childProcess.stdout, {
|
|
62
|
+
// event: { data: true, error: true },
|
|
63
|
+
// });
|
|
65
64
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
// lm.addStderr(logger, childProcess.stderr);
|
|
66
|
+
try {
|
|
67
|
+
await childProcess;
|
|
68
|
+
} catch {
|
|
69
|
+
// eslint-disable-next-line no-process-exit
|
|
70
|
+
process.exit(1);
|
|
71
|
+
}
|
|
72
|
+
// lm.disappearCompiling();
|
|
73
|
+
// console.info(lg.colors.title(title));
|
|
74
|
+
// console.info(a.all);
|
|
75
|
+
},
|
|
76
|
+
{ concurrency: 1 },
|
|
77
|
+
);
|
|
71
78
|
|
|
72
|
-
lm.disappearCompiling();
|
|
73
|
-
for (const key of Object.keys(loggerMap)) {
|
|
74
|
-
|
|
75
|
-
}
|
|
79
|
+
// lm.disappearCompiling();
|
|
80
|
+
// for (const key of Object.keys(loggerMap)) {
|
|
81
|
+
// console.info(loggerMap[key].value);
|
|
82
|
+
// }
|
|
76
83
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import { Import, fs } from '@modern-js/utils';
|
|
2
3
|
import type { NormalizedConfig } from '@modern-js/core';
|
|
3
4
|
import type { IBuildConfig } from '../../types';
|
|
4
5
|
|
|
@@ -7,27 +8,44 @@ const buildWatchFeature: typeof import('./build-watch') = Import.lazy(
|
|
|
7
8
|
'./build-watch',
|
|
8
9
|
require,
|
|
9
10
|
);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
const bp: typeof import('./build-platform') = Import.lazy(
|
|
12
|
+
'./build-platform',
|
|
13
|
+
require,
|
|
14
|
+
);
|
|
14
15
|
|
|
15
16
|
export const build = async (
|
|
16
17
|
config: IBuildConfig,
|
|
17
18
|
modernConfig: NormalizedConfig,
|
|
18
19
|
) => {
|
|
19
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
appDirectory,
|
|
22
|
+
enableWatchMode,
|
|
23
|
+
platform,
|
|
24
|
+
clear = true,
|
|
25
|
+
isTsProject,
|
|
26
|
+
} = config;
|
|
27
|
+
const {
|
|
28
|
+
output: { path: outputPath = 'dist' },
|
|
29
|
+
} = modernConfig;
|
|
20
30
|
// TODO: maybe need watch mode in build platform
|
|
21
31
|
if (typeof platform === 'boolean' && platform) {
|
|
22
|
-
|
|
32
|
+
if (process.env.RUN_PLATFORM) {
|
|
33
|
+
await bp.buildPlatform({ platform: 'all', isTsProject });
|
|
34
|
+
}
|
|
23
35
|
return;
|
|
24
36
|
}
|
|
25
37
|
|
|
26
38
|
if (typeof platform === 'string') {
|
|
27
|
-
|
|
39
|
+
if (process.env.RUN_PLATFORM) {
|
|
40
|
+
await bp.buildPlatform({ platform, isTsProject });
|
|
41
|
+
}
|
|
28
42
|
return;
|
|
29
43
|
}
|
|
30
44
|
|
|
45
|
+
if (clear) {
|
|
46
|
+
fs.removeSync(path.join(appDirectory, outputPath));
|
|
47
|
+
}
|
|
48
|
+
|
|
31
49
|
if (enableWatchMode) {
|
|
32
50
|
await buildWatchFeature.buildInWatchMode(config, modernConfig);
|
|
33
51
|
} else {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
1
|
import * as path from 'path';
|
|
3
2
|
import * as os from 'os';
|
|
4
3
|
import { Import, chalk } from '@modern-js/utils';
|
|
@@ -234,5 +233,3 @@ export class TimeCounter {
|
|
|
234
233
|
return span < 1000 ? `${span}ms` : `${(span / 1000).toFixed(2)}s`;
|
|
235
234
|
}
|
|
236
235
|
}
|
|
237
|
-
|
|
238
|
-
/* eslint-enable max-classes-per-file */
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Import
|
|
1
|
+
import { Import } from '@modern-js/utils';
|
|
2
2
|
|
|
3
3
|
const core: typeof import('@modern-js/core') = Import.lazy(
|
|
4
4
|
'@modern-js/core',
|
|
@@ -20,8 +20,8 @@ const lang: typeof import('./utils/language') = Import.lazy(
|
|
|
20
20
|
export const { defineConfig } = core;
|
|
21
21
|
|
|
22
22
|
core.usePlugins([
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
require.resolve('@modern-js/plugin-changeset/cli'),
|
|
24
|
+
require.resolve('@modern-js/plugin-analyze/cli'),
|
|
25
25
|
]);
|
|
26
26
|
|
|
27
27
|
export default core.createPlugin(
|
package/src/tasks/build-style.ts
CHANGED
|
@@ -97,21 +97,24 @@ const taskMain = async ({
|
|
|
97
97
|
} = modernConfig.output as ModuleToolsOutput;
|
|
98
98
|
const { appDirectory } = appContext;
|
|
99
99
|
|
|
100
|
-
const lessOption = await core
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
100
|
+
const lessOption = await core
|
|
101
|
+
.mountHook()
|
|
102
|
+
.moduleLessConfig(
|
|
103
|
+
{ modernConfig },
|
|
104
|
+
{ onLast: async (_: any) => undefined },
|
|
105
|
+
);
|
|
106
|
+
const sassOption = await core
|
|
107
|
+
.mountHook()
|
|
108
|
+
.moduleSassConfig(
|
|
109
|
+
{ modernConfig },
|
|
110
|
+
{ onLast: async (_: any) => undefined },
|
|
111
|
+
);
|
|
112
|
+
const tailwindPlugin = await core
|
|
113
|
+
.mountHook()
|
|
114
|
+
.moduleTailwindConfig(
|
|
115
|
+
{ modernConfig },
|
|
116
|
+
{ onLast: async (_: any) => undefined },
|
|
117
|
+
);
|
|
115
118
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
116
119
|
if (tailwindPlugin) {
|
|
117
120
|
postcssOption.plugins?.push(tailwindPlugin);
|
|
@@ -107,14 +107,12 @@ const taskMain = async ({
|
|
|
107
107
|
} = modernConfig.output as ModuleToolsOutput;
|
|
108
108
|
const { appDirectory } = appContext;
|
|
109
109
|
|
|
110
|
-
const lessOption = await (core.mountHook() as any).moduleLessConfig(
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{ onLast: async (_: any) => null as any },
|
|
117
|
-
);
|
|
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
|
+
});
|
|
118
116
|
const postcssOption = getPostcssOption(appDirectory, modernConfig);
|
|
119
117
|
const existStylesDir = checkStylesDirExist({ appDirectory });
|
|
120
118
|
const compilerMessage = {
|
package/src/types.ts
CHANGED
|
@@ -29,12 +29,14 @@ export interface IPackageFields {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface IBuildConfig {
|
|
32
|
+
appDirectory: string;
|
|
32
33
|
platform: boolean | Exclude<Platform, 'all'>;
|
|
33
34
|
enableTscCompiler: boolean;
|
|
34
35
|
enableWatchMode?: boolean;
|
|
35
36
|
isTsProject: boolean;
|
|
36
37
|
sourceDir: string;
|
|
37
38
|
tsconfigName?: string;
|
|
39
|
+
clear?: boolean;
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
export interface IPackageModeValue {
|
package/src/utils/logger.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable max-classes-per-file */
|
|
2
1
|
import type { ChildProcess } from 'child_process';
|
|
3
2
|
import EventEmitter from 'events';
|
|
4
3
|
import { Import } from '@modern-js/utils';
|
|
@@ -140,5 +139,3 @@ export class LoggerManager extends EventEmitter {
|
|
|
140
139
|
console.info(loggerText.value);
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
|
-
|
|
144
|
-
/* eslint-enable max-classes-per-file */
|