@modern-js/module-tools 1.4.5 → 1.5.1
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 +85 -0
- package/dist/js/modern/commands/build.js +1 -2
- package/dist/js/modern/commands/dev.js +1 -2
- package/dist/js/modern/features/dev/index.js +1 -2
- package/dist/js/modern/tasks/build-style.js +3 -3
- package/dist/js/modern/tasks/generator-dts/index.js +2 -3
- package/dist/js/modern/utils/copy.js +2 -4
- package/dist/js/modern/utils/tsconfig.js +1 -2
- package/dist/js/modern/utils/tspaths-transform/index.js +2 -2
- package/dist/js/node/commands/build.js +3 -3
- package/dist/js/node/commands/dev.js +3 -3
- package/dist/js/node/features/dev/index.js +1 -3
- package/dist/js/node/tasks/build-style.js +3 -3
- package/dist/js/node/tasks/generator-dts/index.js +1 -3
- package/dist/js/node/utils/copy.js +3 -7
- package/dist/js/node/utils/tsconfig.js +1 -3
- package/dist/js/node/utils/tspaths-transform/index.js +2 -2
- package/dist/types/features/dev/index.d.ts +1 -1
- package/dist/types/utils/tspaths-transform/index.d.ts +2 -2
- package/package.json +15 -21
- package/tests/dev-cli.test.ts +0 -59
- package/tests/dev-command.test.ts +0 -70
- package/tests/dev-feature.test.ts +0 -78
- package/tests/fixtures/tspaths/a.ts +0 -1
- package/tests/fixtures/tspaths/b.ts +0 -1
- package/tests/generate-dts.test.ts +0 -9
- package/tests/generator-dts-utils.test.ts +0 -10
- package/tests/generator-dts.test.ts +0 -37
- package/tests/index.test.ts +0 -7
- package/tests/tsconfig.json +0 -11
- package/tests/tspaths-transform.test.ts +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,90 @@
|
|
|
1
1
|
# @modern-js/module-tools
|
|
2
2
|
|
|
3
|
+
## 1.5.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 69a728375: fix: remove exports.jsnext:source after publish
|
|
8
|
+
- Updated dependencies [cd7346b0d]
|
|
9
|
+
- Updated dependencies [0e0537005]
|
|
10
|
+
- Updated dependencies [6b0bb5e3b]
|
|
11
|
+
- Updated dependencies [69a728375]
|
|
12
|
+
- @modern-js/utils@1.7.2
|
|
13
|
+
- @modern-js/babel-preset-module@1.3.4
|
|
14
|
+
- @modern-js/babel-compiler@1.2.4
|
|
15
|
+
- @modern-js/new-action@1.3.8
|
|
16
|
+
- @modern-js/core@1.10.1
|
|
17
|
+
- @modern-js/css-config@1.2.5
|
|
18
|
+
- @modern-js/plugin-analyze@1.4.2
|
|
19
|
+
- @modern-js/plugin-changeset@1.2.6
|
|
20
|
+
- @modern-js/plugin-fast-refresh@1.2.5
|
|
21
|
+
- @modern-js/plugin-i18n@1.2.5
|
|
22
|
+
- @modern-js/style-compiler@1.2.5
|
|
23
|
+
|
|
24
|
+
## 1.5.0
|
|
25
|
+
|
|
26
|
+
### Minor Changes
|
|
27
|
+
|
|
28
|
+
- 0b26b93b: feat: prebundle all dependencies of @modern-js/core
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- 592edabc: feat: prebundle url-join,mime-types,json5,fast-glob,globby,ora,inquirer
|
|
33
|
+
- 895fa0ff: chore: using "workspace:\*" in devDependencies
|
|
34
|
+
- Updated dependencies [2d155c4c]
|
|
35
|
+
- Updated dependencies [123e432d]
|
|
36
|
+
- Updated dependencies [e5a9b26d]
|
|
37
|
+
- Updated dependencies [0b26b93b]
|
|
38
|
+
- Updated dependencies [123e432d]
|
|
39
|
+
- Updated dependencies [f9f66ef9]
|
|
40
|
+
- Updated dependencies [592edabc]
|
|
41
|
+
- Updated dependencies [f9f66ef9]
|
|
42
|
+
- Updated dependencies [895fa0ff]
|
|
43
|
+
- Updated dependencies [3578913e]
|
|
44
|
+
- Updated dependencies [1c3beab3]
|
|
45
|
+
- @modern-js/utils@1.6.0
|
|
46
|
+
- @modern-js/core@1.9.0
|
|
47
|
+
- @modern-js/plugin-analyze@1.4.1
|
|
48
|
+
- @modern-js/new-action@1.3.7
|
|
49
|
+
- @modern-js/babel-preset-module@1.3.3
|
|
50
|
+
- @modern-js/css-config@1.2.4
|
|
51
|
+
- @modern-js/plugin-changeset@1.2.5
|
|
52
|
+
- @modern-js/plugin-fast-refresh@1.2.4
|
|
53
|
+
|
|
54
|
+
## 1.4.6
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
|
|
59
|
+
- 60f7d8bf: feat: add tests dir to npmignore
|
|
60
|
+
- 3bf4f8b0: feat: support start api server only
|
|
61
|
+
- 305e0bb4: fix: commander.commandsMap typing not work
|
|
62
|
+
- Updated dependencies [a4330c73]
|
|
63
|
+
- Updated dependencies [b8599d09]
|
|
64
|
+
- Updated dependencies [6cffe99d]
|
|
65
|
+
- Updated dependencies [04ae5262]
|
|
66
|
+
- Updated dependencies [60f7d8bf]
|
|
67
|
+
- Updated dependencies [e4cec1ce]
|
|
68
|
+
- Updated dependencies [3b7aa8bb]
|
|
69
|
+
- Updated dependencies [5dbbeb57]
|
|
70
|
+
- Updated dependencies [ebfcbb35]
|
|
71
|
+
- Updated dependencies [3bf4f8b0]
|
|
72
|
+
- Updated dependencies [305e0bb4]
|
|
73
|
+
- Updated dependencies [ebfcbb35]
|
|
74
|
+
- @modern-js/core@1.8.0
|
|
75
|
+
- @modern-js/utils@1.5.0
|
|
76
|
+
- @modern-js/babel-preset-module@1.3.2
|
|
77
|
+
- @modern-js/css-config@1.2.4
|
|
78
|
+
- @modern-js/i18n-cli-language-detector@1.2.2
|
|
79
|
+
- @modern-js/plugin-changeset@1.2.5
|
|
80
|
+
- @modern-js/plugin-fast-refresh@1.2.4
|
|
81
|
+
- @modern-js/plugin-i18n@1.2.4
|
|
82
|
+
- @modern-js/new-action@1.3.6
|
|
83
|
+
- @modern-js/babel-compiler@1.2.3
|
|
84
|
+
- @modern-js/style-compiler@1.2.4
|
|
85
|
+
- @modern-js/plugin@1.3.3
|
|
86
|
+
- @modern-js/plugin-analyze@1.4.0
|
|
87
|
+
|
|
3
88
|
## 1.4.5
|
|
4
89
|
|
|
5
90
|
### Patch Changes
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { fs, Import } from '@modern-js/utils';
|
|
2
|
+
import { fs, Import, dotenv } from '@modern-js/utils';
|
|
3
3
|
const tsConfigutils = Import.lazy('../utils/tsconfig', require);
|
|
4
4
|
const valid = Import.lazy('../utils/valide', require);
|
|
5
5
|
const buildFeature = Import.lazy('../features/build', require);
|
|
6
|
-
const dotenv = Import.lazy('dotenv', require);
|
|
7
6
|
export const build = async (api, {
|
|
8
7
|
watch: _watch = false,
|
|
9
8
|
tsconfig: tsconfigName,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { Import } from '@modern-js/utils';
|
|
2
|
+
import { dotenv, Import } from '@modern-js/utils';
|
|
3
3
|
const devFeature = Import.lazy('../features/dev', require);
|
|
4
|
-
const dotenv = Import.lazy('dotenv', require);
|
|
5
4
|
const tsConfigutils = Import.lazy('../utils/tsconfig', require);
|
|
6
5
|
const valid = Import.lazy('../utils/valide', require);
|
|
7
6
|
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { chalk, Import } from '@modern-js/utils';
|
|
2
|
-
const inquirer = Import.lazy('inquirer', require);
|
|
1
|
+
import { chalk, Import, inquirer } from '@modern-js/utils';
|
|
3
2
|
const color = Import.lazy('../../utils/color', require);
|
|
4
3
|
export const showMenu = async (api, config) => {
|
|
5
4
|
const runners = api.useHookRunners();
|
|
@@ -118,13 +118,13 @@ const taskMain = async ({
|
|
|
118
118
|
|
|
119
119
|
|
|
120
120
|
const srcDir = path.resolve(appDirectory, SRC_STYLE_DIRS);
|
|
121
|
-
const
|
|
121
|
+
const outputDirToSrc = path.join(appDirectory, outputPath, jsPath, assetsPath);
|
|
122
122
|
|
|
123
123
|
if (importStyle === 'compiled-code') {
|
|
124
124
|
const srcStyleResult = await compiler.styleCompiler({
|
|
125
125
|
projectDir: appDirectory,
|
|
126
126
|
stylesDir: srcDir,
|
|
127
|
-
outDir:
|
|
127
|
+
outDir: outputDirToSrc,
|
|
128
128
|
enableVirtualDist: true,
|
|
129
129
|
compilerOption: {
|
|
130
130
|
less: lessOption,
|
|
@@ -136,7 +136,7 @@ const taskMain = async ({
|
|
|
136
136
|
} else {
|
|
137
137
|
copyOriginStyleFiles({
|
|
138
138
|
targetDir: srcDir,
|
|
139
|
-
outputDir:
|
|
139
|
+
outputDir: outputDirToSrc
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
};
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Import, execa, fs, isObject } from '@modern-js/utils';
|
|
1
|
+
import { Import, execa, fs, json5, isObject } from '@modern-js/utils';
|
|
2
2
|
import { getTscBinPath } from "./utils";
|
|
3
3
|
const core = Import.lazy('@modern-js/core', require);
|
|
4
|
-
const JSON5 = Import.lazy('json5', require);
|
|
5
4
|
const argv = Import.lazy('process.argv', require);
|
|
6
5
|
const utils = Import.lazy('./utils', require);
|
|
7
6
|
let removeTsconfigPath = '';
|
|
@@ -11,7 +10,7 @@ const getProjectTsconfig = tsconfigPath => {
|
|
|
11
10
|
return {};
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
return
|
|
13
|
+
return json5.parse(fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
const resolveLog = (childProgress, {
|
|
@@ -5,9 +5,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
|
|
7
7
|
import * as path from 'path';
|
|
8
|
-
import { fs, Import } from '@modern-js/utils';
|
|
9
|
-
const globby = Import.lazy('globby', require);
|
|
10
|
-
const fastGlob = Import.lazy('fast-glob', require);
|
|
8
|
+
import { fs, Import, globby, fastGlob } from '@modern-js/utils';
|
|
11
9
|
const normalizePath = Import.lazy('normalize-path', require);
|
|
12
10
|
export const copyTask = async option => {
|
|
13
11
|
const {
|
|
@@ -33,7 +31,7 @@ export const copyTask = async option => {
|
|
|
33
31
|
try {
|
|
34
32
|
// 类型暂时这样处理,待之后优化copy的逻辑
|
|
35
33
|
for (const copyOption of copy) {
|
|
36
|
-
// 在原来的基础上,引入了类似于 copy-
|
|
34
|
+
// 在原来的基础上,引入了类似于 copy-webpack-plugin 的 context 属性,可以设置项目根路径
|
|
37
35
|
const {
|
|
38
36
|
context = appDirectory,
|
|
39
37
|
from,
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { fs,
|
|
2
|
-
const json5 = Import.lazy('json5', require);
|
|
1
|
+
import { fs, json5 } from '@modern-js/utils';
|
|
3
2
|
export const readTsConfig = (tsconfigPath, noExistReturn = null) => {
|
|
4
3
|
// 如果不存在,则返回 noExistReturn
|
|
5
4
|
if (!fs.existsSync(tsconfigPath)) {
|
|
@@ -75,7 +75,7 @@ const transformExport = option => nodePath => {
|
|
|
75
75
|
mapPathString(nodePath.get('source'), option);
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const
|
|
78
|
+
const transformSingleFileAlias = ({
|
|
79
79
|
filename,
|
|
80
80
|
baseUrl,
|
|
81
81
|
paths
|
|
@@ -118,7 +118,7 @@ export const transformDtsAlias = option => {
|
|
|
118
118
|
for (const filename of filenames) {
|
|
119
119
|
transformResult.push({
|
|
120
120
|
path: filename,
|
|
121
|
-
content:
|
|
121
|
+
content: transformSingleFileAlias({
|
|
122
122
|
filename,
|
|
123
123
|
baseUrl,
|
|
124
124
|
paths
|
|
@@ -19,8 +19,6 @@ const valid = _utils.Import.lazy('../utils/valide', require);
|
|
|
19
19
|
|
|
20
20
|
const buildFeature = _utils.Import.lazy('../features/build', require);
|
|
21
21
|
|
|
22
|
-
const dotenv = _utils.Import.lazy('dotenv', require);
|
|
23
|
-
|
|
24
22
|
const build = async (api, {
|
|
25
23
|
watch: _watch = false,
|
|
26
24
|
tsconfig: tsconfigName,
|
|
@@ -33,7 +31,9 @@ const build = async (api, {
|
|
|
33
31
|
} = api.useAppContext();
|
|
34
32
|
const modernConfig = api.useResolvedConfigContext();
|
|
35
33
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
_utils.dotenv.config();
|
|
36
|
+
|
|
37
37
|
const isTsProject = tsConfigutils.existTsConfigFile(tsconfigPath);
|
|
38
38
|
const enableTscCompiler = isTsProject && tsc && !modernConfig.output.disableTsChecker;
|
|
39
39
|
valid.valideBeforeTask({
|
|
@@ -15,8 +15,6 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
15
15
|
|
|
16
16
|
const devFeature = _utils.Import.lazy('../features/dev', require);
|
|
17
17
|
|
|
18
|
-
const dotenv = _utils.Import.lazy('dotenv', require);
|
|
19
|
-
|
|
20
18
|
const tsConfigutils = _utils.Import.lazy('../utils/tsconfig', require);
|
|
21
19
|
|
|
22
20
|
const valid = _utils.Import.lazy('../utils/valide', require);
|
|
@@ -33,7 +31,9 @@ const dev = async (api, option, subCmd = '') => {
|
|
|
33
31
|
appDirectory
|
|
34
32
|
} = appContext;
|
|
35
33
|
const tsconfigPath = path.join(appDirectory, tsconfigName);
|
|
36
|
-
|
|
34
|
+
|
|
35
|
+
_utils.dotenv.config();
|
|
36
|
+
|
|
37
37
|
valid.valideBeforeTask({
|
|
38
38
|
modernConfig,
|
|
39
39
|
tsconfigPath
|
|
@@ -7,8 +7,6 @@ exports.showMenu = exports.runSubCmd = exports.devStorybook = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
|
-
const inquirer = _utils.Import.lazy('inquirer', require);
|
|
11
|
-
|
|
12
10
|
const color = _utils.Import.lazy('../../utils/color', require);
|
|
13
11
|
|
|
14
12
|
const showMenu = async (api, config) => {
|
|
@@ -24,7 +22,7 @@ const showMenu = async (api, config) => {
|
|
|
24
22
|
const menuMessage = color.devMenuTitle('Select the debug mode:');
|
|
25
23
|
const {
|
|
26
24
|
type
|
|
27
|
-
} = await inquirer.prompt([{
|
|
25
|
+
} = await _utils.inquirer.prompt([{
|
|
28
26
|
name: 'type',
|
|
29
27
|
message: menuMessage,
|
|
30
28
|
type: 'list',
|
|
@@ -133,13 +133,13 @@ const taskMain = async ({
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
const srcDir = path.resolve(appDirectory, SRC_STYLE_DIRS);
|
|
136
|
-
const
|
|
136
|
+
const outputDirToSrc = path.join(appDirectory, outputPath, jsPath, assetsPath);
|
|
137
137
|
|
|
138
138
|
if (importStyle === 'compiled-code') {
|
|
139
139
|
const srcStyleResult = await compiler.styleCompiler({
|
|
140
140
|
projectDir: appDirectory,
|
|
141
141
|
stylesDir: srcDir,
|
|
142
|
-
outDir:
|
|
142
|
+
outDir: outputDirToSrc,
|
|
143
143
|
enableVirtualDist: true,
|
|
144
144
|
compilerOption: {
|
|
145
145
|
less: lessOption,
|
|
@@ -151,7 +151,7 @@ const taskMain = async ({
|
|
|
151
151
|
} else {
|
|
152
152
|
copyOriginStyleFiles({
|
|
153
153
|
targetDir: srcDir,
|
|
154
|
-
outputDir:
|
|
154
|
+
outputDir: outputDirToSrc
|
|
155
155
|
});
|
|
156
156
|
}
|
|
157
157
|
};
|
|
@@ -6,8 +6,6 @@ var _utils2 = require("./utils");
|
|
|
6
6
|
|
|
7
7
|
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
8
8
|
|
|
9
|
-
const JSON5 = _utils.Import.lazy('json5', require);
|
|
10
|
-
|
|
11
9
|
const argv = _utils.Import.lazy('process.argv', require);
|
|
12
10
|
|
|
13
11
|
const utils = _utils.Import.lazy('./utils', require);
|
|
@@ -19,7 +17,7 @@ const getProjectTsconfig = tsconfigPath => {
|
|
|
19
17
|
return {};
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
return
|
|
20
|
+
return _utils.json5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
23
21
|
};
|
|
24
22
|
|
|
25
23
|
const resolveLog = (childProgress, {
|
|
@@ -19,10 +19,6 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
19
19
|
|
|
20
20
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
21
21
|
|
|
22
|
-
const globby = _utils.Import.lazy('globby', require);
|
|
23
|
-
|
|
24
|
-
const fastGlob = _utils.Import.lazy('fast-glob', require);
|
|
25
|
-
|
|
26
22
|
const normalizePath = _utils.Import.lazy('normalize-path', require);
|
|
27
23
|
|
|
28
24
|
const copyTask = async option => {
|
|
@@ -49,7 +45,7 @@ const copyTask = async option => {
|
|
|
49
45
|
try {
|
|
50
46
|
// 类型暂时这样处理,待之后优化copy的逻辑
|
|
51
47
|
for (const copyOption of copy) {
|
|
52
|
-
// 在原来的基础上,引入了类似于 copy-
|
|
48
|
+
// 在原来的基础上,引入了类似于 copy-webpack-plugin 的 context 属性,可以设置项目根路径
|
|
53
49
|
const {
|
|
54
50
|
context = appDirectory,
|
|
55
51
|
from,
|
|
@@ -73,9 +69,9 @@ const copyTask = async option => {
|
|
|
73
69
|
options = globOptions;
|
|
74
70
|
}
|
|
75
71
|
|
|
76
|
-
glob = path.isAbsolute(fromOrigin) ? fromOrigin : path.posix.join(fastGlob.escapePath(normalizePath(path.resolve(context))), fromOrigin); // 计算 glob,获取目标文件
|
|
72
|
+
glob = path.isAbsolute(fromOrigin) ? fromOrigin : path.posix.join(_utils.fastGlob.escapePath(normalizePath(path.resolve(context))), fromOrigin); // 计算 glob,获取目标文件
|
|
77
73
|
|
|
78
|
-
const paths = await globby(glob, options);
|
|
74
|
+
const paths = await (0, _utils.globby)(glob, options);
|
|
79
75
|
|
|
80
76
|
if (!paths.length) {
|
|
81
77
|
return;
|
|
@@ -7,8 +7,6 @@ exports.readTsConfig = exports.existTsConfigFile = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
|
-
const json5 = _utils.Import.lazy('json5', require);
|
|
11
|
-
|
|
12
10
|
const readTsConfig = (tsconfigPath, noExistReturn = null) => {
|
|
13
11
|
// 如果不存在,则返回 noExistReturn
|
|
14
12
|
if (!_utils.fs.existsSync(tsconfigPath)) {
|
|
@@ -17,7 +15,7 @@ const readTsConfig = (tsconfigPath, noExistReturn = null) => {
|
|
|
17
15
|
|
|
18
16
|
const content = _utils.fs.readFileSync(tsconfigPath, 'utf-8');
|
|
19
17
|
|
|
20
|
-
return json5.parse(content);
|
|
18
|
+
return _utils.json5.parse(content);
|
|
21
19
|
};
|
|
22
20
|
|
|
23
21
|
exports.readTsConfig = readTsConfig;
|
|
@@ -97,7 +97,7 @@ const transformExport = option => nodePath => {
|
|
|
97
97
|
mapPathString(nodePath.get('source'), option);
|
|
98
98
|
};
|
|
99
99
|
|
|
100
|
-
const
|
|
100
|
+
const transformSingleFileAlias = ({
|
|
101
101
|
filename,
|
|
102
102
|
baseUrl,
|
|
103
103
|
paths
|
|
@@ -141,7 +141,7 @@ const transformDtsAlias = option => {
|
|
|
141
141
|
for (const filename of filenames) {
|
|
142
142
|
transformResult.push({
|
|
143
143
|
path: filename,
|
|
144
|
-
content:
|
|
144
|
+
content: transformSingleFileAlias({
|
|
145
145
|
filename,
|
|
146
146
|
baseUrl,
|
|
147
147
|
paths
|
|
@@ -3,7 +3,7 @@ export interface IDevConfig {
|
|
|
3
3
|
appDirectory: string;
|
|
4
4
|
isTsProject: boolean;
|
|
5
5
|
}
|
|
6
|
-
export declare type DevTaskType = 'storybook' | 'docsite' | '
|
|
6
|
+
export declare type DevTaskType = 'storybook' | 'docsite' | 'unknown';
|
|
7
7
|
export declare const showMenu: (api: PluginAPI, config: IDevConfig) => Promise<void>;
|
|
8
8
|
export declare const devStorybook: (api: PluginAPI, config: IDevConfig) => Promise<void>;
|
|
9
9
|
export declare const runSubCmd: (api: PluginAPI, subCmd: string, config: IDevConfig) => Promise<void>;
|
|
@@ -3,12 +3,12 @@ export interface TransformOption {
|
|
|
3
3
|
baseUrl: string;
|
|
4
4
|
paths: Record<string, string[] | string>;
|
|
5
5
|
}
|
|
6
|
-
interface
|
|
6
|
+
interface TransformDtsAliasOption {
|
|
7
7
|
filenames?: string[];
|
|
8
8
|
baseUrl: string;
|
|
9
9
|
paths: Record<string, string[] | string>;
|
|
10
10
|
}
|
|
11
|
-
export declare const transformDtsAlias: (option:
|
|
11
|
+
export declare const transformDtsAlias: (option: TransformDtsAliasOption) => {
|
|
12
12
|
path: string;
|
|
13
13
|
content: string;
|
|
14
14
|
}[];
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.5.1",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -54,24 +54,19 @@
|
|
|
54
54
|
"@babel/runtime": "^7",
|
|
55
55
|
"@babel/traverse": "^7.15.0",
|
|
56
56
|
"@babel/types": "^7.17.0",
|
|
57
|
-
"@modern-js/babel-compiler": "^1.2.
|
|
58
|
-
"@modern-js/babel-preset-module": "^1.3.
|
|
59
|
-
"@modern-js/core": "^1.
|
|
60
|
-
"@modern-js/css-config": "^1.2.
|
|
61
|
-
"@modern-js/i18n-cli-language-detector": "^1.2.
|
|
62
|
-
"@modern-js/new-action": "^1.3.
|
|
63
|
-
"@modern-js/plugin": "^1.3.
|
|
64
|
-
"@modern-js/plugin-analyze": "^1.
|
|
65
|
-
"@modern-js/plugin-changeset": "^1.2.
|
|
66
|
-
"@modern-js/plugin-fast-refresh": "^1.2.
|
|
67
|
-
"@modern-js/plugin-i18n": "^1.2.
|
|
68
|
-
"@modern-js/style-compiler": "^1.2.
|
|
69
|
-
"@modern-js/utils": "^1.
|
|
70
|
-
"dotenv": "^10.0.0",
|
|
71
|
-
"fast-glob": "^3.2.5",
|
|
72
|
-
"globby": "^11",
|
|
73
|
-
"inquirer": "^8.1.5",
|
|
74
|
-
"json5": "^2.2.0",
|
|
57
|
+
"@modern-js/babel-compiler": "^1.2.4",
|
|
58
|
+
"@modern-js/babel-preset-module": "^1.3.4",
|
|
59
|
+
"@modern-js/core": "^1.10.1",
|
|
60
|
+
"@modern-js/css-config": "^1.2.5",
|
|
61
|
+
"@modern-js/i18n-cli-language-detector": "^1.2.2",
|
|
62
|
+
"@modern-js/new-action": "^1.3.8",
|
|
63
|
+
"@modern-js/plugin": "^1.3.3",
|
|
64
|
+
"@modern-js/plugin-analyze": "^1.4.2",
|
|
65
|
+
"@modern-js/plugin-changeset": "^1.2.6",
|
|
66
|
+
"@modern-js/plugin-fast-refresh": "^1.2.5",
|
|
67
|
+
"@modern-js/plugin-i18n": "^1.2.5",
|
|
68
|
+
"@modern-js/style-compiler": "^1.2.5",
|
|
69
|
+
"@modern-js/utils": "^1.7.2",
|
|
75
70
|
"normalize-path": "^3.0.0",
|
|
76
71
|
"p-map": "^4",
|
|
77
72
|
"process.argv": "^0.6.0",
|
|
@@ -79,14 +74,13 @@
|
|
|
79
74
|
},
|
|
80
75
|
"devDependencies": {
|
|
81
76
|
"@babel/preset-typescript": "^7.15.0",
|
|
82
|
-
"@modern-js/babel-chain": "
|
|
77
|
+
"@modern-js/babel-chain": "1.2.2",
|
|
83
78
|
"@scripts/build": "0.0.0",
|
|
84
79
|
"@scripts/jest-config": "0.0.0",
|
|
85
80
|
"@types/babel__core": "^7.1.15",
|
|
86
81
|
"@types/babel__generator": "^7.6.3",
|
|
87
82
|
"@types/babel__traverse": "^7.14.2",
|
|
88
83
|
"@types/glob": "^7.1.4",
|
|
89
|
-
"@types/inquirer": "^8.1.1",
|
|
90
84
|
"@types/jest": "^26",
|
|
91
85
|
"@types/node": "^14",
|
|
92
86
|
"@types/normalize-path": "^3.0.0",
|
package/tests/dev-cli.test.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { manager } from '@modern-js/core';
|
|
2
|
-
import { program } from '@modern-js/utils';
|
|
3
|
-
import { devCli } from '../src/cli/dev';
|
|
4
|
-
|
|
5
|
-
const mockCommandDev = jest.fn();
|
|
6
|
-
|
|
7
|
-
describe('dev cli subCmd', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
jest.resetAllMocks();
|
|
10
|
-
jest.mock('../src/commands', () => ({
|
|
11
|
-
__esModule: true,
|
|
12
|
-
dev: mockCommandDev,
|
|
13
|
-
}));
|
|
14
|
-
});
|
|
15
|
-
it('should be storybook with "dev storybook"', async () => {
|
|
16
|
-
const mockAPI = {
|
|
17
|
-
useAppContext: jest.fn((): any => ({
|
|
18
|
-
existSrc: false,
|
|
19
|
-
distDirectory: '',
|
|
20
|
-
})),
|
|
21
|
-
useResolvedConfigContext: jest.fn(),
|
|
22
|
-
useHookRunners: (): any => ({}),
|
|
23
|
-
};
|
|
24
|
-
const cloned = manager.clone(mockAPI);
|
|
25
|
-
cloned.usePlugin({
|
|
26
|
-
setup(api) {
|
|
27
|
-
devCli(program, api);
|
|
28
|
-
program.parse(['', '', 'dev', 'storybook']);
|
|
29
|
-
expect(mockCommandDev.mock.calls[0][2]).toBe('storybook');
|
|
30
|
-
},
|
|
31
|
-
});
|
|
32
|
-
await cloned.init();
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('should be undefined with "dev"', async () => {
|
|
36
|
-
const mockBeforeBuild = jest.fn();
|
|
37
|
-
const mockAfterBuild = jest.fn();
|
|
38
|
-
const mockAPI = {
|
|
39
|
-
useAppContext: jest.fn((): any => ({
|
|
40
|
-
existSrc: false,
|
|
41
|
-
distDirectory: '',
|
|
42
|
-
})),
|
|
43
|
-
useResolvedConfigContext: jest.fn(),
|
|
44
|
-
useHookRunners: (): any => ({
|
|
45
|
-
afterBuild: mockAfterBuild,
|
|
46
|
-
beforeBuild: mockBeforeBuild,
|
|
47
|
-
}),
|
|
48
|
-
};
|
|
49
|
-
const cloned = manager.clone(mockAPI);
|
|
50
|
-
cloned.usePlugin({
|
|
51
|
-
setup(api) {
|
|
52
|
-
devCli(program, api);
|
|
53
|
-
program.parse(['', '', 'dev']);
|
|
54
|
-
expect(mockCommandDev.mock.calls[0][2]).toBe(undefined);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
await cloned.init();
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { manager } from '@modern-js/core';
|
|
2
|
-
import { dev } from '../src/commands/dev';
|
|
3
|
-
|
|
4
|
-
const mockRunSubCmd = jest.fn();
|
|
5
|
-
jest.mock('../src/features/dev', () => ({
|
|
6
|
-
__esModule: true,
|
|
7
|
-
runSubCmd: mockRunSubCmd,
|
|
8
|
-
devStorybook: jest.fn(),
|
|
9
|
-
}));
|
|
10
|
-
|
|
11
|
-
jest.mock('dotenv', () => ({
|
|
12
|
-
__esModule: true,
|
|
13
|
-
config: jest.fn(),
|
|
14
|
-
}));
|
|
15
|
-
|
|
16
|
-
jest.mock('../src/utils/valide', () => ({
|
|
17
|
-
__esModule: true,
|
|
18
|
-
valideBeforeTask: jest.fn(),
|
|
19
|
-
}));
|
|
20
|
-
|
|
21
|
-
jest.mock('../src/utils/tsconfig', () => ({
|
|
22
|
-
__esModule: true,
|
|
23
|
-
existTsConfigFile: jest.fn(),
|
|
24
|
-
}));
|
|
25
|
-
|
|
26
|
-
describe('dev command with subCmd', () => {
|
|
27
|
-
beforeEach(() => {
|
|
28
|
-
jest.clearAllMocks();
|
|
29
|
-
});
|
|
30
|
-
it('should call runSubCmd with storybook param', async () => {
|
|
31
|
-
const mockAPI = {
|
|
32
|
-
useAppContext: jest.fn((): any => ({
|
|
33
|
-
existSrc: false,
|
|
34
|
-
distDirectory: '',
|
|
35
|
-
appDirectory: '',
|
|
36
|
-
})),
|
|
37
|
-
useResolvedConfigContext: jest.fn(),
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const cloned = manager.clone(mockAPI);
|
|
41
|
-
cloned.usePlugin({
|
|
42
|
-
async setup(api) {
|
|
43
|
-
await dev(api, { tsconfig: 'tsconfig.json' }, 'storybook');
|
|
44
|
-
expect(mockRunSubCmd.mock.calls.length).toBe(1);
|
|
45
|
-
expect(mockRunSubCmd.mock.calls[0][1]).toBe('storybook');
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
await cloned.init();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should not call runSubCmd with nothing param', async () => {
|
|
52
|
-
const mockAPI = {
|
|
53
|
-
useAppContext: jest.fn((): any => ({
|
|
54
|
-
existSrc: false,
|
|
55
|
-
distDirectory: '',
|
|
56
|
-
appDirectory: '',
|
|
57
|
-
})),
|
|
58
|
-
useResolvedConfigContext: jest.fn(),
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
const cloned = manager.clone(mockAPI);
|
|
62
|
-
cloned.usePlugin({
|
|
63
|
-
async setup(api) {
|
|
64
|
-
await dev(api, { tsconfig: 'tsconfig.json' });
|
|
65
|
-
expect(mockRunSubCmd.mock.calls.length).toBe(0);
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
await cloned.init();
|
|
69
|
-
});
|
|
70
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { manager } from '@modern-js/core';
|
|
2
|
-
import { runSubCmd } from '../src/features/dev';
|
|
3
|
-
|
|
4
|
-
const mockModuleToolsMenu = jest.fn();
|
|
5
|
-
const mockDevMeta = jest.fn();
|
|
6
|
-
const exit = jest.spyOn(process, 'exit').mockImplementation();
|
|
7
|
-
const mockAPI = {
|
|
8
|
-
useAppContext: jest.fn((): any => ({})),
|
|
9
|
-
useResolvedConfigContext: jest.fn(),
|
|
10
|
-
useHookRunners: (): any => ({
|
|
11
|
-
moduleToolsMenu: mockModuleToolsMenu,
|
|
12
|
-
}),
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
describe('dev feature with subCmd', () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
jest.clearAllMocks();
|
|
18
|
-
});
|
|
19
|
-
it('should run task with "storybook" params when storybook plugin exist', async () => {
|
|
20
|
-
mockModuleToolsMenu.mockReturnValue([
|
|
21
|
-
{ value: 'storybook', runTask: mockDevMeta },
|
|
22
|
-
]);
|
|
23
|
-
const cloned = manager.clone(mockAPI);
|
|
24
|
-
cloned.usePlugin({
|
|
25
|
-
async setup(api) {
|
|
26
|
-
await runSubCmd(api, 'storybook', {
|
|
27
|
-
isTsProject: true,
|
|
28
|
-
appDirectory: '',
|
|
29
|
-
});
|
|
30
|
-
expect(mockDevMeta.mock.calls.length).toBe(1);
|
|
31
|
-
},
|
|
32
|
-
});
|
|
33
|
-
await cloned.init();
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should run task with "storybook" params when storybook plugin not exist', async () => {
|
|
37
|
-
mockModuleToolsMenu.mockReturnValue([]);
|
|
38
|
-
const cloned = manager.clone(mockAPI);
|
|
39
|
-
cloned.usePlugin({
|
|
40
|
-
async setup(api) {
|
|
41
|
-
await runSubCmd(api, 'storybook', {
|
|
42
|
-
isTsProject: true,
|
|
43
|
-
appDirectory: '',
|
|
44
|
-
});
|
|
45
|
-
expect(exit).toHaveBeenCalled();
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
await cloned.init();
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should run task with alias name "story" params when storybook plugin exist', async () => {
|
|
52
|
-
mockModuleToolsMenu.mockReturnValue([
|
|
53
|
-
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
54
|
-
]);
|
|
55
|
-
const cloned = manager.clone(mockAPI);
|
|
56
|
-
cloned.usePlugin({
|
|
57
|
-
async setup(api) {
|
|
58
|
-
await runSubCmd(api, 'story', { isTsProject: true, appDirectory: '' });
|
|
59
|
-
expect(mockDevMeta.mock.calls.length).toBe(1);
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
await cloned.init();
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('should run task with alias name "story1" params when storybook plugin exist', async () => {
|
|
66
|
-
mockModuleToolsMenu.mockReturnValue([
|
|
67
|
-
{ value: 'storybook', aliasValues: ['story'], runTask: mockDevMeta },
|
|
68
|
-
]);
|
|
69
|
-
const cloned = manager.clone(mockAPI);
|
|
70
|
-
cloned.usePlugin({
|
|
71
|
-
async setup(api) {
|
|
72
|
-
await runSubCmd(api, 'story1', { isTsProject: true, appDirectory: '' });
|
|
73
|
-
expect(mockDevMeta.mock.calls.length).toBe(0);
|
|
74
|
-
},
|
|
75
|
-
});
|
|
76
|
-
await cloned.init();
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import '@/b.ts';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const b = 10;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import * as path from 'path';
|
|
2
|
-
import { generatorTsConfig } from '../src/tasks/generator-dts/utils';
|
|
3
|
-
|
|
4
|
-
describe('test generator dts utils', () => {
|
|
5
|
-
it('test generatorTsConfig', () => {
|
|
6
|
-
const appDir = path.join(__dirname, './fixtures/tsconfig');
|
|
7
|
-
const ret = generatorTsConfig({}, { appDirectory: appDir, distDir: '' });
|
|
8
|
-
expect(ret).toContain('tsconfig.temp.json');
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
jest.mock('@modern-js/core', () => ({
|
|
2
|
-
manager: {
|
|
3
|
-
run: async (fn: any) => {
|
|
4
|
-
await fn();
|
|
5
|
-
},
|
|
6
|
-
},
|
|
7
|
-
cli: {
|
|
8
|
-
init: () => ({}),
|
|
9
|
-
},
|
|
10
|
-
}));
|
|
11
|
-
jest.mock('process.argv', () => () => (o: any) => ({ ...o, tsCheck: false }));
|
|
12
|
-
jest.mock('../src/tasks/generator-dts/utils');
|
|
13
|
-
jest.mock('@modern-js/utils', () => {
|
|
14
|
-
const originalModule = jest.requireActual('@modern-js/utils');
|
|
15
|
-
return {
|
|
16
|
-
__esModule: true, // Use it when dealing with esModules
|
|
17
|
-
...originalModule,
|
|
18
|
-
fs: {
|
|
19
|
-
...originalModule.fs,
|
|
20
|
-
removeSync: jest.fn(),
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
});
|
|
24
|
-
process.argv = [];
|
|
25
|
-
|
|
26
|
-
describe('generator dts test', () => {
|
|
27
|
-
it('test tsCheck is true', () => {
|
|
28
|
-
console.info = jest.fn(str => {
|
|
29
|
-
expect(str).toBe(
|
|
30
|
-
"There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'",
|
|
31
|
-
);
|
|
32
|
-
});
|
|
33
|
-
require('../src/tasks/generator-dts');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
export {};
|
package/tests/index.test.ts
DELETED
package/tests/tsconfig.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { transformDtsAlias } from '../src/utils/tspaths-transform';
|
|
3
|
-
|
|
4
|
-
describe('tspaths-transform', () => {
|
|
5
|
-
it('transformDtsAlias', () => {
|
|
6
|
-
const filepath = path.join(__dirname, 'fixtures/tspaths/a.ts');
|
|
7
|
-
const options = {
|
|
8
|
-
filenames: [filepath],
|
|
9
|
-
baseUrl: './',
|
|
10
|
-
paths: {
|
|
11
|
-
'@/*': ['./*'],
|
|
12
|
-
},
|
|
13
|
-
};
|
|
14
|
-
expect(transformDtsAlias(options)).toEqual([
|
|
15
|
-
{
|
|
16
|
-
path: filepath,
|
|
17
|
-
content: "import '@/b.ts';",
|
|
18
|
-
},
|
|
19
|
-
]);
|
|
20
|
-
});
|
|
21
|
-
});
|