@rife/cli 0.0.6-beta.11 → 0.0.6-beta.12

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.
Files changed (66) hide show
  1. package/dist/cjs/cli.cjs +25 -0
  2. package/dist/cjs/index.cjs +110 -0
  3. package/dist/cjs/logger.cjs +46 -0
  4. package/dist/cjs/plugin/commander.cjs +66 -0
  5. package/dist/cjs/plugin/compiler/compiler.cjs +207 -0
  6. package/dist/cjs/plugin/compiler/index.cjs +126 -0
  7. package/dist/cjs/plugin/compiler/swc.cjs +107 -0
  8. package/dist/cjs/plugin/compiler/tsc.cjs +115 -0
  9. package/dist/cjs/plugin/config.cjs +107 -0
  10. package/dist/cjs/plugin/index.cjs +96 -0
  11. package/dist/cjs/plugin/package.cjs +71 -0
  12. package/dist/cjs/plugin/release.cjs +129 -0
  13. package/dist/cjs/runner.cjs +137 -0
  14. package/dist/{sync.js → cjs/sync.cjs} +12 -23
  15. package/dist/cjs/util.cjs +57 -0
  16. package/dist/{1.mjs → esm/cli.mjs} +4 -3
  17. package/dist/esm/index.mjs +8 -0
  18. package/dist/esm/logger.mjs +14 -0
  19. package/dist/esm/plugin/commander.mjs +34 -0
  20. package/dist/esm/plugin/compiler/compiler.mjs +160 -0
  21. package/dist/esm/plugin/compiler/index.mjs +94 -0
  22. package/dist/esm/plugin/compiler/swc.mjs +75 -0
  23. package/dist/esm/plugin/compiler/tsc.mjs +73 -0
  24. package/dist/esm/plugin/config.mjs +65 -0
  25. package/dist/esm/plugin/index.mjs +7 -0
  26. package/dist/{plugin/package.js → esm/plugin/package.mjs} +11 -14
  27. package/dist/{plugin/release.js → esm/plugin/release.mjs} +33 -38
  28. package/dist/esm/runner.mjs +92 -0
  29. package/dist/esm/sync.mjs +46 -0
  30. package/dist/esm/util.mjs +9 -0
  31. package/package.json +12 -6
  32. package/dist/1.js +0 -24
  33. package/dist/cjs/1.js +0 -24
  34. package/dist/cli.js +0 -22
  35. package/dist/cli.js.map +0 -1
  36. package/dist/esm/1.mjs +0 -20
  37. package/dist/index.js +0 -11
  38. package/dist/index.js.map +0 -1
  39. package/dist/logger.js +0 -18
  40. package/dist/logger.js.map +0 -1
  41. package/dist/plugin/commander.js +0 -47
  42. package/dist/plugin/commander.js.map +0 -1
  43. package/dist/plugin/compiler/compiler.js +0 -166
  44. package/dist/plugin/compiler/compiler.js.map +0 -1
  45. package/dist/plugin/compiler/index.js +0 -88
  46. package/dist/plugin/compiler/index.js.map +0 -1
  47. package/dist/plugin/compiler/swc.js +0 -48
  48. package/dist/plugin/compiler/swc.js.map +0 -1
  49. package/dist/plugin/compiler/swc2.js +0 -65
  50. package/dist/plugin/compiler/swc2.js.map +0 -1
  51. package/dist/plugin/compiler/tsc.js +0 -75
  52. package/dist/plugin/compiler/tsc.js.map +0 -1
  53. package/dist/plugin/config.js +0 -77
  54. package/dist/plugin/config.js.map +0 -1
  55. package/dist/plugin/index.js +0 -9
  56. package/dist/plugin/index.js.map +0 -1
  57. package/dist/plugin/package copy.js +0 -32
  58. package/dist/plugin/package copy.js.map +0 -1
  59. package/dist/plugin/package.js.map +0 -1
  60. package/dist/plugin/release.js.map +0 -1
  61. package/dist/runner.js +0 -81
  62. package/dist/runner.js.map +0 -1
  63. package/dist/sync.js.map +0 -1
  64. package/dist/tsconfig.tsbuildinfo +0 -1
  65. package/dist/util.js +0 -14
  66. package/dist/util.js.map +0 -1
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __webpack_exports__ = {};
3
+ const index_cjs_namespaceObject = require("./plugin/index.cjs");
4
+ const external_runner_cjs_namespaceObject = require("./runner.cjs");
5
+ const plugins = [
6
+ (0, index_cjs_namespaceObject.pluginPackage)(),
7
+ (0, index_cjs_namespaceObject.pluginConfig)(),
8
+ (0, index_cjs_namespaceObject.pluginCommander)(),
9
+ (0, index_cjs_namespaceObject.pluginRelease)()
10
+ ];
11
+ const runner = (0, external_runner_cjs_namespaceObject.createRunner)();
12
+ plugins.forEach((plugin)=>plugin.apply(runner));
13
+ (async ()=>{
14
+ await runner.hook.loadPackage.promise();
15
+ await runner.hook.loadConfig.promise();
16
+ await runner.hook.validateConfig.promise();
17
+ await runner.hook.applyConfig.promise();
18
+ await runner.hook.validatePlugin.promise();
19
+ await runner.hook.registerCommand.promise();
20
+ await runner.hook.startCommand.promise();
21
+ })();
22
+ for(var __webpack_i__ in __webpack_exports__)exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
23
+ Object.defineProperty(exports, '__esModule', {
24
+ value: true
25
+ });
@@ -0,0 +1,110 @@
1
+ "use strict";
2
+ var __webpack_modules__ = {
3
+ "./logger": function(module) {
4
+ module.exports = require("./logger.cjs");
5
+ },
6
+ "./plugin": function(module) {
7
+ module.exports = require("./plugin/index.cjs");
8
+ },
9
+ "./runner": function(module) {
10
+ module.exports = require("./runner.cjs");
11
+ },
12
+ "fs-extra": function(module) {
13
+ module.exports = require("fs-extra");
14
+ },
15
+ tapable: function(module) {
16
+ module.exports = require("tapable");
17
+ }
18
+ };
19
+ var __webpack_module_cache__ = {};
20
+ function __webpack_require__(moduleId) {
21
+ var cachedModule = __webpack_module_cache__[moduleId];
22
+ if (void 0 !== cachedModule) return cachedModule.exports;
23
+ var module = __webpack_module_cache__[moduleId] = {
24
+ exports: {}
25
+ };
26
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
27
+ return module.exports;
28
+ }
29
+ (()=>{
30
+ __webpack_require__.n = (module)=>{
31
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
32
+ __webpack_require__.d(getter, {
33
+ a: getter
34
+ });
35
+ return getter;
36
+ };
37
+ })();
38
+ (()=>{
39
+ __webpack_require__.d = (exports1, definition)=>{
40
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
41
+ enumerable: true,
42
+ get: definition[key]
43
+ });
44
+ };
45
+ })();
46
+ (()=>{
47
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
48
+ })();
49
+ (()=>{
50
+ __webpack_require__.r = (exports1)=>{
51
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
52
+ value: 'Module'
53
+ });
54
+ Object.defineProperty(exports1, '__esModule', {
55
+ value: true
56
+ });
57
+ };
58
+ })();
59
+ var __webpack_exports__ = {};
60
+ (()=>{
61
+ __webpack_require__.r(__webpack_exports__);
62
+ __webpack_require__.d(__webpack_exports__, {
63
+ fs: ()=>fs_extra__WEBPACK_IMPORTED_MODULE_3___default.a
64
+ });
65
+ var _runner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__("./runner");
66
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
67
+ for(var __WEBPACK_IMPORT_KEY__ in _runner__WEBPACK_IMPORTED_MODULE_0__)if ([
68
+ "default",
69
+ "fs"
70
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
71
+ return _runner__WEBPACK_IMPORTED_MODULE_0__[key];
72
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
73
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
74
+ var _plugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__("./plugin");
75
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
76
+ for(var __WEBPACK_IMPORT_KEY__ in _plugin__WEBPACK_IMPORTED_MODULE_1__)if ([
77
+ "default",
78
+ "fs"
79
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
80
+ return _plugin__WEBPACK_IMPORTED_MODULE_1__[key];
81
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
82
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
83
+ var _logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__("./logger");
84
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
85
+ for(var __WEBPACK_IMPORT_KEY__ in _logger__WEBPACK_IMPORTED_MODULE_2__)if ([
86
+ "default",
87
+ "fs"
88
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
89
+ return _logger__WEBPACK_IMPORTED_MODULE_2__[key];
90
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
91
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
92
+ var fs_extra__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__("fs-extra");
93
+ var fs_extra__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/ __webpack_require__.n(fs_extra__WEBPACK_IMPORTED_MODULE_3__);
94
+ var tapable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__("tapable");
95
+ var __WEBPACK_REEXPORT_OBJECT__ = {};
96
+ for(var __WEBPACK_IMPORT_KEY__ in tapable__WEBPACK_IMPORTED_MODULE_4__)if ([
97
+ "default",
98
+ "fs"
99
+ ].indexOf(__WEBPACK_IMPORT_KEY__) < 0) __WEBPACK_REEXPORT_OBJECT__[__WEBPACK_IMPORT_KEY__] = (function(key) {
100
+ return tapable__WEBPACK_IMPORTED_MODULE_4__[key];
101
+ }).bind(0, __WEBPACK_IMPORT_KEY__);
102
+ __webpack_require__.d(__webpack_exports__, __WEBPACK_REEXPORT_OBJECT__);
103
+ })();
104
+ exports.fs = __webpack_exports__.fs;
105
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
106
+ "fs"
107
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
108
+ Object.defineProperty(exports, '__esModule', {
109
+ value: true
110
+ });
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ createLogger: ()=>createLogger
28
+ });
29
+ const external_consola_namespaceObject = require("consola");
30
+ function createLogger(options) {
31
+ const instance = (0, external_consola_namespaceObject.createConsola)({
32
+ level: options?.debug ? 4 : 3,
33
+ formatOptions: {
34
+ compact: false,
35
+ date: false
36
+ }
37
+ });
38
+ return instance;
39
+ }
40
+ exports.createLogger = __webpack_exports__.createLogger;
41
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
42
+ "createLogger"
43
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
44
+ Object.defineProperty(exports, '__esModule', {
45
+ value: true
46
+ });
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ pluginCommander: ()=>pluginCommander
28
+ });
29
+ function pluginCommander() {
30
+ const plugin = {
31
+ name: pluginCommander.name,
32
+ apply: (runner)=>{
33
+ const { hook, command, config, z, logger } = runner;
34
+ const log = logger.withTag(pluginCommander.name);
35
+ hook.registerCommand.tapPromise(pluginCommander.name, async ()=>{
36
+ command.command('dev').description("\u542F\u52A8\u5F00\u53D1").action(async ()=>{
37
+ process.env.NODE_ENV = 'development';
38
+ await hook.dev.promise();
39
+ });
40
+ command.command('build').description("\u6784\u5EFA\u9879\u76EE").action(async ()=>{
41
+ process.env.NODE_ENV = 'production';
42
+ await hook.build.promise();
43
+ });
44
+ command.command('release').description("\u53D1\u5E03\u5305").action(async ()=>{
45
+ await hook.release.promise();
46
+ });
47
+ command.command('deploy').description("\u90E8\u7F72\u9879\u76EE").action(async ()=>{
48
+ await hook.deploy.promise().catch((e)=>{
49
+ log.fail(`\u{90E8}\u{7F72}\u{5931}\u{8D25}\u{FF0C}${runner.duration}\u{FF0C}${e.message}`);
50
+ });
51
+ });
52
+ });
53
+ hook.startCommand.tapPromise(pluginCommander.name, async ()=>{
54
+ await command.parseAsync(process.argv);
55
+ });
56
+ }
57
+ };
58
+ return plugin;
59
+ }
60
+ exports.pluginCommander = __webpack_exports__.pluginCommander;
61
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
62
+ "pluginCommander"
63
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
64
+ Object.defineProperty(exports, '__esModule', {
65
+ value: true
66
+ });
@@ -0,0 +1,207 @@
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
+ });
@@ -0,0 +1,126 @@
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
+ });