@modern-js/module-tools 1.4.0 → 1.4.3
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 +63 -0
- package/dist/js/modern/cli/build.js +2 -2
- package/dist/js/modern/cli/dev.js +2 -2
- package/dist/js/modern/commands/build.js +5 -6
- package/dist/js/modern/commands/dev.js +6 -7
- package/dist/js/modern/features/build/build-platform.js +3 -3
- package/dist/js/modern/features/build/build-watch.js +5 -6
- package/dist/js/modern/features/build/build.js +5 -6
- package/dist/js/modern/features/build/index.js +5 -5
- package/dist/js/modern/features/build/utils.js +9 -10
- package/dist/js/modern/features/dev/index.js +9 -7
- package/dist/js/modern/index.js +37 -37
- package/dist/js/modern/schema/output.js +0 -5
- package/dist/js/modern/tasks/build-source-code.js +2 -1
- package/dist/js/modern/tasks/build-watch-source-code.js +2 -1
- package/dist/js/modern/tasks/generator-dts/index.js +144 -0
- package/dist/js/modern/tasks/generator-dts/utils.js +82 -0
- package/dist/js/modern/utils/babel.js +10 -3
- package/dist/js/node/cli/build.js +2 -2
- package/dist/js/node/cli/dev.js +2 -2
- package/dist/js/node/commands/build.js +5 -7
- package/dist/js/node/commands/dev.js +6 -8
- package/dist/js/node/features/build/build-platform.js +3 -4
- package/dist/js/node/features/build/build-watch.js +5 -7
- package/dist/js/node/features/build/build.js +5 -7
- package/dist/js/node/features/build/index.js +5 -5
- package/dist/js/node/features/build/utils.js +9 -11
- package/dist/js/node/features/dev/index.js +9 -8
- package/dist/js/node/index.js +50 -42
- package/dist/js/node/schema/output.js +0 -5
- package/dist/js/node/tasks/build-source-code.js +2 -1
- package/dist/js/node/tasks/build-watch-source-code.js +2 -1
- package/dist/js/node/tasks/generator-dts/index.js +158 -0
- package/dist/js/node/tasks/{generator-dts.js → generator-dts/utils.js} +11 -151
- package/dist/js/node/utils/babel.js +9 -2
- package/dist/types/cli/build.d.ts +2 -1
- package/dist/types/cli/dev.d.ts +2 -1
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/features/build/build-platform.d.ts +2 -1
- package/dist/types/features/build/build-watch.d.ts +2 -2
- package/dist/types/features/build/build.d.ts +2 -2
- package/dist/types/features/build/index.d.ts +2 -2
- package/dist/types/features/build/utils.d.ts +4 -3
- package/dist/types/features/dev/index.d.ts +4 -3
- package/dist/types/index.d.ts +3 -19
- package/dist/types/tasks/{generator-dts.d.ts → generator-dts/index.d.ts} +0 -0
- package/dist/types/tasks/generator-dts/utils.d.ts +23 -0
- package/jest.config.js +2 -0
- package/lib/types.d.ts +92 -0
- package/package.json +12 -13
- package/tests/dev-cli.test.ts +42 -8
- package/tests/dev-command.test.ts +36 -10
- package/tests/dev-feature.test.ts +45 -13
- package/tests/generator-dts-utils.test.ts +10 -0
- package/tests/generator-dts.test.ts +48 -0
- package/dist/js/modern/tasks/generator-dts.js +0 -226
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var path = _interopRequireWildcard(require("path"));
|
|
4
|
+
|
|
5
|
+
var _utils = require("@modern-js/utils");
|
|
6
|
+
|
|
7
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
+
|
|
9
|
+
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; }
|
|
10
|
+
|
|
11
|
+
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
12
|
+
|
|
13
|
+
const execa = _utils.Import.lazy('execa', require);
|
|
14
|
+
|
|
15
|
+
const JSON5 = _utils.Import.lazy('json5', require);
|
|
16
|
+
|
|
17
|
+
const argv = _utils.Import.lazy('process.argv', require);
|
|
18
|
+
|
|
19
|
+
const utils = _utils.Import.lazy('./utils', require);
|
|
20
|
+
|
|
21
|
+
let removeTsconfigPath = '';
|
|
22
|
+
|
|
23
|
+
const getProjectTsconfig = tsconfigPath => {
|
|
24
|
+
if (!tsconfigPath || !_utils.fs.existsSync(tsconfigPath)) {
|
|
25
|
+
return {};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return JSON5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const resolveLog = (childProgress, {
|
|
32
|
+
tsCheck: _tsCheck = false,
|
|
33
|
+
watch: _watch = false
|
|
34
|
+
} = {}) => {
|
|
35
|
+
var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* tsc 所有的log信息都是从stdout data 事件中获取
|
|
39
|
+
* 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
|
|
40
|
+
* watch 模式下,则使用这里的信息
|
|
41
|
+
*/
|
|
42
|
+
(_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
|
|
43
|
+
if (!_tsCheck) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (_watch) {
|
|
48
|
+
console.info(data.toString());
|
|
49
|
+
}
|
|
50
|
+
}); // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
|
|
51
|
+
|
|
52
|
+
(_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
|
|
53
|
+
console.error(error.message);
|
|
54
|
+
});
|
|
55
|
+
(_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
|
|
56
|
+
console.error(chunk.toString());
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const generatorDts = async (_, config) => {
|
|
61
|
+
const {
|
|
62
|
+
tsconfigPath,
|
|
63
|
+
distDir,
|
|
64
|
+
sourceDirName = 'src',
|
|
65
|
+
projectData: {
|
|
66
|
+
appDirectory
|
|
67
|
+
},
|
|
68
|
+
tsCheck = false,
|
|
69
|
+
watch = false
|
|
70
|
+
} = config;
|
|
71
|
+
const userTsconfig = getProjectTsconfig(tsconfigPath);
|
|
72
|
+
const willDeleteTsconfigPath = utils.generatorTsConfig(userTsconfig, {
|
|
73
|
+
appDirectory,
|
|
74
|
+
distDir,
|
|
75
|
+
sourceDir: sourceDirName
|
|
76
|
+
});
|
|
77
|
+
removeTsconfigPath = willDeleteTsconfigPath;
|
|
78
|
+
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
79
|
+
const watchParams = watch ? ['-w'] : [];
|
|
80
|
+
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
81
|
+
stdio: 'pipe',
|
|
82
|
+
cwd: appDirectory
|
|
83
|
+
});
|
|
84
|
+
resolveLog(childProgress, {
|
|
85
|
+
tsCheck,
|
|
86
|
+
watch
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
await childProgress;
|
|
91
|
+
console.info('[Tsc Compiler]: Successfully');
|
|
92
|
+
} catch (e) {
|
|
93
|
+
if (!tsCheck) {
|
|
94
|
+
console.info(`There are some type warnings, which can be checked by configuring 'output.disableTsChecker = false'`);
|
|
95
|
+
} else {
|
|
96
|
+
const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
if (isRecord(e)) {
|
|
100
|
+
console.error(e.stdout);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
_utils.fs.removeSync(willDeleteTsconfigPath);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const taskMain = async ({
|
|
109
|
+
modernConfig
|
|
110
|
+
}) => {
|
|
111
|
+
const processArgv = argv(process.argv.slice(2));
|
|
112
|
+
const config = processArgv({
|
|
113
|
+
appDirectory: process.cwd(),
|
|
114
|
+
srcDir: 'src',
|
|
115
|
+
distDir: 'dist/types',
|
|
116
|
+
tsconfigPath: './tsconfig.json',
|
|
117
|
+
sourceDirName: 'src'
|
|
118
|
+
});
|
|
119
|
+
const option = {
|
|
120
|
+
srcDir: config.srcDir,
|
|
121
|
+
distDir: config.distDir,
|
|
122
|
+
projectData: {
|
|
123
|
+
appDirectory: config.appDirectory
|
|
124
|
+
},
|
|
125
|
+
tsconfigPath: config.tsconfigPath,
|
|
126
|
+
watch: config.watch,
|
|
127
|
+
tsCheck: config.tsCheck,
|
|
128
|
+
sourceDirName: config.sourceDirName
|
|
129
|
+
};
|
|
130
|
+
await generatorDts(modernConfig, option); // // TODO: watch 模式下无法转换
|
|
131
|
+
|
|
132
|
+
utils.resolveAlias(modernConfig, option);
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
(async () => {
|
|
136
|
+
let options;
|
|
137
|
+
|
|
138
|
+
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
139
|
+
({
|
|
140
|
+
options
|
|
141
|
+
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const {
|
|
145
|
+
resolved
|
|
146
|
+
} = await core.cli.init([], options);
|
|
147
|
+
await core.manager.run(async () => {
|
|
148
|
+
try {
|
|
149
|
+
await taskMain({
|
|
150
|
+
modernConfig: resolved
|
|
151
|
+
});
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.error(e.message);
|
|
154
|
+
|
|
155
|
+
_utils.fs.removeSync(removeTsconfigPath);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
})();
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.resolveAlias = exports.generatorTsConfig = void 0;
|
|
4
7
|
|
|
5
|
-
var
|
|
8
|
+
var path = _interopRequireWildcard(require("path"));
|
|
6
9
|
|
|
7
10
|
var _utils = require("@modern-js/utils");
|
|
8
11
|
|
|
@@ -16,26 +19,16 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
16
19
|
|
|
17
20
|
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
21
|
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
const babel = _utils.Import.lazy('../utils/babel', require);
|
|
22
|
-
|
|
23
|
-
const constants = _utils.Import.lazy('./constants', require);
|
|
24
|
-
|
|
25
|
-
const core = _utils.Import.lazy('@modern-js/core', require);
|
|
22
|
+
const glob = _utils.Import.lazy('glob', require);
|
|
26
23
|
|
|
27
|
-
const
|
|
24
|
+
const babel = _utils.Import.lazy('../../utils/babel', require);
|
|
28
25
|
|
|
29
|
-
const
|
|
26
|
+
const tsPathsTransform = _utils.Import.lazy('../../utils/tspaths-transform', require);
|
|
30
27
|
|
|
31
|
-
const
|
|
28
|
+
const constants = _utils.Import.lazy('../constants', require);
|
|
32
29
|
|
|
33
30
|
const deepMerge = _utils.Import.lazy('lodash.merge', require);
|
|
34
31
|
|
|
35
|
-
const glob = _utils.Import.lazy('glob', require);
|
|
36
|
-
|
|
37
|
-
let removeTsconfigPath = '';
|
|
38
|
-
|
|
39
32
|
const generatorTsConfig = (projectTsconfig, {
|
|
40
33
|
appDirectory,
|
|
41
34
|
distDir,
|
|
@@ -82,90 +75,7 @@ const generatorTsConfig = (projectTsconfig, {
|
|
|
82
75
|
return tempTsconfigPath;
|
|
83
76
|
};
|
|
84
77
|
|
|
85
|
-
|
|
86
|
-
if (!tsconfigPath || !_utils.fs.existsSync(tsconfigPath)) {
|
|
87
|
-
return {};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return JSON5.parse(_utils.fs.readFileSync(tsconfigPath, 'utf-8'));
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const resolveLog = (childProgress, {
|
|
94
|
-
tsCheck: _tsCheck = false,
|
|
95
|
-
watch: _watch = false
|
|
96
|
-
} = {}) => {
|
|
97
|
-
var _childProgress$stdout, _childProgress$stdout2, _childProgress$stderr;
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* tsc 所有的log信息都是从stdout data 事件中获取
|
|
101
|
-
* 正常模式下,如果有报错信息,交给 resolveLog 后面的逻辑来处理
|
|
102
|
-
* watch 模式下,则使用这里的信息
|
|
103
|
-
*/
|
|
104
|
-
(_childProgress$stdout = childProgress.stdout) === null || _childProgress$stdout === void 0 ? void 0 : _childProgress$stdout.on('data', data => {
|
|
105
|
-
if (!_tsCheck) {
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
if (_watch) {
|
|
110
|
-
console.info(data.toString());
|
|
111
|
-
}
|
|
112
|
-
}); // 正常以下内容都不会触发,因为tsc 不会产生以下类型的log信息,不过防止意外情况
|
|
113
|
-
|
|
114
|
-
(_childProgress$stdout2 = childProgress.stdout) === null || _childProgress$stdout2 === void 0 ? void 0 : _childProgress$stdout2.on('error', error => {
|
|
115
|
-
console.error(error.message);
|
|
116
|
-
});
|
|
117
|
-
(_childProgress$stderr = childProgress.stderr) === null || _childProgress$stderr === void 0 ? void 0 : _childProgress$stderr.on('data', chunk => {
|
|
118
|
-
console.error(chunk.toString());
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const generatorDts = async (_, config) => {
|
|
123
|
-
const {
|
|
124
|
-
tsconfigPath,
|
|
125
|
-
distDir,
|
|
126
|
-
sourceDirName = 'src',
|
|
127
|
-
projectData: {
|
|
128
|
-
appDirectory
|
|
129
|
-
},
|
|
130
|
-
tsCheck = false,
|
|
131
|
-
watch = false
|
|
132
|
-
} = config;
|
|
133
|
-
const userTsconfig = getProjectTsconfig(tsconfigPath);
|
|
134
|
-
const willDeleteTsconfigPath = generatorTsConfig(userTsconfig, {
|
|
135
|
-
appDirectory,
|
|
136
|
-
distDir,
|
|
137
|
-
sourceDir: sourceDirName
|
|
138
|
-
});
|
|
139
|
-
removeTsconfigPath = willDeleteTsconfigPath;
|
|
140
|
-
const tscBinFile = path.join(appDirectory, './node_modules/.bin/tsc');
|
|
141
|
-
const watchParams = watch ? ['-w'] : [];
|
|
142
|
-
const childProgress = execa(tscBinFile, ['-p', willDeleteTsconfigPath, ...watchParams], {
|
|
143
|
-
stdio: 'pipe',
|
|
144
|
-
cwd: appDirectory
|
|
145
|
-
});
|
|
146
|
-
resolveLog(childProgress, {
|
|
147
|
-
tsCheck,
|
|
148
|
-
watch
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
await childProgress;
|
|
153
|
-
console.info('[Tsc Compiler]: Successfully');
|
|
154
|
-
} catch (e) {
|
|
155
|
-
if (!tsCheck) {
|
|
156
|
-
console.warn(`There are some type issues, which can be checked by configuring 'source.enableTsChecker = true' ${os.EOL} in modern.config.js`);
|
|
157
|
-
} else {
|
|
158
|
-
const isRecord = input => typeof input === 'object'; // 通过使用 execa,可以将tsc 的 data 类型的报错信息变为异常错误信息
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (isRecord(e)) {
|
|
162
|
-
console.error(e.stdout);
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
_utils.fs.removeSync(willDeleteTsconfigPath);
|
|
168
|
-
};
|
|
78
|
+
exports.generatorTsConfig = generatorTsConfig;
|
|
169
79
|
|
|
170
80
|
const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
171
81
|
const {
|
|
@@ -195,54 +105,4 @@ const resolveAlias = (modernConfig, config, watchFilenames = []) => {
|
|
|
195
105
|
}
|
|
196
106
|
};
|
|
197
107
|
|
|
198
|
-
|
|
199
|
-
modernConfig
|
|
200
|
-
}) => {
|
|
201
|
-
const processArgv = argv(process.argv.slice(2));
|
|
202
|
-
const config = processArgv({
|
|
203
|
-
appDirectory: process.cwd(),
|
|
204
|
-
srcDir: 'src',
|
|
205
|
-
distDir: 'dist/types',
|
|
206
|
-
tsconfigPath: './tsconfig.json',
|
|
207
|
-
sourceDirName: 'src'
|
|
208
|
-
});
|
|
209
|
-
const option = {
|
|
210
|
-
srcDir: config.srcDir,
|
|
211
|
-
distDir: config.distDir,
|
|
212
|
-
projectData: {
|
|
213
|
-
appDirectory: config.appDirectory
|
|
214
|
-
},
|
|
215
|
-
tsconfigPath: config.tsconfigPath,
|
|
216
|
-
watch: config.watch,
|
|
217
|
-
tsCheck: config.tsCheck,
|
|
218
|
-
sourceDirName: config.sourceDirName
|
|
219
|
-
};
|
|
220
|
-
await generatorDts(modernConfig, option); // TODO: watch 模式下无法转换
|
|
221
|
-
|
|
222
|
-
resolveAlias(modernConfig, option);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
(async () => {
|
|
226
|
-
let options;
|
|
227
|
-
|
|
228
|
-
if (process.env.CORE_INIT_OPTION_FILE) {
|
|
229
|
-
({
|
|
230
|
-
options
|
|
231
|
-
} = require(process.env.CORE_INIT_OPTION_FILE));
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
const {
|
|
235
|
-
resolved
|
|
236
|
-
} = await core.cli.init([], options);
|
|
237
|
-
await core.manager.run(async () => {
|
|
238
|
-
try {
|
|
239
|
-
await taskMain({
|
|
240
|
-
modernConfig: resolved
|
|
241
|
-
});
|
|
242
|
-
} catch (e) {
|
|
243
|
-
console.error(e.message);
|
|
244
|
-
|
|
245
|
-
_utils.fs.removeSync(removeTsconfigPath);
|
|
246
|
-
}
|
|
247
|
-
});
|
|
248
|
-
})();
|
|
108
|
+
exports.resolveAlias = resolveAlias;
|
|
@@ -48,7 +48,8 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
48
48
|
importStyle
|
|
49
49
|
},
|
|
50
50
|
tools: {
|
|
51
|
-
lodash: userLodashOption
|
|
51
|
+
lodash: userLodashOption,
|
|
52
|
+
styledComponents
|
|
52
53
|
}
|
|
53
54
|
} = modernConfig; // alias config
|
|
54
55
|
|
|
@@ -70,7 +71,13 @@ const resolveBabelConfig = (appDirectory, modernConfig, option) => {
|
|
|
70
71
|
globalVars,
|
|
71
72
|
lodashOptions,
|
|
72
73
|
jsxTransformRuntime,
|
|
73
|
-
importStyle
|
|
74
|
+
importStyle,
|
|
75
|
+
styledComponentsOptions: (0, _utils.applyOptionsChain)({
|
|
76
|
+
pure: true,
|
|
77
|
+
displayName: true,
|
|
78
|
+
ssr: (0, _utils.isUseSSRBundle)(modernConfig),
|
|
79
|
+
transpileTemplateLiterals: true
|
|
80
|
+
}, styledComponents)
|
|
74
81
|
}, {
|
|
75
82
|
type: option.type,
|
|
76
83
|
syntax: option.syntax
|
package/dist/types/cli/dev.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
import type { Platform } from '../types';
|
|
2
3
|
export interface IBuildOption {
|
|
3
4
|
watch: boolean;
|
|
@@ -7,7 +8,7 @@ export interface IBuildOption {
|
|
|
7
8
|
tsc: boolean;
|
|
8
9
|
clear: boolean;
|
|
9
10
|
}
|
|
10
|
-
export declare const build: ({
|
|
11
|
+
export declare const build: (api: PluginAPI, {
|
|
11
12
|
watch,
|
|
12
13
|
tsconfig: tsconfigName,
|
|
13
14
|
tsc,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IDevOption {
|
|
2
3
|
tsconfig: string;
|
|
3
4
|
}
|
|
4
|
-
export declare const dev: (option: IDevOption, subCmd?: string) => Promise<void>;
|
|
5
|
+
export declare const dev: (api: PluginAPI, option: IDevOption, subCmd?: string) => Promise<void>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export declare type Platform = 'all' | 'docs' | 'storybook';
|
|
2
3
|
export interface IBuildPlatformOption {
|
|
3
4
|
platform: Platform;
|
|
4
5
|
isTsProject?: boolean;
|
|
5
6
|
}
|
|
6
|
-
export declare const buildPlatform: (option: IBuildPlatformOption) => Promise<void>;
|
|
7
|
+
export declare const buildPlatform: (api: PluginAPI, option: IBuildPlatformOption) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
|
1
|
+
import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { IBuildConfig } from '../../types';
|
|
3
|
-
export declare const buildInWatchMode: (config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
|
|
3
|
+
export declare const buildInWatchMode: (api: PluginAPI, config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
|
1
|
+
import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { IBuildConfig } from '../../types';
|
|
3
|
-
export declare const buildSourceCode: (config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
|
|
3
|
+
export declare const buildSourceCode: (api: PluginAPI, config: IBuildConfig, _: NormalizedConfig) => Promise<void>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
|
1
|
+
import type { NormalizedConfig, PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { IBuildConfig } from '../../types';
|
|
3
|
-
export declare const build: (config: IBuildConfig, modernConfig: NormalizedConfig) => Promise<void>;
|
|
3
|
+
export declare const build: (api: PluginAPI, config: IBuildConfig, modernConfig: NormalizedConfig) => Promise<void>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
import type { IBuildConfig, IPackageModeValue, ITaskMapper } from '../../types';
|
|
2
3
|
import type { LoggerText } from './logger';
|
|
3
|
-
export declare const getCodeInitMapper: (_: IBuildConfig) => IPackageModeValue[];
|
|
4
|
-
export declare const getCodeMapper: ({
|
|
4
|
+
export declare const getCodeInitMapper: (api: PluginAPI, _: IBuildConfig) => IPackageModeValue[];
|
|
5
|
+
export declare const getCodeMapper: (api: PluginAPI, {
|
|
5
6
|
logger,
|
|
6
7
|
taskPath,
|
|
7
8
|
config,
|
|
@@ -18,7 +19,7 @@ export declare const getCodeMapper: ({
|
|
|
18
19
|
taskPath: string;
|
|
19
20
|
params: string[];
|
|
20
21
|
}[];
|
|
21
|
-
export declare const getDtsMapper: (config: IBuildConfig, logger: LoggerText) => {
|
|
22
|
+
export declare const getDtsMapper: (api: PluginAPI, config: IBuildConfig, logger: LoggerText) => {
|
|
22
23
|
logger: LoggerText;
|
|
23
24
|
taskPath: string;
|
|
24
25
|
params: string[];
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IDevConfig {
|
|
2
3
|
appDirectory: string;
|
|
3
4
|
isTsProject: boolean;
|
|
4
5
|
}
|
|
5
6
|
export declare type DevTaskType = 'storybook' | 'docsite' | 'unknow';
|
|
6
|
-
export declare const showMenu: (config: IDevConfig) => Promise<void>;
|
|
7
|
-
export declare const devStorybook: (config: IDevConfig) => Promise<void>;
|
|
8
|
-
export declare const runSubCmd: (subCmd: string, config: IDevConfig) => Promise<void>;
|
|
7
|
+
export declare const showMenu: (api: PluginAPI, config: IDevConfig) => Promise<void>;
|
|
8
|
+
export declare const devStorybook: (api: PluginAPI, config: IDevConfig) => Promise<void>;
|
|
9
|
+
export declare const runSubCmd: (api: PluginAPI, subCmd: string, config: IDevConfig) => Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { CliPlugin } from '@modern-js/core';
|
|
2
|
+
export { defineConfig } from '@modern-js/core';
|
|
2
3
|
|
|
3
|
-
declare const _default:
|
|
4
|
-
config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
5
|
-
resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
|
|
6
|
-
resolved: import("@modern-js/core").NormalizedConfig;
|
|
7
|
-
}>;
|
|
8
|
-
validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
9
|
-
prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
10
|
-
commands: import("@modern-js/core").AsyncWorkflow<{
|
|
11
|
-
program: import("commander").Command;
|
|
12
|
-
}, void>;
|
|
13
|
-
watchFiles: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
14
|
-
fileChange: import("@modern-js/core").AsyncWorkflow<{
|
|
15
|
-
filename: string;
|
|
16
|
-
eventType: "add" | "unlink" | "change";
|
|
17
|
-
}, void>;
|
|
18
|
-
beforeExit: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
19
|
-
beforeRestart: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
20
|
-
} & import("@modern-js/core").ClearDraftProgress<import("@modern-js/core").Hooks>>>>;
|
|
4
|
+
declare const _default: () => CliPlugin;
|
|
21
5
|
|
|
22
6
|
export default _default;
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NormalizedConfig } from '@modern-js/core';
|
|
2
|
+
import type { ITsconfig } from '../../types';
|
|
3
|
+
export interface IGeneratorConfig {
|
|
4
|
+
sourceDirName?: string;
|
|
5
|
+
srcDir: string;
|
|
6
|
+
distDir: string;
|
|
7
|
+
projectData: {
|
|
8
|
+
appDirectory: string;
|
|
9
|
+
};
|
|
10
|
+
tsconfigPath?: string;
|
|
11
|
+
tsCheck?: boolean;
|
|
12
|
+
watch?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare const generatorTsConfig: (projectTsconfig: ITsconfig, {
|
|
15
|
+
appDirectory,
|
|
16
|
+
distDir,
|
|
17
|
+
sourceDir
|
|
18
|
+
}: {
|
|
19
|
+
appDirectory: string;
|
|
20
|
+
distDir: string;
|
|
21
|
+
sourceDir?: string | undefined;
|
|
22
|
+
}) => string;
|
|
23
|
+
export declare const resolveAlias: (modernConfig: NormalizedConfig, config: IGeneratorConfig, watchFilenames?: string[]) => void;
|
package/jest.config.js
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -55,6 +55,98 @@ declare module '*.svg' {
|
|
|
55
55
|
export default src;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
declare module '*.bmp?inline' {
|
|
59
|
+
const src: string;
|
|
60
|
+
export default src;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
declare module '*.gif?inline' {
|
|
64
|
+
const src: string;
|
|
65
|
+
export default src;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
declare module '*.jpg?inline' {
|
|
69
|
+
const src: string;
|
|
70
|
+
export default src;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
declare module '*.jpeg?inline' {
|
|
74
|
+
const src: string;
|
|
75
|
+
export default src;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
declare module '*.png?inline' {
|
|
79
|
+
const src: string;
|
|
80
|
+
export default src;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare module '*.ico?inline' {
|
|
84
|
+
const src: string;
|
|
85
|
+
export default src;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
declare module '*.webp?inline' {
|
|
89
|
+
const src: string;
|
|
90
|
+
export default src;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
declare module '*.svg?inline' {
|
|
94
|
+
import * as React from 'react';
|
|
95
|
+
|
|
96
|
+
export const ReactComponent: React.FunctionComponent<
|
|
97
|
+
React.SVGProps<SVGSVGElement>
|
|
98
|
+
>;
|
|
99
|
+
|
|
100
|
+
const src: string;
|
|
101
|
+
export default src;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare module '*.bmp?url' {
|
|
105
|
+
const src: string;
|
|
106
|
+
export default src;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
declare module '*.gif?url' {
|
|
110
|
+
const src: string;
|
|
111
|
+
export default src;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
declare module '*.jpg?url' {
|
|
115
|
+
const src: string;
|
|
116
|
+
export default src;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
declare module '*.jpeg?url' {
|
|
120
|
+
const src: string;
|
|
121
|
+
export default src;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
declare module '*.png?url' {
|
|
125
|
+
const src: string;
|
|
126
|
+
export default src;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare module '*.ico?url' {
|
|
130
|
+
const src: string;
|
|
131
|
+
export default src;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
declare module '*.webp?url' {
|
|
135
|
+
const src: string;
|
|
136
|
+
export default src;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
declare module '*.svg?url' {
|
|
140
|
+
import * as React from 'react';
|
|
141
|
+
|
|
142
|
+
export const ReactComponent: React.FunctionComponent<
|
|
143
|
+
React.SVGProps<SVGSVGElement>
|
|
144
|
+
>;
|
|
145
|
+
|
|
146
|
+
const src: string;
|
|
147
|
+
export default src;
|
|
148
|
+
}
|
|
149
|
+
|
|
58
150
|
declare module '*.css' {
|
|
59
151
|
const classes: { readonly [key: string]: string };
|
|
60
152
|
export default classes;
|