@rife/cli 0.0.6-beta.13 → 0.0.6-beta.15
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/dist/cjs/logger.cjs +2 -0
- package/dist/cjs/plugin/index.cjs +3 -12
- package/dist/cjs/runner.cjs +4 -1
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/logger.mjs +3 -1
- package/dist/esm/plugin/commander.mjs +1 -1
- package/dist/esm/plugin/config.mjs +2 -2
- package/dist/esm/plugin/index.mjs +1 -2
- package/dist/esm/plugin/package.mjs +2 -2
- package/dist/esm/plugin/release.mjs +1 -1
- package/dist/esm/runner.mjs +9 -6
- package/dist/esm/sync.mjs +1 -1
- package/dist/esm/util.mjs +3 -3
- package/package.json +7 -17
- package/src/index.ts +0 -6
- package/src/logger.ts +2 -1
- package/src/plugin/index.ts +0 -1
- package/src/runner.ts +5 -1
- package/dist/cjs/plugin/compiler/compiler.cjs +0 -207
- package/dist/cjs/plugin/compiler/index.cjs +0 -126
- package/dist/cjs/plugin/compiler/swc.cjs +0 -107
- package/dist/cjs/plugin/compiler/tsc.cjs +0 -115
- package/dist/esm/plugin/compiler/compiler.mjs +0 -160
- package/dist/esm/plugin/compiler/index.mjs +0 -94
- package/dist/esm/plugin/compiler/swc.mjs +0 -75
- package/dist/esm/plugin/compiler/tsc.mjs +0 -73
- package/src/plugin/compiler/compiler.ts +0 -198
- package/src/plugin/compiler/index.ts +0 -115
- package/src/plugin/compiler/swc.ts +0 -56
- package/src/plugin/compiler/tsc.ts +0 -101
package/dist/cjs/logger.cjs
CHANGED
|
@@ -30,6 +30,8 @@ const external_consola_namespaceObject = require("consola");
|
|
|
30
30
|
function createLogger(options) {
|
|
31
31
|
const instance = (0, external_consola_namespaceObject.createConsola)({
|
|
32
32
|
level: options?.debug ? 4 : 3,
|
|
33
|
+
throttle: 10,
|
|
34
|
+
throttleMin: 500,
|
|
33
35
|
formatOptions: {
|
|
34
36
|
compact: false,
|
|
35
37
|
date: false
|
|
@@ -3,9 +3,6 @@ var __webpack_modules__ = {
|
|
|
3
3
|
"./commander": function(module) {
|
|
4
4
|
module.exports = require("./commander.cjs");
|
|
5
5
|
},
|
|
6
|
-
"./compiler": function(module) {
|
|
7
|
-
module.exports = require("./compiler/index.cjs");
|
|
8
|
-
},
|
|
9
6
|
"./config": function(module) {
|
|
10
7
|
module.exports = require("./config.cjs");
|
|
11
8
|
},
|
|
@@ -77,16 +74,10 @@ var __webpack_exports__ = {};
|
|
|
77
74
|
return _commander__WEBPACK_IMPORTED_MODULE_2__[key];
|
|
78
75
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
79
76
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
80
|
-
var
|
|
81
|
-
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
82
|
-
for(var __WEBPACK_IMPORT_KEY__ in _compiler__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
83
|
-
return _compiler__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
84
|
-
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
85
|
-
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
86
|
-
var _release__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("./release");
|
|
77
|
+
var _release__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("./release");
|
|
87
78
|
var __WEBPACK_REEXPORT_OBJECT__ = {};
|
|
88
|
-
for(var __WEBPACK_IMPORT_KEY__ in
|
|
89
|
-
return
|
|
79
|
+
for(var __WEBPACK_IMPORT_KEY__ in _release__WEBPACK_IMPORTED_MODULE_3__)if ("default" !== __WEBPACK_IMPORT_KEY__) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
|
|
80
|
+
return _release__WEBPACK_IMPORTED_MODULE_3__[key];
|
|
90
81
|
}).bind(0, __WEBPACK_IMPORT_KEY__);
|
|
91
82
|
__webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
|
|
92
83
|
})();
|
package/dist/cjs/runner.cjs
CHANGED
|
@@ -113,11 +113,14 @@ var __webpack_exports__ = {};
|
|
|
113
113
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
114
114
|
return `\u{8017}\u{65F6} ${duration} s`;
|
|
115
115
|
},
|
|
116
|
-
tempDir: './node_modules/.
|
|
116
|
+
tempDir: './node_modules/.rife/',
|
|
117
117
|
clear: ()=>{
|
|
118
118
|
console.clear();
|
|
119
119
|
process.stdout.write('\x1b[3J');
|
|
120
120
|
console.log(`${utils_namespaceObject.colors.bgBlue(" \u9879\u76EE\u540D\u79F0 ")} ${runner.package.name} \n`);
|
|
121
|
+
},
|
|
122
|
+
throwError: (message, options)=>{
|
|
123
|
+
throw new Error(message, options);
|
|
121
124
|
}
|
|
122
125
|
};
|
|
123
126
|
return runner;
|
package/dist/esm/cli.mjs
CHANGED
package/dist/esm/index.mjs
CHANGED
package/dist/esm/logger.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { createConsola } from "consola";
|
|
4
4
|
function createLogger(options) {
|
|
5
5
|
const instance = createConsola({
|
|
6
6
|
level: options?.debug ? 4 : 3,
|
|
7
|
+
throttle: 10,
|
|
8
|
+
throttleMin: 500,
|
|
7
9
|
formatOptions: {
|
|
8
10
|
compact: false,
|
|
9
11
|
date: false
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import __rslib_shim_module__ from 'module';
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
3
|
-
import
|
|
3
|
+
import path from "path";
|
|
4
4
|
function pluginConfig() {
|
|
5
5
|
const plugin = {
|
|
6
6
|
name: pluginConfig.name,
|
|
@@ -17,7 +17,7 @@ function pluginConfig() {
|
|
|
17
17
|
];
|
|
18
18
|
let isEsm = false;
|
|
19
19
|
for (const fileName of fileNames)if (await fs.exists(fileName)) {
|
|
20
|
-
filePath =
|
|
20
|
+
filePath = path.posix.resolve(fileName);
|
|
21
21
|
isEsm = fileName === mjs;
|
|
22
22
|
break;
|
|
23
23
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
export * from "./config.mjs";
|
|
4
4
|
export * from "./package.mjs";
|
|
5
5
|
export * from "./commander.mjs";
|
|
6
|
-
export * from "./compiler/index.mjs";
|
|
7
6
|
export * from "./release.mjs";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import __rslib_shim_module__ from 'module';
|
|
2
2
|
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
3
|
-
import
|
|
3
|
+
import path from "path";
|
|
4
4
|
function pluginPackage() {
|
|
5
5
|
const plugin = {
|
|
6
6
|
name: pluginPackage.name,
|
|
@@ -9,7 +9,7 @@ function pluginPackage() {
|
|
|
9
9
|
const log = logger.withTag(pluginPackage.name);
|
|
10
10
|
hook.loadPackage.tapPromise(pluginPackage.name, async ()=>{
|
|
11
11
|
const fileName = 'package.json';
|
|
12
|
-
const filePath =
|
|
12
|
+
const filePath = path.resolve(fileName);
|
|
13
13
|
if (!fs.existsSync(filePath)) {
|
|
14
14
|
log.error(`\u{627E}\u{4E0D}\u{5230}\u{6587}\u{4EF6} ${fileName}`);
|
|
15
15
|
process.exit(1);
|
package/dist/esm/runner.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import * as __WEBPACK_EXTERNAL_MODULE_commander__ from "commander";
|
|
4
4
|
import { colors } from "consola/utils";
|
|
5
5
|
import { AsyncSeriesHook } from "tapable";
|
|
6
|
-
import
|
|
6
|
+
import zod from "zod";
|
|
7
7
|
import { createLogger } from "./logger.mjs";
|
|
8
8
|
import { fs, glob } from "./util.mjs";
|
|
9
9
|
var __webpack_modules__ = {
|
|
@@ -42,8 +42,8 @@ function createRunner() {
|
|
|
42
42
|
command.option('-n, --name <string>', "\u6267\u884C\u6307\u5B9A\u914D\u7F6E");
|
|
43
43
|
command.option('-h, --help', "\u5E2E\u52A9");
|
|
44
44
|
command.parse();
|
|
45
|
-
const args =
|
|
46
|
-
debug:
|
|
45
|
+
const args = zod.object({
|
|
46
|
+
debug: zod.boolean().default(false)
|
|
47
47
|
}).default({}).safeParse(command.opts());
|
|
48
48
|
const runner = {
|
|
49
49
|
env: 'prod',
|
|
@@ -70,18 +70,21 @@ function createRunner() {
|
|
|
70
70
|
current: void 0
|
|
71
71
|
},
|
|
72
72
|
package: {},
|
|
73
|
-
z:
|
|
73
|
+
z: zod,
|
|
74
74
|
fs: fs,
|
|
75
75
|
glob: glob.glob,
|
|
76
76
|
get duration () {
|
|
77
77
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
78
78
|
return `\u{8017}\u{65F6} ${duration} s`;
|
|
79
79
|
},
|
|
80
|
-
tempDir: './node_modules/.
|
|
80
|
+
tempDir: './node_modules/.rife/',
|
|
81
81
|
clear: ()=>{
|
|
82
82
|
console.clear();
|
|
83
83
|
process.stdout.write('\x1b[3J');
|
|
84
84
|
console.log(`${colors.bgBlue(" \u9879\u76EE\u540D\u79F0 ")} ${runner.package.name} \n`);
|
|
85
|
+
},
|
|
86
|
+
throwError: (message, options)=>{
|
|
87
|
+
throw new Error(message, options);
|
|
85
88
|
}
|
|
86
89
|
};
|
|
87
90
|
return runner;
|
package/dist/esm/sync.mjs
CHANGED
package/dist/esm/util.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
|
-
import
|
|
3
|
+
import fs_extra from "fs-extra";
|
|
4
4
|
import * as __WEBPACK_EXTERNAL_MODULE_glob__ from "glob";
|
|
5
5
|
const getDuration = (perfStart)=>{
|
|
6
6
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
7
7
|
return `\u{8017}\u{65F6} ${duration} s`;
|
|
8
8
|
};
|
|
9
|
-
export {
|
|
9
|
+
export { fs_extra as fs, getDuration, __WEBPACK_EXTERNAL_MODULE_glob__ as glob };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rife/cli",
|
|
3
|
-
"version": "0.0.6-beta.
|
|
3
|
+
"version": "0.0.6-beta.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,32 +18,22 @@
|
|
|
18
18
|
"src/**/*"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@swc/cli": "^0.6.0",
|
|
22
|
-
"@swc/core": "^1.12.9",
|
|
23
|
-
"@swc/helpers": "^0.5.17",
|
|
24
|
-
"chokidar": "^4.0.3",
|
|
25
21
|
"commander": "^10.0.1",
|
|
26
22
|
"consola": "^3.4.2",
|
|
27
|
-
"
|
|
28
|
-
"eslint": "^9.30.1",
|
|
29
|
-
"fs-extra": "^11.3.0",
|
|
23
|
+
"fs-extra": "^11.3.1",
|
|
30
24
|
"glob": "^11.0.3",
|
|
31
25
|
"tapable": "^2.2.2",
|
|
32
|
-
"
|
|
33
|
-
"typescript": "^5.8.3",
|
|
34
|
-
"vitest": "^3.2.4",
|
|
35
|
-
"zod": "^3.25.71",
|
|
36
|
-
"@rife/config": "0.0.6-beta.8"
|
|
26
|
+
"zod": "^3.25.71"
|
|
37
27
|
},
|
|
38
28
|
"devDependencies": {
|
|
39
|
-
"@rslib/core": "^0.
|
|
29
|
+
"@rslib/core": "^0.11.2",
|
|
40
30
|
"@types/fs-extra": "^11.0.4",
|
|
41
|
-
"@types/node": "^22.16.0"
|
|
31
|
+
"@types/node": "^22.16.0",
|
|
32
|
+
"vitest": "^3.2.4",
|
|
33
|
+
"@rife/config": "0.0.6-beta.9"
|
|
42
34
|
},
|
|
43
35
|
"rife": {
|
|
44
36
|
"hostDependencies": {
|
|
45
|
-
"tslib": "prod",
|
|
46
|
-
"@swc/helpers": "prod",
|
|
47
37
|
"@types/node": true,
|
|
48
38
|
"@rife/config": true,
|
|
49
39
|
"vitest": true,
|
package/src/index.ts
CHANGED
package/src/logger.ts
CHANGED
|
@@ -3,7 +3,8 @@ import { createConsola } from 'consola';
|
|
|
3
3
|
export function createLogger(options?: { debug?: boolean }) {
|
|
4
4
|
const instance = createConsola({
|
|
5
5
|
level: options?.debug ? 4 : 3,
|
|
6
|
-
|
|
6
|
+
throttle: 10,
|
|
7
|
+
throttleMin: 500,
|
|
7
8
|
formatOptions: {
|
|
8
9
|
// columns: 80,
|
|
9
10
|
// colors: false,
|
package/src/plugin/index.ts
CHANGED
package/src/runner.ts
CHANGED
|
@@ -42,6 +42,7 @@ export interface Runner {
|
|
|
42
42
|
duration: string;
|
|
43
43
|
tempDir: string;
|
|
44
44
|
clear: () => void;
|
|
45
|
+
throwError: (message?: string, options?: ErrorOptions) => never;
|
|
45
46
|
}
|
|
46
47
|
|
|
47
48
|
export interface Plugin {
|
|
@@ -112,12 +113,15 @@ export function createRunner() {
|
|
|
112
113
|
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
113
114
|
return `耗时 ${duration} s`;
|
|
114
115
|
},
|
|
115
|
-
tempDir: './node_modules/.
|
|
116
|
+
tempDir: './node_modules/.rife/',
|
|
116
117
|
clear: () => {
|
|
117
118
|
console.clear();
|
|
118
119
|
process.stdout.write('\x1b[3J');
|
|
119
120
|
console.log(`${colors.bgBlue(' 项目名称 ')} ${runner.package.name} \n`);
|
|
120
121
|
},
|
|
122
|
+
throwError: (message?: string, options?: ErrorOptions) => {
|
|
123
|
+
throw new Error(message, options);
|
|
124
|
+
},
|
|
121
125
|
};
|
|
122
126
|
|
|
123
127
|
return runner;
|
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_modules__ = {
|
|
3
|
-
"consola/utils": function(module) {
|
|
4
|
-
module.exports = require("consola/utils");
|
|
5
|
-
},
|
|
6
|
-
typescript: function(module) {
|
|
7
|
-
module.exports = require("typescript");
|
|
8
|
-
}
|
|
9
|
-
};
|
|
10
|
-
var __webpack_module_cache__ = {};
|
|
11
|
-
function __webpack_require__(moduleId) {
|
|
12
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
13
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
14
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
15
|
-
exports: {}
|
|
16
|
-
};
|
|
17
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
18
|
-
return module.exports;
|
|
19
|
-
}
|
|
20
|
-
(()=>{
|
|
21
|
-
__webpack_require__.n = (module)=>{
|
|
22
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
23
|
-
__webpack_require__.d(getter, {
|
|
24
|
-
a: getter
|
|
25
|
-
});
|
|
26
|
-
return getter;
|
|
27
|
-
};
|
|
28
|
-
})();
|
|
29
|
-
(()=>{
|
|
30
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
31
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
32
|
-
enumerable: true,
|
|
33
|
-
get: definition[key]
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
(()=>{
|
|
38
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
39
|
-
})();
|
|
40
|
-
(()=>{
|
|
41
|
-
__webpack_require__.r = (exports1)=>{
|
|
42
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
43
|
-
value: 'Module'
|
|
44
|
-
});
|
|
45
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
46
|
-
value: true
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
})();
|
|
50
|
-
var __webpack_exports__ = {};
|
|
51
|
-
(()=>{
|
|
52
|
-
__webpack_require__.r(__webpack_exports__);
|
|
53
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
54
|
-
checkAndEmitType: ()=>checkAndEmitType,
|
|
55
|
-
compileTs: ()=>compileTs,
|
|
56
|
-
formatDiagnostic: ()=>formatDiagnostic
|
|
57
|
-
});
|
|
58
|
-
const external_path_namespaceObject = require("path");
|
|
59
|
-
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
60
|
-
var utils_ = __webpack_require__("consola/utils");
|
|
61
|
-
const external_swc_cjs_namespaceObject = require("./swc.cjs");
|
|
62
|
-
const external_tsc_cjs_namespaceObject = require("./tsc.cjs");
|
|
63
|
-
const clear = ()=>{
|
|
64
|
-
console.clear();
|
|
65
|
-
process.stdout.write('\x1b[3J');
|
|
66
|
-
};
|
|
67
|
-
async function compileTs(runner, tsxConfig, { dev, build } = {
|
|
68
|
-
dev: false,
|
|
69
|
-
build: true
|
|
70
|
-
}) {
|
|
71
|
-
const { logger, fs } = runner;
|
|
72
|
-
const log = logger.withTag(compileTs.name);
|
|
73
|
-
log.debug('tsxConfig %j', tsxConfig);
|
|
74
|
-
if (tsxConfig.clean) {
|
|
75
|
-
log.info("\u6E05\u7A7A\u76EE\u5F55 %s", tsxConfig.outDir);
|
|
76
|
-
await fs.emptyDir(tsxConfig.outDir);
|
|
77
|
-
}
|
|
78
|
-
const showProjectName = ()=>{
|
|
79
|
-
clear();
|
|
80
|
-
console.log(`${utils_.colors.bgBlue(" \u9879\u76EE\u540D\u79F0 ")} ${runner.package.name} \n`);
|
|
81
|
-
};
|
|
82
|
-
if ('tsc' === tsxConfig.type) {
|
|
83
|
-
const diagnostics = [];
|
|
84
|
-
let perfStart = performance.now();
|
|
85
|
-
(0, external_tsc_cjs_namespaceObject.tsc)({
|
|
86
|
-
...tsxConfig,
|
|
87
|
-
watch: dev,
|
|
88
|
-
onWatchStatusChanged: (data)=>{
|
|
89
|
-
switch(data.status){
|
|
90
|
-
case 'startWatch':
|
|
91
|
-
diagnostics.length = 0;
|
|
92
|
-
perfStart = performance.now();
|
|
93
|
-
break;
|
|
94
|
-
case 'reCompile':
|
|
95
|
-
diagnostics.length = 0;
|
|
96
|
-
perfStart = performance.now();
|
|
97
|
-
if (dev) showProjectName();
|
|
98
|
-
break;
|
|
99
|
-
case 'error':
|
|
100
|
-
{
|
|
101
|
-
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
102
|
-
log.error(`\u{7C7B}\u{578B}\u{68C0}\u{67E5}\u{5931}\u{8D25}\u{FF0C}\u{8017}\u{65F6} ${duration} s\n\n%s`, formatDiagnostic(diagnostics));
|
|
103
|
-
break;
|
|
104
|
-
}
|
|
105
|
-
case 'success':
|
|
106
|
-
{
|
|
107
|
-
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
108
|
-
log.success(`\u{7F16}\u{8BD1}\u{6210}\u{529F}\u{FF0C}\u{8017}\u{65F6} ${duration} s`);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
default:
|
|
112
|
-
console.log(data);
|
|
113
|
-
process.exit(1);
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
onReportDiagnostic: ({ diagnostic })=>{
|
|
117
|
-
diagnostics.push(diagnostic);
|
|
118
|
-
},
|
|
119
|
-
onEmitDiagnostics: ({ diagnostics })=>{
|
|
120
|
-
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
121
|
-
if (diagnostics.length) {
|
|
122
|
-
log.error(`\u{7F16}\u{8BD1}\u{5931}\u{8D25}\u{FF0C}\u{8017}\u{65F6} ${duration} s\n\n%s`, formatDiagnostic(diagnostics));
|
|
123
|
-
runner.compiler.fail = true;
|
|
124
|
-
} else log.success(`\u{7F16}\u{8BD1}\u{6210}\u{529F}\u{FF0C}\u{8017}\u{65F6} ${duration} s`);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if ('swc' === tsxConfig.type) {
|
|
130
|
-
const { promise, resolve } = Promise.withResolvers();
|
|
131
|
-
(0, external_swc_cjs_namespaceObject.swc)({
|
|
132
|
-
...tsxConfig,
|
|
133
|
-
watch: dev,
|
|
134
|
-
onSuccess: async ({ watch, first, duration })=>{
|
|
135
|
-
if (watch && !first) showProjectName();
|
|
136
|
-
log.success(`\u{7F16}\u{8BD1}\u{6210}\u{529F}\u{FF0C}\u{8017}\u{65F6} ${(duration / 1000).toFixed(3)} s`);
|
|
137
|
-
if (dev) runner.compiler.hook.execMain.promise();
|
|
138
|
-
await runner.compiler.hook.checkAndEmitType.promise();
|
|
139
|
-
resolve();
|
|
140
|
-
},
|
|
141
|
-
onFail: ({ watch, first, duration, reasons })=>{
|
|
142
|
-
if (watch && !first) showProjectName();
|
|
143
|
-
const message = [
|
|
144
|
-
...reasons.entries()
|
|
145
|
-
].map(([key, value])=>{
|
|
146
|
-
const index = value.indexOf(key);
|
|
147
|
-
if (index > -1) return value.replace(key, external_path_default().resolve(key));
|
|
148
|
-
return `${value}`;
|
|
149
|
-
}).join('\n');
|
|
150
|
-
log.error(`\u{7F16}\u{8BD1}\u{5931}\u{8D25}\u{FF0C}\u{8017}\u{65F6} ${(duration / 1000).toFixed(3)} s\n\n%s`, message);
|
|
151
|
-
runner.compiler.fail = true;
|
|
152
|
-
resolve();
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
if (build) return promise;
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
log.error(`compiler type '${tsxConfig.type}' \u{4E0D}\u{5B58}\u{5728}`);
|
|
159
|
-
process.exit(1);
|
|
160
|
-
}
|
|
161
|
-
function checkAndEmitType() {
|
|
162
|
-
const perfStart = performance.now();
|
|
163
|
-
const ts = __webpack_require__("typescript");
|
|
164
|
-
const tsConfigPath = external_path_default().resolve('tsconfig.json');
|
|
165
|
-
const configFile = ts.readConfigFile(tsConfigPath, ts.sys.readFile);
|
|
166
|
-
const compilerOptions = ts.parseJsonConfigFileContent(configFile.config, ts.sys, external_path_default().dirname(tsConfigPath), {
|
|
167
|
-
noEmit: true,
|
|
168
|
-
incremental: false
|
|
169
|
-
});
|
|
170
|
-
if (true === compilerOptions.options.declaration) {
|
|
171
|
-
compilerOptions.options.noEmit = false;
|
|
172
|
-
compilerOptions.options.emitDeclarationOnly = true;
|
|
173
|
-
}
|
|
174
|
-
const host = ts.createCompilerHost(compilerOptions.options);
|
|
175
|
-
const program = ts.createProgram(compilerOptions.fileNames, compilerOptions.options, host);
|
|
176
|
-
const emitResult = program.emit();
|
|
177
|
-
const diagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
|
178
|
-
const duration = ((performance.now() - perfStart) / 1000).toFixed(3);
|
|
179
|
-
return {
|
|
180
|
-
diagnostics,
|
|
181
|
-
duration
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function formatDiagnostic(diagnostics) {
|
|
185
|
-
const ts = __webpack_require__("typescript");
|
|
186
|
-
const { colors } = __webpack_require__("consola/utils");
|
|
187
|
-
return diagnostics.map((diagnostic)=>{
|
|
188
|
-
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, '\n');
|
|
189
|
-
if (diagnostic.file) {
|
|
190
|
-
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
191
|
-
return `${colors.gray(diagnostic.file.fileName)} ${colors.yellow(`(${line + 1},${character + 1})`)}: ${colors.white(message)}`;
|
|
192
|
-
}
|
|
193
|
-
return message;
|
|
194
|
-
}).join('\n');
|
|
195
|
-
}
|
|
196
|
-
})();
|
|
197
|
-
exports.checkAndEmitType = __webpack_exports__.checkAndEmitType;
|
|
198
|
-
exports.compileTs = __webpack_exports__.compileTs;
|
|
199
|
-
exports.formatDiagnostic = __webpack_exports__.formatDiagnostic;
|
|
200
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
201
|
-
"checkAndEmitType",
|
|
202
|
-
"compileTs",
|
|
203
|
-
"formatDiagnostic"
|
|
204
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
205
|
-
Object.defineProperty(exports, '__esModule', {
|
|
206
|
-
value: true
|
|
207
|
-
});
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_modules__ = {
|
|
3
|
-
child_process: function(module) {
|
|
4
|
-
module.exports = require("child_process");
|
|
5
|
-
}
|
|
6
|
-
};
|
|
7
|
-
var __webpack_module_cache__ = {};
|
|
8
|
-
function __webpack_require__(moduleId) {
|
|
9
|
-
var cachedModule = __webpack_module_cache__[moduleId];
|
|
10
|
-
if (void 0 !== cachedModule) return cachedModule.exports;
|
|
11
|
-
var module = __webpack_module_cache__[moduleId] = {
|
|
12
|
-
exports: {}
|
|
13
|
-
};
|
|
14
|
-
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
15
|
-
return module.exports;
|
|
16
|
-
}
|
|
17
|
-
(()=>{
|
|
18
|
-
__webpack_require__.d = (exports1, definition)=>{
|
|
19
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: definition[key]
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
})();
|
|
25
|
-
(()=>{
|
|
26
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
-
})();
|
|
28
|
-
(()=>{
|
|
29
|
-
__webpack_require__.r = (exports1)=>{
|
|
30
|
-
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
31
|
-
value: 'Module'
|
|
32
|
-
});
|
|
33
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
34
|
-
value: true
|
|
35
|
-
});
|
|
36
|
-
};
|
|
37
|
-
})();
|
|
38
|
-
var __webpack_exports__ = {};
|
|
39
|
-
(()=>{
|
|
40
|
-
__webpack_require__.r(__webpack_exports__);
|
|
41
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
-
pluginCompiler: ()=>pluginCompiler
|
|
43
|
-
});
|
|
44
|
-
const external_tapable_namespaceObject = require("tapable");
|
|
45
|
-
const external_compiler_cjs_namespaceObject = require("./compiler.cjs");
|
|
46
|
-
const external_util_cjs_namespaceObject = require("../../util.cjs");
|
|
47
|
-
function pluginCompiler(options) {
|
|
48
|
-
const plugin = {
|
|
49
|
-
name: pluginCompiler.name,
|
|
50
|
-
apply: (runner)=>{
|
|
51
|
-
const { hook, logger, z, fs } = runner;
|
|
52
|
-
const log = logger.withTag(pluginCompiler.name);
|
|
53
|
-
const validation = z.object({
|
|
54
|
-
tsx: z.object({
|
|
55
|
-
type: z.enum([
|
|
56
|
-
'tsc',
|
|
57
|
-
'swc'
|
|
58
|
-
]).default('swc'),
|
|
59
|
-
rootDir: z.string().trim().min(1).default('.'),
|
|
60
|
-
outDir: z.string().trim().min(1).default('./dist/'),
|
|
61
|
-
clean: z.boolean().default(true),
|
|
62
|
-
main: z.string().trim().optional(),
|
|
63
|
-
options: z.object({}).passthrough().optional()
|
|
64
|
-
}).default({})
|
|
65
|
-
}).optional().default({}).safeParse(options);
|
|
66
|
-
if (!validation.success) {
|
|
67
|
-
log.error("\u914D\u7F6E\u9519\u8BEF\n", validation.error.message);
|
|
68
|
-
process.exit(1);
|
|
69
|
-
}
|
|
70
|
-
runner.compiler = {
|
|
71
|
-
fail: false,
|
|
72
|
-
process: null,
|
|
73
|
-
hook: {
|
|
74
|
-
checkAndEmitType: new external_tapable_namespaceObject.AsyncSeriesHook(),
|
|
75
|
-
execMain: new external_tapable_namespaceObject.AsyncSeriesHook()
|
|
76
|
-
},
|
|
77
|
-
tsx: validation.data.tsx
|
|
78
|
-
};
|
|
79
|
-
hook.dev.tapPromise(pluginCompiler.name, async ()=>{
|
|
80
|
-
const tsxConfig = validation.data.tsx;
|
|
81
|
-
(0, external_compiler_cjs_namespaceObject.compileTs)(runner, tsxConfig, {
|
|
82
|
-
dev: true
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
hook.build.tapPromise(pluginCompiler.name, async ()=>{
|
|
86
|
-
const perfStart = performance.now();
|
|
87
|
-
const tsxConfig = validation.data.tsx;
|
|
88
|
-
await (0, external_compiler_cjs_namespaceObject.compileTs)(runner, tsxConfig, {
|
|
89
|
-
build: true
|
|
90
|
-
});
|
|
91
|
-
if (runner.compiler.fail) {
|
|
92
|
-
log.fail(`\u{6784}\u{5EFA}\u{5931}\u{8D25}\u{FF0C}${(0, external_util_cjs_namespaceObject.getDuration)(perfStart)}`);
|
|
93
|
-
process.exit(1);
|
|
94
|
-
} else log.success(`\u{6784}\u{5EFA}\u{6210}\u{529F}\u{FF0C}${(0, external_util_cjs_namespaceObject.getDuration)(perfStart)}`);
|
|
95
|
-
});
|
|
96
|
-
runner.compiler.hook.checkAndEmitType.tapPromise(pluginCompiler.name, async ()=>{
|
|
97
|
-
const { diagnostics, duration } = (0, external_compiler_cjs_namespaceObject.checkAndEmitType)();
|
|
98
|
-
if (diagnostics.length) {
|
|
99
|
-
log.error(`\u{7C7B}\u{578B}\u{68C0}\u{67E5}\u{5931}\u{8D25}\u{FF0C}\u{8017}\u{65F6} ${duration} s\n\n%s`, (0, external_compiler_cjs_namespaceObject.formatDiagnostic)(diagnostics));
|
|
100
|
-
runner.compiler.fail = true;
|
|
101
|
-
} else log.success(`\u{7C7B}\u{578B}\u{68C0}\u{67E5}\u{6210}\u{529F}\u{FF0C}\u{8017}\u{65F6} ${duration} s`);
|
|
102
|
-
});
|
|
103
|
-
runner.compiler.hook.execMain.tapPromise(pluginCompiler.name, async ()=>{
|
|
104
|
-
const compiler = runner.compiler;
|
|
105
|
-
const { main } = compiler.tsx;
|
|
106
|
-
if (!main) return void log.debug("\u6CA1\u6709\u6307\u5B9A main");
|
|
107
|
-
if (!await fs.exists(main)) return void log.warn(`\u{542F}\u{52A8}\u{6587}\u{4EF6}\u{4E0D}\u{5B58}\u{5728} %s`, main);
|
|
108
|
-
log.info(`\u{542F}\u{52A8}\u{6587}\u{4EF6} node %s`, main);
|
|
109
|
-
const { fork } = __webpack_require__("child_process");
|
|
110
|
-
compiler.process?.kill();
|
|
111
|
-
compiler.process = fork(main, {
|
|
112
|
-
stdio: 'inherit'
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
return plugin;
|
|
118
|
-
}
|
|
119
|
-
})();
|
|
120
|
-
exports.pluginCompiler = __webpack_exports__.pluginCompiler;
|
|
121
|
-
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
122
|
-
"pluginCompiler"
|
|
123
|
-
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
124
|
-
Object.defineProperty(exports, '__esModule', {
|
|
125
|
-
value: true
|
|
126
|
-
});
|