@modern-js/module-tools 1.0.0-rc.4 → 1.0.0-rc.9
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 +115 -0
- package/dist/js/modern/commands/build.js +2 -4
- package/dist/js/modern/commands/dev.js +2 -2
- package/dist/js/modern/features/build/build-watch.js +1 -1
- package/dist/js/modern/features/build/build.js +1 -1
- package/dist/js/modern/features/build/utils.js +8 -12
- package/dist/js/modern/features/dev/index.js +1 -1
- package/dist/js/modern/tasks/build-style.js +1 -0
- package/dist/js/modern/utils/babel.js +3 -1
- package/dist/js/node/commands/build.js +2 -4
- package/dist/js/node/commands/dev.js +2 -2
- package/dist/js/node/features/build/build-watch.js +1 -1
- package/dist/js/node/features/build/build.js +1 -1
- package/dist/js/node/features/build/utils.js +8 -12
- package/dist/js/node/features/dev/index.js +1 -1
- package/dist/js/node/tasks/build-style.js +2 -0
- package/dist/js/node/utils/babel.js +3 -1
- package/package.json +19 -19
- package/src/commands/build.ts +2 -4
- package/src/commands/dev.ts +2 -2
- package/src/features/build/build-watch.ts +1 -1
- package/src/features/build/build.ts +1 -1
- package/src/features/build/utils.ts +8 -20
- package/src/features/dev/index.ts +1 -1
- package/src/tasks/build-style.ts +1 -0
- package/src/utils/babel.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,120 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.0.0-rc.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 224f7fe: fix server route match
|
|
8
|
+
- 204c626: feat: initial
|
|
9
|
+
- Updated dependencies [224f7fe]
|
|
10
|
+
- Updated dependencies [204c626]
|
|
11
|
+
- @modern-js/babel-preset-module@1.0.0-rc.9
|
|
12
|
+
- @modern-js/core@1.0.0-rc.9
|
|
13
|
+
- @modern-js/css-config@1.0.0-rc.9
|
|
14
|
+
- @modern-js/i18n-cli-language-detector@1.0.0-rc.9
|
|
15
|
+
- @modern-js/plugin-analyze@1.0.0-rc.9
|
|
16
|
+
- @modern-js/plugin-changeset@1.0.0-rc.9
|
|
17
|
+
- @modern-js/plugin-fast-refresh@1.0.0-rc.9
|
|
18
|
+
- @modern-js/plugin-i18n@1.0.0-rc.9
|
|
19
|
+
- @modern-js/new-action@1.0.0-rc.9
|
|
20
|
+
- @modern-js/babel-compiler@1.0.0-rc.9
|
|
21
|
+
- @modern-js/style-compiler@1.0.0-rc.9
|
|
22
|
+
- @modern-js/module-tools-hooks@1.0.0-rc.9
|
|
23
|
+
- @modern-js/plugin@1.0.0-rc.9
|
|
24
|
+
- @modern-js/utils@1.0.0-rc.9
|
|
25
|
+
|
|
26
|
+
## 1.0.0-rc.8
|
|
27
|
+
|
|
28
|
+
### Patch Changes
|
|
29
|
+
|
|
30
|
+
- 224f7fe: fix server route match
|
|
31
|
+
- 204c626: feat: initial
|
|
32
|
+
- Updated dependencies [224f7fe]
|
|
33
|
+
- Updated dependencies [204c626]
|
|
34
|
+
- @modern-js/babel-preset-module@1.0.0-rc.8
|
|
35
|
+
- @modern-js/core@1.0.0-rc.8
|
|
36
|
+
- @modern-js/css-config@1.0.0-rc.8
|
|
37
|
+
- @modern-js/i18n-cli-language-detector@1.0.0-rc.8
|
|
38
|
+
- @modern-js/plugin-analyze@1.0.0-rc.8
|
|
39
|
+
- @modern-js/plugin-changeset@1.0.0-rc.8
|
|
40
|
+
- @modern-js/plugin-fast-refresh@1.0.0-rc.8
|
|
41
|
+
- @modern-js/plugin-i18n@1.0.0-rc.8
|
|
42
|
+
- @modern-js/new-action@1.0.0-rc.8
|
|
43
|
+
- @modern-js/babel-compiler@1.0.0-rc.8
|
|
44
|
+
- @modern-js/style-compiler@1.0.0-rc.8
|
|
45
|
+
- @modern-js/module-tools-hooks@1.0.0-rc.8
|
|
46
|
+
- @modern-js/plugin@1.0.0-rc.8
|
|
47
|
+
- @modern-js/utils@1.0.0-rc.8
|
|
48
|
+
|
|
49
|
+
## 1.0.0-rc.7
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- 224f7fe: fix server route match
|
|
54
|
+
- 204c626: feat: initial
|
|
55
|
+
- Updated dependencies [224f7fe]
|
|
56
|
+
- Updated dependencies [204c626]
|
|
57
|
+
- @modern-js/babel-preset-module@1.0.0-rc.7
|
|
58
|
+
- @modern-js/core@1.0.0-rc.7
|
|
59
|
+
- @modern-js/css-config@1.0.0-rc.7
|
|
60
|
+
- @modern-js/i18n-cli-language-detector@1.0.0-rc.7
|
|
61
|
+
- @modern-js/plugin-analyze@1.0.0-rc.7
|
|
62
|
+
- @modern-js/plugin-changeset@1.0.0-rc.7
|
|
63
|
+
- @modern-js/plugin-fast-refresh@1.0.0-rc.7
|
|
64
|
+
- @modern-js/plugin-i18n@1.0.0-rc.7
|
|
65
|
+
- @modern-js/new-action@1.0.0-rc.7
|
|
66
|
+
- @modern-js/babel-compiler@1.0.0-rc.7
|
|
67
|
+
- @modern-js/style-compiler@1.0.0-rc.7
|
|
68
|
+
- @modern-js/module-tools-hooks@1.0.0-rc.7
|
|
69
|
+
- @modern-js/plugin@1.0.0-rc.7
|
|
70
|
+
- @modern-js/utils@1.0.0-rc.7
|
|
71
|
+
|
|
72
|
+
## 1.0.0-rc.6
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- 224f7fe: fix server route match
|
|
77
|
+
- 204c626: feat: initial
|
|
78
|
+
- Updated dependencies [224f7fe]
|
|
79
|
+
- Updated dependencies [204c626]
|
|
80
|
+
- @modern-js/babel-preset-module@1.0.0-rc.6
|
|
81
|
+
- @modern-js/core@1.0.0-rc.6
|
|
82
|
+
- @modern-js/css-config@1.0.0-rc.6
|
|
83
|
+
- @modern-js/i18n-cli-language-detector@1.0.0-rc.6
|
|
84
|
+
- @modern-js/plugin-analyze@1.0.0-rc.6
|
|
85
|
+
- @modern-js/plugin-changeset@1.0.0-rc.6
|
|
86
|
+
- @modern-js/plugin-fast-refresh@1.0.0-rc.6
|
|
87
|
+
- @modern-js/plugin-i18n@1.0.0-rc.6
|
|
88
|
+
- @modern-js/new-action@1.0.0-rc.6
|
|
89
|
+
- @modern-js/babel-compiler@1.0.0-rc.6
|
|
90
|
+
- @modern-js/style-compiler@1.0.0-rc.6
|
|
91
|
+
- @modern-js/module-tools-hooks@1.0.0-rc.6
|
|
92
|
+
- @modern-js/plugin@1.0.0-rc.6
|
|
93
|
+
- @modern-js/utils@1.0.0-rc.6
|
|
94
|
+
|
|
95
|
+
## 1.0.0-rc.5
|
|
96
|
+
|
|
97
|
+
### Patch Changes
|
|
98
|
+
|
|
99
|
+
- 224f7fe: fix server route match
|
|
100
|
+
- 204c626: feat: initial
|
|
101
|
+
- Updated dependencies [224f7fe]
|
|
102
|
+
- Updated dependencies [204c626]
|
|
103
|
+
- @modern-js/babel-preset-module@1.0.0-rc.5
|
|
104
|
+
- @modern-js/core@1.0.0-rc.5
|
|
105
|
+
- @modern-js/css-config@1.0.0-rc.5
|
|
106
|
+
- @modern-js/i18n-cli-language-detector@1.0.0-rc.5
|
|
107
|
+
- @modern-js/plugin-analyze@1.0.0-rc.5
|
|
108
|
+
- @modern-js/plugin-changeset@1.0.0-rc.5
|
|
109
|
+
- @modern-js/plugin-fast-refresh@1.0.0-rc.5
|
|
110
|
+
- @modern-js/plugin-i18n@1.0.0-rc.5
|
|
111
|
+
- @modern-js/new-action@1.0.0-rc.5
|
|
112
|
+
- @modern-js/babel-compiler@1.0.0-rc.5
|
|
113
|
+
- @modern-js/style-compiler@1.0.0-rc.5
|
|
114
|
+
- @modern-js/module-tools-hooks@1.0.0-rc.5
|
|
115
|
+
- @modern-js/plugin@1.0.0-rc.5
|
|
116
|
+
- @modern-js/utils@1.0.0-rc.5
|
|
117
|
+
|
|
3
118
|
## 1.0.0-rc.4
|
|
4
119
|
|
|
5
120
|
### Patch Changes
|
|
@@ -13,11 +13,9 @@ export const build = async ({
|
|
|
13
13
|
platform
|
|
14
14
|
}) => {
|
|
15
15
|
const {
|
|
16
|
-
|
|
17
|
-
appDirectory
|
|
18
|
-
}
|
|
16
|
+
appDirectory
|
|
19
17
|
} = core.useAppContext();
|
|
20
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
18
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
21
19
|
const {
|
|
22
20
|
output: {
|
|
23
21
|
path: outputPath = 'dist'
|
|
@@ -9,8 +9,8 @@ export const dev = async option => {
|
|
|
9
9
|
const {
|
|
10
10
|
tsconfig: tsconfigName
|
|
11
11
|
} = option;
|
|
12
|
-
const appContext = core.useAppContext()
|
|
13
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
12
|
+
const appContext = core.useAppContext();
|
|
13
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
14
14
|
const {
|
|
15
15
|
appDirectory
|
|
16
16
|
} = appContext;
|
|
@@ -15,7 +15,7 @@ export const buildSourceCode = async (config, _) => {
|
|
|
15
15
|
} = config;
|
|
16
16
|
const {
|
|
17
17
|
appDirectory
|
|
18
|
-
} = core.useAppContext()
|
|
18
|
+
} = core.useAppContext();
|
|
19
19
|
const concurrency = os.cpus().length;
|
|
20
20
|
const srcRootDir = path.join(appDirectory, sourceDir);
|
|
21
21
|
const lm = new lg.LoggerManager();
|
|
@@ -35,14 +35,14 @@ export const getCodeInitMapper = _ => {
|
|
|
35
35
|
packageFields,
|
|
36
36
|
packageMode
|
|
37
37
|
}
|
|
38
|
-
} = core.useResolvedConfigContext()
|
|
38
|
+
} = core.useResolvedConfigContext();
|
|
39
39
|
let initMapper = []; // 如果不存在packageFields配置或者packageFields为空对象,则使用 packageMode
|
|
40
40
|
|
|
41
41
|
if (!packageFields || typeof packageFields === 'object' && Object.keys(packageFields).length === 0) {
|
|
42
42
|
initMapper = constants.PACKAGE_MODES[packageMode || constants.DEFAULT_PACKAGE_MODE];
|
|
43
43
|
} else if (packageFields && Object.keys(packageFields).length > 0) {
|
|
44
|
-
if (packageFields
|
|
45
|
-
initMapper = updateMapper(packageFields
|
|
44
|
+
if (packageFields.modern) {
|
|
45
|
+
initMapper = updateMapper(packageFields.modern, 'modern', initMapper);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
if (packageFields.main) {
|
|
@@ -54,7 +54,7 @@ export const getCodeInitMapper = _ => {
|
|
|
54
54
|
} // TODO: 如果存在其他配置,需要提示
|
|
55
55
|
|
|
56
56
|
|
|
57
|
-
if (!packageFields
|
|
57
|
+
if (!packageFields.modern && !packageFields.main && !packageFields.module) {
|
|
58
58
|
console.error(chalk.red(`Unrecognized ${JSON.stringify(packageFields)} configuration, please use keys: 'modern, main, jupiter:modern' and use values: 'CJS+ES6, ESM+ES5, ESM+ES6'`)); // eslint-disable-next-line no-process-exit
|
|
59
59
|
|
|
60
60
|
process.exit(1);
|
|
@@ -73,11 +73,9 @@ export const getCodeMapper = ({
|
|
|
73
73
|
willCompilerDirOrFile
|
|
74
74
|
}) => {
|
|
75
75
|
const {
|
|
76
|
-
|
|
77
|
-
appDirectory
|
|
78
|
-
}
|
|
76
|
+
appDirectory
|
|
79
77
|
} = core.useAppContext();
|
|
80
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
78
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
81
79
|
const {
|
|
82
80
|
output: {
|
|
83
81
|
enableSourceMap,
|
|
@@ -104,11 +102,9 @@ export const getCodeMapper = ({
|
|
|
104
102
|
|
|
105
103
|
export const getDtsMapper = (config, logger) => {
|
|
106
104
|
const {
|
|
107
|
-
|
|
108
|
-
appDirectory
|
|
109
|
-
}
|
|
105
|
+
appDirectory
|
|
110
106
|
} = core.useAppContext();
|
|
111
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
107
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
112
108
|
const {
|
|
113
109
|
output: {
|
|
114
110
|
disableTsChecker,
|
|
@@ -34,7 +34,7 @@ export const devStorybook = async config => {
|
|
|
34
34
|
if (findStorybook) {
|
|
35
35
|
await findStorybook.runTask(config);
|
|
36
36
|
} else {
|
|
37
|
-
console.info(chalk.yellow('
|
|
37
|
+
console.info(chalk.yellow('No development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
|
|
38
38
|
|
|
39
39
|
process.exit(0);
|
|
40
40
|
}
|
|
@@ -62,7 +62,9 @@ export const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
62
62
|
}, {
|
|
63
63
|
type: option.type,
|
|
64
64
|
syntax: option.syntax
|
|
65
|
-
});
|
|
65
|
+
}); // Preventing warning when files are too large
|
|
66
|
+
|
|
67
|
+
internalBabelConfig.compact = false;
|
|
66
68
|
const babelChain = getModuleBabelChain({
|
|
67
69
|
appDirectory,
|
|
68
70
|
enableReactPreset: true,
|
|
@@ -31,11 +31,9 @@ const build = async ({
|
|
|
31
31
|
platform
|
|
32
32
|
}) => {
|
|
33
33
|
const {
|
|
34
|
-
|
|
35
|
-
appDirectory
|
|
36
|
-
}
|
|
34
|
+
appDirectory
|
|
37
35
|
} = core.useAppContext();
|
|
38
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
36
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
39
37
|
const {
|
|
40
38
|
output: {
|
|
41
39
|
path: outputPath = 'dist'
|
|
@@ -27,8 +27,8 @@ const dev = async option => {
|
|
|
27
27
|
const {
|
|
28
28
|
tsconfig: tsconfigName
|
|
29
29
|
} = option;
|
|
30
|
-
const appContext = core.useAppContext()
|
|
31
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
30
|
+
const appContext = core.useAppContext();
|
|
31
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
32
32
|
const {
|
|
33
33
|
appDirectory
|
|
34
34
|
} = appContext;
|
|
@@ -35,7 +35,7 @@ const buildSourceCode = async (config, _) => {
|
|
|
35
35
|
} = config;
|
|
36
36
|
const {
|
|
37
37
|
appDirectory
|
|
38
|
-
} = core.useAppContext()
|
|
38
|
+
} = core.useAppContext();
|
|
39
39
|
const concurrency = os.cpus().length;
|
|
40
40
|
const srcRootDir = path.join(appDirectory, sourceDir);
|
|
41
41
|
const lm = new lg.LoggerManager();
|
|
@@ -51,14 +51,14 @@ const getCodeInitMapper = _ => {
|
|
|
51
51
|
packageFields,
|
|
52
52
|
packageMode
|
|
53
53
|
}
|
|
54
|
-
} = core.useResolvedConfigContext()
|
|
54
|
+
} = core.useResolvedConfigContext();
|
|
55
55
|
let initMapper = []; // 如果不存在packageFields配置或者packageFields为空对象,则使用 packageMode
|
|
56
56
|
|
|
57
57
|
if (!packageFields || typeof packageFields === 'object' && Object.keys(packageFields).length === 0) {
|
|
58
58
|
initMapper = constants.PACKAGE_MODES[packageMode || constants.DEFAULT_PACKAGE_MODE];
|
|
59
59
|
} else if (packageFields && Object.keys(packageFields).length > 0) {
|
|
60
|
-
if (packageFields
|
|
61
|
-
initMapper = updateMapper(packageFields
|
|
60
|
+
if (packageFields.modern) {
|
|
61
|
+
initMapper = updateMapper(packageFields.modern, 'modern', initMapper);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
if (packageFields.main) {
|
|
@@ -70,7 +70,7 @@ const getCodeInitMapper = _ => {
|
|
|
70
70
|
} // TODO: 如果存在其他配置,需要提示
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
if (!packageFields
|
|
73
|
+
if (!packageFields.modern && !packageFields.main && !packageFields.module) {
|
|
74
74
|
console.error(_utils.chalk.red(`Unrecognized ${JSON.stringify(packageFields)} configuration, please use keys: 'modern, main, jupiter:modern' and use values: 'CJS+ES6, ESM+ES5, ESM+ES6'`)); // eslint-disable-next-line no-process-exit
|
|
75
75
|
|
|
76
76
|
process.exit(1);
|
|
@@ -92,11 +92,9 @@ const getCodeMapper = ({
|
|
|
92
92
|
willCompilerDirOrFile
|
|
93
93
|
}) => {
|
|
94
94
|
const {
|
|
95
|
-
|
|
96
|
-
appDirectory
|
|
97
|
-
}
|
|
95
|
+
appDirectory
|
|
98
96
|
} = core.useAppContext();
|
|
99
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
97
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
100
98
|
const {
|
|
101
99
|
output: {
|
|
102
100
|
enableSourceMap,
|
|
@@ -126,11 +124,9 @@ exports.getCodeMapper = getCodeMapper;
|
|
|
126
124
|
|
|
127
125
|
const getDtsMapper = (config, logger) => {
|
|
128
126
|
const {
|
|
129
|
-
|
|
130
|
-
appDirectory
|
|
131
|
-
}
|
|
127
|
+
appDirectory
|
|
132
128
|
} = core.useAppContext();
|
|
133
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
129
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
134
130
|
const {
|
|
135
131
|
output: {
|
|
136
132
|
disableTsChecker,
|
|
@@ -51,7 +51,7 @@ const devStorybook = async config => {
|
|
|
51
51
|
if (findStorybook) {
|
|
52
52
|
await findStorybook.runTask(config);
|
|
53
53
|
} else {
|
|
54
|
-
console.info(_chalk.default.yellow('
|
|
54
|
+
console.info(_chalk.default.yellow('No development features found.\nYou can use the `new` command to enable the development features')); // eslint-disable-next-line no-process-exit
|
|
55
55
|
|
|
56
56
|
process.exit(0);
|
|
57
57
|
}
|
|
@@ -72,6 +72,8 @@ const copyOriginStyleFiles = ({
|
|
|
72
72
|
for (const styleFile of styleFiles) {
|
|
73
73
|
const file = path.relative(targetDir, styleFile);
|
|
74
74
|
|
|
75
|
+
_utils.fs.ensureDirSync(path.dirname(path.join(outputDir, file)));
|
|
76
|
+
|
|
75
77
|
_utils.fs.copyFileSync(styleFile, path.join(outputDir, file));
|
|
76
78
|
}
|
|
77
79
|
};
|
|
@@ -74,7 +74,9 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
74
74
|
}, {
|
|
75
75
|
type: option.type,
|
|
76
76
|
syntax: option.syntax
|
|
77
|
-
});
|
|
77
|
+
}); // Preventing warning when files are too large
|
|
78
|
+
|
|
79
|
+
internalBabelConfig.compact = false;
|
|
78
80
|
const babelChain = (0, _babelPresetModule.getModuleBabelChain)({
|
|
79
81
|
appDirectory,
|
|
80
82
|
enableReactPreset: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/module-tools",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
4
4
|
"bin": {
|
|
5
5
|
"modern": "./bin/modern.js"
|
|
6
6
|
},
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
"@babel/runtime": "^7",
|
|
34
34
|
"@babel/traverse": "^7.15.0",
|
|
35
35
|
"@babel/types": "^7.15.0",
|
|
36
|
-
"@modern-js/babel-compiler": "^1.0.0-rc.
|
|
37
|
-
"@modern-js/babel-preset-module": "^1.0.0-rc.
|
|
38
|
-
"@modern-js/core": "^1.0.0-rc.
|
|
39
|
-
"@modern-js/css-config": "^1.0.0-rc.
|
|
40
|
-
"@modern-js/i18n-cli-language-detector": "^1.0.0-rc.
|
|
41
|
-
"@modern-js/module-tools-hooks": "^1.0.0-rc.
|
|
42
|
-
"@modern-js/new-action": "^1.0.0-rc.
|
|
43
|
-
"@modern-js/plugin": "^1.0.0-rc.
|
|
44
|
-
"@modern-js/plugin-analyze": "^1.0.0-rc.
|
|
45
|
-
"@modern-js/plugin-changeset": "^1.0.0-rc.
|
|
46
|
-
"@modern-js/plugin-fast-refresh": "^1.0.0-rc.
|
|
47
|
-
"@modern-js/plugin-i18n": "^1.0.0-rc.
|
|
48
|
-
"@modern-js/style-compiler": "^1.0.0-rc.
|
|
49
|
-
"@modern-js/utils": "^1.0.0-rc.
|
|
36
|
+
"@modern-js/babel-compiler": "^1.0.0-rc.9",
|
|
37
|
+
"@modern-js/babel-preset-module": "^1.0.0-rc.9",
|
|
38
|
+
"@modern-js/core": "^1.0.0-rc.9",
|
|
39
|
+
"@modern-js/css-config": "^1.0.0-rc.9",
|
|
40
|
+
"@modern-js/i18n-cli-language-detector": "^1.0.0-rc.9",
|
|
41
|
+
"@modern-js/module-tools-hooks": "^1.0.0-rc.9",
|
|
42
|
+
"@modern-js/new-action": "^1.0.0-rc.9",
|
|
43
|
+
"@modern-js/plugin": "^1.0.0-rc.9",
|
|
44
|
+
"@modern-js/plugin-analyze": "^1.0.0-rc.9",
|
|
45
|
+
"@modern-js/plugin-changeset": "^1.0.0-rc.9",
|
|
46
|
+
"@modern-js/plugin-fast-refresh": "^1.0.0-rc.9",
|
|
47
|
+
"@modern-js/plugin-i18n": "^1.0.0-rc.9",
|
|
48
|
+
"@modern-js/style-compiler": "^1.0.0-rc.9",
|
|
49
|
+
"@modern-js/utils": "^1.0.0-rc.9",
|
|
50
50
|
"chalk": "^4.1.2",
|
|
51
51
|
"chokidar": "^3.5.2",
|
|
52
52
|
"dotenv": "^10.0.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@babel/preset-typescript": "^7.15.0",
|
|
68
|
-
"@modern-js/babel-chain": "^1.0.0-rc.
|
|
68
|
+
"@modern-js/babel-chain": "^1.0.0-rc.9",
|
|
69
69
|
"@types/babel__core": "^7.1.15",
|
|
70
70
|
"@types/babel__generator": "^7.6.3",
|
|
71
71
|
"@types/babel__traverse": "^7.14.2",
|
|
@@ -78,8 +78,8 @@
|
|
|
78
78
|
"@types/signale": "^1.4.2",
|
|
79
79
|
"commander": "^8.1.0",
|
|
80
80
|
"typescript": "^4",
|
|
81
|
-
"@modern-js/plugin-testing": "^1.0.0-rc.
|
|
82
|
-
"@modern-js/module-tools": "^1.0.0-rc.
|
|
81
|
+
"@modern-js/plugin-testing": "^1.0.0-rc.9",
|
|
82
|
+
"@modern-js/module-tools": "^1.0.0-rc.9"
|
|
83
83
|
},
|
|
84
84
|
"sideEffects": false,
|
|
85
85
|
"modernConfig": {
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"packageMode": "node-js"
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
|
-
"
|
|
90
|
+
"publishConfig": {
|
|
91
91
|
"registry": "https://registry.npmjs.org/",
|
|
92
92
|
"access": "public"
|
|
93
93
|
},
|
package/src/commands/build.ts
CHANGED
|
@@ -37,10 +37,8 @@ export const build = async ({
|
|
|
37
37
|
clear = true,
|
|
38
38
|
platform,
|
|
39
39
|
}: IBuildOption) => {
|
|
40
|
-
const {
|
|
41
|
-
|
|
42
|
-
} = core.useAppContext();
|
|
43
|
-
const modernConfig = core.useResolvedConfigContext().value;
|
|
40
|
+
const { appDirectory } = core.useAppContext();
|
|
41
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
44
42
|
const {
|
|
45
43
|
output: { path: outputPath = 'dist' },
|
|
46
44
|
} = modernConfig;
|
package/src/commands/dev.ts
CHANGED
|
@@ -25,8 +25,8 @@ export interface IDevOption {
|
|
|
25
25
|
|
|
26
26
|
export const dev = async (option: IDevOption) => {
|
|
27
27
|
const { tsconfig: tsconfigName } = option;
|
|
28
|
-
const appContext = core.useAppContext()
|
|
29
|
-
const modernConfig = core.useResolvedConfigContext()
|
|
28
|
+
const appContext = core.useAppContext();
|
|
29
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
30
30
|
const { appDirectory } = appContext;
|
|
31
31
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
32
32
|
|
|
@@ -22,7 +22,7 @@ export const buildInWatchMode = async (
|
|
|
22
22
|
config: IBuildConfig,
|
|
23
23
|
_: NormalizedConfig,
|
|
24
24
|
) => {
|
|
25
|
-
const { appDirectory } = core.useAppContext()
|
|
25
|
+
const { appDirectory } = core.useAppContext();
|
|
26
26
|
const { sourceDir, enableTscCompiler } = config;
|
|
27
27
|
const srcRootDir = path.join(appDirectory, sourceDir);
|
|
28
28
|
const concurrency = os.cpus().length;
|
|
@@ -23,7 +23,7 @@ export const buildSourceCode = async (
|
|
|
23
23
|
_: NormalizedConfig,
|
|
24
24
|
) => {
|
|
25
25
|
const { sourceDir, enableTscCompiler } = config;
|
|
26
|
-
const { appDirectory } = core.useAppContext()
|
|
26
|
+
const { appDirectory } = core.useAppContext();
|
|
27
27
|
const concurrency = os.cpus().length;
|
|
28
28
|
const srcRootDir = path.join(appDirectory, sourceDir);
|
|
29
29
|
const lm = new lg.LoggerManager();
|
|
@@ -40,7 +40,7 @@ const updateMapper = (
|
|
|
40
40
|
export const getCodeInitMapper = (_: IBuildConfig) => {
|
|
41
41
|
const {
|
|
42
42
|
output: { packageFields, packageMode },
|
|
43
|
-
} = core.useResolvedConfigContext()
|
|
43
|
+
} = core.useResolvedConfigContext() as ModuleToolsConfig;
|
|
44
44
|
let initMapper: IPackageModeValue[] = [];
|
|
45
45
|
|
|
46
46
|
// 如果不存在packageFields配置或者packageFields为空对象,则使用 packageMode
|
|
@@ -52,12 +52,8 @@ export const getCodeInitMapper = (_: IBuildConfig) => {
|
|
|
52
52
|
initMapper =
|
|
53
53
|
constants.PACKAGE_MODES[packageMode || constants.DEFAULT_PACKAGE_MODE];
|
|
54
54
|
} else if (packageFields && Object.keys(packageFields).length > 0) {
|
|
55
|
-
if (packageFields
|
|
56
|
-
initMapper = updateMapper(
|
|
57
|
-
packageFields['modern'],
|
|
58
|
-
'modern',
|
|
59
|
-
initMapper,
|
|
60
|
-
);
|
|
55
|
+
if (packageFields.modern) {
|
|
56
|
+
initMapper = updateMapper(packageFields.modern, 'modern', initMapper);
|
|
61
57
|
}
|
|
62
58
|
|
|
63
59
|
if (packageFields.main) {
|
|
@@ -73,11 +69,7 @@ export const getCodeInitMapper = (_: IBuildConfig) => {
|
|
|
73
69
|
}
|
|
74
70
|
|
|
75
71
|
// TODO: 如果存在其他配置,需要提示
|
|
76
|
-
if (
|
|
77
|
-
!packageFields['modern'] &&
|
|
78
|
-
!packageFields.main &&
|
|
79
|
-
!packageFields.module
|
|
80
|
-
) {
|
|
72
|
+
if (!packageFields.modern && !packageFields.main && !packageFields.module) {
|
|
81
73
|
console.error(
|
|
82
74
|
chalk.red(
|
|
83
75
|
`Unrecognized ${JSON.stringify(
|
|
@@ -108,10 +100,8 @@ export const getCodeMapper = ({
|
|
|
108
100
|
srcRootDir: string;
|
|
109
101
|
willCompilerDirOrFile: string;
|
|
110
102
|
}) => {
|
|
111
|
-
const {
|
|
112
|
-
|
|
113
|
-
} = core.useAppContext();
|
|
114
|
-
const modernConfig = core.useResolvedConfigContext().value;
|
|
103
|
+
const { appDirectory } = core.useAppContext();
|
|
104
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
115
105
|
const {
|
|
116
106
|
output: { enableSourceMap, jsPath = 'js', path: distDir = 'dist' },
|
|
117
107
|
} = modernConfig as ModuleToolsConfig;
|
|
@@ -147,10 +137,8 @@ export const getCodeMapper = ({
|
|
|
147
137
|
|
|
148
138
|
// 获取执行生成 d.ts 的参数
|
|
149
139
|
export const getDtsMapper = (config: IBuildConfig, logger: LoggerText) => {
|
|
150
|
-
const {
|
|
151
|
-
|
|
152
|
-
} = core.useAppContext();
|
|
153
|
-
const modernConfig = core.useResolvedConfigContext().value;
|
|
140
|
+
const { appDirectory } = core.useAppContext();
|
|
141
|
+
const modernConfig = core.useResolvedConfigContext();
|
|
154
142
|
const {
|
|
155
143
|
output: { disableTsChecker, path: outputPath = 'dist' },
|
|
156
144
|
} = modernConfig as ModuleToolsConfig;
|
|
@@ -53,7 +53,7 @@ export const devStorybook = async (config: IDevConfig) => {
|
|
|
53
53
|
} else {
|
|
54
54
|
console.info(
|
|
55
55
|
chalk.yellow(
|
|
56
|
-
'
|
|
56
|
+
'No development features found.\nYou can use the `new` command to enable the development features',
|
|
57
57
|
),
|
|
58
58
|
);
|
|
59
59
|
// eslint-disable-next-line no-process-exit
|
package/src/tasks/build-style.ts
CHANGED
|
@@ -82,6 +82,7 @@ const copyOriginStyleFiles = ({
|
|
|
82
82
|
}
|
|
83
83
|
for (const styleFile of styleFiles) {
|
|
84
84
|
const file = path.relative(targetDir, styleFile);
|
|
85
|
+
fs.ensureDirSync(path.dirname(path.join(outputDir, file)));
|
|
85
86
|
fs.copyFileSync(styleFile, path.join(outputDir, file));
|
|
86
87
|
}
|
|
87
88
|
};
|
package/src/utils/babel.ts
CHANGED